程序猿的量化交易之路(29)--Cointrader之Tick实体(16)
转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrade.top
Tick:什么是Tick,在交易平台中很常见,事实上就 单笔交易时某仅仅证券的基本数据。
我们通过代码来学习吧:
package org.cryptocoinpartners.schema; import javax.annotation.Nullable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient; import org.joda.time.Instant; /**
* A Tick is a point-in-time snapshot of a Market's last price, volume and most recent Book
*一个Tick是某一时刻某个交易品的最新交易价格、量和最新的报价单列表
* @author Tim Olson
*/
@Entity//在数据库中会创建数据表Tick
public class Tick extends PriceData implements Spread {
//继承自PriceData,一些市场的数据就包括了。
public Instant getStartInstant() {
return startInstant;
} @Transient
public Instant getEndInstant() {
return getTime();
} @ManyToOne
public Book getLastBook() {
return lastBook;
} /** @return null if no book was found prior to the window */
@Override
@Transient
public @Nullable
Offer getBestBid() {
return lastBook == null ? null : lastBook.getBestBid();
} /** @return null if no book was found prior to the window */
@Override
@Transient
public @Nullable
Offer getBestAsk() {
return lastBook == null ? null : lastBook.getBestAsk();
} public Tick(Market market, Instant startInstant, Instant endInstant, @Nullable Long lastPriceCount, @Nullable Long volumeCount, Book lastBook) {
super(endInstant, null, market, lastPriceCount, volumeCount);
this.startInstant = startInstant;
this.lastBook = lastBook;
} @Override
public String toString() {
return String.format("Tick{%s last:%g@%g bid:%s ask:%s}", getMarket(), getVolumeAsDouble(), getPriceAsDouble(), getBestBid(), getBestAsk());
} // JPA
protected Tick() {
} protected void setStartInstant(Instant startInstant) {
this.startInstant = startInstant;
} protected void setLastBook(Book lastBook) {
this.lastBook = lastBook;
} private Instant startInstant;
private Book lastBook;//报价单
}
程序猿的量化交易之路(29)--Cointrader之Tick实体(16)的更多相关文章
- 程序猿的量化交易之路(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 ...
- 程序猿的量化交易之路(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:组合,代表的是多个 ...
- 程序猿的量化交易之路(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中基本实体 ...
随机推荐
- 转:onConfigurationChanged的作用
API原文说明:android:configChangesLists configuration changes that the activity will handle itself. When ...
- Beginning MyBatis 3 Part 2 : How to Handle One-to-Many and One-to-One Selects
One of the latest MyBatis feature is the ability to use Annotations or XML to do One-to-One or One-t ...
- 简单的http代理服务器
简单的http代理服务器 本项目课程是基于 Python 实现的一个简单的 HTTP 代理服务器,要求用户需了解 Python 基础和一定的 HTTP 服务器基础知识.
- Python 30分钟入门——数据类型 & 控制结构
Python是一门脚本语言,我也久闻大名,但正真系统的接触学习是在去年(2013)年底到今年(2014)年初的时候.不得不说的是Python的官方文档相当齐全,假设你是在Windows上学习Pytho ...
- Spring笔记 - Bean xml装配
命名空间表 aop Provides elements for declaring aspects and for automatically proxying @AspectJannotated c ...
- C#对数字添加逗号,千分位
/// <summary> /// 对数字添加”,“号,可以处理负数以及带有小数的情况 /// </summary> /// <param name="vers ...
- lsh341999的资源
懒得下载了,仔细研究: http://download.csdn.net/user/lsh341999/uploads/2
- “/” 应用程序中的服务器错误 - IIS 发布错误
解决方法, 将bin目录下的全部文件复制到iis下
- 使用最新的log4cplus(1.1.1)隔离不同的 log 文件输出
部分参考了博客. http://www.cppblog.com/tx7do/articles/11719.html 基于脚本配置来过滤log信息 除了通过程序实现对log环境的配置之外,log4cpl ...
- Delphi - XP扫雷外挂制作
技术交流,DH讲解. 本来之前就在写这个文章,还写了War3挂的教程,后来因为一些事就没有弄了.现在过年在家又没有事就继续把这个写完吧.哈哈.不要以为写个挂很容易,要想写个挂肯定要了解游戏呀.我们现在 ...