public MainViewModel() { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("bMNcUXrq4ZzUpMTM3jrNVqNIihI0sAeK6Zytudd7qEhCfyHdUPtL2uDmZSmEQ7J5 ", "qkA8T5Q6lNcUSTAhwi9jYaEbZpxmpvfoD0xB9ZdwLEEEQhYEqim1cJBjv2m1dNma"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("bMNcUXrq4ZzUpMTM3jrNVqNIihI0sAeK6Zytudd7qEhCfyHdUPtL2uDmZSmEQ7J5 ", "qkA8T5Q6lNcUSTAhwi9jYaEbZpxmpvfoD0xB9ZdwLEEEQhYEqim1cJBjv2m1dNma"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); using (var client = new BinanceClient()) { var historicalTrades = client.GetHistoricalSymbolTrades("BNBBTC"); } var socketClient = new BinanceSocketClient(); var successTrades = socketClient.SubscribeToTradeUpdates("bnbbtc", (data) => { Application.Current.Dispatcher.Invoke(() => { AllPrices.Add(data); }); }); }
public BinanceAdapter(SubscriptionManager subMgr) { _subMgr = subMgr; string BINANCE_API_KEY = Environment.GetEnvironmentVariable("BINANCE_API_KEY"); string BINANCE_SECRET = Environment.GetEnvironmentVariable("BINANCE_SECRET"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(BINANCE_API_KEY, BINANCE_SECRET), // LogVerbosity = CryptoExchange.Net.Logging.LogVerbosity.Debug, // LogWriters = { Console.Out } }); BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials(BINANCE_API_KEY, BINANCE_SECRET), LogVerbosity = CryptoExchange.Net.Logging.LogVerbosity.Debug, LogWriters = { Console.Out } }); socketClient = new BinanceSocketClient(); _exchangeInfo = QueryExchangeInfo(); _drift = QueryDrift(); }
static void Main(string[] args) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("API KEY", "SECRET API KEY"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("API KEY", "SECRET API KEY"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); Console.WriteLine("Введите торговую пару большими буквами без пробелов"); couple = Console.ReadLine(); Console.WriteLine("Введите количество монет, которыми будете торговать"); coins = Convert.ToDecimal(Console.ReadLine()); Console.WriteLine("Хотите скрыть консольное окно?"); Console.WriteLine("0 - нет, 1 - да"); trey = Convert.ToInt32(Console.ReadLine()); ShowWindow(GetConsoleWindow(), 1); // 0 - свернуть в трей, 1 - показать консольное окно while (true) { Buy(); Sell(); } }
/// <summary> /// Authentication Information to access Binance API /// </summary> /// <param name="ApiKey"></param> /// <param name="ApiSecret"></param> public void AddAuthenticationInformation(string ApiKey, string ApiSecret) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), }); }
// Initiate stream public static void InitiateStream(string binanceAPIKey, string binanceAPISecret, string symbol, string powerBIAPIURL) { // Trade aggregations int tradeCount = 0; decimal cumulativeQuantity = 0; // Configure websocket BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(binanceAPIKey, binanceAPISecret), LogVerbosity = LogVerbosity.None, // Change to Debug if required LogWriters = new List <TextWriter> { Console.Out }, }); var socketClient = new BinanceSocketClient(); Console.WriteLine("Connecting to Binance Websocket @ " + socketClient.BaseAddress + "\n"); // Binance exposes many streams and we can connect to whichever ones we want // Here we are connecting to trade updates for a specified pair var successSingleTicker = socketClient.Spot.SubscribeToTradeUpdates(symbol, data => { // Increment aggregations tradeCount++; cumulativeQuantity += data.Quantity; // Create Trade instance var trade = new Trade(symbol, data.TradeTime, tradeCount, cumulativeQuantity, data.Price, data.Quantity); // Convert to string var jsonString = JsonConvert.SerializeObject(trade); // Write to console Console.WriteLine(jsonString + "\n"); // Post to Power BI Streaming Dataset try { var postToPowerBi = PowerBIPostAsync(powerBIAPIURL, "[" + jsonString + "]"); } catch (Exception e) { Console.WriteLine(e); } }); Console.ReadLine(); }
public void SetApiKeys(string ApiKey, string ApiSecret) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), }); this.Client = new BinanceClient(); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), }); this.Socket = new BinanceSocketClient(); this.Account.UpdateAccount(); }
public void SetApiKeys(string ApiKey, string ApiSecret) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), RateLimitingBehaviour = CryptoExchange.Net.Objects.RateLimitingBehaviour.Wait }); this.Client = new BinanceClient(); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(ApiKey, ApiSecret), }); this.Socket = new BinanceSocketClient(); this.Account.UpdateAccount(); }
public static void BinanceMain() { //https://github.com/JKorf/Binance.Net BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("p5X0rxCZaLKbzPJNAGOo2vQ6JusPbKU85dElpK6M81P4HneGm37F0dGNEOMsMaE6", "Flr5VPJiDTcElglnuvNz1JW6pmjBZKcxWUGUdcLhGS1L9CuBx43RuyXlFJN4V1xd"), LogVerbosity = LogVerbosity.Debug }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("p5X0rxCZaLKbzPJNAGOo2vQ6JusPbKU85dElpK6M81P4HneGm37F0dGNEOMsMaE6", "Flr5VPJiDTcElglnuvNz1JW6pmjBZKcxWUGUdcLhGS1L9CuBx43RuyXlFJN4V1xd"), LogVerbosity = LogVerbosity.Debug }); using (var client = new BinanceClient()) { var ping = client.Ping(); var exchangeInfo = client.GetExchangeInfo(); var serverTime = client.GetServerTime(); //var orderBook = client.GetOrderBook("BNBBTC", 10); //var aggTrades = client.GetAggregatedTrades("BNBBTC", startTime: DateTime.UtcNow.AddMinutes(-2), endTime: DateTime.UtcNow, limit: 10); //var klines = client.GetKlines("BNBBTC", KlineInterval.OneHour, startTime: DateTime.UtcNow.AddHours(-10), endTime: DateTime.UtcNow, limit: 10); //var price = client.GetPrice("BNBBTC"); //var prices24h = client.Get24HPrice("BNBBTC"); //var allPrices = client.GetAllPrices(); //var allBookPrices = client.GetAllBookPrices(); //var historicalTrades = client.GetHistoricalTrades("BNBBTC"); // Private //avar openOrders = client.GetOpenOrders("BNBBTC"); //var allOrders = client.GetAllOrders("BNBBTC"); //var testOrderResult = client.PlaceTestOrder("BNBBTC", OrderSide.Buy, OrderType.Limit, 1, price: 1, timeInForce: TimeInForce.GoodTillCancel); //var queryOrder = client.QueryOrder("BNBBTC", allOrders.Data[0].OrderId); //var orderResult = client.PlaceOrder("BNBBTC", OrderSide.Sell, OrderType.Limit, 10, price: 0.0002m, timeInForce: TimeInForce.GoodTillCancel); //var cancelResult = client.CancelOrder("BNBBTC", orderResult.Data.OrderId); //var accountInfo = client.GetAccountInfo(); //var myTrades = client.GetMyTrades("BNBBTC"); // Withdrawal/deposit var withdrawalHistory = client.GetWithdrawHistory(); var depositHistory = client.GetDepositHistory(); var withdraw = client.Withdraw("ASSET", "ADDRESS", 0); } }
public MainWindowViewModel() { TradingHistory = new ObservableCollectionExtended <BinanceOrder>(); BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(_apiKey, _secretKey), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(_apiKey, _secretKey), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); using (var client = new BinanceClient()) { var allOrders = client.GetAllOrders(_symbol); Application.Current.Dispatcher.Invoke(() => { TradingHistory.AddRange(allOrders.Data); }); } //var socketClient = new BinanceSocketClient(); //var successTrades = socketClient.subs("bnbbtc", (data) => //{ // Application.Current.Dispatcher.Invoke(() => // { // TradingHistory.Add(data); // }); //}); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); // Register the clients, options can be provided in the callback parameter services.AddBinance((restClientOptions, socketClientOptions) => { restClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET"); restClientOptions.LogLevel = LogLevel.Trace; // Point the logging to use the ILogger configuration, which uses Serilog here restClientOptions.LogWriters = new List <ILogger> { _loggerFactory.CreateLogger <IBinanceClient>() }; socketClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET"); }); BinanceClient.SetDefaultOptions(new BinanceClientOptions { ApiCredentials = new ApiCredentials("KEY", "SECRET"), LogLevel = LogLevel.Trace }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions { ApiCredentials = new ApiCredentials("KEY", "SECRET"), }); services.AddTransient <IBinanceClient, BinanceClient>(); services.AddScoped <IBinanceSocketClient, BinanceSocketClient>(); services.AddBitfinex(); services.AddBittrex(); services.AddBybit(); services.AddCoinEx(); services.AddFTX(); services.AddHuobi(); services.AddKraken(); services.AddKucoin(); }
public void Initialize() { string apiKey = ""; string apiSecret = ""; BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(apiKey, apiSecret), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(apiKey, apiSecret), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); }
//private IBinanceApiUser iuser; public VolumeInfo() { InitializeComponent(); enableTrading = chkLiveTrading.Checked; BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("", ""), LogVerbosity = LogVerbosity.Debug //, //LogWriters = Console.Out }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("", ""), LogVerbosity = LogVerbosity.Debug //, //LogWriters = Console.Out }); //BinanceDefaults.SetDefaultApiCredentials("", ""); //BinanceDefaults.SetDefaultLogVerbosity(LogVerbosity.Debug); TableInit(); //RefreshButton.Visible = false; FontSet(); //this.loopThread = new Thread(new ThreadStart(this.GetVolumes)); //this.loopThread.Start(); this.backgroundWorkerView = new System.ComponentModel.BackgroundWorker(); this.backgroundWorkerView.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.backgroundWorkerView_RunWorkerCompleted); this.backgroundWorkerView.DoWork += new DoWorkEventHandler(backgroundWorkerView_DoWork); //Task.Run(() => //{ //GetVolumes(); //}); //this.Show(); }
public Instance(string pair, string api, string apisec) { Logger = LogManager.GetCurrentClassLogger(); PairLink = pair; BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(api, apisec), LogVerbosity = LogVerbosity.Debug }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(api, apisec), LogVerbosity = LogVerbosity.Debug }); client = new BinanceClient(); var accountInfo = client.GetAccountInfo(); ListenerKey = client.StartUserStream().Data; OrderDataStream(); }
public Class1() { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("APIKEY", "ZkCeNPdKLjXFn9oQehoQwe226E6Z0iW5IOYcnHzMroE969XVuipu543A84uVkzE1"), LogVerbosity = LogVerbosity.Debug, // LogWriter = Console.Out }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("APIKEY", "kTGx5jlVkCOvqVa95G1WQ3xa6B1aC5beJiBlQvbzKURvFPcQ4tudS0Hp8JSL3Kkv"), LogVerbosity = LogVerbosity.Debug, // LogWriter = Console.Out }); String symbol = "POABTC"; DateTime?fecha = null; using (var client = new BinanceClient()) { /* * while (true) * { * fecha = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, 0); * CallResult<BinanceKline[]> klines = client.GetKlines(symbol, KlineInterval.OneMinute, startTime: fecha.Value.AddMinutes(-1), endTime: fecha, limit: 1); * if (klines.Success) { * foreach (BinanceKline kline in klines.Data) { * printKline(kline, symbol); * } * } * Thread.Sleep(60000); * } */ // Public /* * var ping = client.Ping(); * var exchangeInfo = client.GetExchangeInfo(); * var serverTime = client.GetServerTime(); * var orderBook = client.GetOrderBook("BNBBTC", 10); * var aggTrades = client.GetAggregatedTrades("BNBBTC", startTime: DateTime.UtcNow.AddMinutes(-2), endTime: DateTime.UtcNow, limit: 10); */ DateTime inicio = new DateTime(2018, 4, 7, 14, 30, 0); DateTime fin = new DateTime(2018, 4, 7, 16, 15, 0); var klines = client.GetKlines(symbol, KlineInterval.FiveMinutes, startTime: inicio, endTime: fin); if (klines.Success) { foreach (BinanceKline kline in klines.Data) { printKline(kline, symbol); } } /* * var price = client.GetPrice("BNBBTC"); * var prices24h = client.Get24HPrice("BNBBTC"); * var allPrices = client.GetAllPrices(); * var allBookPrices = client.GetAllBookPrices(); * var historicalTrades = client.GetHistoricalTrades("BNBBTC"); * * // Private * * var openOrders = client.GetOpenOrders("BNBBTC"); * var allOrders = client.GetAllOrders("BNBBTC"); * var testOrderResult = client.PlaceTestOrder("BNBBTC", OrderSide.Buy, OrderType.Limit, 1, price: 1, timeInForce: TimeInForce.GoodTillCancel); * var queryOrder = client.QueryOrder("BNBBTC", allOrders.Data[0].OrderId); * var orderResult = client.PlaceOrder("BNBBTC", OrderSide.Sell, OrderType.Limit, 10, price: 0.0002m, timeInForce: TimeInForce.GoodTillCancel); * var cancelResult = client.CancelOrder("BNBBTC", orderResult.Data.OrderId); * var accountInfo = client.GetAccountInfo(); * var myTrades = client.GetMyTrades("BNBBTC"); * * // Withdrawal/deposit * var withdrawalHistory = client.GetWithdrawHistory(); * var depositHistory = client.GetDepositHistory(); * var withdraw = client.Withdraw("ASSET", "ADDRESS", 0); */ } /* * var socketClient = new BinanceSocketClient(); * // Streams * var successDepth = socketClient.SubscribeToDepthStream("bnbbtc", (data) => * { * // handle data * }); * var successTrades = socketClient.SubscribeToTradesStream("bnbbtc", (data) => * { * // handle data * }); * * var successKline = socketClient. SubscribeToKlineStreamAsync("bnbbtc", KlineInterval.OneMinute, (data) => * { * Console.Out.Write("PAR: " + data.Data.Symbol + Environment.NewLine); * Console.Out.Write("OPEN TIME: " + data.Data.OpenTime + Environment.NewLine); * Console.Out.Write("CLOSE TIME: " + data.Data.CloseTime + Environment.NewLine); * Console.Out.Write("OPEN: " + data.Data.Open + Environment.NewLine); * Console.Out.Write("CLOSE: " + data.Data.Close + Environment.NewLine); * Console.Out.Write("HIGH: " + data.Data.High + Environment.NewLine); * Console.Out.Write("LOW: " + data.Data.Low + Environment.NewLine); * Console.Out.Write("TRADES: " + data.Data.TradeCount + Environment.NewLine); * Console.Out.Write("VOLUME: " + data.Data.Volume + Environment.NewLine); * Console.Out.Write("=============== " + data.Data.Volume + Environment.NewLine); * }); * * var successTicker = socketClient.SubscribeToAllSymbolTicker((data) => * { * // handle data * }); * var successSingleTicker = socketClient.SubscribeToSymbolTicker("bnbbtc", (data) => * { * // handle data * }); * * string listenKey; * using (var client = new BinanceClient()) * listenKey = client.StartUserStream().Data.ListenKey; * * var successAccount = socketClient.SubscribeToUserStream(listenKey, data => * { * // Hanlde account info data * }, * data => * { * // Hanlde order update info data * }); * socketClient.UnsubscribeAllStreams(); */ Console.ReadLine(); }
static void Main(string[] args) { var apikey = ConfigurationManager.AppSettings.Get("apiKey"); var secret = ConfigurationManager.AppSettings.Get("apiKey"); BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(apikey, secret), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(apikey, secret), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); using (var client = new BinanceClient()) { // Spot.Market | Spot market info endpoints client.Spot.Market.GetBookPrice("BTCUSDT"); // Spot.Order | Spot order info endpoints client.Spot.Order.GetAllOrders("BTCUSDT"); // Spot.System | Spot system endpoints client.Spot.System.GetExchangeInfo(); // Spot.UserStream | Spot user stream endpoints. Should be used to subscribe to a user stream with the socket client client.Spot.UserStream.StartUserStream(); // Spot.Futures | Transfer to/from spot from/to the futures account + cross-collateral endpoints //client.Spot.Futures.TransferFuturesAccount("ASSET", 1, FuturesTransferType.FromSpotToUsdtFutures); //// FuturesCoin | Coin-M general endpoints //client.FuturesCoin.GetPositionInformation(); //// FuturesCoin.Market | Coin-M futures market endpoints //client.FuturesCoin.Market.GetBookPrices("BTCUSD"); //// FuturesCoin.Order | Coin-M futures order endpoints //client.FuturesCoin.Order.GetMyTrades(); //// FuturesCoin.Account | Coin-M account info //client.FuturesCoin.Account.GetAccountInfo(); //// FuturesCoin.System | Coin-M system endpoints //client.FuturesCoin.System.GetExchangeInfo(); //// FuturesCoin.UserStream | Coin-M user stream endpoints. Should be used to subscribe to a user stream with the socket client //client.FuturesCoin.UserStream.StartUserStream(); //// FuturesUsdt | USDT-M general endpoints //client.FuturesUsdt.GetPositionInformation(); //// FuturesUsdt.Market | USDT-M futures market endpoints //client.FuturesUsdt.Market.GetBookPrices("BTCUSDT"); //// FuturesUsdt.Order | USDT-M futures order endpoints //client.FuturesUsdt.Order.GetMyTrades("BTCUSDT"); //// FuturesUsdt.Account | USDT-M account info //client.FuturesUsdt.Account.GetAccountInfo(); //// FuturesUsdt.System | USDT-M system endpoints //client.FuturesUsdt.System.GetExchangeInfo(); //// FuturesUsdt.UserStream | USDT-M user stream endpoints. Should be used to subscribe to a user stream with the socket client //client.FuturesUsdt.UserStream.StartUserStream(); // General | General/account endpoints client.General.GetAccountInfo(); // Lending | Lending endpoints client.Lending.GetFlexibleProductList(); //// Margin | Margin general/account info //client.Margin.GetMarginAccountInfo(); //// Margin.Market | Margin market endpoints //client.Margin.Market.GetMarginPairs(); //// Margin.Order | Margin order endpoints //client.Margin.Order.GetAllMarginAccountOrders("BTCUSDT"); //// Margin.UserStream | Margin user stream endpoints. Should be used to subscribe to a user stream with the socket client //client.Margin.UserStream.StartUserStream(); //// Margin.IsolatedUserStream | Isolated margin user stream endpoints. Should be used to subscribe to a user stream with the socket client //client.Margin.IsolatedUserStream.StartIsolatedMarginUserStream("BTCUSDT"); //// Mining | Mining endpoints //client.Mining.GetMiningCoinList(); //// SubAccount | Sub account management //client.SubAccount.TransferSubAccount("fromEmail", "toEmail", "asset", 1); //// Brokerage | Brokerage management //client.Brokerage.CreateSubAccountAsync(); //// WithdrawDeposit | Withdraw and deposit endpoints //client.WithdrawDeposit.GetWithdrawalHistory(); } var socketClient = new BinanceSocketClient(); // Spot | Spot market and user subscription methods socketClient.Spot.SubscribeToAllBookTickerUpdates(data => { // Handle data }); // FuturesCoin | Coin-M futures market and user subscription methods socketClient.FuturesCoin.SubscribeToAllBookTickerUpdates(data => { // Handle data }); // FuturesUsdt | USDT-M futures market and user subscription methods socketClient.FuturesUsdt.SubscribeToAllBookTickerUpdates(data => { // Handle data }); // Unsubscribe socketClient.UnsubscribeAll(); Console.ReadLine(); }
static void Main(string[] args) { BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials("APIKEY", "APISECRET"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials("APIKEY", "APISECRET"), LogVerbosity = LogVerbosity.Debug, LogWriters = new List <TextWriter> { Console.Out } }); using (var client = new BinanceClient()) { // Public var ping = client.Ping(); var exchangeInfo = client.GetExchangeInfo(); var serverTime = client.GetServerTime(); var orderBook = client.GetOrderBook("BNBBTC", 10); var aggTrades = client.GetAggregatedTrades("BNBBTC", startTime: DateTime.UtcNow.AddMinutes(-2), endTime: DateTime.UtcNow, limit: 10); var klines = client.GetKlines("BNBBTC", KlineInterval.OneHour, startTime: DateTime.UtcNow.AddHours(-10), endTime: DateTime.UtcNow, limit: 10); var price = client.GetPrice("BNBBTC"); var prices24h = client.Get24HPrice("BNBBTC"); var allPrices = client.GetAllPrices(); var allBookPrices = client.GetAllBookPrices(); var historicalTrades = client.GetHistoricalTrades("BNBBTC"); // Private var openOrders = client.GetOpenOrders("BNBBTC"); var allOrders = client.GetAllOrders("BNBBTC"); var testOrderResult = client.PlaceTestOrder("BNBBTC", OrderSide.Buy, OrderType.Limit, 1, price: 1, timeInForce: TimeInForce.GoodTillCancel); var queryOrder = client.QueryOrder("BNBBTC", allOrders.Data[0].OrderId); var orderResult = client.PlaceOrder("BNBBTC", OrderSide.Sell, OrderType.Limit, 10, price: 0.0002m, timeInForce: TimeInForce.GoodTillCancel); var cancelResult = client.CancelOrder("BNBBTC", orderResult.Data.OrderId); var accountInfo = client.GetAccountInfo(); var myTrades = client.GetMyTrades("BNBBTC"); // Withdrawal/deposit var withdrawalHistory = client.GetWithdrawHistory(); var depositHistory = client.GetDepositHistory(); var withdraw = client.Withdraw("ASSET", "ADDRESS", 0); } var socketClient = new BinanceSocketClient(); // Streams var successDepth = socketClient.SubscribeToDepthStream("bnbbtc", (data) => { // handle data }); var successTrades = socketClient.SubscribeToTradesStream("bnbbtc", (data) => { // handle data }); var successKline = socketClient.SubscribeToKlineStream("bnbbtc", KlineInterval.OneMinute, (data) => { // handle data }); var successTicker = socketClient.SubscribeToAllSymbolTicker((data) => { // handle data }); var successSingleTicker = socketClient.SubscribeToSymbolTicker("bnbbtc", (data) => { // handle data }); string listenKey; using (var client = new BinanceClient()) listenKey = client.StartUserStream().Data.ListenKey; var successAccount = socketClient.SubscribeToUserStream(listenKey, data => { // Hanlde account info data }, data => { // Hanlde order update info data }); socketClient.UnsubscribeAllStreams(); Console.ReadLine(); }
public void AtualizaInformacoesResumo() { List <EntMoeda> listaMoedas = new BllMoeda().ObterTodos("", "", 1); foreach (EntMoeda objMoeda in listaMoedas) { if (objMoeda.OperacaoCompraAberta.IdOperacao > 0) { objMoeda.OperacaoCompraAberta = new BllOperacao().ObterPorId(objMoeda.OperacaoCompraAberta.IdOperacao); } if (objMoeda.OperacaoVendaAberta.IdOperacao > 0) { objMoeda.OperacaoVendaAberta = new BllOperacao().ObterPorId(objMoeda.OperacaoVendaAberta.IdOperacao); } } BinanceClient.SetDefaultOptions(new BinanceClientOptions() { ApiCredentials = new ApiCredentials(ConfigurationManager.AppSettings["BinanceClientKey"], ConfigurationManager.AppSettings["BinanceSecretKey"]), LogVerbosity = LogVerbosity.Warning, LogWriters = new List <TextWriter> { Console.Out } }); BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions() { ApiCredentials = new ApiCredentials(ConfigurationManager.AppSettings["BinanceClientKey"], ConfigurationManager.AppSettings["BinanceSecretKey"]), LogVerbosity = LogVerbosity.Warning, LogWriters = new List <TextWriter> { Console.Out } }); client = new BinanceClient(); /*foreach (EntMoeda moeda in listaMoedas) * { * if (moeda.IdMoeda == EntMoeda.MOEDA_ETH) * { * MonitorarVenda(moeda, new EntCarteira()); * } * }*/ foreach (EntMoeda moeda in listaMoedas) { AtualizaInformacoesResumoMoeda(moeda); CalculaRsi(moeda); } while (true) { if (DateTime.Now.Subtract(DataUltimaAtualizacao).TotalMilliseconds / 1000 >= StringUtils.ToInt(ConfigurationManager.AppSettings["SegundosAtualizacaoResumo"])) { DataUltimaAtualizacao = DateTime.Now; foreach (EntMoeda moeda in listaMoedas) { AtualizaInformacoesResumoMoeda(moeda); CalculaRsi(moeda); } } System.Threading.Thread.Sleep(5 * 1000); } }