Skip to content

Commit

Permalink
CryptoExchange.Net v8.0.0, shared interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf authored Sep 27, 2024
1 parent 0255a4c commit c05ed86
Show file tree
Hide file tree
Showing 33 changed files with 3,465 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;
using System;

Expand All @@ -14,7 +15,7 @@ public BinanceRestApiClient(ILogger logger, BinanceRestOptions options, BinanceR
}

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode futuresType, DateTime? deliverDate = null) => $"{baseAsset.ToUpperInvariant()}{quoteAsset.ToUpperInvariant()}";
public override TimeSpan? GetTimeOffset() => null;
public override TimeSyncInfo GetTimeSyncInfo() => null;
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) => throw new NotImplementedException();
Expand Down
1 change: 1 addition & 0 deletions Binance.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class TestSocket: IWebsocket
public event Func<Task> OnReconnected;
public event Func<Task> OnReconnecting;
public event Func<int, Task> OnRequestRateLimited;
public event Func<Task> OnConnectRateLimited;
public event Func<Exception, Task> OnError;
#pragma warning restore 0067
public event Func<int, Task> OnRequestSent;
Expand Down
6 changes: 3 additions & 3 deletions Binance.Net/Binance.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>10.0</LangVersion>
Expand Down Expand Up @@ -31,7 +31,7 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup Label="Deterministic Build" Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -48,10 +48,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.11.2" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="8.0.0" />
</ItemGroup>
</Project>
83 changes: 70 additions & 13 deletions Binance.Net/Binance.Net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceRestClientCoinFuturesApi.GetServerTimestampAsync">
Expand Down Expand Up @@ -469,7 +469,7 @@
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceSocketClientCoinFuturesApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceSocketClientCoinFuturesApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceSocketClientCoinFuturesApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.CoinFuturesApi.BinanceSocketClientCoinFuturesApi.GetListenerIdentifier(CryptoExchange.Net.Interfaces.IMessageAccessor)">
Expand Down Expand Up @@ -628,7 +628,7 @@
<member name="M:Binance.Net.Clients.GeneralApi.BinanceRestClientGeneralApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.GeneralApi.BinanceRestClientGeneralApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.GeneralApi.BinanceRestClientGeneralApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.GeneralApi.BinanceRestClientGeneralApi.GetServerTimestampAsync">
Expand Down Expand Up @@ -1133,7 +1133,7 @@
<member name="M:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.SpotApi.BinanceRestClientSpotApi.GetServerTimestampAsync">
Expand Down Expand Up @@ -1673,7 +1673,7 @@
<member name="P:Binance.Net.Clients.SpotApi.BinanceSocketClientSpotApi.Trading">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.SpotApi.BinanceSocketClientSpotApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.SpotApi.BinanceSocketClientSpotApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.SpotApi.BinanceSocketClientSpotApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
Expand Down Expand Up @@ -1908,7 +1908,7 @@
Event triggered when an order is canceled via this client. Note that this does not trigger when using CancelAllOrdersAsync. Only available for Spot orders
</summary>
</member>
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceRestClientUsdFuturesApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
Expand Down Expand Up @@ -2224,7 +2224,7 @@
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.CreateAuthenticationProvider(CryptoExchange.Net.Authentication.ApiCredentials)">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.FormatSymbol(System.String,System.String)">
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.FormatSymbol(System.String,System.String,CryptoExchange.Net.SharedApis.TradingMode,System.Nullable{System.DateTime})">
<inheritdoc />
</member>
<member name="M:Binance.Net.Clients.UsdFuturesApi.BinanceSocketClientUsdFuturesApi.SubscribeToMarkPriceUpdatesAsync(System.String,System.Nullable{System.Int32},System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Futures.Socket.BinanceFuturesUsdtStreamMarkPrice}},System.Threading.CancellationToken)">
Expand Down Expand Up @@ -5494,9 +5494,13 @@
</member>
<member name="P:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApi.CommonFuturesClient">
<summary>
Get the IFuturesClient for this client. This is a common interface which allows for some basic operations without knowing any details of the exchange.
DEPRECATED; use <see cref="T:CryptoExchange.Net.SharedApis.ISharedClient" /> instead for common/shared functionality. See <see href="https://jkorf.github.io/CryptoExchange.Net/docs/index.html#shared" /> for more info.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApi.SharedClient">
<summary>
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiAccount">
<summary>
Expand Down Expand Up @@ -5981,6 +5985,11 @@
<param name="ct">Cancellation token</param>
<returns>List of prices</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiShared">
<summary>
Shared interface for COIN-M Futures rest API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceRestClientCoinFuturesApiTrading">
<summary>
Binance COIN-M futures trading endpoints, placing and mananging orders.
Expand Down Expand Up @@ -6149,6 +6158,11 @@
Binance Coin futures streams
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceSocketClientCoinFuturesApi.SharedClient">
<summary>
Get the shared socket subscription client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="M:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceSocketClientCoinFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)">
<summary>
Subscribes to the aggregated trades update stream for the provided symbol
Expand Down Expand Up @@ -6539,6 +6553,11 @@
<param name="ct">Cancellation token for closing this subscription</param>
<returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.CoinFuturesApi.IBinanceSocketClientCoinFuturesApiShared">
<summary>
Shared interface for COIN-M Futures socket API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.GeneralApi.IBinanceRestClientGeneralApi">
<summary>
Binance general API endpoints
Expand Down Expand Up @@ -8479,9 +8498,13 @@
</member>
<member name="P:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApi.CommonSpotClient">
<summary>
Get the ISpotClient for this client. This is a common interface which allows for some basic operations without knowing any details of the exchange.
DEPRECATED; use <see cref="T:CryptoExchange.Net.SharedApis.ISharedClient" /> instead for common/shared functionality. See <see href="https://jkorf.github.io/CryptoExchange.Net/docs/index.html#shared" /> for more info.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApi.SharedClient">
<summary>
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiAccount">
<summary>
Expand Down Expand Up @@ -9745,6 +9768,11 @@
<param name="ct">Cancellation token</param>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiShared">
<summary>
Shared interface for Spot rest API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceRestClientSpotApiTrading">
<summary>
Binance Spot trading endpoints, placing and mananging orders.
Expand Down Expand Up @@ -10479,6 +10507,11 @@
Trading data and queries
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.SpotApi.IBinanceSocketClientSpotApi.SharedClient">
<summary>
Get the shared socket subscription client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceSocketClientSpotApiAccount">
<summary>
Binance Spot Account socket requests and subscriptions
Expand Down Expand Up @@ -10949,6 +10982,11 @@
<param name="ct">Cancellation token for closing this subscription</param>
<returns>A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected</returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceSocketClientSpotApiShared">
<summary>
Shared interface for Spot socket API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.SpotApi.IBinanceSocketClientSpotApiTrading">
<summary>
Binance Spot Trading socket requests
Expand Down Expand Up @@ -11227,9 +11265,13 @@
</member>
<member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApi.CommonFuturesClient">
<summary>
Get the IFuturesClient for this client. This is a common interface which allows for some basic operations without knowing any details of the exchange.
DEPRECATED; use <see cref="T:CryptoExchange.Net.SharedApis.ISharedClient" /> instead for common/shared functionality. See <see href="https://jkorf.github.io/CryptoExchange.Net/docs/index.html#shared" /> for more info.
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApi.SharedClient">
<summary>
Get the shared rest requests client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiAccount">
<summary>
Expand Down Expand Up @@ -11897,6 +11939,11 @@
<param name="toAsset">To asset</param>
<param name="ct">Cancellation token</param>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiShared">
<summary>
Shared interface for USD-M Futures rest API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceRestClientUsdFuturesApiTrading">
<summary>
Binance USD-M futures trading endpoints, placing and mananging orders.
Expand Down Expand Up @@ -12225,6 +12272,11 @@
Binance USD futures streams
</summary>
</member>
<member name="P:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SharedClient">
<summary>
Get the shared socket subscription client. This interface is shared with other exhanges to allow for a common implementation for different exchanges.
</summary>
</member>
<member name="M:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApi.SubscribeToAggregatedTradeUpdatesAsync(System.String,System.Action{CryptoExchange.Net.Objects.Sockets.DataEvent{Binance.Net.Objects.Models.Spot.Socket.BinanceStreamAggregatedTrade}},System.Threading.CancellationToken)">
<summary>
Subscribes to the aggregated trades update stream for the provided symbol
Expand Down Expand Up @@ -12582,6 +12634,11 @@
<param name="ct">Cancellation token for closing this subscription</param>
<returns></returns>
</member>
<member name="T:Binance.Net.Interfaces.Clients.UsdFuturesApi.IBinanceSocketClientUsdFuturesApiShared">
<summary>
Shared interface for USD-M Futures socket API usage
</summary>
</member>
<member name="T:Binance.Net.Interfaces.IBinance24HPrice">
<summary>
24 hour price stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.RateLimiting.Interfaces;
using CryptoExchange.Net.SharedApis;

namespace Binance.Net.Clients.CoinFuturesApi
{
/// <inheritdoc cref="IBinanceRestClientCoinFuturesApi" />
internal class BinanceRestClientCoinFuturesApi : RestApiClient, IBinanceRestClientCoinFuturesApi, IFuturesClient
internal partial class BinanceRestClientCoinFuturesApi : RestApiClient, IBinanceRestClientCoinFuturesApi, IFuturesClient
{
#region fields
/// <inheritdoc />
Expand Down Expand Up @@ -75,7 +76,10 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null)
{
return baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant() + (deliverTime == null ? "_PERP" : "_" + deliverTime.Value.ToString("yyMMdd"));
}

internal Uri GetUrl(string endpoint, string api, string? version = null)
{
Expand Down Expand Up @@ -256,6 +260,7 @@ protected override Task<WebCallResult<DateTime>> GetServerTimestampAsync()

/// <inheritdoc />
public IFuturesClient CommonFuturesClient => this;
public IBinanceRestClientCoinFuturesApiShared SharedClient => this;

/// <inheritdoc />
public string GetSymbolName(string baseAsset, string quoteAsset) =>
Expand Down
Loading

0 comments on commit c05ed86

Please sign in to comment.