Binance.Net icon indicating copy to clipboard operation
Binance.Net copied to clipboard

using with Net Framework 4.8 application

Open NoamStudio opened this issue 2 years ago • 3 comments

Hi, i'm trying to use this library to integrate with a trading software, which accept only Net Framework 4.8 libraries. when trying to use any client Task (lets say GetKlinesAsync method) with the 'await' keyword, the library failed to load with a 'TypeLoadException' when using the same method without 'await' the library will load and the method will get the first 500 klines, and not the full request.

is there any reason why i can't use 'await' with any of the methods? is it even possible to use this library in a Net Framework 4.8 environment?

hope anyone can help.

NoamStudio avatar Jun 21 '22 02:06 NoamStudio

Can you show your code? Fully method

Kirill2Kirill avatar Jul 14 '22 13:07 Kirill2Kirill

Hi, Thank you for replying! any method from the manual will cause this exception, as soon as 'await' keyword is before the Task.

for the problem with only getting 500 klines i followed another example from somewhere, to loop the request like so

'

        int size = 1000;
        DateTime fromDate1 = toDate1.AddMinutes(-1 * size);
        List<IBinanceKline> sourceList = new List<IBinanceKline>();
        while (true)
        {
            var source = _binanceClient.UsdFuturesApi.ExchangeData.GetKlinesAsync(symbol1, (KlineInterval)interval, fromDate1, toDate1, size);
            if (source.Result.Success)
                sourceList = source.Result.Data.ToList();

            sourceList.ForEach(k => Bars.Add(new Bars()
            {
                Close = (double)k.ClosePrice,
                High = (double)k.HighPrice,
                Low = (double)k.LowPrice,
                Open = (double)k.OpenPrice,
                Volume = (double)k.Volume * 1000,
                TimeStamp = k.CloseTime
            }));

                if (fromDate1 < dateRange[0] || fromDate1 >= DateTime.Now)
                    break;

            toDate1 = fromDate1;
            if (barsPeriodType == BarsPeriodType.Minute)
                fromDate1 = toDate1.AddMinutes(-1 * 1000);
            else if (barsPeriodType == BarsPeriodType.Day)
                fromDate1 = toDate1.AddDays(-1 * 100);
        }

`

this is an example of how i can use this function, (but for as much as i was investigating, it seems like not all the request returned success, or maybe beacuse it didn't awaited) if i were to put an 'await' before the call like so: var source = await _binanceClient.UsdFuturesApi.ExchangeData.GetKlinesAsync(symbol1, (KlineInterval)interval, fromDate1, toDate1, size); this will cause a LoaderException.

NoamStudio avatar Jul 14 '22 22:07 NoamStudio

Can you show fully method? With it name and returning values and etc?

Kirill2Kirill avatar Jul 18 '22 08:07 Kirill2Kirill