Skip to content

Commit

Permalink
Feature/cryptoclients update (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf authored Apr 28, 2024
1 parent 874448c commit f624a9a
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BingX.Net/BingX.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.3.3" />
<PackageReference Include="CryptoExchange.Net" Version="7.4.0" />
</ItemGroup>
</Project>
48 changes: 48 additions & 0 deletions BingX.Net/BingX.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions BingX.Net/BingXExchange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace BingX.Net
{
/// <summary>
/// BingX exchange information and configuration
/// </summary>
public static class BingXExchange
{
/// <summary>
/// Exchange name
/// </summary>
public static string ExchangeName => "BingX";

/// <summary>
/// Url to the main website
/// </summary>
public static string Url { get; } = "https://www.bingx.com";

/// <summary>
/// Urls to the API documentation
/// </summary>
public static string[] ApiDocsUrl { get; } = new[] {
"https://bingx-api.github.io/docs"
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ internal BingXRestClientPerpetualFuturesApi(ILogger logger, HttpClient? httpClie

#endregion

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => baseAsset.ToUpperInvariant() + "-" + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ internal BingXSocketClientPerpetualFuturesApi(ILogger logger, BingXSocketOptions
}
#endregion

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => baseAsset.ToUpperInvariant() + "-" + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
=> new BingXAuthenticationProvider(credentials);
Expand Down
3 changes: 3 additions & 0 deletions BingX.Net/Clients/SpotApi/BingXRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ internal BingXRestClientSpotApi(ILogger logger, HttpClient? httpClient, BingXRes
}
#endregion

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => baseAsset.ToUpperInvariant() + "-" + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();
/// <inheritdoc />
Expand Down
3 changes: 3 additions & 0 deletions BingX.Net/Clients/SpotApi/BingXSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ internal BingXSocketClientSpotApi(ILogger logger, BingXSocketOptions options) :
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
=> new BingXAuthenticationProvider(credentials);

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => baseAsset.ToUpperInvariant() + "-" + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();
/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion BingX.Net/ExtensionMethods/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static IServiceCollection AddBingX(

services.AddTransient<ICryptoRestClient, CryptoRestClient>();
services.AddSingleton<ICryptoSocketClient, CryptoSocketClient>();
services.AddSingleton<IBingXOrderBookFactory, BingXOrderBookFactory>();
services.AddTransient<IBingXOrderBookFactory, BingXOrderBookFactory>();
services.AddTransient(x => x.GetRequiredService<IBingXRestClient>().SpotApi.CommonSpotClient);
if (socketClientLifeTime == null)
services.AddSingleton<IBingXSocketClient, BingXSocketClient>();
Expand Down
9 changes: 9 additions & 0 deletions BingX.Net/Interfaces/IBingXOrderBookFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ namespace BingX.Net.Interfaces
/// </summary>
public interface IBingXOrderBookFactory
{
/// <summary>
/// Spot order book factory methods
/// </summary>
public IOrderBookFactory<BingXOrderBookOptions> Spot { get; }
/// <summary>
/// Perpetual Futures order book factory methods
/// </summary>
public IOrderBookFactory<BingXOrderBookOptions> PerpetualFutures { get; }

/// <summary>
/// Create a new futures local order book instance
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions BingX.Net/SymbolOrderBooks/BingXOrderBookFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using BingX.Net.Interfaces;
using BingX.Net.Interfaces.Clients;
using BingX.Net.Objects.Options;
using CryptoExchange.Net.OrderBook;

namespace BingX.Net.SymbolOrderBooks
{
Expand All @@ -22,8 +23,16 @@ public class BingXOrderBookFactory : IBingXOrderBookFactory
public BingXOrderBookFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;

Spot = new OrderBookFactory<BingXOrderBookOptions>((symbol, options) => CreateSpot(symbol, options), (baseAsset, quoteAsset, options) => CreateSpot(baseAsset + "-" + quoteAsset, options));
PerpetualFutures = new OrderBookFactory<BingXOrderBookOptions>((symbol, options) => CreatePerpetualFutures(symbol, options), (baseAsset, quoteAsset, options) => CreatePerpetualFutures(baseAsset + quoteAsset, options));
}

/// <inheritdoc />
public IOrderBookFactory<BingXOrderBookOptions> Spot { get; }
/// <inheritdoc />
public IOrderBookFactory<BingXOrderBookOptions> PerpetualFutures { get; }

/// <inheritdoc />
public ISymbolOrderBook CreateSpot(string symbol, Action<BingXOrderBookOptions>? options = null)
=> new BingXSpotSymbolOrderBook(symbol,
Expand Down

0 comments on commit f624a9a

Please sign in to comment.