Beispiel #1
0
        public async Task Sell(string coin, double price, double quantity)
        {
            if (price > 1)
            {
                price = price / 100000000;
            }

            ConsoleHelpers.WriteColored($"\tWARNING: GOING TO SELL {quantity:0.00000000} {coin} at a rate of {price:0.00000000}, " +
                                        $"DO YOU WANT TO CONTINUE? (YES/NO) ", ConsoleColor.Yellow);

            if (Console.ReadLine()?.ToLower() == "yes")
            {
                await _bittrexApi.Sell("BTC-" + coin.ToUpper(), quantity, price);

                ConsoleHelpers.WriteColoredLine("\tSell order placed.", ConsoleColor.Green);
            }
            else
            {
                ConsoleHelpers.WriteColoredLine("\tSell cancelled.", ConsoleColor.Red);
            }
        }
Beispiel #2
0
        public async Task Sell(string coin, double price, double quantity)
        {
            if (price > 1)
            {
                price = price / 100000000;
            }

            ConsoleHelpers.WriteColored($"\tWARNING: GOING TO SELL {quantity:0.00000000} {coin} at a rate of {price:0.00000000}, " +
                                        $"DO YOU WANT TO CONTINUE? (YES/NO) ", ConsoleColor.Yellow);

            if (Console.ReadLine()?.ToLower() == "yes")
            {
                var result = await _binanceApi.PlaceOrderAsync(coin.ToUpper() + "BTC", OrderSide.Sell, OrderType.Limit, TimeInForce.GoodTillCancel, (decimal)quantity, (decimal)price);

                ConsoleHelpers.WriteColoredLine("\tSell order placed.", ConsoleColor.Green);
            }
            else
            {
                ConsoleHelpers.WriteColoredLine("\tSell cancelled.", ConsoleColor.Red);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            try
            {
                _binanceManager = new BinanceManager();
                _bittrexManager = new BittrexManager();

                ConsoleHelpers.WriteSeparator();
                ConsoleHelpers.WriteIntro();
                ConsoleHelpers.WriteSeparator();
                ConsoleHelpers.WriteDonation();
                ConsoleHelpers.WriteSeparator();
                Console.WriteLine("\tPlease type your commands, type \"-h\" or \"--help\" to see an overview of all possible commands.");
                ShowMenu().Wait();
            }
            catch (Exception ex)
            {
                ConsoleHelpers.WriteColoredLine($"\tAn error occurred: {ex.InnerException?.Message}. " +
                                                $"Application will close once you hit return.", ConsoleColor.Red);
                Console.WriteLine();
                Console.Write("\t");
                Console.ReadLine();
            }
        }
Beispiel #4
0
        public async Task CancelOrder(Prices prices, string coin = null)
        {
            var orders = await _bittrexApi.GetOpenOrders();

            if (coin != null)
            {
                orders = orders.Where(x => x.Exchange.Replace("BTC-", string.Empty) == coin).ToList();
            }

            if (orders.Count > 0)
            {
                Console.WriteLine(orders
                                  .ToStringTable <OpenOrder>(
                                      new[]
                {
                    "ID", "Market", "Bid/Ask", "Quantity", "Remaining", "Estimated Total",
                    "Estimated EUR Value", "Estimated USD Value"
                },
                                      x => orders.IndexOf(x) + 1, x => x.Exchange, x => x.Limit.ToString("0.00000000"), x => x.Quantity,
                                      x => x.QuantityRemaining, x => ((x.Limit * x.Quantity) * 0.9975).ToString("0.00000000"),
                                      x => (((x.Limit * x.Quantity) * 0.9975) * (double)prices.Eur.Last).ToString("0.00 EUR"),
                                      x => (((x.Limit * x.Quantity) * 0.9975) * (double)prices.Usd.Last).ToString("0.00 USD")));


                Console.Write("\tWhich order should be cancelled (ID) (or enter -1 for all): ");
                int orderId = 0;
                if (int.TryParse(Console.ReadLine(), out orderId))
                {
                    if (orderId > 0 && orderId <= orders.Count)
                    {
                        ConsoleHelpers.WriteColored("\tWARNING: GOING TO CANCEL AN ORDER, DO YOU WANT TO CONTINUE? (YES/NO) ",
                                                    ConsoleColor.Yellow);

                        if (Console.ReadLine()?.ToLower() == "yes")
                        {
                            await _bittrexApi.CancelOrder(orders[orderId - 1].OrderUuid);

                            ConsoleHelpers.WriteColoredLine($"\tOrder {orders[orderId - 1].OrderUuid} cancelled.", ConsoleColor.Green);
                        }
                        else
                        {
                            ConsoleHelpers.WriteColoredLine("\tCancel cancelled (cancelception?).", ConsoleColor.Red);
                        }
                    }
                    else if (orderId == -1)
                    {
                        ConsoleHelpers.WriteColored("\tWARNING: GOING TO CANCEL ALL OF THE ABOVE ORDERS, DO YOU WANT TO CONTINUE? (YES/NO) ", ConsoleColor.Yellow);

                        if (Console.ReadLine()?.ToLower() == "yes")
                        {
                            foreach (var order in orders)
                            {
                                await _bittrexApi.CancelOrder(order.OrderUuid);

                                ConsoleHelpers.WriteColoredLine($"\tOrder {order.OrderUuid} cancelled.", ConsoleColor.Green);
                            }
                        }
                        else
                        {
                            ConsoleHelpers.WriteColoredLine("\tCancel cancelled (cancelception?).", ConsoleColor.Red);
                        }
                    }
                    else
                    {
                        ConsoleHelpers.WriteColoredLine("\tInvalid order ID.", ConsoleColor.Red);
                    }
                }
                else
                {
                    ConsoleHelpers.WriteColoredLine("\tInvalid order ID.", ConsoleColor.Red);
                }
            }
            else
            {
                Console.WriteLine("\tNo open orders found...");
            }
        }
Beispiel #5
0
        public static void ShowHelp()
        {
            ConsoleHelpers.WriteColoredLine("\tOptions:", ConsoleColor.Yellow);

            ConsoleHelpers.WriteColored("\t  -h, --help", ConsoleColor.Green);
            Console.WriteLine("\t\tDisplays this help message.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -w, --wallet", ConsoleColor.Green);
            Console.WriteLine("\t\tDisplays your wallet balance on the given exchange.");

            ConsoleHelpers.WriteColored("\t      <exchange>", ConsoleColor.Green);
            Console.WriteLine("\tThe exchange to check, valid options: binance | bin | bittrex | trex.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -o, --orders", ConsoleColor.Green);
            Console.WriteLine("\t\tDisplays your open orders on the given exchange.");
            ConsoleHelpers.WriteColored("\t      <exchange>", ConsoleColor.Green);
            Console.WriteLine("\tThe exchange to check, valid options: binance | bin | bittrex | trex.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -b, --buy", ConsoleColor.Green);
            Console.WriteLine("\t\tPlaces a buy limit order on the given exchange.");
            ConsoleHelpers.WriteColored("\t      <exchange>", ConsoleColor.Green);
            Console.WriteLine("\tThe exchange to place the order, valid options: binance | bin | bittrex | trex.");
            ConsoleHelpers.WriteColored("\t      <coin>", ConsoleColor.Green);
            Console.WriteLine("\t\tThe coin for which orders should be placed e.g. ETH.");
            ConsoleHelpers.WriteColored("\t      <price>", ConsoleColor.Green);
            Console.WriteLine("\t\tPrice it should be listed for e.g. 0,00031.");
            ConsoleHelpers.WriteColoredLine("\t\t\t\tYou can also enter the above price as 31000.", ConsoleColor.Cyan);
            ConsoleHelpers.WriteColored("\t      <quantity>", ConsoleColor.Green);
            Console.WriteLine("\tThe amount that should be bought.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -s, --sell", ConsoleColor.Green);
            Console.WriteLine("\t\tPlaces a sell limit order on the given exchange.");
            ConsoleHelpers.WriteColored("\t      <exchange>", ConsoleColor.Green);
            Console.WriteLine("\tThe exchange to place the order, valid options: binance | bin | bittrex | trex.");
            ConsoleHelpers.WriteColored("\t      <coin>", ConsoleColor.Green);
            Console.WriteLine("\t\tThe coin for which orders should be placed e.g. ETH.");
            ConsoleHelpers.WriteColored("\t      <price>", ConsoleColor.Green);
            Console.WriteLine("\t\tPrice it should be listed for e.g. 0,00031.");
            ConsoleHelpers.WriteColoredLine("\t\t\t\tYou can also enter the above price as 31000.", ConsoleColor.Cyan);
            ConsoleHelpers.WriteColored("\t      <quantity>", ConsoleColor.Green);
            Console.WriteLine("\tThe amount that should be sold.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -c, --cancel", ConsoleColor.Green);
            Console.WriteLine("\t\tCancels an order on the given exchange.");
            ConsoleHelpers.WriteColored("\t      <exchange>", ConsoleColor.Green);
            Console.WriteLine("\tThe exchange to check, valid options: binance | bin | bittrex | trex.");
            ConsoleHelpers.WriteColored("\t      <coin>", ConsoleColor.Green);
            Console.WriteLine("\t\tThe coin for which orders should be displayed e.g. ETH.");
            Console.WriteLine();

            ConsoleHelpers.WriteColored("\t  -e, --exit", ConsoleColor.Green);
            Console.WriteLine("\t\tYou're done, time to close the tool.");

            Console.WriteLine();
            ConsoleHelpers.WriteColoredLine("\tSamples:", ConsoleColor.Yellow);
            ConsoleHelpers.WriteColored("\t  -w trex", ConsoleColor.Green);
            Console.WriteLine("\t\t\tShow your wallet balances on Bittrex.");
            ConsoleHelpers.WriteColored("\t  -o trex", ConsoleColor.Green);
            Console.WriteLine("\t\t\tShows all open orders on Bittrex.");
            ConsoleHelpers.WriteColored("\t  -b trex neo 192012 30", ConsoleColor.Green);
            Console.WriteLine("\t\tPlace a buy order for 30 NEO at 0,00192012 on Bittrex.");
            ConsoleHelpers.WriteColored("\t  -s trex eth 0,00932013 15", ConsoleColor.Green);
            Console.WriteLine("\t\tPlace a sell order for 15 ETH at 0,00932013 on Bittrex.");
            ConsoleHelpers.WriteColored("\t  -c trex", ConsoleColor.Green);
            Console.WriteLine("\t\t\tLists all cancellable orders on Bittrex.");
            ConsoleHelpers.WriteColored("\t  -c trex eth", ConsoleColor.Green);
            Console.WriteLine("\t\t\tLists all cancellable ETH orders on Bittrex.");
        }