예제 #1
0
        public override decimal GetSingleNowPrice(EnumType.CoinType coin, EnumType.CurrencyType currency = EnumType.CurrencyType.USDT)
        {
            string Symbol = ConvertSymbolTool.HBConvertSymbol(coin, currency);

            var result = coinealAPI.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

            if (result == null || result.data.buy <= 0)
            {
                return(0);
            }

            return(result.data.buy);
        }
예제 #2
0
        /// <summary>
        /// 获取单个币种在火币的价格
        /// </summary>
        /// <param name="coin"></param>
        /// <param name="currency"></param>
        /// <returns></returns>
        public override decimal GetSingleNowPrice(CoinType coin, EnumType.CurrencyType currency = EnumType.CurrencyType.USDT)
        {
            string Symbol = ConvertSymbolTool.BiAnConvertSymbol(coin, currency);

            var result = api.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

            if (result == null || result.lastPrice <= 0)
            {
                return(0);
            }

            return(result.lastPrice);
        }
예제 #3
0
        public override decimal GetSingleNowPrice(CoinType coin, EnumType.CurrencyType currency = EnumType.CurrencyType.USDT)
        {
            string symbol = ConvertSymbolTool.OKConvertSymbol(coin, currency);

            TicketRequset ticket = OkAPi.SendRequestContent <TicketRequset>(ApiUrlList.API_Ticker, symbol);

            if (ticket == null || ticket.ticker == null)
            {
                Alert("获取价格失败!");
                return(0);
            }

            return(ticket.ticker.last);
        }
예제 #4
0
        public override BasePriceModel GetNowPrice(string coin, string currency)
        {
            BasePriceModel basePrice = new BasePriceModel();
            string         Symbol    = ConvertSymbolTool.GateConvertSymbol(coin, currency);
            var            result    = gateAPI.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

            if (result == null)
            {
                Log.Error("GATE数据为空" + coin);
                return(basePrice);
            }
            basePrice.buyPrice = result.highestBid;
            basePrice.sellPice = result.lowestAsk;
            basePrice.price    = result.last;
            return(basePrice);
        }
예제 #5
0
        public override BasePriceModel GetNowPrice(string coin, string currency)
        {
            BasePriceModel basePrice = new BasePriceModel();
            string         Symbol    = ConvertSymbolTool.OKConvertSymbol(coin, currency);
            var            result    = OkAPi.SendRequestContent <TicketRequset>(ApiUrlList.API_Ticker, Symbol);

            if (result == null)
            {
                Log.Error("okex数据为空" + coin);
                return(basePrice);
            }
            basePrice.buyPrice = result.ticker.buy;
            basePrice.sellPice = result.ticker.sell;
            basePrice.price    = result.ticker.last;
            return(basePrice);
        }
예제 #6
0
        public override BasePriceModel GetNowPrice(string coin, string currency)
        {
            BasePriceModel basePrice = new BasePriceModel();
            string         Symbol    = ConvertSymbolTool.BiAnConvertSymbol(coin, currency);
            var            result    = api.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

            if (result == null)
            {
                Log.Error("币安数据为空" + coin);
                return(basePrice);
            }

            basePrice.buyPrice = result.bidPrice;
            basePrice.sellPice = result.askPrice;
            basePrice.price    = result.lastPrice;
            return(basePrice);
        }
예제 #7
0
        /// <summary>
        /// 获取单个币种在火币的价格
        /// </summary>
        /// <param name="coin"></param>
        /// <param name="currency"></param>
        /// <returns></returns>
        public override decimal GetSingleNowPrice(CoinType coin, EnumType.CurrencyType currency = EnumType.CurrencyType.USDT)
        {
            try
            {
                string Symbol = ConvertSymbolTool.HBConvertSymbol(coin, currency);

                var result = api.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

                if (result == null || result.tick.ask.Length <= 0)
                {
                    return(0);
                }

                return(decimal.Parse(result.tick.ask[0].ToString("f3")));
            }
            catch
            {
                return(0);
            }
        }
예제 #8
0
        public override BasePriceModel GetNowPrice(string coin, string currency)
        {
            BasePriceModel basePrice = new BasePriceModel();
            string         Symbol    = ConvertSymbolTool.HBConvertSymbol(coin, currency);

            var result = api.SendRequestContent <TicketRequest>(ApiUrlList.API_Ticker, Symbol);

            if (result.status != "ok")
            {
                return(basePrice);
            }
            if (result.tick == null)
            {
                Log.Error("HUOBI数据为空" + coin);
                return(basePrice);
            }
            basePrice.buyPrice = result.tick.bid[0];
            basePrice.sellPice = result.tick.ask[0];
            basePrice.price    = result.tick.close;
            return(basePrice);
        }
예제 #9
0
        /// <summary>
        /// 获取市场深度
        /// </summary>
        /// <param name="coin"></param>
        /// <param name="currency"></param>
        /// <returns></returns>
        public override LatePriceModel GetLatestRecord(string coin, string currency)
        {
            LatePriceModel latePrice = new LatePriceModel();
            string         Symbol    = ConvertSymbolTool.HBConvertSymbol(coin, currency);

            Symbol += "&type=step0";
            var result = api.SendRequestContent <DepthRequest>(ApiUrlList.Api_Depth, Symbol);

            if (result == null)
            {
                Log.Error("火币数据为空" + coin);
                return(latePrice);
            }
            List <PriceModel> asksList = new List <PriceModel>();

            foreach (var asksPrice in result.tick.asks)
            {
                PriceModel asks = new PriceModel();
                asks.price  = asksPrice[0];
                asks.amount = asksPrice[1];
                asksList.Add(asks);
            }

            List <PriceModel> bidsList = new List <PriceModel>();

            foreach (var bidsPrice in result.tick.bids)
            {
                PriceModel bids = new PriceModel();
                bids.price  = bidsPrice[0];
                bids.amount = bidsPrice[1];
                bidsList.Add(bids);
            }

            latePrice.Asks = asksList;
            latePrice.Bids = bidsList;
            return(latePrice);
        }
예제 #10
0
        public override LatePriceModel GetLatestRecord(string coin, string currency)
        {
            LatePriceModel latePrice = new LatePriceModel();
            string         Symbol    = ConvertSymbolTool.BiAnConvertSymbol(coin, currency);
            var            result    = api.SendRequestContent <DepthRequest>(ApiUrlList.API_Depth, Symbol);

            if (result == null)
            {
                Log.Error("币安数据为空" + coin);
                return(latePrice);
            }

            List <PriceModel> asksList = new List <PriceModel>();

            foreach (var asksPrice in result.asks)
            {
                PriceModel asks = new PriceModel();
                asks.price  = Convert.ToDecimal(asksPrice[0]);
                asks.amount = Convert.ToDecimal(asksPrice[1]);
                asksList.Add(asks);
            }

            List <PriceModel> bidsList = new List <PriceModel>();

            foreach (var bidsPrice in result.bids)
            {
                PriceModel bids = new PriceModel();
                bids.price  = Convert.ToDecimal(bidsPrice[0]);
                bids.amount = Convert.ToDecimal(bidsPrice[1]);
                bidsList.Add(bids);
            }

            latePrice.Asks = asksList;
            latePrice.Bids = bidsList;
            return(latePrice);
        }