Example #1
0
        /// <summary>
        /// Called when a publisher has committed an event to the <see cref="T:Disruptor.RingBuffer`1"/>
        /// </summary>
        /// <param name="data">Data committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="sequence">Sequence number committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="endOfBatch">flag to indicate if this is the last event in a batch from the <see cref="T:Disruptor.RingBuffer`1"/></param>
        public void OnNext(MarketDataObject data, long sequence, bool endOfBatch)
        {
            if (data.IsTick)
            {
                // Publish Tick if the subscription request is received
                if (TickSubscriptionList.Contains(data.Tick.Security.Symbol))
                {
                    // Raise Event to notify listeners
                    if (TickReceived != null)
                    {
                        TickReceived(data.Tick);
                    }
                }
            }
            else
            {
                // Publish Bar if the subscription request is received
                if (BarSubscriptionList.Contains(data.Bar.Security.Symbol))
                {
                    // Raise Event to notify listeners
                    if (BarReceived != null)
                    {
                        BarReceived(data.Bar);
                    }
                }
            }

            // Save data locally for future use
            if (_localPersistance)
            {
                _localPersistanceData.Add(_persistanceDataCount, data);
                _persistanceDataCount++;
            }
        }
Example #2
0
        /// <summary>
        /// Subscribes Tick data for the given symbol
        /// </summary>
        /// <param name="subscribe">Contains info for the symbol to be subscribed</param>
        public void SubscribeSymbol(Subscribe subscribe)
        {
            try
            {
                if (_classLogger.IsInfoEnabled)
                {
                    _classLogger.Info("New subscription request received " + subscribe, _type.FullName, "SubscribeSymbol");
                }

                // Add new symbol to the Tick list
                if (!TickSubscriptionList.Contains(subscribe.Security.Symbol))
                {
                    TickSubscriptionList.Add(subscribe.Security.Symbol);
                }

                // Fetch data if its not already fetched for bars
                if (!BarSubscriptionList.Contains(subscribe.Security.Symbol))
                {
                    FetchData(subscribe);
                }
            }
            catch (Exception exception)
            {
                _classLogger.Error(exception, _type.FullName, "SubscribeSymbol");
            }
        }
Example #3
0
        /// <summary>
        /// Subscribe to New Symbol for bar data
        /// </summary>
        /// <param name="barDataRequest"></param>
        public void SubscribeSymbol(BarDataRequest barDataRequest)
        {
            if (_classLogger.IsInfoEnabled)
            {
                _classLogger.Info("New subscription request recieved Request for " + barDataRequest, _type.FullName,
                                  "SubscribeSymbol");
            }

            // Add new symbol to the Bar list
            if (!BarSubscriptionList.Contains(barDataRequest.Security.Symbol))
            {
                BarSubscriptionList.Add(barDataRequest.Security.Symbol);
            }

            // Fetch data if its not already fetched for ticks
            if (!TickSubscriptionList.Contains(barDataRequest.Security.Symbol))
            {
                // Use locally saved data
                if (_persistanceDataCount > 0)
                {
                    var task = Task.Factory.StartNew(UseLocalData);

                    _tasksCollection.Add(task);
                }
                // Fetch fresh data
                else
                {
                    FetchData(barDataRequest);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Subscribe to New Symbol for bar data
 /// </summary>
 /// <param name="barDataRequest"></param>
 public void SubscribeMultiSymbol(BarDataRequest[] barDataRequest)
 {
     if (_classLogger.IsInfoEnabled)
     {
         _classLogger.Info("New subscription request recieved Request for " + barDataRequest, _type.FullName,
                           "SubscribeSymbol");
     }
     for (int i = 0; i < barDataRequest.Length; i++)
     {
         // Add new symbol to the Bar list
         if (!BarSubscriptionList.Contains(barDataRequest[i].Security.Symbol))
         {
             BarSubscriptionList.Add(barDataRequest[i].Security.Symbol);
         }
     }
     FetchData(barDataRequest);
 }
Example #5
0
        /// <summary>
        /// Subscribe to New Symbol for bar data
        /// </summary>
        /// <param name="barDataRequest"></param>
        public void SubscribeSymbol(BarDataRequest barDataRequest)
        {
            if (_classLogger.IsInfoEnabled)
            {
                _classLogger.Info("New subscription request recieved Request for " + barDataRequest, _type.FullName, "SubscribeSymbol");
            }

            // Add new symbol to the Bar list
            if (!BarSubscriptionList.Contains(barDataRequest.Security.Symbol))
            {
                BarSubscriptionList.Add(barDataRequest.Security.Symbol);
            }

            // Fetch data if its not already fetched for ticks
            if (!TickSubscriptionList.Contains(barDataRequest.Security.Symbol))
            {
                FetchData(barDataRequest);
            }
        }
 /// <summary>
 /// Called when a publisher has committed an event to the <see cref="T:Disruptor.RingBuffer`1"/>
 /// </summary>
 /// <param name="data">Data committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="sequence">Sequence number committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="endOfBatch">flag to indicate if this is the last event in a batch from the <see cref="T:Disruptor.RingBuffer`1"/></param>
 public void OnNext(MarketDataObject data, long sequence, bool endOfBatch)
 {
     if (data.IsTick)
     {
         // Publish Tick if the subscription request is received
         if (TickSubscriptionList.Contains(data.Tick.Security.Symbol))
         {
             TickArrived(data.Tick);
         }
     }
     else
     {
         // Publish Bar if the subscription request is received
         if (BarSubscriptionList.Contains(data.Bar.Security.Symbol))
         {
             BarArrived(data.Bar);
         }
     }
 }
Example #7
0
        /// <summary>
        /// Subscribes Tick data for the given symbol
        /// </summary>
        /// <param name="subscribe">Contains info for the symbol to be subscribed</param>
        public void SubscribeSymbol(Subscribe subscribe)
        {
            try
            {
                if (_classLogger.IsInfoEnabled)
                {
                    _classLogger.Info("New subscription request received " + subscribe, _type.FullName,
                                      "SubscribeSymbol");
                }

                // Add new symbol to the Tick list
                if (!TickSubscriptionList.Contains(subscribe.Security.Symbol))
                {
                    TickSubscriptionList.Add(subscribe.Security.Symbol);
                }

                // Fetch data if its not already fetched for bars
                if (!BarSubscriptionList.Contains(subscribe.Security.Symbol))
                {
                    // Use locally saved data
                    if (_persistanceDataCount > 0)
                    {
                        var task = Task.Factory.StartNew(UseLocalData);

                        _tasksCollection.Add(task);
                    }
                    // Fetch fresh data
                    else
                    {
                        FetchData(subscribe);
                    }
                }
            }
            catch (Exception exception)
            {
                _classLogger.Error(exception, _type.FullName, "SubscribeSymbol");
            }
        }
Example #8
0
        /// <summary>
        /// Called when a publisher has committed an event to the <see cref="T:Disruptor.RingBuffer`1"/>
        /// </summary>
        /// <param name="data">Data committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="sequence">Sequence number committed to the <see cref="T:Disruptor.RingBuffer`1"/></param><param name="endOfBatch">flag to indicate if this is the last event in a batch from the <see cref="T:Disruptor.RingBuffer`1"/></param>
        public void OnNext(MarketDataObject data, long sequence, bool endOfBatch)
        {
            if (data.IsTick)
            {
                // Publish Tick if the subscription request is received
                if (TickSubscriptionList.Contains(data.Tick.Security.Symbol))
                {
                    // Raise Event to notify listeners
                    if (TickReceived != null)
                    {
                        TickReceived(data.Tick);
                    }

                    if (_classLogger.IsDebugEnabled)
                    {
                        _classLogger.Debug(data.Tick.ToString(), _type.FullName, "OnNext");
                    }
                }
            }
            else
            {
                // Publish Bar if the subscription request is received
                if (BarSubscriptionList.Contains(data.Bar.Security.Symbol))
                {
                    // Raise Event to notify listeners
                    if (BarReceived != null)
                    {
                        BarReceived(data.Bar);
                    }

                    if (_classLogger.IsDebugEnabled)
                    {
                        _classLogger.Debug(data.Bar.ToString(), _type.FullName, "OnNext");
                    }
                }
            }
        }