转载须注明出处: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. bzoj 1137 [POI2009]Wsp 岛屿

    题目大意 Byteotia岛屿是一个凸多边形.城市全都在海岸上.按顺时针编号1到n.任意两个城市之间都有一条笔直的道路相连.道路相交处可以自由穿行.有一些道路被游击队控制了,不能走,但是可以经过这条道 ...

  2. 通过例子学习 Keystone

    上一节介绍了 Keystone 的核心概念.本节我们通过“查询可用 image”这个实际操作让大家对这些概念建立更加感性的认识. User admin 要查看 Project 中的 image 第 1 ...

  3. 标准C程序设计七---73

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

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

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

  5. shell - sed 简单使用记录

    时间长不用,总是会忘掉的........还是烂笔头好些. sed 命令使用帮助及实操举例 功能:主要用来对一个或多个文件进行编辑,简化对文件的反复操作. 语法: sed [-hnV] [-e<s ...

  6. 洛谷—— P3807 【模板】卢卡斯定理

    https://www.luogu.org/problemnew/show/3807 题目背景 这是一道模板题. 题目描述 给定n,m,p(1\le n,m,p\le 10^51≤n,m,p≤105) ...

  7. Codeforces Gym 100338C Important Roads 最短路+Tarjan找桥

    原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...

  8. Hdoj 3506 Monkey Party

    Discription Far away from our world, there is a banana forest. And many lovely monkeys live there. O ...

  9. Chelly的串串专题

    CF149E 题意:给出一个长度为n的文本串和m个模式串,求有多少个模式串可以拆成两半,使得这两半按顺序匹配(n<=2e5,m<=100) 最暴力的想法就是对于每个询问串,全部和原串做一遍 ...

  10. BZOJ1001[BeiJing2006]狼抓兔子最小割網絡流

    Description 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的, 而且现在的兔子还比较笨,它们只有两个窝,现在你做为狼王,面对下面这样一 ...