Skip to content

Commit

Permalink
Update Binance Futures account & balance API to v2 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored Sep 18, 2023
1 parent c00cc44 commit 08bcb21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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");
}
}
}

0 comments on commit 08bcb21

Please sign in to comment.