程序猿的量化交易之路(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中基本实体 ...
随机推荐
- [ CodeVS冲杯之路 ] P1039
不充钱,你怎么AC? 题目:http://codevs.cn/problem/1039/ 一道赤裸裸的嘲讽型数学题,推出来的话算法代码就3行,没有推出来连暴力都无从入手…… 设 f(n,m) 为整数 ...
- 俄罗斯方块(NOIP模拟赛)(水·模拟)
真是一道神奇的题目233~ 原题传送门 迫不得已贴了个题解的链接.. 好吧,这道题就是分情况讨论,纯模拟,, 没有什么难的.. 脑洞要大,四面都要考虑,不能漏! #include<iostrea ...
- POCO库中文编程参考指南(2)基本数据类型(Poco/Types.h)
POCO库中文编程参考指南(2)基本数据类型 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> ...
- Vim文字编辑
首先说明发现的vim编辑器的一个特点:vim编辑只有按[ENTER]键或命令模式下[o]才会换行,否则虽然在vim编辑器里显示的内容换行了,但事实上没有换行.如果你发现自己测试的效果和下面描述的不符, ...
- 【linux高级程序设计】(第十四章)TCP高级应用 2
socket多路复用应用 int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct time ...
- luogu P1091 合唱队形
题目描述 N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2…,K,他们的身高分别为T1,T2, ...
- (转)unity3d加密资源并缓存加载
http://www.haogongju.net/art/1931680 首先要鄙视下unity3d的文档编写人员极度不负责任,到发帖为止依然没有更新正确的示例代码. view source pr ...
- 尝试解答java内存问题
在园子中看见了这个园友的问题,高手指点一下,关于编写Java程序让Jvm崩溃,恰巧这两天看了点相关的东西,也尝试了一下,下面是仁兄提出的第一个疑问,我来复现一下: package jvm; publi ...
- 快速搭建一个restful风格的springboot项目
1.创建一个工程. 2.引入pom.xml依赖,如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi ...
- 一篇不错的讲解Java异常的文章(转载)----感觉很不错,读了以后很有启发
六种异常处理的陋习 你觉得自己是一个Java专家吗?是否肯定自己已经全面掌握了Java的异常处理机制?在下面这段代码中,你能够迅速找出异常处理的六个问题吗? OutputStreamWriter ou ...