Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Gray; //Console.ResetColor() is not working :(
            Console.CancelKeyPress += Console_CancelKeyPress;

            var    ticker    = string.Empty;
            string indicator = string.Empty;

            HandleArgs(args, ref ticker, ref indicator);

            Console.WriteLine($"Fetching trade data for {ticker.ToUpper()}...");

            //on the next version, it's gonna be an interface
            RSI            RSITrades   = null;
            CCI            CCITrades   = null;
            BollingerBands BBandTrades = null;

            var bfxReader = new Core.Exchanges.Bitfinex.TickerReader();

            TickerHandler tickerHndl = null;

            //getting the 14 last minutes history
            var hist = new Core.Exchanges.Bitfinex.TickerCandlesReader();

            if (indicator.ToUpper() == "RSI")
            {
                RSICalc(out RSITrades, bfxReader, out tickerHndl, hist);
            }
            else if (indicator.ToUpper() == "CCI")
            {
                CCICalc(out CCITrades, bfxReader, out tickerHndl, hist);
            }
            else if (indicator.ToUpper() == "BBANDS")
            {
                BBandCalc(out BBandTrades, bfxReader, out tickerHndl, hist);
            }
            else
            {
                Console.WriteLine("Invalid Parameter");
                return;
            }

            tickerHndl.OnError += tickerHndl_OnError;

            bfxReader.Enabled = true;
            Task.Run(async() =>
            {
                await bfxReader.Start(ticker.ToUpper());
            });

            while (enabled)
            {
                ;
            }

            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine($"Program ended.");
        }
Ejemplo n.º 2
0
        private static void RSICalc(out RSI RSITrades, Core.Exchanges.Bitfinex.TickerReader bfxReader, out TickerHandler tickerHndl, Core.Exchanges.Bitfinex.TickerCandlesReader hist)
        {
            RSITrades            = new RSI();
            tickerHndl           = new TickerHandler(bfxReader, RSITrades);
            tickerHndl.RSIReady += tickerHndl_RSI_IndicatorReady;

            var lista = hist.GetHistory("BTCUSD", Core.Exchanges.Bitfinex.Common.CandleInterval1Min, 28);

            foreach (Ticker t in lista)
            {
                RSITrades.Add(t.UtcDateTime, t.last_price);
            }
        }
Ejemplo n.º 3
0
        private static void BBandCalc(out BollingerBands BBandTrades, Core.Exchanges.Bitfinex.TickerReader bfxReader, out TickerHandler tickerHndl, Core.Exchanges.Bitfinex.TickerCandlesReader hist)
        {
            BBandTrades            = new BollingerBands();
            tickerHndl             = new TickerHandler(bfxReader, BBandTrades);
            tickerHndl.BBandReady += tickerHndl_BBand_IndicatorReady;

            var lista = hist.GetHistory("BTCUSD", Core.Exchanges.Bitfinex.Common.CandleInterval1Min, 22);

            foreach (Ticker t in lista)
            {
                BBandTrades.Add(t.UtcDateTime, t.last_price);
            }
        }
Ejemplo n.º 4
0
        private static void CCICalc(out CCI CCITrades, Core.Exchanges.Bitfinex.TickerReader bfxReader, out TickerHandler tickerHndl, Core.Exchanges.Bitfinex.TickerCandlesReader hist)
        {
            CCITrades            = new CCI();
            tickerHndl           = new TickerHandler(bfxReader, CCITrades);
            tickerHndl.CCIReady += tickerHndl_CCI_IndicatorReady;

            var lista = hist.GetHistory("BTCUSD", Core.Exchanges.Bitfinex.Consts.CandleInterval1Min, 22);

            foreach (Ticker t in lista)
            {
                CCITrades.Add(t.UtcDateTime, t.high, t.low, t.last_price);
            }
        }