Beispiel #1
0
        /// <summary>
        /// Gets ticker info for currency pair from the API.
        /// </summary>
        /// <param name="currency">Currency pair to get data about</param>
        /// <returns>TickerResult containing ticker data for specified currency on Bitfinex</returns>
        public TickerResult GetTickerResult(CurrencyPair currency)
        {
            string rawData = DownloadString("https://api.bitfinex.com/v2/ticker/" + currency.GetBitfinexCurrencyPair()); // Downloads raw data from API

            double[] array = JsonConvert.DeserializeObject <double[]>(rawData);                                          // Converts raw data to double[]

            TickerResult result = TickerArrayToTickerResult(array);                                                      // Converts array to TickerResult

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Converts double[] containing ticker info to TickerResult object
        /// </summary>
        /// <param name="input">Input as a double[]</param>
        /// <returns>TickerResult of input</returns>
        TickerResult TickerArrayToTickerResult(double[] input)
        {
            TickerResult result = new TickerResult();             // Create a blank TickerResult

            result.bid             = input[0];
            result.bidSize         = input[1];
            result.ask             = input[2];
            result.askSize         = input[3];
            result.dailyChange     = input[4];
            result.dailyChangePerc = input[5];
            result.lastPrice       = input[6];
            result.volume          = input[7];
            result.high            = input[8];
            result.low             = input[9];

            return(result);
        }