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 #236

Merged
merged 50 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
417e12a
wip
JKorf Aug 9, 2024
78619fb
wip
JKorf Aug 9, 2024
2b42aef
wip
JKorf Aug 11, 2024
ba7a112
wip
JKorf Aug 12, 2024
a7c6b6a
wip
JKorf Aug 12, 2024
0d6dd40
wip
JKorf Aug 13, 2024
ca16762
wip
JKorf Aug 14, 2024
9ae9045
wip
JKorf Aug 14, 2024
4c18a53
wip
JKorf Aug 15, 2024
bf6e430
wip
JKorf Aug 15, 2024
067ca01
wip
JKorf Aug 15, 2024
b52410b
wip
JKorf Aug 16, 2024
5a613b1
wip
JKorf Aug 18, 2024
c30dc3d
Merge branch 'main' into feature/shared
JKorf Aug 19, 2024
dc89ad4
wip
JKorf Aug 20, 2024
04d15bc
wip
JKorf Aug 22, 2024
d37c69a
wip
JKorf Aug 25, 2024
61e4fde
wip
JKorf Aug 25, 2024
6437dca
wip
JKorf Aug 28, 2024
2d23dde
wip
JKorf Sep 1, 2024
5546ecd
Merge branch 'main' into feature/shared
JKorf Sep 2, 2024
8a49adc
wip
JKorf Sep 2, 2024
0f16878
wip
JKorf Sep 3, 2024
0964aeb
wip
JKorf Sep 4, 2024
6b263fa
wip
JKorf Sep 4, 2024
9eb8066
wip
JKorf Sep 4, 2024
0d8936e
wip
JKorf Sep 5, 2024
a63ce12
wip
JKorf Sep 5, 2024
8209584
wip
JKorf Sep 6, 2024
92ea61a
wip
JKorf Sep 9, 2024
5b38d75
wip
JKorf Sep 10, 2024
b9a184f
wip
JKorf Sep 10, 2024
ab2d0a3
wip
JKorf Sep 10, 2024
dd54dbb
wip
JKorf Sep 12, 2024
37b59f8
wip
JKorf Sep 12, 2024
11121d2
wip
JKorf Sep 13, 2024
172118b
wip
JKorf Sep 17, 2024
f288234
wip
JKorf Sep 18, 2024
6d80a04
wip
JKorf Sep 19, 2024
6a7bec2
wip
JKorf Sep 20, 2024
a061c54
wip
JKorf Sep 22, 2024
031491e
wip
JKorf Sep 23, 2024
24c31b0
wip
JKorf Sep 23, 2024
a9d6f6b
wip
JKorf Sep 24, 2024
a63041a
wip
JKorf Sep 25, 2024
4512b1c
wip
JKorf Sep 25, 2024
93417d7
wip
JKorf Sep 25, 2024
ea86f74
wip
JKorf Sep 26, 2024
ec6066c
wip
JKorf Sep 27, 2024
f6e4b9b
Update Bybit.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
4 changes: 2 additions & 2 deletions ByBit.Net/Bybit.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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 @@ -52,6 +52,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.11.0" />
<PackageReference Include="CryptoExchange.Net" Version="8.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -58,7 +59,7 @@ internal BybitRestClientCopyTradingApi(ILogger logger, HttpClient? httpClient, B
#endregion

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -69,7 +70,7 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
=> new BybitAuthenticationProvider(credentials);

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <summary>
/// Get url for an endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Sockets;
using CryptoExchange.Net.SharedApis;
using CryptoExchange.Net.Sockets;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
Expand Down Expand Up @@ -43,7 +44,7 @@ internal BybitSocketClientDerivativesPublicApi(ILogger log, BybitSocketOptions o
}

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
public override string? GetListenerIdentifier(IMessageAccessor message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public async Task<WebCallResult> SetRiskLimitAsync(string symbol, long riskId, P
#region SetTradeModeAsync

/// <inheritdoc />
public async Task<WebCallResult> SetTradeModeAsync(string symbol, TradeMode tradeMode, decimal buyLeverage, decimal sellLeverage, long? receiveWindow = null, CancellationToken ct = default)
public async Task<WebCallResult> SetTradeModeAsync(string symbol, Bybit.Net.Enums.TradeMode tradeMode, decimal buyLeverage, decimal sellLeverage, long? receiveWindow = null, CancellationToken ct = default)
{
var parameters = new Dictionary<string, object>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Sockets;
using CryptoExchange.Net.SharedApis;
using CryptoExchange.Net.Sockets;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -39,7 +40,7 @@ internal BybitSocketClientContractApi(ILogger log, BybitSocketOptions options)
}

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Objects.Sockets;
using CryptoExchange.Net.SharedApis;
using CryptoExchange.Net.Sockets;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
Expand All @@ -41,7 +42,7 @@ internal BybitSocketClientUnifiedMarginApi(ILogger log, BybitSocketOptions optio
}

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
Expand Down
3 changes: 2 additions & 1 deletion ByBit.Net/Clients/SpotApi/v3/BybitRestClientSpotApiV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using CryptoExchange.Net.CommonObjects;
using CryptoExchange.Net.Interfaces.CommonClients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.SharedApis;
using Microsoft.Extensions.Logging;

namespace Bybit.Net.Clients.SpotApi.v3
Expand Down Expand Up @@ -44,7 +45,7 @@ internal BybitRestClientSpotApiV3(ILogger logger, HttpClient? httpClient, BybitR
#endregion

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

#region Common interface

Expand Down
3 changes: 2 additions & 1 deletion ByBit.Net/Clients/SpotApi/v3/BybitSocketClientSpotApiV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.SharedApis;

namespace Bybit.Net.Clients.SpotApi.v3
{
Expand All @@ -41,7 +42,7 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
=> new BybitAuthenticationProvider(credentials);

/// <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) => baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

/// <inheritdoc />
public override string? GetListenerIdentifier(IMessageAccessor message)
Expand Down
26 changes: 23 additions & 3 deletions ByBit.Net/Clients/V5/BybitRestClientApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using CryptoExchange.Net;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Objects;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -17,11 +16,13 @@
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Interfaces;
using Bybit.Net.Interfaces.Clients;
using CryptoExchange.Net.SharedApis;

namespace Bybit.Net.Clients.V5
{
/// <inheritdoc cref="IBybitRestClientApi"/>
internal class BybitRestClientApi : RestApiClient, IBybitRestClientApi, ISpotClient
internal partial class BybitRestClientApi : RestApiClient, IBybitRestClientApi, ISpotClient
{
internal TimeSyncState _timeSyncState = new TimeSyncState("Bybit V5 API");

Expand All @@ -32,6 +33,7 @@ internal class BybitRestClientApi : RestApiClient, IBybitRestClientApi, ISpotCli

/// <inheritdoc />
public ISpotClient CommonSpotClient => this;
public IBybitRestClientApiShared SharedClient => this;

/// <summary>
/// Options
Expand Down Expand Up @@ -77,7 +79,25 @@ protected override AuthenticationProvider CreateAuthenticationProvider(ApiCreden
=> new BybitAuthenticationProvider(credentials);

/// <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)
{
if (tradingMode == TradingMode.Spot)
return baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();

if (tradingMode.IsLinear()) {
if (tradingMode.IsPerpetual())
{
if (quoteAsset == "USDC")
return baseAsset + "PERP";

return baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant();
}

return baseAsset.ToUpperInvariant() + "-" + deliverTime!.Value.ToString("ddMMMyy").ToUpperInvariant();
}

return baseAsset.ToUpperInvariant() + quoteAsset.ToUpperInvariant() + (deliverTime == null ? string.Empty : (ExchangeHelpers.GetDeliveryMonthSymbol(deliverTime.Value) + deliverTime.Value.ToString("yy")));
}

/// <summary>
/// Get url for an endpoint
Expand Down
2 changes: 1 addition & 1 deletion ByBit.Net/Clients/V5/BybitRestClientApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<WebCallResult> SetMultipleCollateralAssetsAsync(
public async Task<WebCallResult> SwitchCrossIsolatedMarginAsync(
Category category,
string symbol,
TradeMode tradeMode,
Enums.TradeMode tradeMode,
decimal buyLeverage,
decimal sellLeverage,
CancellationToken ct = default)
Expand Down
Loading
Loading