Exemple #1
0
        //max Limit=1000
        public async Task <List <BaseTypes.Candle> > GetCandles(BaseTypes.Market Market, Candle_Interval Interval, int Limit, InvokePrint Print)
        {
            try
            {
                var tinterval = GetTimeInterval(Interval);
                var BCandles  = await binanceClient.GetCandleSticks(Market.MarketName.Replace("-", ""), tinterval, null, null, Limit);

                var Candles = new List <BaseTypes.Candle>();
                foreach (var t in BCandles)
                {
                    Candles.Add(new BaseTypes.Candle
                    {
                        Open  = t.Open,
                        Hight = t.High,
                        Low   = t.Low,
                        Close = t.Close,
                        Time  = TimeFromUTC(t.OpenTime)
                    });
                }

                return(Candles);
            }
            catch (Exception ex)
            {
                System.Media.SystemSounds.Beep.Play();
                Print(String.Format("Ошибка BinanceApi GetCandles: {0}.\r\nMarket: {1}, Interval: {2}",
                                    ex.Message, Market.ToString(), Interval.ToString()));
                return(null);
            }
        }
Exemple #2
0
        public async Task <List <BaseTypes.Candle> > GetCandles(BaseTypes.Market Market, Candle_Interval Interval, int Limit, InvokePrint Print)
        {
            try
            {
                var tmp = await bittrex.GetCandles(Market.MarketName, Interval.ToString());

                List <Candle>           BCandles      = tmp.ToList();
                List <BaseTypes.Candle> lastByHistory = await CandleByMarketHistory(Market, Interval, Print);

                List <BaseTypes.Candle> Candles = new List <BaseTypes.Candle>(BCandles.Count);
                foreach (var t in BCandles)
                {
                    Candles.Add(new BaseTypes.Candle
                    {
                        Open  = t.Open,
                        Hight = t.Hight,
                        Low   = t.Low,
                        Close = t.Close,
                        Time  = t.Time
                    });
                }

                if (lastByHistory != null)
                {
                    Candles.AddRange(lastByHistory);
                }
                return(Candles);
            }
            catch (Exception ex)
            {
                System.Media.SystemSounds.Beep.Play();
                Print(String.Format("Ошибка BittrexApi GetCandles: {0}.\r\nMarket: {1}, Interval: {2}",
                                    ex.Message, Market.ToString(), Interval.ToString()));
                return(null);
            }
        }
Exemple #3
0
        private async Task <Candle> GetLastCandle(BaseTypes.Market Market, Candle_Interval Interval, InvokePrint Print)
        {
            try
            {
                var tmp = await bittrex.GetLastCandle(Market.MarketName, Interval.ToString());

                Candle result = new Candle
                {
                    Open  = tmp.Open,
                    Hight = tmp.Hight,
                    Low   = tmp.Low,
                    Close = tmp.Close,
                    Time  = tmp.Time
                };
                return(result);
            }
            catch (Exception ex)
            {
                System.Media.SystemSounds.Beep.Play();
                Print("Ошибка BittrexApi GetLastCandle: " + ex.Message);
                return(null);
            }
        }