Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
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++;
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Unsubscribes the given symbol for Bar data
        /// </summary>
        /// <param name="barDataRequest"></param>
        public void UnsubscribleSymbol(BarDataRequest barDataRequest)
        {
            if (_classLogger.IsInfoEnabled)
            {
                _classLogger.Info("Unsubscription request received " + barDataRequest, _type.FullName,
                                  "UnsubscribleSymbol");
            }

            // Remove symbol from the Bar list
            BarSubscriptionList.Remove(barDataRequest.Security.Symbol);
        }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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))
         {
             TickArrived(data.Tick);
         }
     }
     else
     {
         // Publish Bar if the subscription request is received
         if (BarSubscriptionList.Contains(data.Bar.Security.Symbol))
         {
             BarArrived(data.Bar);
         }
     }
 }
Exemplo n.º 8
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");
            }
        }
Exemplo n.º 9
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");
                    }
                }
            }
        }