Exemplo n.º 1
0
 static void client_RealTimeDataReceived(object sender, RealTimeDataEventArgs e)
 {
     Console.WriteLine("Real Time Data Received: O: {0}  H: {1}  L: {2}  C: {3}",
         e.Open,
         e.High,
         e.Low,
         e.Close);
 }
Exemplo n.º 2
0
        /// <summary>
        ///     When data arrives from an external data source to the broker, this event is fired.
        /// </summary>
        private void BrokerRealTimeDataArrived(object sender, RealTimeDataEventArgs e)
        {
            lock (_publisherSocketLock)
            {
                if (_publisherSocket != null)
                {
                    using (var ms = new MemoryStream())
                    {
                        Serializer.Serialize(ms, e);
                        _publisherSocket.SendMoreFrame(BitConverter.GetBytes(e.InstrumentID)); // Start by sending the ticker before the data
                        _publisherSocket.SendFrame(ms.ToArray()); // Then send the serialized bar

                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// When one of the data sources receives new real time data, it raises an event which is handled by this method,
        /// which then forwards the data over the PUB socket after serializing it.
        /// </summary>
        public void RealTimeData(object sender, RealTimeDataEventArgs e)
        {
            lock (_pubSocketLock)
            {
                _ms.SetLength(0);
                _pubSocket.SendMore(Encoding.UTF8.GetBytes(e.Symbol)); //start by sending the ticker before the data
                Serializer.Serialize(_ms, e);
                _pubSocket.Send(_ms.ToArray()); //then send the serialized bar
            }

            #if DEBUG
            Application.Current.Dispatcher.Invoke(() => Log(LogLevel.Trace,
                string.Format("RTD Received Symbol: {0} O:{1} H:{2} L:{3} C:{4} V:{5} T:{6}",
                    e.Symbol,
                    e.Open,
                    e.High,
                    e.Low,
                    e.Close,
                    e.Volume,
                    e.Time)));
            #endif
        }
Exemplo n.º 4
0
 /// <summary>
 /// When data arrives from an external data source to the broker, this event is fired.
 /// </summary>
 void _broker_RealTimeDataArrived(object sender, RealTimeDataEventArgs e)
 {
     using (var ms = new MemoryStream())
     {
         Serializer.Serialize(ms, e);
         //this lock is needed because this method will be called from
         //the thread of each DataSource in the broker
         lock (_pubSocketLock)
         {
             _pubSocket.SendMore(BitConverter.GetBytes(e.InstrumentID)); //start by sending the ticker before the data
             _pubSocket.Send(ms.ToArray()); //then send the serialized bar
         }
     }
 }