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

PriceData:价格数据。价格数据是市场数据的子类。

详细代码例如以下:

package org.cryptocoinpartners.schema;

import java.math.BigDecimal;

import javax.annotation.Nullable;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient; import org.joda.time.Instant; /**
* Superclass for any MarketData which contains a price and volume, such as an Offer or a Trade ???靠,这个有问题。 只是整个平台的代码事实上非常垃圾。
*
* @author Tim Olson
*/
@MappedSuperclass
public abstract class PriceData extends MarketData { /**
* @param time when the pricing event originally occured
* @param remoteKey the exchange's unique ID for the pricing event (to prevent duplicates)
* @param market which Market this pricing is for
* @param priceCount relative to the Market's quoteBasis
* @param volumeCount relative to the Market's volumeBasis
*/
public PriceData(Instant time, @Nullable String remoteKey, Market market, @Nullable Long priceCount, @Nullable Long volumeCount) {
super(time, remoteKey, market);
this.priceCount = priceCount;
this.volumeCount = volumeCount;
} public PriceData(Instant time, @Nullable String remoteKey, Market market, @Nullable BigDecimal price, @Nullable BigDecimal volume) {
super(time, remoteKey, market);
this.priceCount = DiscreteAmount.roundedCountForBasis(price, market.getPriceBasis());
this.volumeCount = DiscreteAmount.roundedCountForBasis(volume, market.getVolumeBasis());
} /**
* @param time when the pricing event originally occured
* @param remoteKey the exchange's unique ID for the pricing event (to prevent duplicates)
* @param market which Market this pricing is for
* @param priceCount relative to the Market's quoteBasis
* @param volumeCount relative to the Market's volumeBasis
*/
public PriceData(Instant time, Instant timeReceived, @Nullable String remoteKey, Market market, @Nullable Long priceCount, @Nullable Long volumeCount) {
super(time, timeReceived, remoteKey, market);
this.priceCount = priceCount;
this.volumeCount = volumeCount;
} public PriceData(Instant time, Instant timeReceived, @Nullable String remoteKey, Market market, @Nullable BigDecimal price, @Nullable BigDecimal volume) {
super(time, timeReceived, remoteKey, market);
this.priceCount = DiscreteAmount.roundedCountForBasis(price, market.getPriceBasis());
this.volumeCount = DiscreteAmount.roundedCountForBasis(volume, market.getVolumeBasis());
} public @Nullable
Long getPriceCount() {
return priceCount;
} public @Nullable
Long getVolumeCount() {
return volumeCount;
} @Transient
@Nullable
public DiscreteAmount getPrice() {
if (priceCount == null)
return null;
if (price == null)
price = new DiscreteAmount(priceCount, getMarket().getPriceBasis());
return price;
} @Transient
@Nullable
public Double getPriceAsDouble() {
Amount price = getPrice();
return price == null ? null : price.asDouble();
} @Transient
@Nullable
public Double getPriceCountAsDouble() {
Long price = getPriceCount();
return price == null ? null : price.doubleValue();
} @Transient
@Nullable
public Double getVolumeCountAsDouble() {
Long volume = getVolumeCount();
return volume == null ? null : volume.doubleValue();
} @Transient
@Nullable
public BigDecimal getPriceAsBigDecimal() {
Amount price = getPrice();
return price == null ? null : price.asBigDecimal();
} @Transient
@Nullable
public DiscreteAmount getVolume() {
if (volumeCount == null)
return null;
if (volume == null)
volume = new DiscreteAmount(volumeCount, getMarket().getVolumeBasis());
return volume;
} @Transient
@Nullable
public Double getVolumeAsDouble() {
Amount volume = getVolume();
return volume == null ? null : volume.asDouble();
} @Transient
@Nullable
public BigDecimal getVolumeAsBigDecimal() {
Amount volume = getVolume();
return volume == null ? null : volume.asBigDecimal();
} // JPA
protected PriceData() {
super();
} protected void setPriceCount(Long priceCount) {
this.priceCount = priceCount;
} protected void setVolumeCount(Long volumeCount) {
this.volumeCount = volumeCount;
} private DiscreteAmount price;//价
private DiscreteAmount volume;//量
private Long priceCount;
private Long volumeCount;
}

程序猿的量化交易之路(27)--Cointrader之PriceData价格数据(14)的更多相关文章

  1. 程序猿的量化交易之路(13)--Cointrader类图(1)

    转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents, htpp://cloudtrader.top 今天開始正式切入到Cointrad ...

  2. 程序猿的量化交易之路(20)--Cointrader之Assert实体(8)

    转载需说明出处:http://blog.csdn.net/minimicall, http://cloudtrade.top 不论什么可交易的都能够称之为Assert,资产.其类代码例如以下: pac ...

  3. 程序猿的量化交易之路(29)--Cointrader之Tick实体(16)

    转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrade.top Tick:什么是Tick,在交易平台中很常见,事实上就 单笔交易时某仅仅证券 ...

  4. 程序猿的量化交易之路(24)--Cointrader之RemoteEvent远程事件实体(11)

    转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrader.top/ 在量化交易系统中.有些事件是远端传来的,比方股票的价格数据等.所以,在这 ...

  5. 程序猿的量化交易之路(30)--Cointrader之ConfigUtil(17)

    转载须注明出处:viewmode=contents">http://blog.csdn.net/minimicall?viewmode=contents.http://cloudtra ...

  6. 程序猿的量化交易之路(26)--Cointrader之Listing挂牌实体(13)

    转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrade.top Listing:挂牌. 比方某仅仅股票 ...

  7. 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)

    转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...

  8. 程序猿的量化交易之路(18)--Cointrader之Event实体(6)

    转载需注明: 事件,是Esper的重要概念. 这里我们定义个事件类.它是Temporal实体的派生类. 不过对Temporal简单的包装.其代码例如以下: package org.cryptocoin ...

  9. 程序猿的量化交易之路(21)--Cointrader之Currency货币实体(9)

    转载须注明出自:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrader.top 货币,Cointrader中基本实体 ...

随机推荐

  1. 数据库操作之——key与index的区别

    mysql的key和index多少有点令人迷惑,这实际上考察对数据库体系结构的了解的. 1 key 是数据库的物理结构,它包含两层意义,一是约束(偏重于约束和规范数据库的结构完整性),二是索引(辅助查 ...

  2. 【CF505D】Mr. Kitayuta's Technology

    题目大意: 在一个有向图中,有n个顶点,给出m对数字(u,v)表示顶点u和顶点v必须直接或者间接相连,让你构造一个这样的图,输出最少需要多少条边. 挖坑待填 官方题解链接:http://codefor ...

  3. Linux之进程的等待与其内核实现解析

    进程通过fork产生子进程,进程也会死亡,进程退出的时候将会进行内核清理,释放所有进程的资源,资源包括:内存资源,文件资源,信号量资源,共享内存资源,或者引用计数减一,或者彻底释放.     不过进程 ...

  4. U3D层的运用

    在操作 LayerMask 时常令一些初学者摸不着头脑下面简单说一下层的开关方法:1.首先引入'|'.'&'.'~'的概念与(交集):10000001 & 10000100 == 10 ...

  5. 模块化开发(seajs)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. OceanBase分区表有什么不同?

    概述 分区表是ORACLE从8.0开始引入的功能,也是第一个支持物理分区的数据库,随后其他数据库纷纷跟进.分区表是一种“分而治之”的思想,通过将大表.索引分成可以独立管理的.小的片段(Segment) ...

  7. JAVA通过使用sort方法排序

    java 代码: 对集合排序: //升序public void listSort1(){ List<Integer> list = new ArrayList<Integer> ...

  8. Ext 上传文件

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <title> ...

  9. javascript对象初探 (五)--- 函数对象的属性

    与其他对象相同的是,函数对象中也有一个叫做constructor的属性,其引用就是Function()这个构造函数. function her(a){ return a; } console.log( ...

  10. Linux进程管理(3):总结

    7. exit与_exit的差异    为了理解这两个系统调用的差异,先来讨论文件内存缓存区的问题. 在linux中,标准输入输出(I/O)函数都是作为文件来处理.对应于打开的每个文件,在内存中都有对 ...