Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/shared #1427

Merged
merged 60 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a1df754
wip
JKorf Aug 9, 2024
e43b137
wip
JKorf Aug 9, 2024
c6d73c5
wip
JKorf Aug 11, 2024
7491ada
wip
JKorf Aug 12, 2024
2802ac5
wip
JKorf Aug 12, 2024
6a232bf
wip
JKorf Aug 13, 2024
6e50e67
Merge branch 'master' into feature/shared
JKorf Aug 13, 2024
e618f35
wip
JKorf Aug 14, 2024
9736be9
wip
JKorf Aug 14, 2024
a457a49
wip
JKorf Aug 15, 2024
4fa5c20
wip
JKorf Aug 15, 2024
63cef47
wip
JKorf Aug 16, 2024
aad8fe4
wip
JKorf Aug 18, 2024
a8df78f
Merge branch 'master' into feature/shared
JKorf Aug 19, 2024
b1d61dc
wip
JKorf Aug 20, 2024
b029a83
wip
JKorf Aug 22, 2024
83bb087
wip
JKorf Aug 25, 2024
a951021
wip
JKorf Aug 25, 2024
3c4c16a
wip
JKorf Aug 28, 2024
0f383e2
Merge branch 'master' into feature/shared
JKorf Aug 28, 2024
742a28c
wip
JKorf Sep 1, 2024
0c830d5
Merge branch 'master' into feature/shared
JKorf Sep 2, 2024
e854dc6
wip
JKorf Sep 2, 2024
2ab6cc2
wip
JKorf Sep 3, 2024
4a68b15
wip
JKorf Sep 4, 2024
b5b6c18
wip
JKorf Sep 4, 2024
db82414
wip
JKorf Sep 4, 2024
7bc3988
wip
JKorf Sep 5, 2024
e118bcf
wip
JKorf Sep 5, 2024
3d29b0a
wip
JKorf Sep 6, 2024
00d6757
wip
JKorf Sep 8, 2024
abb309e
wip
JKorf Sep 9, 2024
0de250b
wip
JKorf Sep 9, 2024
fe2f186
wip
JKorf Sep 9, 2024
69c46d2
wip
JKorf Sep 10, 2024
ea4b8af
wip
JKorf Sep 10, 2024
80395a0
wip
JKorf Sep 10, 2024
dc863df
Merge branch 'master' into feature/shared
JKorf Sep 11, 2024
d6a3d01
wip
JKorf Sep 11, 2024
dc0d830
wip
JKorf Sep 12, 2024
cf182e0
wip
JKorf Sep 12, 2024
b46a84c
wip
JKorf Sep 13, 2024
546541c
wip
JKorf Sep 15, 2024
59297ef
wip
JKorf Sep 17, 2024
b14f929
wip
JKorf Sep 18, 2024
d84b62f
wip
JKorf Sep 19, 2024
09c6f0e
wip
JKorf Sep 20, 2024
389e326
wip
JKorf Sep 22, 2024
241f052
wip
JKorf Sep 23, 2024
da9fd49
wip
JKorf Sep 23, 2024
777fcf7
wip
JKorf Sep 24, 2024
161c223
wip
JKorf Sep 25, 2024
a7c6f08
wip
JKorf Sep 25, 2024
c76d08d
Merge branch 'master' into feature/shared
JKorf Sep 25, 2024
f224519
wip
JKorf Sep 25, 2024
a5c7d59
wip
JKorf Sep 26, 2024
deff832
wip
JKorf Sep 26, 2024
1bf6910
wip
JKorf Sep 27, 2024
e7d086c
Update Binance.Net.csproj
JKorf Sep 27, 2024
f97b750
Update Binance.Net.csproj
JKorf Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading