How to fetch Futures Cumulative Profit & Loss via API?

Is there a way to fetch Futures Cumulative PnL via API?

Checked the API documentation and couldn’t find anything.

Tried calculating and the accurate result isn’t coming.

Talking about the results on - https://www.binance.com/en/my/wallet/futures/balance/analysis

(PnL Analysis)

Hi. Hope this endpoint includes all the information you want.
GET /fapi/v2/account. https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data

No it doesn’t have the cumulative PnL.

Cumulative Pnl is calculated in the PnL analysis of the futures.

So far there is no specific API providing this info. If you really want cumulated pnl, one approach is to get the income history and calculate it from your end. https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data

I’ve tried this API to get the income, the document states that without passing in the stateTime and endTime, the recent 7-day data will be returned, is it the maximum data we can get, if I want to get more than that, i.e 1 month, 3 months… what should I do? if Binance does support?

@fuatto You are required to paginate the response using the startTime and endTime parameters.

  1. Start off by calling the endpoint with endTime = current time and startTime = endTime - 7 days.
    1a. If the endpoint returns no records or number of records is less than the limit, repeat step 1 with new endTime = old startTime and new startTime = new endTime - 7 days.
    1b. If the endpoint returns number of records equal to the limit, repeat step 1 with new endTime = oldest record’s timestamp and startTime = new endTime - 7 days.

Perform the above till startTime reaches the start of the desirable time window. (Ex. 3 months)

1 Like

it’s very instructive, thank you @tantialex

1 Like

I’ve got another question on how exactly should I calculate the cumulative PNL to reach the closest result to results on page /balance/analysis with the outputs received from the income APIs/ streamed data?
(e.g there are some incomeType such as "TRANSFER", "WELCOME_BONUS", "REALIZED_PNL", "FUNDING_FEE", "COMMISSION" and for now I would sum up all incomes with type REALIZED_PNL and subtract it to all incomes with type “FUNDING_FEE” - any further types to be noticed?)

We cannot provide an answer to that question as it is outside the scope of this forum. I suggest trying different combinations and comparing with the UI until you are satisfied with the result.

Yeah, seems like trying all combinations is the best choice.
Thanks again, @tantialex