程序猿的量化交易之路(27)--Cointrader之PriceData价格数据(14)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://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)的更多相关文章
- 程序猿的量化交易之路(13)--Cointrader类图(1)
转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents, htpp://cloudtrader.top 今天開始正式切入到Cointrad ...
- 程序猿的量化交易之路(20)--Cointrader之Assert实体(8)
转载需说明出处:http://blog.csdn.net/minimicall, http://cloudtrade.top 不论什么可交易的都能够称之为Assert,资产.其类代码例如以下: pac ...
- 程序猿的量化交易之路(29)--Cointrader之Tick实体(16)
转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrade.top Tick:什么是Tick,在交易平台中很常见,事实上就 单笔交易时某仅仅证券 ...
- 程序猿的量化交易之路(24)--Cointrader之RemoteEvent远程事件实体(11)
转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrader.top/ 在量化交易系统中.有些事件是远端传来的,比方股票的价格数据等.所以,在这 ...
- 程序猿的量化交易之路(30)--Cointrader之ConfigUtil(17)
转载须注明出处:viewmode=contents">http://blog.csdn.net/minimicall?viewmode=contents.http://cloudtra ...
- 程序猿的量化交易之路(26)--Cointrader之Listing挂牌实体(13)
转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrade.top Listing:挂牌. 比方某仅仅股票 ...
- 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...
- 程序猿的量化交易之路(18)--Cointrader之Event实体(6)
转载需注明: 事件,是Esper的重要概念. 这里我们定义个事件类.它是Temporal实体的派生类. 不过对Temporal简单的包装.其代码例如以下: package org.cryptocoin ...
- 程序猿的量化交易之路(21)--Cointrader之Currency货币实体(9)
转载须注明出自:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrader.top 货币,Cointrader中基本实体 ...
随机推荐
- No change while using CSS <form target="blank">
I want to open another Window when I use <form> to request a query. So I used target="bla ...
- Java-河内塔问题
河内之塔(Towers of Hanoi)是法国人M.Claus(Lucas)于1883年从泰国带至法国的,河内为越战时北越的首都,即现在的胡志明市:1883年法国数学家 Edouard Lucas曾 ...
- php validator classes
<?php /** * 验证类 */ class Validator { /* 函数名称:isNumber 简要描述:检查输入的是否为数字 输入:string 输出:boolean */ pub ...
- 应用defineProperty简单实现vue的双向数据绑定
双向数据绑定简易版本如何应用defineProperty的getter setter 方法 有这样HTML片段 <input type="text" id="dem ...
- hdu 4183(网络流)
Pahom on Water Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- poj 1274(网络流解二分图的最大匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22539 Accepted: 100 ...
- spring lifeCycle
Lifecycle接口定义了每个对象的生命周期.如下 public interface Lifecycle { void start(); void stop(); boolean isRunning ...
- Cesium 显示CZML数据
转自文章 Cesium随笔(5)CZML介绍(介个文章是转的嘿嘿) 通过czml可以在cesium上实现非常棒的动态效果 CZML的结构 CZML是一种用来描述动态场景的JSON架构的语言,主 ...
- SQL-基础学习2--ORDER BY ,DESC,WHERE, BETWEEN,AND ,OR ,IN ,NOT
所使用的数据库资料在:数据库资料 第三课:排序检索数据 3.1 排序数据 按单列排序 如果不排序,数据一般将以它在底层表中出现的顺序显示,这有可能是数据最初添加到表中的顺序.但是,如果数据随后进行 ...
- ubuntu允许mysql远程连接
ubuntu允许mysql远程连接 第一步: vim /etc/MySQL/my.cnf找到bind-address = 127.0.0.1 注释掉这行,如:#bind-address = 127.0 ...