JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.02k stars 420 forks source link

Cannot define BinanceRestClient with options #1310

Closed alaky2 closed 8 months ago

alaky2 commented 8 months ago

Hi, After updating to new version of Binance.Net, I cannot define RestClient with option. The code below:

Dim BRClient As New Binance.Net.Clients.BinanceRestClient(New Binance.Net.Objects.Options.BinanceRestOptions With { .ApiCredentials = New CryptoExchange.Net.Authentication.ApiCredentials(ApiKey, SecKey), .AutoTimestamp = False, .OutputOriginalData = False })

Or this one:

Dim Opt As New Binance.Net.Objects.Options.BinanceRestOptions Opt.ApiCredentials = New CryptoExchange.Net.Authentication.ApiCredentials(ApiKey, SecKey) Opt.AutoTimestamp = False Opt.OutputOriginalData = False Dim BRClient As New Binance.Net.Clients.BinanceRestClient(Opt)

gives the error:

'Unable to cast object of type 'Binance.Net.Objects.Options.BinanceRestOptions' to type 'Microsoft.Extensions.Logging.ILoggerFactory'.'

alaky2 commented 8 months ago

I figured out that my code was wrong. This one works:

Dim BRClient as New Binance.Net.Clients.BinanceRestClient( New Action(Of Binance.Net.Objects.Options.BinanceRestOptions) _ ( Sub(Opt As Binance.Net.Objects.Options.BinanceRestOptions) Opt.AutoTimestamp = True Opt.TimestampRecalculationInterval = New TimeSpan(1, 0, 0) Opt.OutputOriginalData = False Opt.ApiCredentials = New CryptoExchange.Net.Authentication.ApiCredentials(ApiKey, SecKey) End Sub ) )