Example #1
0
        public static async Task Main(string[] args)
        {
            // set bot settings
            const string token = "ETHBTC";

            IBinanceRestClient binanceRestClient = new BinanceRestClient(new BinanceClientConfiguration
            {
                ApiKey    = "<your_api_key>",
                SecretKey = "<your_secret_key>"
            });

            var strategyConfig = new MarketStrategyConfiguration
            {
                MinOrderVolume             = 1.0M,
                MaxOrderVolume             = 50.0M,
                TradeWhenSpreadGreaterThan = .02M
            };


            // create bot
            IMarketBot bot = new MarketMakerBot(
                token,
                new NaiveMarketMakerStrategy(strategyConfig, Logger),
                binanceRestClient,
                new BinanceWebSocketClient(binanceRestClient, Logger),
                Logger);


            // start bot
            try
            {
                await bot.RunAsync();

                System.Console.WriteLine("Press Enter to stop bot...");
                System.Console.ReadLine();
            }
            finally
            {
                bot.Stop();
            }

            System.Console.WriteLine("Press Enter to exit...");
            System.Console.ReadLine();
        }
Example #2
0
        /// <summary>
        /// create robot
        /// создать робота
        /// </summary>
        public static BotPanel GetStrategyForName(string nameClass, string name, StartProgram startProgram, bool isScript)
        {
            BotPanel bot = null;

            // примеры и бесплатные боты

            if (isScript)
            {
                bot = CreateScriptStrategyByName(nameClass, name, startProgram);
                return(bot);
            }

            if (nameClass == "BbPowerTrade")
            {
                bot = new BbPowerTrade(name, startProgram);
            }
            if (nameClass == "BollingerRevers")
            {
                bot = new BollingerRevers(name, startProgram);
            }
            if (nameClass == "BollingerTrailing")
            {
                bot = new BollingerTrailing(name, startProgram);
            }
            if (nameClass == "CciTrade")
            {
                bot = new CciTrade(name, startProgram);
            }
            if (nameClass == "MacdRevers")
            {
                bot = new MacdRevers(name, startProgram);
            }
            if (nameClass == "MacdTrail")
            {
                bot = new MacdTrail(name, startProgram);
            }
            if (nameClass == "OneLegArbitrage")
            {
                bot = new OneLegArbitrage(name, startProgram);
            }
            if (nameClass == "PairRsiTrade")
            {
                bot = new PairRsiTrade(name, startProgram);
            }
            if (nameClass == "PriceChannelBreak")
            {
                bot = new PriceChannelBreak(name, startProgram);
            }
            if (nameClass == "PriceChannelVolatility")
            {
                bot = new PriceChannelVolatility(name, startProgram);
            }
            if (nameClass == "RsiTrade")
            {
                bot = new RsiTrade(name, startProgram);
            }
            if (nameClass == "RviTrade")
            {
                bot = new RviTrade(name, startProgram);
            }

            if (nameClass == "MomentumMACD")
            {
                bot = new MomentumMacd(name, startProgram);
            }

            if (nameClass == "Engine")
            {
                bot = new CandleEngine(name, startProgram);
            }
            if (nameClass == "ClusterEngine")
            {
                bot = new ClusterEngine(name, startProgram);
            }

            if (nameClass == "PairTraderSimple")
            {
                bot = new PairTraderSimple(name, startProgram);
            }
            if (nameClass == "EnvelopTrend")
            {
                bot = new EnvelopTrend(name, startProgram);
            }
            if (nameClass == "ClusterCountertrend")
            {
                bot = new ClusterCountertrend(name, startProgram);
            }
            if (nameClass == "PatternTrader")
            {
                bot = new PatternTrader(name, startProgram);
            }
            if (nameClass == "HighFrequencyTrader")
            {
                bot = new HighFrequencyTrader(name, startProgram);
            }
            if (nameClass == "PivotPointsRobot")
            {
                bot = new PivotPointsRobot(name, startProgram);
            }
            if (nameClass == "Williams Band")
            {
                bot = new StrategyBillWilliams(name, startProgram);
            }
            if (nameClass == "MarketMakerBot")
            {
                bot = new MarketMakerBot(name, startProgram);
            }
            if (nameClass == "Bollinger")
            {
                bot = new StrategyBollinger(name, startProgram);
            }
            if (nameClass == "ParabolicSarTrade")
            {
                bot = new ParabolicSarTrade(name, startProgram);
            }
            if (nameClass == "PriceChannelTrade")
            {
                bot = new PriceChannelTrade(name, startProgram);
            }
            if (nameClass == "WilliamsRangeTrade")
            {
                bot = new WilliamsRangeTrade(name, startProgram);
            }
            if (nameClass == "SmaStochastic")
            {
                bot = new SmaStochastic(name, startProgram);
            }
            if (nameClass == "PinBarTrade")
            {
                bot = new PinBarTrade(name, startProgram);
            }
            if (nameClass == "TwoLegArbitrage")
            {
                bot = new TwoLegArbitrage(name, startProgram);
            }
            if (nameClass == "ThreeSoldier")
            {
                bot = new ThreeSoldier(name, startProgram);
            }
            if (nameClass == "RsiContrtrend")
            {
                bot = new RsiContrtrend(name, startProgram);
            }
            if (nameClass == "PairTraderSpreadSma")
            {
                bot = new PairTraderSpreadSma(name, startProgram);
            }


            return(bot);
        }
Example #3
0
        static async Task Main(string[] args)
        {
            // 1. create connections with exchange
            var credentials = new ApiCredentials(ApiKey, Secret);

            using IBinanceClient binanceRestClient         = new BinanceClient(new BinanceClientOptions { ApiCredentials = credentials });
            using IBinanceSocketClient binanceSocketClient = new BinanceSocketClient(new BinanceSocketClientOptions { ApiCredentials = credentials });


            // 2. test connection
            Logger.Info("Testing connection...");
            var pingAsyncResult = await binanceRestClient.PingAsync();

            Logger.Info($"Ping {pingAsyncResult.Data} ms");


            // 2.1. check permissions
            var permissionsResponse = await binanceRestClient.General.GetAPIKeyPermissionsAsync();

            if (!permissionsResponse.Success)
            {
                Logger.Error($"{permissionsResponse.Error?.Message}");
                ReadLine();
            }
            else if (permissionsResponse.Data.IpRestrict | !permissionsResponse.Data.EnableSpotAndMarginTrading)
            {
                Logger.Error("Insufficient API permissions");
                ReadLine();
            }


            // 3. set bot strategy config
            var exchangeInfoResult = binanceRestClient.Spot.System.GetExchangeInfoAsync(Symbol);

            var symbolInfo = exchangeInfoResult.Result.Data.Symbols
                             .Single(s => s.Name.Equals(Symbol, StringComparison.InvariantCultureIgnoreCase));

            if (!(symbolInfo.Status == SymbolStatus.Trading && symbolInfo.OrderTypes.Contains(OrderType.Market)))
            {
                Logger.Error($"Symbol {symbolInfo.Name} doesn't suitable for this strategy");
                return;
            }

            if (symbolInfo.LotSizeFilter == null)
            {
                Logger.Error($"Cannot define risks strategy for {symbolInfo.Name}");
                return;
            }

            if (symbolInfo.PriceFilter == null)
            {
                Logger.Error($"Cannot define price precision for {symbolInfo.Name}. Please define it manually.");
                return;
            }
            int pricePrecision = (int)Math.Abs(Math.Log10(Convert.ToDouble(symbolInfo.PriceFilter.TickSize)));


            // WARN: set thresholds for strategy here
            var strategyConfig = new MarketStrategyConfiguration
            {
                TradeWhenSpreadGreaterThan = .02M, // or 0.02%, (price spread*min_volume) should be greater than broker's commissions for trade
                MinOrderVolume             = symbolInfo.LotSizeFilter.MinQuantity * 10,
                MaxOrderVolume             = symbolInfo.LotSizeFilter.MinQuantity * 100,
                QuoteAssetPrecision        = symbolInfo.QuoteAssetPrecision,
                PricePrecision             = pricePrecision,
                ReceiveWindow = ReceiveWindow
            };

            var marketStrategy = new NaiveMarketMakerStrategy(strategyConfig, Logger);


            // 3. start bot
            IMarketBot bot = new MarketMakerBot(Symbol, marketStrategy, binanceRestClient, binanceSocketClient, Logger);

            try
            {
                await bot.RunAsync();

                WriteLine($"Press Enter to stop {Symbol} bot...");
                ReadLine();
            }
            finally
            {
                bot.Stop();
            }

            WriteLine("Press Enter to exit...");
            ReadLine();
        }
Example #4
0
        /// <summary>
        /// create robot
        /// создать робота
        /// </summary>
        public static BotPanel GetStrategyForName(string nameClass, string name, StartProgram startProgram, bool isScript)
        {
            BotPanel bot = null;

            // примеры и бесплатные боты
            if (isScript && bot == null)
            {
                bot = CreateScriptStrategyByName(nameClass, name, startProgram);
                return(bot);
            }

            if (nameClass == "Breakdown")
            {
                bot = new Breakdown(name, startProgram);
            }
            if (nameClass == "Hftone")
            {
                bot = new Hftone(name, startProgram);
            }
            if (nameClass == "Frank_2")
            {
                bot = new Frank_2(name, startProgram);
            }
            if (nameClass == "Frankbol_for_bnb")
            {
                bot = new Frankbol_for_bnb(name, startProgram);
            }
            if (nameClass == "Frankbol")
            {
                bot = new Frankbol(name, startProgram);
            }
            if (nameClass == "Frank")
            {
                bot = new Frank(name, startProgram);
            }
            if (nameClass == "Storog")
            {
                bot = new Storog(name, startProgram);
            }
            if (nameClass == "Depozit")
            {
                bot = new Depozit(name, startProgram);
            }
            if (nameClass == "Ver_01")
            {
                bot = new Ver_01(name, startProgram);
            }
            if (nameClass == "NewParabol")
            {
                bot = new NewParabol(name, startProgram);
            }
            if (nameClass == "Start")
            {
                bot = new Start(name, startProgram);
            }
            if (nameClass == "RobotPriceChannel")
            {
                bot = new RobotPriceChannel(name, startProgram);
            }

            if (nameClass == "SmaScreener")
            {
                bot = new SmaScreener(name, startProgram);
            }
            if (nameClass == "ScreenerEngine")
            {
                bot = new ScreenerEngine(name, startProgram);
            }
            if (nameClass == "SmaTrendSample")
            {
                bot = new SmaTrendSample(name, startProgram);
            }
            if (nameClass == "TimeOfDayBot")
            {
                bot = new TimeOfDayBot(name, startProgram);
            }
            if (nameClass == "Fisher")
            {
                bot = new Fisher(name, startProgram);
            }
            if (nameClass == "FundBalanceDivergenceBot")
            {
                bot = new FundBalanceDivergenceBot(name, startProgram);
            }
            if (nameClass == "BbPowerTrade")
            {
                bot = new BbPowerTrade(name, startProgram);
            }
            if (nameClass == "BollingerRevers")
            {
                bot = new BollingerRevers(name, startProgram);
            }
            if (nameClass == "BollingerTrailing")
            {
                bot = new BollingerTrailing(name, startProgram);
            }
            if (nameClass == "CciTrade")
            {
                bot = new CciTrade(name, startProgram);
            }
            if (nameClass == "MacdRevers")
            {
                bot = new MacdRevers(name, startProgram);
            }
            if (nameClass == "MacdTrail")
            {
                bot = new MacdTrail(name, startProgram);
            }
            if (nameClass == "OneLegArbitrage")
            {
                bot = new OneLegArbitrage(name, startProgram);
            }
            if (nameClass == "PairRsiTrade")
            {
                bot = new PairRsiTrade(name, startProgram);
            }
            if (nameClass == "PriceChannelBreak")
            {
                bot = new PriceChannelBreak(name, startProgram);
            }
            if (nameClass == "PriceChannelVolatility")
            {
                bot = new PriceChannelVolatility(name, startProgram);
            }
            if (nameClass == "RsiTrade")
            {
                bot = new RsiTrade(name, startProgram);
            }
            if (nameClass == "RviTrade")
            {
                bot = new RviTrade(name, startProgram);
            }

            if (nameClass == "MomentumMACD")
            {
                bot = new MomentumMacd(name, startProgram);
            }

            if (nameClass == "Engine")
            {
                bot = new CandleEngine(name, startProgram);
            }
            if (nameClass == "ClusterEngine")
            {
                bot = new ClusterEngine(name, startProgram);
            }

            if (nameClass == "PairTraderSimple")
            {
                bot = new PairTraderSimple(name, startProgram);
            }
            if (nameClass == "EnvelopTrend")
            {
                bot = new EnvelopTrend(name, startProgram);
            }
            if (nameClass == "ClusterCountertrend")
            {
                bot = new ClusterCountertrend(name, startProgram);
            }
            if (nameClass == "PatternTrader")
            {
                bot = new PatternTrader(name, startProgram);
            }
            if (nameClass == "HighFrequencyTrader")
            {
                bot = new HighFrequencyTrader(name, startProgram);
            }
            if (nameClass == "PivotPointsRobot")
            {
                bot = new PivotPointsRobot(name, startProgram);
            }
            if (nameClass == "Williams Band")
            {
                bot = new StrategyBillWilliams(name, startProgram);
            }
            if (nameClass == "MarketMakerBot")
            {
                bot = new MarketMakerBot(name, startProgram);
            }
            if (nameClass == "ParabolicSarTrade")
            {
                bot = new ParabolicSarTrade(name, startProgram);
            }
            if (nameClass == "PriceChannelTrade")
            {
                bot = new PriceChannelTrade(name, startProgram);
            }
            if (nameClass == "WilliamsRangeTrade")
            {
                bot = new WilliamsRangeTrade(name, startProgram);
            }
            if (nameClass == "SmaStochastic")
            {
                bot = new SmaStochastic(name, startProgram);
            }
            if (nameClass == "PinBarTrade")
            {
                bot = new PinBarTrade(name, startProgram);
            }
            if (nameClass == "TwoLegArbitrage")
            {
                bot = new TwoLegArbitrage(name, startProgram);
            }
            if (nameClass == "ThreeSoldier")
            {
                bot = new ThreeSoldier(name, startProgram);
            }
            if (nameClass == "RsiContrtrend")
            {
                bot = new RsiContrtrend(name, startProgram);
            }
            if (nameClass == "PairTraderSpreadSma")
            {
                bot = new PairTraderSpreadSma(name, startProgram);
            }
            if (BotsWithAttribute.ContainsKey(nameClass))
            {
                Type botType = BotsWithAttribute[nameClass];
                bot = (BotPanel)Activator.CreateInstance(botType, name, startProgram);
            }

            return(bot);
        }
Example #5
0
        /// <summary>
        /// create robot
        /// создать робота
        /// </summary>
        public static BotPanel GetStrategyForName(string nameClass, string name, StartProgram startProgram)
        {
            BotPanel bot = null;

            // примеры и бесплатные боты

            if (nameClass == "EnvelopTrend")
            {
                bot = new EnvelopTrend(name, startProgram);
            }
            if (nameClass == "ClusterCountertrend")
            {
                bot = new ClusterCountertrend(name, startProgram);
            }
            if (nameClass == "PatternTrader")
            {
                bot = new PatternTrader(name, startProgram);
            }
            if (nameClass == "HighFrequencyTrader")
            {
                bot = new HighFrequencyTrader(name, startProgram);
            }
            if (nameClass == "PivotPointsRobot")
            {
                bot = new PivotPointsRobot(name, startProgram);
            }
            if (nameClass == "Williams Band")
            {
                bot = new StrategyBillWilliams(name, startProgram);
            }
            if (nameClass == "MarketMakerBot")
            {
                bot = new MarketMakerBot(name, startProgram);
            }
            if (nameClass == "Bollinger")
            {
                bot = new StrategyBollinger(name, startProgram);
            }
            if (nameClass == "ParabolicSarTrade")
            {
                bot = new ParabolicSarTrade(name, startProgram);
            }
            if (nameClass == "PriceChannelTrade")
            {
                bot = new PriceChannelTrade(name, startProgram);
            }
            if (nameClass == "WilliamsRangeTrade")
            {
                bot = new WilliamsRangeTrade(name, startProgram);
            }
            if (nameClass == "SmaStochastic")
            {
                bot = new SmaStochastic(name, startProgram);
            }
            if (nameClass == "PinBarTrade")
            {
                bot = new PinBarTrade(name, startProgram);
            }
            if (nameClass == "TwoLegArbitrage")
            {
                bot = new TwoLegArbitrage(name, startProgram);
            }
            if (nameClass == "ThreeSoldier")
            {
                bot = new ThreeSoldier(name, startProgram);
            }
            if (nameClass == "RsiContrtrend")
            {
                bot = new RsiContrtrend(name, startProgram);
            }
            if (nameClass == "PairTraderSpreadSma")
            {
                bot = new PairTraderSpreadSma(name, startProgram);
            }


            return(bot);
        }