Open MCaglarGuldiken opened 2 months ago
Should work, what do you mean with 'not able to get the values'?
I run BinanceDataCollector for two coins. However they are in different thread, still values are confusing. (coinName gives coinName2's value, etc).
dataCollector = new Thread(() =>
{
while (true)
{
BinanceDataCollector(coinName, instantTradeData, totalTradeAmount);
BinanceDataCollector(coinName2, instantTradeData2, totalTradeAmount2);
}
});
public async void BinanceDataCollector(string coin, TradeData instantTradeData, decimal dataAmount) { BinanceSocketClient binanceSocketClient = binance.getBinanceSocketClient();
// Local variables to store prices for the current coin
double spotAskPriceLocal = 0;
double spotBidPriceLocal = 0;
double futuresAskPriceLocal = 0;
double futuresBidPriceLocal = 0;
var tickerSubscriptionResultSpot = binanceSocketClient.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync(coin, (update) =>
{
spotAskPriceLocal = Convert.ToDouble(update.Data.BestAskPrice);
spotBidPriceLocal = Convert.ToDouble(update.Data.BestBidPrice);
log.Error(update.Data);
}); var tickerSubscriptionTaskFutures = binanceSocketClient.UsdFuturesApi.SubscribeToOrderBookUpdatesAsync(coin, null, (update) =>
{
futuresAskPriceLocal = Convert.ToDouble(update.Data.Asks.First().Price);
futuresBidPriceLocal = Convert.ToDouble(update.Data.Bids.First().Price);
log.Error(update.Data);
});
// Wait for both subscriptions to complete
await Task.WhenAll(tickerSubscriptionResultSpot, tickerSubscriptionTaskFutures);
}
}
catch (Exception ex)
{
log.Error("Bot Error --> " + ex);
rtbSpotFutures.AppendText("Bot Error --> " + ex);
}
}
I think you need to learn programming as first a little bit. BinanceSocketClient works perfectly.
@MCaglarGuldiken Set opt.SpotOptions.ApiCredentials
Hi,
I would like to establish websocket connection but I am not able to get the values.
Should I made any extra API settings to manage it?
var binanceSocketClient = new BinanceSocketClient(options => {
Binance.Net 9.6.1 CryptoExchange.Net 7.0.0