Exemplo n.º 1
0
 /// <summary>
 /// Read from reader
 /// </summary>
 /// <param name="reader">Reader</param>
 public void FromBinary(BinaryReader reader)
 {
     Bid    = (decimal)reader.ReadDouble();
     Ask    = (decimal)reader.ReadDouble();
     Last   = (decimal)reader.ReadDouble();
     Volume = (Volume ?? new ExchangeVolume());
     Volume.FromBinary(reader);
 }
        private ExchangeVolume ParseVolume(JToken token)
        {
            ExchangeVolume vol = new ExchangeVolume();

            JProperty[] props = token.Children <JProperty>().ToArray();
            if (props.Length == 3)
            {
                vol.BaseSymbol      = props[0].Name;
                vol.BaseVolume      = props[0].Value.ConvertInvariant <decimal>();
                vol.ConvertedSymbol = props[1].Name;
                vol.ConvertedVolume = props[1].Value.ConvertInvariant <decimal>();
                vol.Timestamp       = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(props[2].Value.ConvertInvariant <long>());
            }

            return(vol);
        }
Exemplo n.º 3
0
        private ExchangeVolume ParseVolume(JToken token)
        {
            ExchangeVolume vol = new ExchangeVolume();

            JProperty[] props = token.Children <JProperty>().ToArray();
            if (props.Length == 3)
            {
                vol.PriceSymbol    = props[0].Name;
                vol.PriceAmount    = (decimal)props[0].Value;
                vol.QuantitySymbol = props[1].Name;
                vol.QuantityAmount = (decimal)props[1].Value;
                vol.Timestamp      = CryptoUtility.UnixTimeStampToDateTimeMilliseconds((long)props[2].Value);
            }

            return(vol);
        }
Exemplo n.º 4
0
        private ExchangeVolume ParseVolume(JToken token, string symbol)
        {
            ExchangeVolume vol = new ExchangeVolume();

            JProperty[] props = token.Children <JProperty>().ToArray();
            if (props.Length == 3)
            {
                var(baseCurrency, quoteCurrency) = ExchangeMarketSymbolToCurrencies(symbol);
                vol.QuoteCurrency       = quoteCurrency.ToUpperInvariant();
                vol.QuoteCurrencyVolume = token[quoteCurrency.ToUpperInvariant()].ConvertInvariant <decimal>();
                vol.BaseCurrency        = baseCurrency.ToUpperInvariant();
                vol.BaseCurrencyVolume  = token[baseCurrency.ToUpperInvariant()].ConvertInvariant <decimal>();
                vol.Timestamp           = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(props[2].Value.ConvertInvariant <long>());
            }

            return(vol);
        }
Exemplo n.º 5
0
        private ExchangeTicker ParseTicker(JToken token)
        {
            return(new ExchangeTicker
            {
                // TODO: Parse out fields...
                // Ticker JSON { "GenTime":12345678901234 "Label":"UFO/BTC", "Ask":0.00000005, "Bid":0.00000003, "Open":0.00000006, "High":0.00000007, "Low":0.00000004, "Close":0.00000003, "Volume":3240956.04453450, "BaseVolume":455533325.98457433 }

                var symbols = token["Label"].ToStringInvariant().Split('/');

                Id = token["GenTime"].ConvertInvariant <Timestamp>(),     // ????
                Ask = token["Ask"].ConvertInvariant <decimal>(),
                Bid = token["Bid"].ConvertInvariant <decimal>(),
                Last = token["Close"].ConvertInvariant <decimal>(),

                Volume = new ExchangeVolume()
                {
                    PriceSymbol = symbols[0],
                    QuantitySymbol = symbols[1],
                    PriceAmount = token["Volume"].ConvertInvariant <decimal>(),
                    QuantityAmount = token["BaseVolume"].ConvertInvariant <decimal>(),
                    Timestamp = token["GenTime"].ConvertInvariant <Timestamp>()
                }
            });