public static void ProcessMarketDataField(ThostFtdcDepthMarketDataField field) { var quotation = new Quotation(field); int volume = 0; Quotation preQuotation; if (quotationDic.TryGetValue(quotation.InstrumentID, out preQuotation) && preQuotation.TradingDay == quotation.TradingDay) { volume = quotation.Volume - preQuotation.Volume; } quotationDic[quotation.InstrumentID] = quotation; CandleCenter.ProcessQuotation(quotation, volume); DataSaver.AddQuotation(quotation); IQuotationReceiver[] receivers; lock (subscribeDic) { List<IQuotationReceiver> receiverList; if (!subscribeDic.TryGetValue(quotation.InstrumentID, out receiverList)) { return; } receivers = receiverList.ToArray(); } foreach (var item in receivers) { item.ProcessQuotation(quotation, volume); } }
public void UpdateCandle(Quotation quotation, int volume) { this.Close = quotation.LastPrice; this.High = Math.Max(this.High, quotation.LastPrice); this.Low = Math.Min(this.Low, quotation.LastPrice); this.Volume += volume; this.OpenInterest = quotation.OpenInterest; }
public static void ProcessQuotation(Quotation quotation, int volume) { CandleBuilder builder; if (!builders.TryGetValue(quotation.InstrumentID, out builder)) { builder = new CandleBuilder(CandleDAL.GetLast(quotation.InstrumentID), CandleType.Minute); builders.Add(quotation.InstrumentID, builder); } builder.ProcessQuotation(quotation, volume); DataSaver.AddCandle(builder.LastData); }
public Candle(Quotation quotation, DateTime candleTime, int volume) { this.InstrumentID = quotation.InstrumentID; this.TradingDay = quotation.TradingDay; this.CandleTime = candleTime; this.Open = quotation.LastPrice; this.Close = quotation.LastPrice; this.High = quotation.LastPrice; this.Low = quotation.LastPrice; this.Volume = volume; this.OpenInterest = quotation.OpenInterest; }
public bool ProcessQuotation(Quotation quotation, int volume) { DateTime newCandleTime = CandleHelper.GetCandleTime(quotation.Time, quotation.TradingDay, this.type); if (this.LastData == null || this.LastData.CandleTime != newCandleTime) { this.LastData = new Candle(quotation, newCandleTime, volume); return true; } else { this.LastData.UpdateCandle(quotation, volume); return false; } }
public static List<Quotation> Get() { var table = new DataTable(); var adapter = new SQLiteDataAdapter("SELECT * FROM quotation", DALUtil.Connection); adapter.Fill(table); var quotations = new List<Quotation>(); foreach (var item in table.Rows) { var row = item as DataRow; var quotation = new Quotation(); quotation.TradingDay = row.Field<DateTime>(0); quotation.InstrumentID = row.Field<string>(1); quotation.ExchangeID = row.Field<string>(2); quotation.ExchangeInstID = row.Field<string>(3); quotation.LastPrice = DALUtil.GetDouble(row[4]); quotation.PreSettlementPrice = DALUtil.GetDouble(row[5]); quotation.PreClosePrice = DALUtil.GetDouble(row[6]); quotation.PreOpenInterest = DALUtil.GetDouble(row[7]); quotation.OpenPrice = DALUtil.GetDouble(row[8]); quotation.HighestPrice = DALUtil.GetDouble(row[9]); quotation.LowestPrice = DALUtil.GetDouble(row[10]); quotation.Volume = row.Field<int>(11); quotation.Turnover = DALUtil.GetDouble(row[12]); quotation.OpenInterest = DALUtil.GetDouble(row[13]); quotation.ClosePrice = DALUtil.GetDouble(row[14]); quotation.SettlementPrice = DALUtil.GetDouble(row[15]); quotation.UpperLimitPrice = DALUtil.GetDouble(row[16]); quotation.LowerLimitPrice = DALUtil.GetDouble(row[17]); quotation.PreDelta = DALUtil.GetDouble(row[18]); quotation.CurrDelta = DALUtil.GetDouble(row[19]); quotation.Time = row.Field<DateTime>(20); quotation.BidPrice1 = DALUtil.GetDouble(row[21]); quotation.BidVolume1 = row.Field<int>(22); quotation.AskPrice1 = DALUtil.GetDouble(row[23]); quotation.AskVolume1 = row.Field<int>(24); quotation.AveragePrice = row.Field<double>(25); quotations.Add(quotation); } return quotations; }
public void Update(Quotation quotation) { this.LastPrice = GetNullableDouble(quotation.LastPrice); this.PreSettlementPrice = GetNullableDouble(quotation.PreSettlementPrice); this.PreClosePrice = GetNullableDouble(quotation.PreClosePrice); this.PreOpenInterest = GetNullableDouble(quotation.PreOpenInterest); this.OpenPrice = GetNullableDouble(quotation.OpenPrice); this.HighestPrice = GetNullableDouble(quotation.HighestPrice); this.LowestPrice = GetNullableDouble(quotation.LowestPrice); this.Volume = quotation.Volume; this.Turnover = GetNullableDouble(quotation.Turnover); this.OpenInterest = GetNullableDouble(quotation.OpenInterest); this.ClosePrice = GetNullableDouble(quotation.ClosePrice); this.SettlementPrice = GetNullableDouble(quotation.SettlementPrice); this.UpperLimitPrice = GetNullableDouble(quotation.UpperLimitPrice); this.LowerLimitPrice = GetNullableDouble(quotation.LowerLimitPrice); this.PreDelta = GetNullableDouble(quotation.PreDelta); this.CurrDelta = GetNullableDouble(quotation.CurrDelta); this.Time = quotation.Time; this.BidPrice1 = GetNullableDouble(quotation.BidPrice1); this.BidVolume1 = quotation.BidVolume1; this.AskPrice1 = GetNullableDouble(quotation.AskPrice1); this.AskVolume1 = quotation.AskVolume1; this.AveragePrice = Math.Round(quotation.AveragePrice, 2); }
public QuotationModel(Quotation quotation) { this.InstrumentID = quotation.InstrumentID; this.Update(quotation); }
public void ProcessQuotation(Quotation quotation, int volume) { QuotationModel quotationModel = this.Quotations.First(p => p.InstrumentID == quotation.InstrumentID); quotationModel.Update(quotation); }
public void ProcessQuotation(Quotation quotation, int volume) { if (this.builder == null) { return; } bool isCreateOrUpdate = this.builder.ProcessQuotation(quotation, volume); this.dispatcher.Invoke(() => { if (isCreateOrUpdate) { this.Candles.Add(this.builder.LastData); } else { this.Candles[this.Candles.Count - 1] = this.builder.LastData; } }); }
public static void AddQuotation(Quotation quotation) { quotationQueue.Enqueue(quotation); }