Beispiel #1
0
        public RealTimeTickEventArgs ToTickEventArgs()
        {
            var args = new RealTimeTickEventArgs(TickType.Trade);

            if (decimal.TryParse(Price, out decimal price))
            {
                args.Last = price;
            }

            if (decimal.TryParse(Quantity, out decimal lastQuant))
            {
                args.LastQuantity = lastQuant;
            }

            args.DT = MyUtils.TimestampToDateTimeByMillisecond(TradeTime);

            return(args);
        }
        /// <summary>
        ///     When tick data arrives from an external data source to the broker, this event is fired.
        /// </summary>
        private void BrokerRealTimeTickArrived(object sender, RealTimeTickEventArgs e)
        {
            lock (_publisherSocketLock)
            {
                if (_publisherSocket == null)
                {
                    return;
                }

                using (var ms = new MemoryStream())
                {
                    Serializer.Serialize(ms, e);
                    _publisherSocket.SendMoreFrame(BitConverter.GetBytes(e.InstrumentID)); // Start by sending the ticker before the data
                    _publisherSocket.SendMoreFrame(MessageType.RealTimeTick);
                    _publisherSocket.SendFrame(ms.ToArray());                              // Then send the serialized bar
                }
            }
        }
Beispiel #3
0
        private void TickReceived(object sender, RealTimeTickEventArgs e)
        {
            RaiseEvent(RealTimeTickArrived, this, e);

            //continuous futures aliases
            lock (_aliasLock)
            {
                int instrumentID = e.InstrumentID;
                if (_aliases.ContainsKey(instrumentID))
                {
                    for (int i = 0; i < _aliases[instrumentID].Count; i++)
                    {
                        e.InstrumentID = _aliases[instrumentID][i];
                        RaiseEvent(RealTimeTickArrived, this, e);
                    }
                }
            }

            //todo add saving to storage after we get a tick storage
        }