//当前时间的最后一笔交易,交易的时间可以是当前时间 public Trade GetLastTrade(string symbol, DateTime lastTime) { Trade trade = null; if (this.seriesNamesToPartitionStore.Contains("Trade")) { this.changeStoreFileForTime(lastTime); if ((this.lastFile != null)) { string seriesName = symbol + ".Trade"; if (this.lastFile.Series.Contains(seriesName)) { FileSeries series = this.lastFile.Series[seriesName]; ISeriesObject seriesObj = series[lastTime, SearchOption.Prev]; trade = (Trade)seriesObj; } } } else { Instrument inst = InstrumentManager.Instruments[symbol]; if (inst != null) { FileSeries series = (FileSeries)inst.GetDataSeries("Trade"); if (series != null) { ISeriesObject seriesObj = series[lastTime, SearchOption.Prev]; trade = (Trade)seriesObj; } } } return(trade); }
//当前时间的下一笔交易,交易时间必须是当前时间之后 public Trade GetNextTrade(string symbol, DateTime lastTime) { Trade trade = null; if (this.seriesNamesToPartitionStore.Contains("Trade")) { this.ChangeStoreFileForTime(lastTime); if (this.lastFile != null) { string seriesName = symbol + ".Trade"; if (this.lastFile.Series.Contains(seriesName)) { FileSeries series = this.lastFile.Series[seriesName]; int index = series.IndexOf(lastTime, SearchOption.Next); if (index >= 0) { ISeriesObject seriesObj = series[index]; if (seriesObj.DateTime == lastTime) { seriesObj = series[index + 1]; } trade = (Trade)seriesObj; } } } } else { Instrument inst = InstrumentManager.Instruments[symbol]; if (inst != null) { FileSeries series = (FileSeries)inst.GetDataSeries("Trade"); if (series != null) { int index = series.IndexOf(lastTime, SearchOption.Next); if (index >= 0) { ISeriesObject seriesObj = series[index]; if (seriesObj.DateTime == lastTime) { seriesObj = series[index + 1]; } trade = (Trade)seriesObj; } } } } return(trade); }
public Dictionary <string, Trade> GetLastTrades(string[] symbols, DateTime lastTime) { Dictionary <string, Trade> tradeDict = new Dictionary <string, Trade>(); if (this.seriesNamesToPartitionStore.Contains("Trade")) { this.changeStoreFileForTime(lastTime); if ((this.lastFile != null)) { foreach (string symbol in symbols) { string seriesName = symbol + ".Trade"; if (this.lastFile.Series.Contains(seriesName)) { FileSeries series = this.lastFile.Series[seriesName]; ISeriesObject trade = series[lastTime, SearchOption.Prev]; tradeDict.Add(symbol, (Trade)trade); } } } } else { foreach (string symbol in symbols) { Instrument inst = InstrumentManager.Instruments[symbol]; if (inst != null) { FileSeries series = (FileSeries)inst.GetDataSeries("Trade"); if (series != null) { ISeriesObject trade = series[lastTime, SearchOption.Prev]; tradeDict.Add(symbol, (Trade)trade); } } } } return(tradeDict); }
public void Add(ISeriesObject obj) { // this.streamer.jGN7PFamp(this, obj); }