Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using with Net Framework 4.8 application #1104

Open
NoamStudio opened this issue Jun 21, 2022 · 3 comments
Open

using with Net Framework 4.8 application #1104

NoamStudio opened this issue Jun 21, 2022 · 3 comments

Comments

@NoamStudio
Copy link

NoamStudio commented Jun 21, 2022

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.

@Kirill2Kirill
Copy link

Can you show your code? Fully method

@NoamStudio
Copy link
Author

NoamStudio commented Jul 14, 2022

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.

@Kirill2Kirill
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants