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

Update Binance Futures account & balance API to v2 #27

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions QuantConnect.BinanceBrokerage/BinanceBaseRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,19 @@ public virtual List<Holding> GetAccountHoldings()
/// Gets the total account cash balance for specified account type
/// </summary>
/// <returns></returns>
public BalanceEntry[] GetCashBalance()
public virtual BalanceEntry[] GetCashBalance()
{
return GetCashBalance(ApiPrefix);
}

/// <summary>
/// Gets the total account cash balance for specified account type
/// </summary>
/// <returns></returns>
protected BalanceEntry[] GetCashBalance(string apiPrefix)
{
var queryString = $"timestamp={GetNonce()}";
var endpoint = $"{ApiPrefix}/account?{queryString}&signature={AuthenticationToken(queryString)}";
var endpoint = $"{apiPrefix}/account?{queryString}&signature={AuthenticationToken(queryString)}";
var request = new RestRequest(endpoint, Method.GET);
request.AddHeader(KeyHeader, ApiKey);

Expand Down
7 changes: 6 additions & 1 deletion QuantConnect.BinanceBrokerage/BinanceFuturesRestApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ string restApiUrl
public override List<Holding> GetAccountHoldings()
{
var queryString = $"timestamp={GetNonce()}";
var endpoint = $"{ApiPrefix}/account?{queryString}&signature={AuthenticationToken(queryString)}";
var endpoint = $"/fapi/v2/account?{queryString}&signature={AuthenticationToken(queryString)}";
var request = new RestRequest(endpoint, Method.GET);
request.AddHeader(KeyHeader, ApiKey);

Expand All @@ -97,5 +97,10 @@ public override List<Holding> GetAccountHoldings()
})
.ToList();
}

public override BalanceEntry[] GetCashBalance()
{
return GetCashBalance("/fapi/v2");
}
}
}
Loading