Exemplo n.º 1
0
        internal override async Task RefreshLastTrade(
            TradingPair tradingPair)
        {
            // https://www.binance.com/api/v1/trades?symbol=ETHBTC&limit=1
            List <BinanceTradeJson> tradeHistory = await Get <List <BinanceTradeJson> >(
                $"api/v1/trades?symbol={GetPairId(tradingPair)}&limit=1");

            if (tradeHistory.Count > 0)
            {
                BinanceTradeJson history = tradeHistory[0];
                decimal          price   = decimal.Parse(history.price);
                decimal          volume  = decimal.Parse(history.qty);
                tradingPair.lastTrade = new LastTrade(price, volume);
            }
        }
Exemplo n.º 2
0
        public void AddTradingPair(
            string baseCoinTicker,
            string quoteCoinTicker,
            decimal askPrice,
            decimal bidPrice,
            bool?isInactive = null)
        {
            if (string.IsNullOrWhiteSpace(baseCoinTicker) ||
                string.IsNullOrWhiteSpace(quoteCoinTicker))
            {
                return;
            }

            Debug.Assert(askPrice == 0 ||
                         bidPrice == 0 ||
                         askPrice >= bidPrice ||
                         supportsOverlappingBooks);

            if (tickerLowerToCoin.TryGetValue(baseCoinTicker.ToLowerInvariant(),
                                              out Coin baseCoin) == false)
            { // May be missing due to coin filtering (e.g. no Tether)
                return;
            }
            if (tickerLowerToCoin.TryGetValue(quoteCoinTicker.ToLowerInvariant(),
                                              out Coin quoteCoin) == false)
            { // May be missing due to book's listing status
                return;
            }

            TradingPair pair = quoteCoin.AddPair(this,
                                                 baseCoin,
                                                 askPrice,
                                                 bidPrice);

            if (isInactive != null)
            {
                pair.isInactive = isInactive.Value;
            }
        }
Exemplo n.º 3
0
 internal virtual Task RefreshLastTrade(
     TradingPair tradingPair)
 {
     return(null);
 }