转载需注明出处:http://blog.csdn.net/minimicall,http://cloudtrader.top
1. 代码
package org.cryptocoinpartners.schema; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; public class Bar extends Event { private long timestamp;//时间戳 private Double open;//开盘价 private Double close;//收盘价 private Double high;//最高价 private Double low;//最低价 private Market market;//市场 private static final DateTimeFormatter FORMAT = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); // private static final SimpleDateFormat FORMAT = new SimpleDateFormat("dd.MM.yyyy kk:mm:ss"); private static final String SEPARATOR = ","; public Bar(long timestamp, Double open, Double close, Double high, Double low, Market market) { this.timestamp = timestamp; this.open = open; this.close = close; this.high = high; this.low = low; this.market = market; } @Override public long getTimestamp() { return timestamp; } public Double getOpen() { return open; } public Double getClose() { return close; } public Double getHigh() { return high; } public Double getLow() { return low; } public Market getMarket() { return market; } protected void setTimestamp(long timestamp) { this.timestamp = timestamp; } protected void setOpen(Double open) { this.open = open; } protected void setHigh(Double high) { this.high = high; } protected void setLow(Double low) { this.low = low; } protected void setClose(Double close) { this.close = close; } protected void setMarket(Market market) { this.market = market; } @Override public String toString() { return "Bar Start=" + (getTimestamp() != 0 ? (FORMAT.print(getTimestamp())) : "") + SEPARATOR + "Market=" + getMarket() + SEPARATOR + "Open=" + getOpen() + SEPARATOR + "High=" + getHigh() + SEPARATOR + "Low=" + getLow() + SEPARATOR + "Close=" + getClose(); } }
这个Bar就是条。就是我们K线图中的一根K线。它包含时间以及该时间点上的OCHL值。
这里有个Market,我们在后面的节中会说明。
我们的每一节都很简单,但就是一节节简单的内容最后走下来就组成了一个复杂的量化交易平台。
路遥知马力。
时间: 2024-09-20 09:37:25