Skip to main content

Get Profit Loss Report

Request

curl --location 'https://api.upstox.com/v2/trade/profit-loss/data?from_date=05-11-2023&to_date=19-12-2023&segment=EQ&financial_year=2324&page_number=1&page_size=4' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'

Additional samples in various languages are available in the Sample Code section on this page.

Query Parameters

NameRequiredTypeDescription
from_datefalsestringDate from which data needs to be fetched. from_date and to_date should fall under the same financial year as mentioned in financial_year attribute. Date in dd-mm-yyyy format
to_datefalsestringDate till which data needs to be fetched. from_date and to_date should fall under the same financial year as mentioned in financial_year attribute. Date in dd-mm-yyyy format
segmenttruestringSegment for which data is requested can be from the following options EQ - Equity, FO - Futures and Options, COM - Commodity, CD - Currency Derivatives
financial_yeartruestringFinancial year for which data has been requested. Concatenation of last 2 digits of from year and to year Sample:for 2021-2022, financial_year will be 2122. For the regex pattern applicable to this field, see the Field Pattern Appendix.
page_numbertrueinteger (int32)Page Number, the pages are starting from 1
page_sizetrueinteger (int32)Page size for pagination. The maximum page size value is obtained from P and L report metadata API.
Responses

Response Body


Sample Code

import requests

url = 'https://api.upstox.com/v2/trade/profit-loss/data'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}

params = {
'from_date': '05-11-2023',
'to_date': '19-12-2023',
'segment': 'EQ',
'financial_year': '2324',
'page_number': '1',
'page_size': '4'
}

response = requests.get(url, headers=headers, params=params)

print(response.status_code)
print(response.json())

Get profit loss report for futures and options segment

import requests

url = 'https://api.upstox.com/v2/trade/profit-loss/data'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}

params = {
'from_date': '05-11-2023',
'to_date': '19-12-2023',
'segment': 'FO',
'financial_year': '2324',
'page_number': '1',
'page_size': '4'
}

response = requests.get(url, headers=headers, params=params)

print(response.status_code)
print(response.json())
Loading...