Giter Site home page Giter Site logo

Comments (3)

JKorf avatar JKorf commented on June 14, 2024

Should work, what do you mean with 'not able to get the values'?

from binance.net.

MCaglarGuldiken avatar MCaglarGuldiken commented on June 14, 2024

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);
     }

}

from binance.net.

masherak avatar masherak commented on June 14, 2024

I think you need to learn programming as first a little bit. BinanceSocketClient works perfectly.

from binance.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.