程序猿的量化交易之路(24)--Cointrader之RemoteEvent远程事件实体(11)
转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrader.top/
在量化交易系统中。有些事件是远端传来的,比方股票的价格数据等。所以,在这一节我们定义了一个远端事件实体。
它是一个基类。并不单独生成数据表。
详细代码例如以下:
package org.cryptocoinpartners.schema; import javax.annotation.Nullable;
import javax.persistence.Basic;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient; import org.hibernate.annotations.Type;
import org.joda.time.Instant; @MappedSuperclass
public abstract class RemoteEvent extends Event { /**
* @return the time when this event object was created. it may be later than getTime() due to transmission delays
*/
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong")
@Basic(optional = false)
public Instant getTimeReceived() {
return timeReceived;
} @Transient
public long getTimestampReceived() {
return timestampReceived;
} @Basic(optional = true)
public String getRemoteKey() {
return remoteKey;
} @Override
public void publishedAt(Instant instant) {
super.publishedAt(instant);
if (timeReceived == null)
timeReceived = instant;
this.timestampReceived = timeReceived.getMillis(); } protected RemoteEvent(Instant time, @Nullable String remoteKey) {
this(time, Instant.now(), remoteKey);
} protected RemoteEvent(Instant time, Instant timeReceived, @Nullable String remoteKey) {
super(time);
this.remoteKey = remoteKey;
this.timeReceived = timeReceived;
this.timestampReceived = timeReceived.getMillis();
} // JPA
protected RemoteEvent() {
} protected void setTimeReceived(Instant timeReceived) {
this.timeReceived = timeReceived;
this.timestampReceived = timeReceived.getMillis();
} protected void setRemoteKey(@Nullable String remoteKey) {
this.remoteKey = remoteKey;
} private Instant timeReceived;
private long timestampReceived;
private String remoteKey;
}
程序猿的量化交易之路(24)--Cointrader之RemoteEvent远程事件实体(11)的更多相关文章
- 程序猿的量化交易之路(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,在交易平台中很常见,事实上就 单笔交易时某仅仅证券 ...
- 程序猿的量化交易之路(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:组合,代表的是多个 ...
- 程序猿的量化交易之路(27)--Cointrader之PriceData价格数据(14)
转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ PriceData:价格数据.价格数据 ...
- 程序猿的量化交易之路(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中基本实体 ...
随机推荐
- 计算器的改良(纯字符串)o1
原题传送门 这题比较水,就是细节..多了点. 首先字符串要处理好(废话..) 基础不行的话要多去看看书.. 然后捏,这题主要就是几个判断: 当我们读字符,如果读到运算符号,那么就要停下来,把之前的常数 ...
- android与java的关系
摘自:http://bbs.51cto.com/thread-944897-1.html 相信学习android的人都会想过或者想知道这个问题,那就请你耐心的看完这篇文章吧,你会对android与 ...
- Kubernetes监控工具
#镜像在谷歌上需要FQ#####################################监控工具#当前最新版本 heapster https://github.com/kubernetes/h ...
- python接口自动化9-https请求(SSL)【转载】
本篇转自博客:上海-悠悠 原文地址:http://www.cnblogs.com/yoyoketang/tag/python%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E ...
- react 使用Form组件如何清空上一次操作
最近在做一个表单联查时候,总是会发现后一个选择器会记住上一次选择的值 ,这会导致前一级选择器已经做出更新后,后一级选择器却还记住上一次的操作, 这里有个方法可以在上级选择器事件操作时清空Form组件的 ...
- HDU 6312.Game-博弈-签到题 (2018 Multi-University Training Contest 2 1004)
2018 Multi-University Training Contest 2 6312.Game 博弈,直接官方题解,懒了. 考虑将游戏变成初始时只有2~n,如果先手必胜的话,那么先手第一步按这样 ...
- 计蒜客 18487.Divisions-大数的所有因子个数-Miller_Rabin+Pollard_rho-超快的(大数质因解+因子个数求解公式) (German Collegiate Programming Contest 2015 ACM-ICPC Asia Training League 暑假第一阶段第三场 F)
这一场两个和大数有关的题目,都用到了米勒拉宾算法,有点东西,备忘一下. 题目传送门 F. Divisions 传送门 这个题是求一个数的所有因子个数,但是数据比较大,1e18,所以是大数的题目,正常的 ...
- ANDROID模拟器访问本地WEB应用10.0.2.2
在一般的Java Web程序开发中,我们通常使用localhost或者127.0.0.1来访问本机的Web服务,但是如果我们在Android模拟器中也采用同样的地址来访问,Android模拟器将无法正 ...
- 在eclipse上部署openfire 3.9.1源码,並配置openfire
参考文章:https://my.oschina.net/u/1409622/blog/205603 在网上找了很久部署openfire源码的文章,由于我使用的是最新的3.9.1源码,试了很多种部署方法 ...
- C#日期格式化,时间
日期转化一 为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007-01-03 14:33:34 ,要转化为其他格式,要用到DateTime.ToString的方法(String, ...