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

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

时间:2015-06-05 17:39:06      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:量化交易   cointrader   offer   

转载须注明出处: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() {}

}


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

标签:量化交易   cointrader   offer   

原文地址:http://blog.csdn.net/minimicall/article/details/46377981

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