/// <summary> /// 添加合约 /// </summary> /// <param name="quote">合约信息</param> public void AddQuote(Quote quote) { quote.SetPanel(this); quote.CreateCells(this.dataTable); DataGridViewCellCollection cells = quote.Cells; cells[0].Value = quote.call.LongPosition.Position; cells[1].Value = quote.call.LongPosition.TodayPosition; cells[2].Value = ""; cells[3].Style.Format = StaticFunction.GetPriceFormat(quote.call.Contract.PriceTick); cells[3].Value = quote.call.MarketData.BidPrice1 > 99999 ? double.NaN : quote.call.MarketData.BidPrice1; cells[4].Value = ""; cells[5].Style.Format = StaticFunction.GetPriceFormat(quote.call.Contract.PriceTick); cells[5].Value = quote.call.MarketData.AskPrice1 > 99999 ? double.NaN : quote.call.MarketData.AskPrice1; cells[6].Value = ""; cells[7].Value = quote.call.ShortPosition.TodayPosition; cells[8].Value = quote.call.ShortPosition.Position; cells[9].Style.Format = "P2"; cells[9].Value = quote.call.ImpliedVolatility; string[] temp = quote.call.Contract.InstrumentID.Split('-'); cells[10].Value = temp[0] + " " + temp[2]; cells[11].Style.Format = "P2"; cells[11].Value = quote.put.ImpliedVolatility; cells[12].Value = quote.put.LongPosition.Position; cells[13].Value = quote.put.LongPosition.TodayPosition; cells[14].Value = ""; cells[15].Style.Format = StaticFunction.GetPriceFormat(quote.put.Contract.PriceTick); cells[15].Value = quote.put.MarketData.BidPrice1 > 99999 ? double.NaN : quote.put.MarketData.BidPrice1; cells[16].Value = ""; cells[16].Style.Format = StaticFunction.GetPriceFormat(quote.put.Contract.PriceTick); cells[17].Value = quote.put.MarketData.AskPrice1 > 99999 ? double.NaN : quote.put.MarketData.AskPrice1; cells[18].Value = ""; cells[19].Value = quote.put.ShortPosition.TodayPosition; cells[20].Value = quote.put.ShortPosition.Position; this.dataTable.Rows.Add(quote); }
/// <summary> /// 显示或者隐藏报价窗口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void quoteFormToolStripMenuItem_Click(object sender, EventArgs e) { QuoteForm = new QuoteForm(); foreach (ActiveContract activeContract in MarketManeger.ActiveContractDictionary.Values) { if (activeContract.Contract.InstrumentID.Contains("C")) { string callID = activeContract.Contract.InstrumentID; string putID = callID.Replace("C", "P"); ActiveContract call; ActiveContract put; ActiveContract underlying; if (MarketManeger.ActiveContractDictionary.TryGetValue(callID, out call) && MarketManeger.ActiveContractDictionary.TryGetValue(putID, out put) && MarketManeger.ActiveContractDictionary.TryGetValue("IF1408", out underlying)) { Quote quote = new Quote(call, put, underlying); QuoteForm.quotePanel.AddQuote(quote); } } } if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { QuoteForm.MdiParent = this; QuoteForm.Show(); } else { QuoteForm.Show(dockPanel); } }