转载需注明出处: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)的更多相关文章

  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. 程序猿的量化交易之路(30)--Cointrader之ConfigUtil(17)

    转载须注明出处:viewmode=contents">http://blog.csdn.net/minimicall?viewmode=contents.http://cloudtra ...

  5. 程序猿的量化交易之路(26)--Cointrader之Listing挂牌实体(13)

    转载须注明出处:http://blog.csdn.net/minimicall? viewmode=contents,http://cloudtrade.top Listing:挂牌. 比方某仅仅股票 ...

  6. 程序猿的量化交易之路(32)--Cointrade之Portfolio组合(19)

    转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ Portfolio:组合,代表的是多个 ...

  7. 程序猿的量化交易之路(27)--Cointrader之PriceData价格数据(14)

    转载须注明出处:http://blog.csdn.net/minimicall?viewmode=contents,http://cloudtrade.top/ PriceData:价格数据.价格数据 ...

  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. (二十二)函数fseek() 用法

    fseek 函数名: fseek功 能: 重定位流上的文件指针用 法: int fseek(FILE *stream, long offset, int fromwhere);描 述: 函数设置文件指 ...

  2. kubernetes 搭建集群外部ip服务

    nginx-pod.yaml apiVersion: v1 kind: Pod metadata: name: webapp labels: app: webapp spec: containers: ...

  3. 1.Openstack-环境安装

    Centos7 OpenStack环境安装 Ifcofnig vim命令 Centos7最小化安装后如没有ifconfig vim命令,执行: 1 yum install -y net-tools v ...

  4. 判断dataset是否被修改—DataSet.HasChanges 方法

    DataSet.HasChanges 方法 获取一个值,该值指示 DataSet 是否有更改,包括新增行.已删除的行或已修改的行. 命名空间:   System.Data程序集:  System.Da ...

  5. 考勤的lua脚本

    ngx.header.content_type = "text/plain;charset=utf-8" local cjson = require "cjson&quo ...

  6. poj2184

    Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13578   Accepted: 5503 D ...

  7. 检查点--JMeter也有之二“检查点”

    检查点:简单的来理解一下,上一章讲到,我们对用户名和密码进行了参数化,那么怎样来判断jmeter有没有正确调用test.dat里面的文件呢.当然,我们可以从结果图表中查看.但我还是想在“登录”这个地方 ...

  8. JAVA RandomAccessFile writeBytes

    writeBytes public final void writeBytes(String s) throws IOException 按字节序列将该字符串写入该文件.该字符串中的每个字符均按顺序写 ...

  9. Python学习笔记——对象

    Python 的对象定义方式如下: class Person:        def __init__(self, name):            self.name = name         ...

  10. DirectoryServicesCOMException

    捕捉到 System.DirectoryServices.DirectoryServicesCOMException Message=该服务器不愿意处理该请求. Source=System.Direc ...