public static void LogSymbolUpdate(Security s) { if (!_loggingenabled) return; Trace.WriteLine(s.ToString()); }
public void PublishMarketData(Security data) { if (null == clients || !clients.Any() || null == data) return; TotalDataPublished++; Parallel.ForEach(clients, callback => InternalPublishMarketData(data, callback)); }
public bool PublishMarketDataNullDataTest(Security sec) { OnDataReceived = PublishMarketDataNullDataTestDataHandler; PublishMarketData(sec); // Excepted result is that NO data will be published to // listeners / clients. return (null == _nullsec); }
public bool PublishMarketDataNullDataHandlerTest() { var sec = new Security("Aggregator", "YYY", 9.05D); OnDataReceived = null; PublishMarketData(sec); // Excepted result is that NO data will be published to // listeners / clients. return (null == _nullsec); }
public bool PublishMarketDataMarketClosedEventTest(string providerid, string name, double value) { OnDataReceived = MarketDataReaderTestsDataReceivedHandler; var sec = new Security(providerid, name, value); PublishMarketData(sec); // Excepted result is this item will be published to // listeners / clients. return (sec == data.First()); }
public bool PublishMarketDataNewDataEventTest(string providerid, string name, double value) { OnDataReceived = PublishMarketDataNewDataEventTestHandler; _onNewSecurityTicksEvent = OnNewSecurityTicksEvent; var sec = new Security(providerid, name, value); PublishMarketData(sec); // Excepted result is this item will be published to // listeners / clients. return (null != _ticks && _ticks.SymbolTicks.First() == _AAAsec); }
internal void ComputeSymbolValue(DataReceivedHandler datareceivedHandler) { // Total Number of Symbols created / updated EOV = // MaxiumSymbolUpdates X MaxiumNumberOfSymbolBots X GetProviderSymbols.Count List<string> symbols = ProviderSymbols; Random rnd = new Random(); int MAXUPDATES = MaxiumSymbolUpdates; for (var i = 0; i < MAXUPDATES; i++) { Parallel.ForEach(symbols, name => { var value = rnd.Next(55, 106) / 10D; var s = new Security(ProviderId, name, value); MarketDataLogger.LogSymbolUpdate(s); if (null != datareceivedHandler) datareceivedHandler(s); }); } }
public void PublishMarketData(Security data) { if (null == data) return; Interlocked.Increment(ref _recordCount); // Market closed event or user requested cancellation if (data.Name == Miscellaneous.END_OF_FEED) { OnMarketClosedEvent(data); return; } else if (IsCancellationRequested) { EndSession(); return; } if (null != OnDataReceived) OnDataReceived(data); }
public bool AggregatorSymbolProcessorTaskWorkPublishResultsTest(string name) { // Intercept the OnPublish so we receive the Security we just sent as a client would Context.OnPublishMaketData = SymbolProcessorTaskWorkPublishResultsTestHandler; Assert.IsTrue(dataQueueAggregator.Count == 0); AddClient(); SecurityTicks[] ticks = { new SecurityTicks("AAA"), new SecurityTicks("BBB"), new SecurityTicks("CCC") }; AddingComplete onCompleteAdding = null; DataReceivedHandler onNewDataReceived = null; foreach (var tick in ticks) { onCompleteAdding += tick.CompleteAdding; onNewDataReceived += tick.OnDataReceived; var sec = new Security("Orion", tick.Symbol, 5.6D); onNewDataReceived(sec); dataQueueAggregator.Add(tick); } dataQueueAggregator.CompleteAdding(); onCompleteAdding(); SymbolProcessorTaskWork(); foreach (var tick in ticks) { onCompleteAdding -= tick.CompleteAdding; onNewDataReceived -= tick.OnDataReceived; } var results = bag.Count(); return (results == 3); }
internal void DataReceived(Security data) { dataQueue.Add((SymbolTick)data); }
public void OnDataReceived(Security data) { if (null == data || data.Name != Symbol) return; SymbolTicks.Add(data); }
private void PublishTestPublishMarketDataMock(Security data) { dataItems.Add(data); }
private void OnMarketInActivityEventTestHandler(Security dataItem) { _onMarketInActivityEvent = dataItem; }
private void PublishMarketDataNewDataEventTestHandler(Security dataItem) { _AAAsec = dataItem; }
private void PublishMarketDataCancellationEventTestHandler(Security dataItem) { data = dataItem; }
public bool PublishMarketDataCancellationEventTest(string providerid, string name, double value) { var cts = new CancellationTokenSource(); base._token = cts.Token; cts.Cancel(); OnDataReceived = PublishMarketDataCancellationEventTestHandler; var sec = new Security(providerid, name, value); PublishMarketData(sec); // Excepted result is this item will NOT be published to // listeners / clients, session will end and cancel property true return (_canceltestEndSessionReceived && IsCancellationRequested); }
private void PublishMarketDataNullDataTestDataHandler(Security dataItem) { _nullsec = dataItem; }
public bool RemoveTest() { BlockingCollection<Security> dataQueue = new BlockingCollection<Security>(); var sec1 = new Security("Aggregator", "AAA", 6.32D); var sec2 = new Security("Aggregator", "BBB", 6.22D); var sec3 = new Security("Aggregator", "CCC", 6.12D); dataQueue.Add(sec1); dataQueue.Add(sec2); dataQueue.Add(sec3); Assert.IsTrue(dataQueue.Remove<Security>(sec1)); Assert.IsTrue(dataQueue.Count == 2); var itm = dataQueue.FirstOrDefault(x => x.Value == sec1.Value); return (null == itm); }
protected virtual void PartitionSecurity(Security data) { if (securities.ContainsKey(data.Name)) return; // Should ONLY perform adding var tick = securities.AddOrUpdate(data.Name, AddSecurityTick, UpdateSecurityTick); if(null != _onNewSecurityTicksEvent) _onNewSecurityTicksEvent(tick); }
protected void OnMarketClosedEvent(Security data) { EndSession(); if (null != OnDataReceived) OnDataReceived(data); }
private void MarketDataReaderTestsDataReceivedHandler(Security dataItem) { data.Add(dataItem); }
public void PublishMarketData(Security data) { // MockPublish if (null != OnPublishMaketData) OnPublishMaketData(data); }
protected void InternalPublishMarketData(Security data, ClientSession<IMarketDataProviderCallback> callback) { if (null == callback || !callback.IsActive) return; try { callback.ClientCallback.PublishMarketData(data); } catch (Exception ex) { RemoveClient(callback); Console.WriteLine( $"Failed to communicate with client with sessionId [{callback.SessionId}] causing exception [ {ex.Message} ]."); } }
private void SymbolProcessorTaskWorkPublishResultsTestHandler(Security data) { bag.Add(data); }
internal virtual void DataReceived(Security data) { dataQueue.Add(data); }