public async Task BinanceBuySell(string BuyOrSell) { var api = new BinanceApi(); if (await api.PingAsync()) { Console.WriteLine("Successfull"); switch (BuyOrSell) { case "buy": using (var user = new BinanceApiUser("yIruCEm5k2TkExflzSf183xBp4HUt66G2BDx6WJqlL7HATRyJmcgp5UAiqYl0XsF", "BEqWhtDUPDIpNmaHFxA5ZhXLElcS74oal6yHLEx5sbE5gu46EsYLAfWAx1veyUr0")) { // Create a client (MARKET) order. var clientOrder = new MarketOrder(user) { Symbol = Symbol.ETH_BTC, Side = Binance.OrderSide.Buy, Quantity = 1m }; try { // Send the TEST order. await api.PlaceAsync(clientOrder); } catch (Exception e) { Console.WriteLine($"TEST Order Failed: \"{e.Message}\""); } WithdrawRequest withdrawRequest = new WithdrawRequest(user) { Address = "", Amount = 2, Asset = Asset.ETH, }; await api.WithdrawAsync(withdrawRequest); } break; case "sell": using (var user = new BinanceApiUser("yIruCEm5k2TkExflzSf183xBp4HUt66G2BDx6WJqlL7HATRyJmcgp5UAiqYl0XsF", "BEqWhtDUPDIpNmaHFxA5ZhXLElcS74oal6yHLEx5sbE5gu46EsYLAfWAx1veyUr0")) { WithdrawRequest withdrawRequest = new WithdrawRequest(user) { Address = "", Amount = 2, Asset = Asset.BTC, }; // Create a client (MARKET) order. var clientOrder = new MarketOrder(user) { Symbol = Symbol.ETH_BTC, Side = Binance.OrderSide.Sell, Quantity = 1m }; try { // Send the TEST order. await api.PlaceAsync(clientOrder); } catch (Exception e) { Console.WriteLine($"TEST Order Failed: \"{e.Message}\""); } await api.WithdrawAsync(withdrawRequest); } break; } } }