Пример #1
0
        private void ProcessTick(ISerializedValue[] arguments)
        {
            // Determine applicable currency pair
            var currencyPairStr = arguments[0].Deserialize <string>();
            var currencyPair    = CurrencyPair.Parse(currencyPairStr);

            if (ReferenceEquals(currencyPair, null))
            {
                Logger.Debug($"Received tick of unknown currency Pair '{currencyPairStr}', skipping tick");
                return;
            }

            // Convert data to TickData
            var tickData = new TickData.Builder(Exchange, currencyPair, DateTimeHelper.ToUnixTime(DateTime.Now), arguments[1].Deserialize <decimal>())
                           .LowestAsk(arguments[2].Deserialize <decimal>())
                           .HighestBid(arguments[3].Deserialize <decimal>())
                           .PercentChange(arguments[4].Deserialize <decimal>())
                           .BaseVolume(arguments[5].Deserialize <decimal>())
                           .QuoteVolume(arguments[6].Deserialize <decimal>())
                           .IsFrozen(arguments[7].Deserialize <byte>() > 0)
                           .DayHigh(arguments[8].Deserialize <decimal>())
                           .DayLow(arguments[9].Deserialize <decimal>())
                           .Build();

            Logger.Debug($"Received new tick: {tickData}");

            // Notify subscribers
            lock (_subscribers)
            {
                foreach (var subscriber in _subscribers)
                {
                    subscriber.OnTick(Exchange, tickData);
                }
            }
        }
Пример #2
0
        public static TickData Convert(Exchange exchange, ISerializedValue[] serializedData)
        {
            // Determine applicable currency pair
            var currencyPair = GetCurrencyPair(serializedData);

            // Convert data to TickData
            var tickData = new TickData.Builder(exchange, currencyPair, DateTimeHelper.ToUnixTime(DateTime.Now), serializedData[1].Deserialize <decimal>())
                           .LowestAsk(serializedData[2].Deserialize <decimal>())
                           .HighestBid(serializedData[3].Deserialize <decimal>())
                           .PercentChange(serializedData[4].Deserialize <decimal>())
                           .BaseVolume(serializedData[5].Deserialize <decimal>())
                           .QuoteVolume(serializedData[6].Deserialize <decimal>())
                           .IsFrozen(serializedData[7].Deserialize <byte>() > 0)
                           .DayHigh(serializedData[8].Deserialize <decimal>())
                           .DayLow(serializedData[9].Deserialize <decimal>())
                           .Build();

            return(tickData);
        }