Skip to content

Commit

Permalink
Merge pull request #7 from JKorf/feature/cryptoclients-update
Browse files Browse the repository at this point in the history
Feature/cryptoclients update
  • Loading branch information
JKorf authored Apr 28, 2024
2 parents 4d069c4 + 9d0cc8d commit 247d063
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Mexc.Net/Clients/SpotApi/MexcRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ internal MexcRestClientSpotApi(ILogger logger, HttpClient? httpClient, MexcRestO
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
=> new MexcAuthenticationProvider(credentials);

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

internal async Task<WebCallResult<T>> SendRequestInternal<T>(string path, HttpMethod method, CancellationToken cancellationToken,
Dictionary<string, object>? parameters = null, bool signed = false, HttpMethodParameterPosition? postPosition = null,
ArrayParametersSerialization? arraySerialization = null) where T : class
Expand Down
3 changes: 3 additions & 0 deletions Mexc.Net/Clients/SpotApi/MexcSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ internal MexcSocketClientSpotApi(ILogger logger, MexcSocketOptions options) :
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
=> new MexcAuthenticationProvider(credentials);

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

/// <inheritdoc />
public async Task<CallResult<UpdateSubscription>> SubscribeToTradeUpdatesAsync(string symbol, Action<DataEvent<IEnumerable<MexcStreamTrade>>> handler, CancellationToken ct = default)
=> await SubscribeToTradeUpdatesAsync(new[] { symbol }, handler, ct).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion Mexc.Net/ExtensionMethods/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static IServiceCollection AddMexc(

services.AddTransient<ICryptoRestClient, CryptoRestClient>();
services.AddTransient<ICryptoSocketClient, CryptoSocketClient>();
services.AddSingleton<IMexcOrderBookFactory, MexcOrderBookFactory>();
services.AddTransient<IMexcOrderBookFactory, MexcOrderBookFactory>();
services.AddTransient(x => x.GetRequiredService<IMexcRestClient>().SpotApi.CommonSpotClient);
if (socketClientLifeTime == null)
services.AddSingleton<IMexcSocketClient, MexcSocketClient>();
Expand Down
5 changes: 5 additions & 0 deletions Mexc.Net/Interfaces/IMexcOrderBookFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace Mexc.Net.Interfaces
/// </summary>
public interface IMexcOrderBookFactory
{
/// <summary>
/// Spot order book factory methods
/// </summary>
public IOrderBookFactory<MexcOrderBookOptions> Spot { get; }

/// <summary>
/// Create a new spot SymbolOrderBook
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Mexc.Net/Mexc.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>
34 changes: 34 additions & 0 deletions Mexc.Net/Mexc.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 Mexc.Net/MexcExchange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Mexc.Net
{
/// <summary>
/// Mexc exchange information and configuration
/// </summary>
public static class MexcExchange
{
/// <summary>
/// Exchange name
/// </summary>
public static string ExchangeName => "Mexc";

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

/// <summary>
/// Urls to the API documentation
/// </summary>
public static string[] ApiDocsUrl { get; } = new[] {
"https://mexcdevelop.github.io/apidocs/spot_v3_en/#introduction"
};
}
}
6 changes: 6 additions & 0 deletions Mexc.Net/SymbolOrderBooks/MexcOrderBookFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.OrderBook;
using Mexc.Net.Interfaces;
using Mexc.Net.Interfaces.Clients;
using Mexc.Net.Objects.Options;
Expand All @@ -15,13 +16,18 @@ public class MexcOrderBookFactory : IMexcOrderBookFactory
{
private readonly IServiceProvider _serviceProvider;

/// <inheritdoc />
public IOrderBookFactory<MexcOrderBookOptions> Spot { get; }

/// <summary>
/// ctor
/// </summary>
/// <param name="serviceProvider">Service provider for resolving logging and clients</param>
public MexcOrderBookFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;

Spot = new OrderBookFactory<MexcOrderBookOptions>((symbol, options) => CreateSpot(symbol, options), (baseAsset, quoteAsset, options) => CreateSpot(baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant(), options));
}

/// <inheritdoc />
Expand Down

0 comments on commit 247d063

Please sign in to comment.