-
-
Notifications
You must be signed in to change notification settings - Fork 5
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 BingXExchange class Added support Side setting on SharedTrade model Added BingXTrackerFactory Added overload to Create method on BingXOrderBookFactory support SharedSymbol parameter Added Shared websocket kline subscription implementation for futures and spot APIs
- Loading branch information
Showing
26 changed files
with
533 additions
and
18 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,92 @@ | ||
using BingX.Net.Clients; | ||
using BingX.Net.Interfaces; | ||
using BingX.Net.Interfaces.Clients; | ||
using CryptoExchange.Net.SharedApis; | ||
using CryptoExchange.Net.Trackers.Klines; | ||
using CryptoExchange.Net.Trackers.Trades; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
|
||
namespace BingX.Net | ||
{ | ||
/// <inheritdoc /> | ||
public class BingXTrackerFactory : IBingXTrackerFactory | ||
{ | ||
private readonly IServiceProvider? _serviceProvider; | ||
|
||
/// <summary> | ||
/// ctor | ||
/// </summary> | ||
public BingXTrackerFactory() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// ctor | ||
/// </summary> | ||
/// <param name="serviceProvider">Service provider for resolving logging and clients</param> | ||
public BingXTrackerFactory(IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IKlineTracker CreateKlineTracker(SharedSymbol symbol, SharedKlineInterval interval, int? limit = null, TimeSpan? period = null) | ||
{ | ||
var restClient = _serviceProvider?.GetRequiredService<IBingXRestClient>() ?? new BingXRestClient(); | ||
var socketClient = _serviceProvider?.GetRequiredService<IBingXSocketClient>() ?? new BingXSocketClient(); | ||
|
||
IKlineRestClient sharedRestClient; | ||
IKlineSocketClient sharedSocketClient; | ||
if (symbol.TradingMode == TradingMode.Spot) | ||
{ | ||
sharedRestClient = restClient.SpotApi.SharedClient; | ||
sharedSocketClient = socketClient.SpotApi.SharedClient; | ||
} | ||
else | ||
{ | ||
sharedRestClient = restClient.PerpetualFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.PerpetualFuturesApi.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<IBingXRestClient>() ?? new BingXRestClient(); | ||
var socketClient = _serviceProvider?.GetRequiredService<IBingXSocketClient>() ?? new BingXSocketClient(); | ||
|
||
IRecentTradeRestClient sharedRestClient; | ||
ITradeSocketClient sharedSocketClient; | ||
if (symbol.TradingMode == TradingMode.Spot) { | ||
sharedRestClient = restClient.SpotApi.SharedClient; | ||
sharedSocketClient = socketClient.SpotApi.SharedClient; | ||
} | ||
else { | ||
sharedRestClient = restClient.PerpetualFuturesApi.SharedClient; | ||
sharedSocketClient = socketClient.PerpetualFuturesApi.SharedClient; | ||
} | ||
|
||
return new TradeTracker( | ||
_serviceProvider?.GetRequiredService<ILoggerFactory>().CreateLogger(restClient.Exchange), | ||
sharedRestClient, | ||
null, | ||
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
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.