转载须注明出处: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. hdu 4671 异面直线的距离

    题目大意:空间中有许多无限长的棒子(圆柱体),求棒子间最小距离. #include <iostream> #include <cstdio> #include <cstr ...

  2. zoj 3791 An Easy Game dp

    An Easy Game Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Edward and Flandre play a ga ...

  3. TSP 旅行商问题(状态压缩dp)

    题意:有n个城市,有p条单向路径,连通n个城市,旅行商从0城市开始旅行,那么旅行完所有城市再次回到城市0至少需要旅行多长的路程. 思路:n较小的情况下可以使用状态压缩dp,设集合S代表还未经过的城市的 ...

  4. es6总结(七)--proxy & reflect

  5. MIPS中的异常处理和系统调用【转】

    转自:http://blog.csdn.net/jasonchen_gbd/article/details/44044091 权声明:本文为博主原创文章,转载请附上原博链接. 异常入口 系统调用是用户 ...

  6. 捕获错误并发邮件 register_shutdown_function

    /** * 脚本程序异常捕获 */ function handleError() { global $config; $error = error_get_last(); if (isset($err ...

  7. file中的一些常用方法

    1.exists();判断文件(目录)是否存在 2.mkdir();创建一级目录:mkdirs()创建多级目录 3.delete();删除文件(目录) 4.isDirectory();判断是否是一个目 ...

  8. Ajax的post方式提交数据

    最新需要学习如何使用 POST 提交方法的接口,正好看到了Ajax 版本的感觉不错分享给大家,欢迎高手指点. <SCRIPT LANGUAGE=”javascript”> <!– f ...

  9. Python语言 介绍

    一.python介绍python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语 ...

  10. 【UTR #2】题目交流通道

    题目描述 定好了难度,雄心勃勃的吉米多出题斯基开始寻找智慧的神犇星球的居民出题. 然而吉米多出题斯基没有料到,神犇星球的居民告诉吉米多出题斯基:"今年神犇星球经济不景气,大家都想宅在家里,哪 ...