示例#1
0
        public void StartRoBot(RobotInput robotInput, bool isLive)
        {
            #region -strategy and function level variables-
            var openclosestrategy = new OpenCloseStrategy();

            StrategyData strategyData = new StrategyData(1);

            var errorCount = 0;

            //improve this further later
            webCall.AssignBinanceWebCallFeatures(robotInput.symbol);
            #endregion

            using (webCall.client = new BinanceClient())
            {
                while (true)
                {
                    try
                    {
                        #region -variables refreshed every cycle-
                        Stopwatch sw = new Stopwatch();

                        sw.Start();

                        var currentPosition = new SimplePosition(robotInput.quantity);

                        strategyData = new StrategyData(strategyData.profitFactor);//tracking updated check for more elegant ways to write this..

                        Thread.Sleep(pingtime);
                        #endregion

                        //get kandles from server
                        webCall.GetKLinesDataCached(robotInput.timeframe, robotInput.candleCount, ref strategyData);

                        //get open positions from server
                        webCall.GetOpenPosition(robotInput, ref strategyData, ref currentPosition, isLive);

                        //run strategy over the kandles
                        openclosestrategy.RunStrategy(robotInput, currentPosition, ref strategyData);

                        //place orders based on strategy output
                        webCall.PlaceOrders(robotInput, strategyData, isLive);

                        sw.Stop();

                        //display data to UI
                        Utility.DumpToConsole(strategyData, currentPosition, robotInput, BollingerFactor, ref LastAvoidReason, sw.ElapsedMilliseconds);
                    }
                    catch (Exception ex)
                    {
                        Utility.LogExceptions(ex, "");

                        Thread.Sleep(10);

                        ++errorCount;
                    }

                    if (errorCount >= 300)
                    {
                        break;
                    }
                }
            }
        }
示例#2
0
        public void StartRoBot(RobotInput robotInput, bool isLive)
        {
            #region -strategy and function level variables-
            var openclosestrategy = new OpenCloseStrategy();

            StrategyData strategyData = new StrategyData(1);

            var errorCount = 0;

            webCall.AssignBinanceWebCallFeatures(robotInput.symbol); //improve this further later
            #endregion

            using (webCall.client = new BinanceClient())
            {
                while (true)
                {
                    try
                    {
                        #region -variables refreshed every cycle-
                        strategyData = new StrategyData(strategyData.profitFactor);//tracking updated check for more elegant ways to write this..

                        Stopwatch sw = new Stopwatch();

                        sw.Start();

                        List <OHLCKandle> ohlckandles = new List <OHLCKandle>();

                        var currentClose = default(decimal);

                        var currentPosition = new SimplePosition(robotInput.quantity);

                        Thread.Sleep(pingtime);
                        #endregion

                        if (isLive)
                        {
                            webCall.GetCurrentPosition(ref currentPosition, robotInput.quantity, ref strategyData);
                        }

                        webCall.GetKLinesDataCached(robotInput.timeframe, robotInput.candleCount, ref currentClose, ref ohlckandles);

                        robotInput.currentClose = currentClose;

                        openclosestrategy.RunStrategy(ohlckandles, robotInput, ref strategyData, ref currentPosition);

                        if (isLive && strategyData.Output != StrategyOutput.None)
                        {
                            PlaceOrders(robotInput.quantity, currentClose, strategyData.Output, strategyData);
                        }

                        sw.Stop();

                        DumpToConsole(strategyData, currentPosition, robotInput, currentClose, sw.ElapsedMilliseconds);
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(10);

                        ++errorCount;
                    }

                    if (errorCount >= 300)
                    {
                        break;
                    }
                }
            }
        }