码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-05-06 15:08:44      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:imp   sel   实体   lis   tran   entity   protected   ice   ons   

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

Offer:报价。

bid:买方报价

ask:卖方报价


非常easy的一个类。是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() {}

}


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

标签:imp   sel   实体   lis   tran   entity   protected   ice   ons   

原文地址:http://www.cnblogs.com/ljbguanli/p/6816708.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!