예제 #1
0
        public async void makeSell()
        {
            try
            {
                int     amountToSell = (int)myCoin;
                decimal a            = (decimal)myCoin;


                BaseCreateOrderResponse response = await client.CreateOrder(new CreateOrderRequest()
                {
                    //IcebergQuantity = amountToSell,
                    // Price = d,
                    //Quantity = amount,
                    Quantity = amountToSell,
                    Side     = OrderSide.Sell,
                    Symbol   = tradeCoin + "BTC",
                    Type     = OrderType.Market,
                });
            }
            catch (BinanceBadRequestException e)
            {
                Console.WriteLine("bad request i sell");


                makeSell();
            }

            Console.WriteLine("sold: " + sold);
        }
예제 #2
0
        public async void makeBuy()
        {
            try
            {
                double  amount      = myBTC / price;
                decimal amountToBuy = (decimal)amount - 1;
                Console.WriteLine("amount to buy: " + amountToBuy);
                int a = (int)amount;


                BaseCreateOrderResponse response = await client.CreateOrder(new CreateOrderRequest()
                {
                    Quantity = a,
                    Side     = OrderSide.Buy,
                    Symbol   = tradeCoin + "BTC",
                    Type     = OrderType.Market,
                });
            }
            catch (BinanceBadRequestException e)
            {
                Console.WriteLine("bad request in buy");

                makeBuy();
            }

            Console.WriteLine("sold: " + sold);
        }
예제 #3
0
        public async void Sell()
        {
            try
            {
                AccountInformationResponse ais = await client.GetAccountInformation();

                BaseCreateOrderResponse cor = await client.CreateOrder(new CreateOrderRequest
                {
                    Type     = OrderType.Market,
                    Side     = OrderSide.Sell,
                    Quantity = ais.Balances.Find(x => x.Asset == SettingsForm.Coin).Free,
                    Symbol   = SettingsForm.Coin + SettingsForm.TradeCoin
                });
            }
            catch (BinanceBadRequestException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceServerException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceTimeoutException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceException ex)
            {
                Form1.AddError(ex);
            }
            catch (Exception ex)
            {
                Form1.AddError(ex);
            }
        }
예제 #4
0
        public async void Buy()
        {
            try
            {
                List <SymbolPriceResponse> spr = await client.GetSymbolsPriceTicker();

                decimal price = (spr.Find(x => x.Symbol == SettingsForm.Coin + SettingsForm.TradeCoin).Price);
                AccountInformationResponse ais = await client.GetAccountInformation();

                decimal quantity = Math.Floor(ais.Balances.Find(x => x.Asset == SettingsForm.TradeCoin).Free / price) - 1;

                BaseCreateOrderResponse cor = await client.CreateOrder(new CreateOrderRequest
                {
                    Type     = OrderType.Market,
                    Side     = OrderSide.Buy,
                    Quantity = quantity,
                    Symbol   = SettingsForm.Coin + SettingsForm.TradeCoin
                });
            }
            catch (BinanceBadRequestException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceServerException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceTimeoutException ex)
            {
                Form1.AddError(ex);
            }
            catch (BinanceException ex)
            {
                Form1.AddError(ex);
            }
            catch (Exception ex)
            {
                Form1.AddError(ex);
            }
        }