程序员的量化交易之路(28)--Cointrader之Offer报价实体(15)

简介:

转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contentshttp://cloudtrade.top/

Offer:报价。

bid:买方报价

ask:卖方报价


很简单的一个类。是PriceData的子类。还记得PriceData有什么吧。

时间戳、量、价,

而PriceData又是MarketData的子类,MarketData封装了Market。Market包含市场数据,Exchange,Listing,priceBasis,volumeBasis等。

package org.cryptocoinpartners.schema;

import org.joda.time.Instant;

import javax.persistence.Entity;
import javax.persistence.Transient;


/**
 * Offers represent a bid or ask, usually from a Book.  Asks are represented by using a negative volumeCount
 *
 * @author Tim Olson
 */
@Entity
public class Offer extends PriceData {


    /** same as new Offer() */
    public static Offer bid(Market market, Instant time, Instant timeReceived, Long priceCount, Long volumeCount) {
        return new Offer( market, time, timeReceived, priceCount, volumeCount );
    }


    /** same as new Offer() except the volumeCount is negated */
    public static Offer ask(Market market, Instant time, Instant timeReceived, Long priceCount, Long volumeCount) {
        return new Offer( market, time, timeReceived, priceCount, -volumeCount );
    }


    public Offer(Market market, Instant time, Instant timeReceived, Long priceCount, Long volumeCount) {
        super(time, timeReceived, null, market, priceCount, volumeCount);
    }

    @Override
    public String toString() {
        return "Offer{" +
                       ", market=" + getMarket() +
                       ", priceCount=" + getPriceCount() +
                       ", volumeCount=" + getVolumeCount() +
                       '}';
    }


    @SuppressWarnings("ConstantConditions")
    @Transient
    public Side getSide() { return getVolumeCount() >= 0 ? Side.BUY : Side.SELL; }


    // JPA
    protected Offer() {}

}


相关文章
|
运维 算法 网络协议
Elastic 认证工程师考试最常被问到 Top10 +问题集锦
关于 Elastic 认证考试,官方文档已经提供了详尽的 Elastic Certification FAQ, 详细地址:https://www.elastic.co/cn/training/certification/faq 近一年,有以下 Elastic 认证相关问题经常被问到。特整理出来,希望对更多需要认证考试的朋友有所帮助。 1、英语不ok,可以参加 Elastic 认证考试吗? 考试的时候可以使用谷歌翻译。 以下是一位通过朋友的最新(2020-06-09)反馈:
281 0