程序猿的量化交易之路(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中基本实体 ...
随机推荐
- stein法求gcd 学习笔记
原理显然 由于当x,y都为奇数时进行辗转相见 每次减完必有偶数 而偶数最多除log次 那么也最多减log次 复杂度有保证 注:代码未验证 int gcd(int x,int y){ int res=1 ...
- Object,String,StringBuffer,StringBuilder,System,Runtime,Date,Math介绍及用法(API)
1 Object对象 面向对象的核心思想:“找合适的对象,做适合的事情”. 合适的对象: 自己描述类,自己创建对象. sun已经描述了好多常用的类,可以使用这些类创建对象. API(App ...
- “百度杯”CTF比赛 十月场_Login
题目在i春秋ctf大本营 打开页面是两个登录框,首先判断是不是注入 尝试了各种语句后,发现登录界面似乎并不存在注入 查看网页源代码,给出了一个账号 用帐密登陆后,跳转到到member.php网页,网页 ...
- WebRTC编译详细介绍 (转)
WebRTC技术交流群:234795279 原文地址:http://blog.csdn.net/temotemo/article/details/7056581 WebRTC编译 本人环境: 操作 ...
- hdu 1588(矩阵好题+递归求解等比数列)
Gauss Fibonacci Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- html --- rem
// rem (function(doc, win) { var docEle = doc.documentElement, evt = "onorientati ...
- Careercup | Chapter 2
链表的题里面,快慢指针.双指针用得很多. 2.1 Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow w ...
- mac 下删除xcode后使用git
1. http://blog.bobbyallen.me/2014/03/07/how-to-install-git-without-having-to-install-xcode-on-macosx ...
- loj #110. 乘法逆元
#110. 乘法逆元 内存限制:256 MiB时间限制:1000 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: 匿名 提交提交记录统计讨论测试数据 题目描述 这是一道模板题. 给定 ...
- 【UTR #2】题目交流通道
题目描述 定好了难度,雄心勃勃的吉米多出题斯基开始寻找智慧的神犇星球的居民出题. 然而吉米多出题斯基没有料到,神犇星球的居民告诉吉米多出题斯基:"今年神犇星球经济不景气,大家都想宅在家里,哪 ...