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.
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)
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.