public override async void Execute(Message message, TelegramBotClient client, string channelId = null)
        {
            long chatId = message.Chat.Id;

            if (TradeBotsStorage <ResponseWrapper> .Exists(chatId, "bittrex"))
            {
                (CommonTradeBot <ResponseWrapper> tradeBot, ManualResetEvent signal) = TradeBotsStorage <ResponseWrapper> .GetTardeBot(chatId, "bittrex");

                JArray openOrders = (JArray)(await tradeBot.GetOpenOrders()).Result;
                string respMess   = "NoOrders";
                if (openOrders.Count > 0)
                {
                    respMess = string.Join("\n",
                                           openOrders.Select(o =>
                                                             "Uuid: " + o["OrderUuid"] + "Type: " + o["OrderType"] + "Pair: " + o["Exchange"])
                                           .ToArray());
                }

                await client.SendTextMessageAsync(chatId, respMess);
            }
            else
            {
                await client.SendTextMessageAsync(chatId, "U dont have bittrex TradeBot");
            }
        }
Exemplo n.º 2
0
        public override void Execute(Message message, TelegramBotClient client, string channelId = null)
        {
            var chatId = message.Chat.Id;

            (string apiKey, string apiSecret) = GetAuthData(message, client, chatId);
            if (apiKey == "" || apiSecret == "")
            {
                /*client.SendTextMessageAsync(chatId, "Error: apiKey or/and apiSecret were not provided");
                 * return;*/
            }

            BittrexTradeBot  bittrexTradeBot = new BittrexTradeBot();//apiKey, apiSecret);
            ManualResetEvent signal          = new ManualResetEvent(false);

            bool exists = TradeBotsStorage <ResponseWrapper> .Exists(chatId, "bittrex");

            if (exists)
            {
                client.SendTextMessageAsync(chatId, $"You already have bot on bittrex");
                return;
            }

            bool created = TradeBotsStorage <ResponseWrapper> .AddTradeBot(chatId, bittrexTradeBot, "bittrex", signal);

            if (created)
            {
                client.SendTextMessageAsync(chatId, $"Trade bot created on Bittrex. Your balances:\n" +
                                            $"{string.Join("; ", bittrexTradeBot.WalletBalances.Select(c => c.Key + ":" + c.Value).ToArray())}\n");
            }
            else
            {
                client.SendTextMessageAsync(chatId, "Error in creating TradeBot");
            }
        }
Exemplo n.º 3
0
        public override void Execute(Message message, TelegramBotClient client, string channelId = null)
        {
            var chatId = message.Chat.Id;

            (string market, decimal amountBtc, decimal amountEth) = GetTradeData(message);
            if (amountBtc != 0 && amountBtc < (decimal)0.0005)
            {
                client.SendTextMessageAsync(chatId, "Can't trade with < 0.0005 btc");
                return;
            }
            if (amountEth != 0 && amountEth < (decimal)0.005)
            {
                client.SendTextMessageAsync(chatId, "Can't trade with < 0.005 eth");
                return;
            }
            if (amountBtc == 0 && amountEth == 0)
            {
                client.SendTextMessageAsync(chatId, "Can't trade with 0 btc and 0 eth");
                return;
            }

            if (TradeBotsStorage <ResponseWrapper> .Exists(chatId, market))
            {
                (CommonTradeBot <ResponseWrapper> tradeBot, ManualResetEvent signal) = TradeBotsStorage <ResponseWrapper> .GetTardeBot(chatId, market);

                (amountBtc, amountEth) = tradeBot.StartTrading(amountBtc, amountEth, client, chatId, signal);
                if (amountBtc == 0 && amountEth == 0)
                {
                    client.SendTextMessageAsync(chatId, string.Format("You don't have enough balance", market));
                    return;
                }
                client.SendTextMessageAsync(chatId, string.Format("Your bot on {0} started trading with {1} btc and {2} eth", market, amountBtc, amountEth));
            }
            else
            {
                client.SendTextMessageAsync(chatId, string.Format("You don't have a bot on {0}", market));
            }
        }
        public override async void Execute(Message message, TelegramBotClient client, string channelId = null)
        {
            long chatId = message.Chat.Id;

            if (TradeBotsStorage <ResponseWrapper> .Exists(chatId, "bittrex"))
            {
                (CommonTradeBot <ResponseWrapper> tradeBot, ManualResetEvent signal) = TradeBotsStorage <ResponseWrapper> .GetTardeBot(chatId, "bittrex");

                string orderUuid = getOrderUuid(message.Text);
                bool   canceled  = (await tradeBot.CancelOrder(orderUuid)).Success;
                if (canceled)
                {
                    await client.SendTextMessageAsync(chatId, $"[Canceled] Order ${getOrderUuid(message.Text)}");
                }
                else
                {
                    await client.SendTextMessageAsync(chatId, $"You dont have order {getOrderUuid(message.Text)}");
                }
            }
            else
            {
                await client.SendTextMessageAsync(chatId, "U dont have bittrex TradeBot");
            }
        }