private void dgvTick_SelectionChanged() { if (dgvTick.CurrentRow == null) { return; } nTickCurrentRowIndex = dgvTick.CurrentRow.Index; if (listTickView == null || nTickCurrentRowIndex >= listTickView.Count) { return; } PbTickView tick2 = listTickView[nTickCurrentRowIndex]; pgBar.SelectedObject = tick2.Bar; pgStatic.SelectedObject = tick2.Static; pgConfig.SelectedObject = tick2.Config; pgSplit.SelectedObject = tick2.Split; if (dgvDepth.CurrentCell == null) { dgvDepth.DataSource = tick2.DepthList; return; } int ColumnIndex = dgvDepth.CurrentCell.ColumnIndex; int RowIndex = dgvDepth.CurrentCell.RowIndex; bool Selected = dgvDepth.CurrentRow.Selected; int FirstDisplayedScrollingRowIndex = dgvDepth.FirstDisplayedScrollingRowIndex; int HorizontalScrollingOffset = dgvDepth.HorizontalScrollingOffset; dgvDepth.DataSource = tick2.DepthList; if (tick2.DepthList != null) { RowIndex = Math.Min(RowIndex, tick2.DepthList.Count - 1); } dgvDepth.CurrentCell = dgvDepth.Rows[RowIndex].Cells[ColumnIndex]; if (Selected) { dgvDepth.CurrentRow.Selected = Selected; } dgvDepth.FirstDisplayedScrollingRowIndex = FirstDisplayedScrollingRowIndex; dgvDepth.HorizontalScrollingOffset = HorizontalScrollingOffset; // 设置背景色 int pos = DepthListHelper.FindAsk1PositionDescending(tick2.DepthList, tick2.AskPrice1); for (int i = 0; i <= pos; ++i) { for (int j = 0; j < dgvDepth.Rows[i].Cells.Count; ++j) { dgvDepth.Rows[i].Cells[j].Style.BackColor = Color.Tomato; } } }
private void pgConfig_Click(object sender, EventArgs e) { ValueChanged(true); PbTickView tick2 = listTickView[nTickCurrentRowIndex]; tick2.Config = (ConfigInfoView)pgConfig.SelectedObject; }
private void pgSplit_Click(object sender, EventArgs e) { ValueChanged(true); PbTickView tick2 = listTickView[nTickCurrentRowIndex]; tick2.Split = (StockSplitInfoView)pgSplit.SelectedObject; }
private void pgStatic_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { ValueChanged(true); PbTickView tick2 = listTickView[nTickCurrentRowIndex]; tick2.Static = (StaticInfoView)pgStatic.SelectedObject; }
private void pgBar_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { ValueChanged(true); PbTickView tick2 = listTickView[nTickCurrentRowIndex]; tick2.Bar = (BarInfoView)pgBar.SelectedObject; }
private static string getTime(PbTickView pbTickView) { return(String.Format("{0}:{1}:{2}.{3}", (pbTickView.Time_HHmm / 100).ToString("D2"), (pbTickView.Time_HHmm % 100).ToString("D2"), (pbTickView.Time_____ssf__ / 10).ToString("D2"), ((pbTickView.Time_____ssf__ % 10) * 100 + pbTickView.Time________ff).ToString("D3") )); }
private void dgvTick_SelectionChanged(object sender, EventArgs e) { if (dgvTick.CurrentRow == null) { return; } nTickCurrentRowIndex = dgvTick.CurrentRow.Index; if (listTickView == null || nTickCurrentRowIndex >= listTickView.Count) { return; } PbTickView tick2 = listTickView[nTickCurrentRowIndex]; BarInfoView bi = tick2.Bar; if (bi == null) { //bi = new BarInfoView(); } pgBar.SelectedObject = bi; StaticInfoView si = tick2.Static; if (si == null) { //si = new StaticInfoView(); } pgStatic.SelectedObject = si; ConfigInfoView ci = tick2.Config; if (ci == null) { //ci = new ConfigInfoView(); } pgConfig.SelectedObject = ci; StockSplitInfoView ssi = tick2.Split; if (ssi == null) { //ssi = new StockSplitInfoView(); } pgSplit.SelectedObject = ssi; dgvDepth.DataSource = Int2DoubleConverter.ToList(tick2.Depth1_3); }
private void dgvDepth_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (listTickView == null || nTickCurrentRowIndex >= listTickView.Count) { return; } ValueChanged(true); PbTickView tick2 = listTickView[nTickCurrentRowIndex]; List <DepthDetailView> list = (List <DepthDetailView>)dgvDepth.DataSource; tick2.Depth1_3 = Int2DoubleConverter.FromList(list); }
private DepthMarketDataField PbTick2DepthMarketDataField(PbTickCodec codec, PbTick tick) { PbTickView tickView = codec.Data2View(tick, false); DepthMarketDataField marketData = default(DepthMarketDataField); codec.GetUpdateTime(tick, out marketData.UpdateTime, out marketData.UpdateMillisec); marketData.TradingDay = tickView.TradingDay; marketData.ActionDay = tickView.ActionDay; marketData.LastPrice = tickView.LastPrice; marketData.Volume = tickView.Volume; marketData.Turnover = tickView.Turnover; marketData.OpenInterest = tickView.OpenInterest; marketData.AveragePrice = tickView.AveragePrice; if (tickView.Bar != null) { marketData.OpenPrice = tickView.Bar.Open; marketData.HighestPrice = tickView.Bar.High; marketData.LowestPrice = tickView.Bar.Low; marketData.ClosePrice = tickView.Bar.Close; } if (tickView.Static != null) { marketData.LowerLimitPrice = tickView.Static.LowerLimitPrice; marketData.UpperLimitPrice = tickView.Static.UpperLimitPrice; marketData.SettlementPrice = tickView.Static.SettlementPrice; marketData.Symbol = tickView.Static.Symbol; if (!string.IsNullOrWhiteSpace(tickView.Static.Exchange)) { marketData.Exchange = Enum <ExchangeType> .Parse(tickView.Static.Exchange); } } int count = tickView.DepthList == null ? 0 : tickView.DepthList.Count; if (count > 0) { int AskPos = DepthListHelper.FindAsk1Position(tickView.DepthList, tickView.AskPrice1); int BidPos = AskPos - 1; int _BidPos = BidPos; if (_BidPos >= 0) { marketData.BidPrice1 = tickView.DepthList[_BidPos].Price; marketData.BidVolume1 = tickView.DepthList[_BidPos].Size; --_BidPos; if (_BidPos >= 0) { marketData.BidPrice2 = tickView.DepthList[_BidPos].Price; marketData.BidVolume2 = tickView.DepthList[_BidPos].Size; --_BidPos; if (_BidPos >= 0) { marketData.BidPrice3 = tickView.DepthList[_BidPos].Price; marketData.BidVolume3 = tickView.DepthList[_BidPos].Size; --_BidPos; if (_BidPos >= 0) { marketData.BidPrice4 = tickView.DepthList[_BidPos].Price; marketData.BidVolume4 = tickView.DepthList[_BidPos].Size; --_BidPos; if (_BidPos >= 0) { marketData.BidPrice5 = tickView.DepthList[_BidPos].Price; marketData.BidVolume5 = tickView.DepthList[_BidPos].Size; } } } } } int _AskPos = AskPos; if (_AskPos < count) { marketData.AskPrice1 = tickView.DepthList[_AskPos].Price; marketData.AskVolume1 = tickView.DepthList[_AskPos].Size; ++_AskPos; if (_AskPos < count) { marketData.AskPrice2 = tickView.DepthList[_AskPos].Price; marketData.AskVolume2 = tickView.DepthList[_AskPos].Size; ++_AskPos; if (_AskPos < count) { marketData.AskPrice3 = tickView.DepthList[_AskPos].Price; marketData.AskVolume3 = tickView.DepthList[_AskPos].Size; ++_AskPos; if (_AskPos < count) { marketData.AskPrice4 = tickView.DepthList[_AskPos].Price; marketData.AskVolume4 = tickView.DepthList[_AskPos].Size; ++_AskPos; if (_AskPos < count) { marketData.AskPrice5 = tickView.DepthList[_AskPos].Price; marketData.AskVolume5 = tickView.DepthList[_AskPos].Size; } } } } } } return(marketData); }
public static PbTickStruct5 toStruct(PbTickView input) { var o = default(PbTickStruct5); codec.GetUpdateTime(input, out o.UpdateTime, out o.UpdateMillisec); o.TradingDay = input.TradingDay; o.ActionDay = input.ActionDay; o.LastPrice = (float)input.LastPrice; o.Volume = input.Volume; o.Turnover = (float)input.Turnover; o.OpenInterest = (float)input.OpenInterest; o.AveragePrice = (float)input.AveragePrice; if (input.Bar != null) { o.OpenPrice = (float)input.Bar.Open; o.HighestPrice = (float)input.Bar.High; o.LowestPrice = (float)input.Bar.Low; o.ClosePrice = (float)input.Bar.Close; } if (input.Static != null) { o.LowerLimitPrice = (float)input.Static.LowerLimitPrice; o.UpperLimitPrice = (float)input.Static.UpperLimitPrice; o.SettlementPrice = (float)input.Static.SettlementPrice; o.Symbol = input.Static.Symbol; o.Exchange = input.Static.Exchange; //o.Symbol = "IF"; //o.Exchange = "CFFEX"; o.PreClosePrice = (float)input.Static.PreClosePrice; o.PreSettlementPrice = (float)input.Static.PreSettlementPrice; o.PreOpenInterest = input.Static.PreOpenInterest; } o.Price = new float[10]; o.Size = new int[10]; int count = input.DepthList == null ? 0 : input.DepthList.Count; if (count > 0) { int AskPos = DepthListHelper.FindAsk1Position(input.DepthList, input.AskPrice1); // 卖一位置 int BidPos = AskPos - 1; // 买一位置,在数组中的位置 int BidCount = BidPos + 1; int AskCount = count - AskPos; if (BidCount > 0) { int j = 0; for (int i = BidPos; i >= 0; --i) { o.Price[4 - j] = (float)input.DepthList[i].Price; o.Size[4 - j] = input.DepthList[i].Size; ++j; } } if (AskCount > 0) { int j = 0; for (int i = AskPos; i < count; ++i) { o.Price[5 + j] = (float)input.DepthList[i].Price; o.Size[5 + j] = input.DepthList[i].Size; ++j; } } } return(o); }
private DepthMarketDataNClass PbTick2DepthMarketDataNClass(PbTickCodec codec, PbTickView tickView) { DepthMarketDataNClass marketData = new DepthMarketDataNClass(); codec.GetUpdateTime(tickView, out marketData.UpdateTime, out marketData.UpdateMillisec); marketData.TradingDay = tickView.TradingDay; marketData.ActionDay = tickView.ActionDay; marketData.LastPrice = tickView.LastPrice; marketData.Volume = tickView.Volume; if (SubscribeExternData) { marketData.Turnover = tickView.Turnover; marketData.OpenInterest = tickView.OpenInterest; marketData.AveragePrice = tickView.AveragePrice; if (tickView.Bar != null) { marketData.OpenPrice = tickView.Bar.Open; marketData.HighestPrice = tickView.Bar.High; marketData.LowestPrice = tickView.Bar.Low; marketData.ClosePrice = tickView.Bar.Close; } if (tickView.Static != null) { marketData.LowerLimitPrice = tickView.Static.LowerLimitPrice; marketData.UpperLimitPrice = tickView.Static.UpperLimitPrice; marketData.SettlementPrice = tickView.Static.SettlementPrice; marketData.Symbol = tickView.Static.Symbol; if (!string.IsNullOrWhiteSpace(tickView.Static.Exchange)) { marketData.Exchange = Enum <ExchangeType> .Parse(tickView.Static.Exchange); } marketData.PreClosePrice = tickView.Static.PreClosePrice; marketData.PreSettlementPrice = tickView.Static.PreSettlementPrice; marketData.PreOpenInterest = tickView.Static.PreOpenInterest; } } int count = tickView.DepthList == null ? 0 : tickView.DepthList.Count; if (count > 0) { int AskPos = DepthListHelper.FindAsk1Position(tickView.DepthList, tickView.AskPrice1); int BidPos = AskPos - 1; int BidCount = BidPos + 1; int AskCount = count - AskPos; marketData.Bids = new DepthField[0]; marketData.Asks = new DepthField[0]; if (SubscribeBid) { if (BidCount > 0) { marketData.Bids = new DepthField[BidCount]; int j = 0; for (int i = BidPos; i >= 0; --i) { marketData.Bids[j] = new DepthField() { Price = tickView.DepthList[i].Price, Size = tickView.DepthList[i].Size, Count = tickView.DepthList[i].Count, }; ++j; } } } if (SubscribeAsk) { if (AskCount > 0) { marketData.Asks = new DepthField[AskCount]; int j = 0; for (int i = AskPos; i < count; ++i) { marketData.Asks[j] = new DepthField() { Price = tickView.DepthList[i].Price, Size = tickView.DepthList[i].Size, Count = tickView.DepthList[i].Count, }; ++j; } } } } return(marketData); }