Exemplo n.º 1
0
        public static jsonTicker FromTicker(Ticker Tick)
        {
            jsonTicker tmp = new jsonTicker();

            try
            {
                if (Tick.Tickers == null)
                {
                    tmp.ask = Tick.Ask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.bid = Tick.Ask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.rolling_24_hour_volume = Tick.Ask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.last_trade             = Tick.Ask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.timestamp = JSON.ToEpoch(Tick.TimeStamp);
                }
                else
                {
                    List <jsonTicker> tmpTickers = new List <jsonTicker>();
                    foreach (Ticker tmpTick in Tick.Tickers)
                    {
                        tmpTickers.Add(jsonTicker.FromTicker(tmpTick));
                    }
                    tmp.tickers = tmpTickers.ToArray();
                }
            }
            catch
            { return(null); }

            return(tmp);
        }
Exemplo n.º 2
0
        public static Ticker ToTicker(jsonTicker Tick)
        {
            Ticker tmp = new Ticker();

            if (tmp.Tickers == null)
            {
                try
                {
                    tmp.Ask           = decimal.Parse(Tick.ask, System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.Bid           = decimal.Parse(Tick.ask, System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.Rolling24HAvg = decimal.Parse(Tick.ask, System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.LastTrade     = decimal.Parse(Tick.ask, System.Globalization.NumberFormatInfo.InvariantInfo);
                    tmp.TimeStamp     = JSON.FromEpoch(Tick.timestamp);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                try
                {
                    List <Ticker> tmpTickers = new List <Ticker>();
                    foreach (jsonTicker tmpTick in Tick.tickers)
                    {
                        tmpTickers.Add(tmpTick.ToTicker());
                    }
                    tmp.Tickers = tmpTickers.ToArray();
                }
                catch
                {
                    return(null);
                }
            }
            return(tmp);
        }
Exemplo n.º 3
0
 public Ticker FromJsonTicker(jsonTicker Tick)
 {
     return(Tick.ToTicker());
 }