程序员的量化交易之路(29)--Cointrader之Tick实体(16)
2015-06-06 13:51
369 查看
转载需注明出处: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;//报价单
}
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;//报价单
}
相关文章推荐
- 程序员的量化交易之路(1)----规划开篇
- 程序员的量化交易之路(2)----Esper文档学习之技术概览(1)
- 程序员的量化交易之路(3)--Esper事件Event(2)
- 程序员的量化交易之路(4)--Esper之事件(3)
- 程序员的量化交易之路(6)-Esper之处理模型(5)
- 程序员的量化交易之路(7)--金融概念Positon
- 程序员的量化交易之路(8)---金融概念Listing&delisting
- 程序员的量化交易之路(9)--金融系统概念basis
- 程序员的量化交易之路(10)--金融概念Stop-limit Order
- 程序员的量化交易之路(11)--命令参数解析库JCommonder学习
- 程序员的量化交易之路(13)--Cointrader类图(1)
- 程序员的量化交易之路(14)--Cointrader数据表(2)
- 程序员的量化交易之路(15)--Cointrader之EntityBase类(3)
- 程序员的量化交易之路(16)--Hibernate注解总结_转发的(4)
- 程序员的量化交易之路(17)--Cointrader之Temporal实体(5)
- swoole tick example
- SylixOS BSP tick驱动流程
- 量化交易 年薪180万的职位要求
- curl量化交易程序初试
- 量化数据