private void OnNewMarketDepth(object sender, MarketDepthEventArgs args) { if (this.HandleMarketData(args.Provider, args.Instrument)) { this.metaStrategyBase.SetNewMarketDepth(args); } }
protected override void OnMarketDepth(MarketDepthEventArgs e) { if (ShowLevelII) { List <LadderRow> rows = null; // Checks to see if the Market Data is of the Ask type if (e.MarketDataType == MarketDataType.Ask) { rows = askRows; } // Checks to see if the Market Data is of the Bid type else if (e.MarketDataType == MarketDataType.Bid) { rows = bidRows; } if (rows == null) { return; } // Checks to see if the action taken by the Ask data was an insertion into the ladder if (e.Operation == Operation.Insert) { rows.Insert(e.Position, new LadderRow(e.Price, e.Volume, e.MarketMaker)); } /* Checks to see if the action taken by the Ask data was a removal of itself from the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Remove && e.Position < rows.Count) { rows.RemoveAt(e.Position); } /* Checks to see if the action taken by the Ask data was to update a data already on the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Update && e.Position < rows.Count) { rows[e.Position].MarketMaker = e.MarketMaker; rows[e.Position].Price = e.Price; rows[e.Position].Volume = e.Volume; } // Calling ChartControl.Refresh() will cause the Level II data to update real-time. Adding // this delay routine will prevent CPU utilization from going through the roof. Setting a // really high value will effectly delay the update until the next tick arrives which could // be a really long time is the market is really slow. This may or may not matter to some. try { if (lastRefresh.AddMilliseconds(LevelIIRefreshDelay) < DateTime.Now) { ChartControl.Refresh(); lastRefresh = DateTime.Now; } } catch {} } }
public void Update(MarketDepthEventArgs args) { RowData val; if (args.Operation == Operation.Update || args.Operation == Operation.Add) { if (Data.TryGetValue(args.Price, out val)) { val.Price = args.Price; val.Liquidity = args.Volume; val.DataType = args.MarketDataType; val.Active = true; } else { Data.Add(args.Price, new RowData(args.Price, args.Volume, args.MarketDataType, true)); } } else if (args.Operation == Operation.Remove) { if (Data.TryGetValue(args.Price, out val)) { val.Active = false; } } FindHighestLiqudity(); }
protected override void OnMarketDepth(MarketDepthEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Ask && e.Operation == Operation.Update){ quote_count = quote_count +1; } //Print("The most recent ask change is " + e.Price + " " + e.Volume); }
private void ProviderManager_NewMarketDepth(object sender, MarketDepthEventArgs args) { lock (this) { ++this.countMarketDepth; ++this.countMarketDataTotal; } }
private static void OnNewMarketDepth(object sender, MarketDepthEventArgs e) { Instrument instrument = e.Instrument as Instrument ?? InstrumentManager.Instruments[e.Instrument.Symbol, e.Provider.Name]; if (instrument != null) { instrument.EmitNewMarketDepth(e); } }
protected override void OnMarketDepth(MarketDepthEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Ask && e.Operation == Operation.Update) { quote_count = quote_count + 1; } //Print("The most recent ask change is " + e.Price + " " + e.Volume); }
internal void EmitNewMarketDepth(MarketDepthEventArgs e) { this.MarketDepth = e.MarketDepth; if (this.NewMarketDepth != null) { this.NewMarketDepth(this, e); } this.OrderBook.Add(e.MarketDepth); }
protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate) { base.OnMarketDepth(marketDepthUpdate); GetPrediction(marketDepthUpdate.Price); if (requests % 50 == 0) { Print(string.Format("{0} requests per second", requests / sw.Elapsed.TotalSeconds)); } }
private void marketDataProvider_NewMarketDepth(object sender, MarketDepthEventArgs args) { FreeQuant.Instruments.Instrument instrument = args.Instrument as FreeQuant.Instruments.Instrument; List <StrategyRunner> list = (List <StrategyRunner>)null; if (!this.instrumentTable.TryGetValue(instrument, out list)) { return; } foreach (StrategyRunner strategyRunner in list) { strategyRunner.SetNewMarketDepth(instrument, args.MarketDepth); } }
protected override void OnMarketDepth(MarketDepthEventArgs e) {/* // Print some data to the Output window if (e.MarketDataType == MarketDataType.Bid && e.Operation == Operation.Update) { Print("The most recent bid change is " + e.Price + " " + e.Volume); //Values[0].Set(0); } if (e.MarketDataType == MarketDataType.Bid && e.Operation == Operation.Insert) { Print("The most recent bid insert is " + e.Price + " " + e.Volume); //Values[0].Set(0); }*/ }
protected override void OnMarketDepth(MarketDepthEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Bid && e.Operation == Operation.Update) { Print("The most recent bid change is " + e.Price + " " + e.Volume); //Values[0].Set(0); } if (e.MarketDataType == MarketDataType.Bid && e.Operation == Operation.Insert) { Print("The most recent bid insert is " + e.Price + " " + e.Volume); //Values[0].Set(0); } }
protected override void OnMarketDepth(MarketDepthEventArgs e) { // Checks to see if the Market Data is of the Ask type if (e.MarketDataType == MarketDataType.Ask) { oneDOMRow = askRows; } // Checks to see if the Market Data is of the Bid type else if (e.MarketDataType == MarketDataType.Bid) { oneDOMRow = bidRows; } if (oneDOMRow == null) { return; } // Checks to see if the action taken by the Ask data was an insertion into the ladder if (e.Operation == Operation.Add) { oneDOMRow.Insert(e.Position, new DOMRow(e.Price, (int)e.Volume)); } /* Checks to see if the action taken by the Ask data was a removal of itself from the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Remove && e.Position < oneDOMRow.Count) { oneDOMRow.RemoveAt(e.Position); } /* Checks to see if the action taken by the Ask data was to update a data already on the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Update && e.Position < oneDOMRow.Count) { oneDOMRow[e.Position].Price = e.Price; oneDOMRow[e.Position].Volume = (int)e.Volume; } try { if (DateTime.Now > lastRefresh.AddMilliseconds(refreshDelay)) { ForceRefresh(); lastRefresh = DateTime.Now; } } catch {} }
private void OnNewMarketDepth(object sender, MarketDepthEventArgs args) { if (!this.isRunning || !this.cbxMarketDepth.Checked) { return; } this.queue.Enqueue((Action)(() => { Instrument local_0 = ((IntradayEventArgs)args).Instrument as Instrument; InstrumentRow local_1 = this.instruments[local_0] as InstrumentRow; if (local_1 == null) { return; } local_0.Add(args.MarketDepth); ++local_1.MarketDepths; })); }
protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate) { }
private void MyOnMarketDepth(object sender, MarketDepthEventArgs e) { Print(e.ToString()); }
/// <summary> /// Called on each incoming real time market depth event /// </summary> protected override void OnMarketDepth(MarketDepthEventArgs e) { List <LadderRow> rows = null; // Checks to see if the Market Data is of the Ask type if (e.MarketDataType == MarketDataType.Ask) { rows = askRows; // Due to race conditions, it is possible the first event is an Update operation instead of an Insert. When this happens, populate your Lists via e.MarketDepth first. if (firstAskEvent) { if (e.Operation == Operation.Update) { // Lock the MarketDepth collection to prevent modification to the collection while we are still processing it lock (e.MarketDepth.Ask) { for (int idx = 0; idx < e.MarketDepth.Ask.Count; idx++) { rows.Add(new LadderRow(e.MarketDepth.Ask[idx].Price, e.MarketDepth.Ask[idx].Volume, e.MarketDepth.Ask[idx].MarketMaker)); } } } firstAskEvent = false; } } // Checks to see if the Market Data is of the Bid type else if (e.MarketDataType == MarketDataType.Bid) { rows = bidRows; // Due to race conditions, it is possible the first event is an Update operation instead of an Insert. When this happens, populate your Lists via e.MarketDepth first. if (firstBidEvent) { if (e.Operation == Operation.Update) { // Lock the MarketDepth collection to prevent modification to the collection while we are still processing it lock (e.MarketDepth.Bid) { for (int idx = 0; idx < e.MarketDepth.Bid.Count; idx++) { rows.Add(new LadderRow(e.MarketDepth.Bid[idx].Price, e.MarketDepth.Bid[idx].Volume, e.MarketDepth.Bid[idx].MarketMaker)); } } } firstBidEvent = false; } } if (rows == null) { return; } // Checks to see if the action taken was an insertion into the ladder if (e.Operation == Operation.Insert) { // Add a new row at the end if the designated position is greater than our current ladder size if (e.Position >= rows.Count) { rows.Add(new LadderRow(e.Price, e.Volume, e.MarketMaker)); } // Insert a new row into our ladder at the designated position else { rows.Insert(e.Position, new LadderRow(e.Price, e.Volume, e.MarketMaker)); } } /* Checks to see if the action taken was a removal of itself from the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Remove && e.Position < rows.Count) { rows.RemoveAt(e.Position); } /* Checks to see if the action taken was to update a data already on the ladder * Note: Due to the multi threaded architecture of the NT core, race conditions could occur * -> check if e.Position is within valid range */ else if (e.Operation == Operation.Update) { rows[e.Position].MarketMaker = e.MarketMaker; rows[e.Position].Price = e.Price; rows[e.Position].Volume = e.Volume; } }
protected override void OnMarketDepth(MarketDepthEventArgs e) { MyOrderBook.Update(e); ForceRefresh(); }