Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
 public MyBinanceClass()
 {
     try
     {
         this.client = new BinanceClient(new ClientConfiguration()
         {
             ApiKey    = SettingsForm.key,
             SecretKey = SettingsForm.secret
         });
     }
     catch (Exception ex)
     {
         Form1.AddError(ex);
     }
 }
Ejemplo n.º 3
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);
            }
        }