Exemple #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.");
        }
 public IBS_G4_Drv(string Name)
 {
     this._name                   = Name != null ? Name : nameof(IBS_G4_Drv);
     this.diagnostic              = new Diagnostic(this._name);
     this.diagnostic.OnException += new ExceptionHandler(this._diagnostic_OnException);
     this._connectionDTI          = "";
     this._connectionMXI          = "";
     this.ticker                  = TickerFactory.Create(Name, this._tIntervall, this._tPriority);
     this.hdTicker                = new TickerHandler(this._ticker_OnTick);
     this.ChangeState(IBS_G4_Drv.DriverState.Idle);
 }
Exemple #3
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);
            }
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Gray; //Console.ResetColor() is not working :(
            Console.CancelKeyPress += Console_CancelKeyPress;

            var ticker = string.Empty;

            if (args.Length > 0)
            {
                ticker = args[0];
            }
            else
            {
                while (ticker == string.Empty)
                {
                    Console.WriteLine("Type in the ticker name to start indicator's calculation: (hit ENTER for BTCUSD)");
                    ticker = Console.ReadLine();
                    if (string.IsNullOrEmpty(ticker))
                    {
                        ticker = "BTCUSD";
                    }
                }
            }

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

            var trades     = new RSI();
            var bfxReader  = new Core.Exchanges.Bitfinex.TickerReader();
            var tickerHndl = new TickerHandler(bfxReader, trades);

            tickerHndl.OnError  += tickerHndl_OnError;
            tickerHndl.RSIReady += tickerHndl_IndicatorReady;
            bfxReader.Enabled    = true;
            Task.Run(async() =>
            {
                await bfxReader.Start(ticker.ToUpper());
            });

            while (enabled)
            {
                ;
            }

            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine($"Program ended.");
        }
 private bool CallEvent(TickerHandler pEvent)
 {
     if (pEvent == null)
     {
         return(true);
     }
     try
     {
         pEvent((object)this);
         return(true);
     }
     catch (Exception ex)
     {
         this.diagnostic.Throw((Enum)IBS_G4_Drv.DiagnosticCodes.EventException, new byte[0], ex);
         return(false);
     }
 }
Exemple #8
0
 internal bool CallEvent(TickerHandler tickerHandler)
 {
     if (tickerHandler == null)
     {
         return(true);
     }
     try
     {
         tickerHandler((object)this);
         return(true);
     }
     catch (Exception ex)
     {
         this.exception = ex;
         return(false);
     }
 }