-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d29b077
commit ce63ef6
Showing
7 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Binance.Net/Clients/GeneralApi/BinanceRestClientGeneralApiCopyTrading.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Binance.Net.Interfaces.Clients.GeneralApi; | ||
using Binance.Net.Objects.Models; | ||
using Binance.Net.Objects.Models.Spot.CopyTrading; | ||
|
||
namespace Binance.Net.Clients.GeneralApi | ||
{ | ||
internal class BinanceRestClientGeneralApiCopyTrading : IBinanceRestClientGeneralApiCopyTrading | ||
{ | ||
private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); | ||
|
||
private readonly BinanceRestClientGeneralApi _baseClient; | ||
|
||
internal BinanceRestClientGeneralApiCopyTrading(BinanceRestClientGeneralApi baseClient) | ||
{ | ||
_baseClient = baseClient; | ||
} | ||
|
||
#region Get User Status | ||
|
||
/// <inheritdoc /> | ||
public async Task<WebCallResult<BinanceCopyTradingUserStatus>> GetUserStatusAsync(long? receiveWindow = null, CancellationToken ct = default) | ||
{ | ||
var parameters = new ParameterCollection(); | ||
parameters.AddOptionalString("recvWindow", receiveWindow ?? (long)_baseClient.ClientOptions.ReceiveWindow.TotalMilliseconds); | ||
|
||
var request = _definitions.GetOrCreate(HttpMethod.Get, "sapi/v1/copyTrading/futures/userStatus", BinanceExchange.RateLimiter.SpotRestUid, 20, true); | ||
var data = await _baseClient.SendAsync<BinanceResult<BinanceCopyTradingUserStatus>>(request, parameters, ct).ConfigureAwait(false); | ||
|
||
return data.As(data.Data.Data); | ||
} | ||
|
||
#endregion | ||
|
||
#region Get Lead Symbol | ||
|
||
/// <inheritdoc /> | ||
public async Task<WebCallResult<IEnumerable<BinanceCopyTradingLeadSymbol>>> GetLeadSymbolAsync(long? receiveWindow = null, CancellationToken ct = default) | ||
{ | ||
var parameters = new ParameterCollection(); | ||
parameters.AddOptionalString("recvWindow", receiveWindow ?? (long)_baseClient.ClientOptions.ReceiveWindow.TotalMilliseconds); | ||
|
||
var request = _definitions.GetOrCreate(HttpMethod.Get, "sapi/v1/copyTrading/futures/leadSymbol", BinanceExchange.RateLimiter.SpotRestUid, 20, true); | ||
var data = await _baseClient.SendAsync<BinanceResult<IEnumerable<BinanceCopyTradingLeadSymbol>>>(request, parameters, ct).ConfigureAwait(false); | ||
|
||
return data.As(data.Data.Data); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Binance.Net/Interfaces/Clients/GeneralApi/IBinanceRestClientGeneralApiCopyTrading.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Binance.Net.Objects.Internal; | ||
using Binance.Net.Objects.Models.Spot.CopyTrading; | ||
|
||
namespace Binance.Net.Interfaces.Clients.GeneralApi | ||
{ | ||
/// <summary> | ||
/// Binance copy trading endpoints | ||
/// </summary> | ||
public interface IBinanceRestClientGeneralApiCopyTrading | ||
{ | ||
/// <summary> | ||
/// Get Futures Lead Trader Status | ||
/// <para><a href="https://binance-docs.github.io/apidocs/spot/en/#copy-trading-endpoints" /></para> | ||
/// </summary> | ||
/// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> | ||
/// <param name="ct">Cancellation token</param> | ||
/// <returns></returns> | ||
Task<WebCallResult<BinanceCopyTradingUserStatus>> GetUserStatusAsync(long? receiveWindow = null, CancellationToken ct = default); | ||
|
||
|
||
/// <summary> | ||
/// Get Futures Lead Trading Symbol Whitelist | ||
/// <para><a href="https://binance-docs.github.io/apidocs/spot/en/#get-futures-lead-trading-symbol-whitelist-user_data" /></para> | ||
/// </summary> | ||
/// <param name="receiveWindow">The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request</param> | ||
/// <param name="ct">Cancellation token</param> | ||
/// <returns></returns> | ||
Task<WebCallResult<IEnumerable<BinanceCopyTradingLeadSymbol>>> GetLeadSymbolAsync(long? receiveWindow = null, CancellationToken ct = default); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Binance.Net/Objects/Models/Spot/CopyTrading/BinanceCopyTradingLeadSymbol.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Binance.Net.Objects.Models.Spot.CopyTrading | ||
{ | ||
/// <summary> | ||
/// Copy trading lead symbol | ||
/// </summary> | ||
public record BinanceCopyTradingLeadSymbol | ||
{ | ||
/// <summary> | ||
/// Symbol | ||
/// </summary> | ||
[JsonPropertyName("symbol")] | ||
public string Symbol { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Base asset | ||
/// </summary> | ||
[JsonPropertyName("baseAsset")] | ||
public string BaseAsset { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Quote asset | ||
/// </summary> | ||
[JsonPropertyName("quoteAsset")] | ||
public string QuoteAsset { get; set; } = string.Empty; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Binance.Net/Objects/Models/Spot/CopyTrading/BinanceCopyTradingUserStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Binance.Net.Objects.Models.Spot.CopyTrading | ||
{ | ||
/// <summary> | ||
/// Copy trading user status | ||
/// </summary> | ||
public record BinanceCopyTradingUserStatus | ||
{ | ||
/// <summary> | ||
/// Is lead trader | ||
/// </summary> | ||
[JsonPropertyName("isLeadTrader")] | ||
public bool IsLeadTrader { get; set; } | ||
/// <summary> | ||
/// Time | ||
/// </summary> | ||
[JsonPropertyName("time")] | ||
public long Timestamp { get; set; } | ||
} | ||
} |