//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event notification for Time & Sales update. </summary> /// <param name="sender"> Source of the event. </param> /// <param name="e"> Time & Sales event information. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// void m_tsSubscription_Update(object sender, TimeAndSalesEventArgs e) { Console.WriteLine("\n================= {0}", m_ps_counter++); if (e.Error == null) { // More than one LTP/LTQ may be received in a single event foreach (TimeAndSalesData ts in e.Data) { Price ltp = ts.TradePrice; Quantity ltq = ts.TradeQuantity; Console.WriteLine("\n[{0}] {1} isOTC={2} isImplied={3} isLegTrade={4} {5} {6} @ {7}", ts.TimeStamp, ts.Instrument.Name, ts.IsOverTheCounter, ts.IsImplied, ts.IsLegTrade, ts.Direction, ts.TradePrice, ts.TradeQuantity); } } else { if (e.Error != null) { Console.WriteLine("Unrecoverable Time and Sales subscription error: {0}", e.Error.Message); tt_net_sdk.TimeAndSalesSubscription ts = (tt_net_sdk.TimeAndSalesSubscription)sender; Console.WriteLine("Unrecoverable price subscription error: {0}", e.Error.Message); ts.Dispose(); } } }
private void tsSub_Update(object sender, TimeAndSalesEventArgs e) { foreach (TimeAndSalesData tsData in e.Data) { Price ltp = tsData.TradePrice; Quantity ltq = tsData.TradeQuantity; if (CSOpen == 0) { CSOpen = ltp.ToTicks(); } if (ltp.ToTicks() > CSHigh) { CSHigh = ltp.ToTicks(); } else if (ltp.ToTicks() < CSLow || CSLow == 0) { CSLow = ltp.ToTicks(); } CSClose = ltp.ToTicks(); } //MainForm.CSInterumData(); }
/// <summary> /// Event notification for Time & Sales update /// </summary> void m_ts_Update(object sender, TimeAndSalesEventArgs e) { if (e.Error == null) { // More than one LTP/LTQ may be received in a single event foreach (TimeAndSalesData tsData in e.Data) { Price ltp = tsData.TradePrice; Quantity ltq = tsData.TradeQuantity; Console.WriteLine("LTP = {0} : LTQ = {1}", ltp.ToString(), ltq.ToInt()); } } }
/// <summary> /// Event notification for trade updates /// </summary> public void tsSub_Update(object sender, TimeAndSalesEventArgs e) { // process the update if (e.Error == null) { foreach (TimeAndSalesData tsData in e.Data) { Console.WriteLine("{0} : {1} --> LTP/LTQ : {2}/{3}", Thread.CurrentThread.Name, e.Instrument.Name, tsData.TradePrice, tsData.TradeQuantity); } // Add strategy logic here } }
// // //****************************************************************** // **** TimeAndSalesSubscription_Updated() **** //****************************************************************** // /// <summary> /// Time and Sales data is uncoalesced trade data. This allows us to a better job /// of diffrentiating sides volume traded on while recording data for analysis. /// This update Volume on all sides but last. The price subscription has a good last traded volume /// field, this is used only for more in depth analysis when needed /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void TimeAndSalesSubscription_Updated(object sender, TimeAndSalesEventArgs eventArgs) { if (m_isDisposing) { return; } if (eventArgs.Error == null) { UVProd.InstrumentName instrumentName; InstrumentKey key = eventArgs.Instrument.Key; if (m_KeyToInstruments.TryGetValue(key, out instrumentName)) { if (eventArgs.Data.Count != 0) { // is any data packed with this event m_NewEvents.Clear(); MarketBase newEvent = m_Market.m_MarketBaseFactory.Get(); // Get an event arg. newEvent.ClearVolume(); // make sure our event is clean. newEvent.Name = instrumentName; int[] instrumentVolumeArray = m_InstrKeyToVolume[key]; foreach (TimeAndSalesData timeAndSalesData in eventArgs.Data) { // for each trade if (!timeAndSalesData.IsOverTheCounter) { // this trade was not OTC int tradeSide = TTConvertNew.ToUVMarketSide(timeAndSalesData.Direction); //long, short or unknown if (timeAndSalesData.TradeQuantity.IsValid) { // qty is valid so aggregate all qty's by the direction of the trade instrumentVolumeArray[tradeSide] += timeAndSalesData.TradeQuantity.ToInt(); } } } for (int side = 0; side < newEvent.Volume.Length; side++) { // update all sides newEvent.Volume[side] = instrumentVolumeArray[side]; } newEvent.IsIncludesTimeAndSales = true; m_NewEvents.Add(newEvent); ProcessPriceChangeEvents(ref m_NewEvents); } } } }
/// <summary> /// Event to notify the application there has been a change in the time and sales feed /// Here we pull the values and publish them to the GUI /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void timeAndSalesSubscription_Update(object sender, TimeAndSalesEventArgs e) { if (e.Error != null) { Console.WriteLine(String.Format("TT API TimeAndSalesSubscription Error: {0}", e.Error.ToString())); return; } this.dgTimeAndSales.SuspendLayout(); // TAS data is delivered as a list. Iterate through and publish to the DataGrid // The zero in the first parameter signifies we're inserting at the beginning of the list (new data always on top) foreach (TimeAndSalesData tsData in e.Data) { m_TimeAndSalesList.Insert(0, tsData); } this.dgTimeAndSales.ResumeLayout(); }
void tsSub_Update(object sender, TimeAndSalesEventArgs e) { if (e.Error == null) { TTInstrument tti = _ttInstruments[e.Instrument.Key]; Price ltp; Quantity ltq; DateTime timestamp; TradeDirection direction; bool isOTC; foreach (TimeAndSalesData tsData in e.Data) { timestamp = tsData.TimeStamp; ltp = tsData.TradePrice; ltq = tsData.TradeQuantity; direction = tsData.Direction; isOTC = tsData.IsOverTheCounter; if (OnTimeAndSales != null) { OnTimeAndSales(tti, timestamp, ltp, ltq, direction, isOTC); } } } }
/// <summary> /// Event to notify the application there has been a change in the time and sales feed /// Here we pull the values and publish them to the GUI /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void timeAndSalesSubscription_Update(object sender, TimeAndSalesEventArgs e) { if (e.Error != null) { Console.WriteLine(String.Format("TT API TimeAndSalesSubscription Error: {0}", e.Error.ToString())); return; } this.dgTimeAndSales.SuspendLayout(); // TAS data is delivered as a list. Iterate through and publish to the DataGrid // The zero in the first parameter signifies we're inserting at the beginning of the list (new data always on top) foreach (TimeAndSalesData tsData in e.Data) m_TimeAndSalesList.Insert(0, tsData); this.dgTimeAndSales.ResumeLayout(); }