-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated examples Updated CryptoExchange.Net to v8.1.0 Moved FormatSymbol to BinanceExchange class Added support Side setting on SharedTrade model Added BinanceTrackerFactory Added overload to Create method on BinanceOrderBookFactory support SharedSymbol parameter Fixed Shared rest GetTradeHistoryAsync pagination Added catch around HttpClientHandler.AutomaticDecompression setting as it's not support on Blazor WASM
- Loading branch information
Showing
32 changed files
with
548 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using Binance.Net.Clients; | ||
using Binance.Net.Interfaces; | ||
using Binance.Net.Interfaces.Clients; | ||
using CryptoExchange.Net.SharedApis; | ||
using CryptoExchange.Net.Trackers.Klines; | ||
using CryptoExchange.Net.Trackers.Trades; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Binance.Net | ||
{ | ||
/// <inheritdoc /> | ||
public class BinanceTrackerFactory : IBinanceTrackerFactory | ||
{ | ||
private readonly IServiceProvider? _serviceProvider; | ||
|
||
/// <summary> | ||
/// ctor | ||
/// </summary> | ||
public BinanceTrackerFactory() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// ctor | ||
/// </summary> | ||
/// <param name="serviceProvider">Service provider for resolving logging and clients</param> | ||
public BinanceTrackerFactory(IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IKlineTracker CreateKlineTracker(SharedSymbol symbol, SharedKlineInterval interval, int? limit = null, TimeSpan? period = null) | ||
{ | ||
var restClient = _serviceProvider?.GetRequiredService<IBinanceRestClient>() ?? new BinanceRestClient(); | ||
var socketClient = _serviceProvider?.GetRequiredService<IBinanceSocketClient>() ?? new BinanceSocketClient(); | ||
|
||
IKlineRestClient sharedRestClient; | ||
IKlineSocketClient sharedSocketClient; | ||
if (symbol.TradingMode == TradingMode.Spot) | ||
{ | ||
sharedRestClient = restClient.SpotApi.SharedClient; | ||
sharedSocketClient = socketClient.SpotApi.SharedClient; | ||
} | ||
else if (symbol.TradingMode.IsLinear()) | ||
{ | ||
sharedRestClient = restClient.UsdFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.UsdFuturesApi.SharedClient; | ||
} | ||
else | ||
{ | ||
sharedRestClient = restClient.CoinFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.CoinFuturesApi.SharedClient; | ||
} | ||
|
||
return new KlineTracker( | ||
_serviceProvider?.GetRequiredService<ILoggerFactory>().CreateLogger(restClient.Exchange), | ||
sharedRestClient, | ||
sharedSocketClient, | ||
symbol, | ||
interval, | ||
limit, | ||
period | ||
); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public ITradeTracker CreateTradeTracker(SharedSymbol symbol, int? limit = null, TimeSpan? period = null) | ||
{ | ||
var restClient = _serviceProvider?.GetRequiredService<IBinanceRestClient>() ?? new BinanceRestClient(); | ||
var socketClient = _serviceProvider?.GetRequiredService<IBinanceSocketClient>() ?? new BinanceSocketClient(); | ||
|
||
ITradeHistoryRestClient sharedRestClient; | ||
ITradeSocketClient sharedSocketClient; | ||
if (symbol.TradingMode == TradingMode.Spot) | ||
{ | ||
sharedRestClient = restClient.SpotApi.SharedClient; | ||
sharedSocketClient = socketClient.SpotApi.SharedClient; | ||
} | ||
else if (symbol.TradingMode.IsLinear()) | ||
{ | ||
sharedRestClient = restClient.UsdFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.UsdFuturesApi.SharedClient; | ||
} | ||
else | ||
{ | ||
sharedRestClient = restClient.CoinFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.CoinFuturesApi.SharedClient; | ||
} | ||
|
||
return new TradeTracker( | ||
_serviceProvider?.GetRequiredService<ILoggerFactory>().CreateLogger(restClient.Exchange), | ||
null, | ||
sharedRestClient, | ||
sharedSocketClient, | ||
symbol, | ||
limit, | ||
period | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.