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