程序员的量化交易之路(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() {}

}


相关文章
|
3月前
|
NoSQL Java 程序员
1年半经验,2本学历,Curd背景,竟给30K,我的美团Offer终于来了
如标题所示,我的个人背景非常简单,Java开发经验1年半,学历普通,2本本科毕业,毕业后出来就一直在Crud,在公司每天重复的工作对我的技术提升并没有什么帮助,但小镇出来的我也深知自我努力的重要性,想要改变“命运”,没有背景没有资本的人,只能通过勤奋获得。
|
3月前
|
消息中间件 NoSQL Java
九大核心专题,630页内容,熬夜23天吃透,我收割了3个大厂offer
今年受疫情影响非常大,春招和金三银四都要比往年来得更迟一些。春招结束之后,我特意把自己的面试经历顺了顺,总结出了不少的经验。对了,这次一共收割了3个大厂offer,分别是蚂蚁金服、美团和网易,特意分享这次对我帮助非常大的宝典资料,一共涉及九大核心专题,分别是计算机网络、操作系统、MySQL、Linux、JAVA、JVM、Redis、消息队列与分布式、网站优化相关,这些内容我熬夜整整23天才读完,希望它也能帮助到你们。
读书笔记—《销售铁军》随记1
读书就好像跟这些大家在请教、交流、探讨,从而不断深化自己的理解和领悟,从今天开始,针对“阿里铁军”销售书籍,分享自己的摘录和心得,与大家共览
11384 0