diff --git a/README.md b/README.md
index d1d084c..911d826 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
## Introduction
-The official Python client for communicating with the Upstox API.
+The official Python client for communicating with the Upstox API.
Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.
diff --git a/examples/README.md b/examples/README.md
index 32cad1e..ec93e8b 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,15 +1,45 @@
-# Python Sample Implementation
+# Upstox Developer API – Example Code
-## Websocket
+This folder contains **ready-to-use Python samples** for the [Upstox API](https://upstox.com/developer/api-documentation/open-api). Each example shows how to call the API using the official [Upstox Python SDK](https://pypi.org/project/upstox-python-sdk/) (`upstox_client`).
-### Market stream feed
+## Why use these samples?
-Python script to connect to the Upstox Websocket API for streaming live market data. It fetches market data for a list of instrument keys and decodes the incoming protobuf data to a JSON format.
+- **Quick start** — Copy-paste examples for common flows (login, orders, market data, portfolio).
+- **Correct usage** — Request/response patterns, error handling, and API version usage as recommended by Upstox.
+- **Reference** — See how to structure `PlaceOrderRequest`, historical data params, and other API payloads.
-[Market updates using Upstox's websocket](websocket/market_data/v3)
+Use these samples to build trading apps, dashboards, or integrations without guessing request shapes or SDK usage.
-### Porfolio stream feed
+## Prerequisites
-Python scripts to connect to the Upstox WebSocket API for streaming live order updates. It fetches the order updates and prints them to the console.
+- **Python** 2.7 or 3.4+
+- **SDK**: `pip install upstox-python-sdk`
+- **Upstox developer account** and API credentials (client ID, client secret, redirect URI).
+- **Access token** for authenticated APIs (obtain via [Login API](login/) samples).
-[Order updates using Upstox's websocket](websocket/order_updates/)
\ No newline at end of file
+For full setup, sandbox mode, and auth flow, see the main [Upstox Python SDK README](../README.md) in the repo root.
+
+## Folder structure
+
+Samples are grouped by API area. Each `.md` file contains one or more Python snippets you can run after replacing placeholders like `{your_access_token}` and `{your_client_id}`.
+
+| Folder | Description |
+|--------|-------------|
+| [**login/**](login/) | Authentication: get token from auth code, access-token request, logout. |
+| [**user/**](user/) | User profile, fund and margin details. |
+| [**orders/**](orders/) | Order lifecycle: place (single/multi, v2 & v3), modify, cancel, order book, order details, order history, trades, historical trades, exit all positions. |
+| [**portfolio/**](portfolio/) | Positions, holdings, MTF positions, convert positions. |
+| [**market-quote/**](market-quote/) | LTP, full market quotes, OHLC (v2 & v3), option Greeks. |
+| [**historical-data/**](historical-data/) | Historical and intraday candle data (v2 & v3). |
+| [**option-chain/**](option-chain/) | Option contracts, put-call option chain. |
+| [**expired-instruments/**](expired-instruments/) | Expiries, expired future/option contracts, expired historical candle data. |
+| [**market-information/**](market-information/) | Exchange status, market timings, market holidays. |
+| [**gtt-orders/**](gtt-orders/) | Place, modify, cancel, and get details for GTT (Good Till Triggered) orders. |
+| [**margins/**](margins/) | Margin details. |
+| [**charges/**](charges/) | Brokerage details. |
+| [**trade-profit-and-loss/**](trade-profit-and-loss/) | P&L report, report metadata, trade charges. |
+
+## Documentation
+
+- [Upstox API Documentation](https://upstox.com/developer/api-documentation)
+- [Upstox Python SDK (PyPI)](https://pypi.org/project/upstox-python-sdk/)
diff --git a/examples/charges/README.md b/examples/charges/README.md
new file mode 100644
index 0000000..70a92ae
--- /dev/null
+++ b/examples/charges/README.md
@@ -0,0 +1,10 @@
+# Charges – Example code
+
+Links to all charges-related examples in the `code/` folder.
+
+## 1. Brokerage Details
+
+- 1.1 [Get brokerage details for equity delivery orders](code/brokerage-details.md#get-brokerage-details-for-equity-delivery-orders)
+- 1.2 [Get brokerage details for equity intraday orders](code/brokerage-details.md#get-brokerage-details-for-equity-intraday-orders)
+- 1.3 [Get brokerage details for equity futures and options delivery orders](code/brokerage-details.md#get-brokerage-details-for-equity-futures-and-options-delivery-orders)
+- 1.4 [Get brokerage details for equity futures and options intraday orders](code/brokerage-details.md#get-brokerage-details-for-equity-futures-and-options-intraday-orders)
diff --git a/examples/charges/code/brokerage-details.md b/examples/charges/code/brokerage-details.md
new file mode 100644
index 0000000..102347f
--- /dev/null
+++ b/examples/charges/code/brokerage-details.md
@@ -0,0 +1,102 @@
+## Get brokerage details for equity delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instrument_token = 'NSE_EQ|INE669E01016'
+quantity = 10
+product = 'D'
+transaction_type = 'BUY'
+price = 13.4
+
+try:
+ # Brokerage details
+ api_response = api_instance.get_brokerage(instrument_token, quantity, product, transaction_type, price, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+
+```
+
+## Get brokerage details for equity intraday orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instrument_token = 'NSE_EQ|INE669E01016'
+quantity = 10
+product = 'I'
+transaction_type = 'BUY'
+price = 13.4
+
+try:
+ # Brokerage details
+ api_response = api_instance.get_brokerage(instrument_token, quantity, product, transaction_type, price, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+
+```
+
+## Get brokerage details for equity futures and options delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instrument_token = 'NSE_FO|35271'
+quantity = 10
+product = 'D'
+transaction_type = 'BUY'
+price = 1333.4
+
+try:
+ # Brokerage details
+ api_response = api_instance.get_brokerage(instrument_token, quantity, product, transaction_type, price, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+
+```
+
+## Get brokerage details for equity futures and options intraday orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instrument_token = 'NSE_FO|35271'
+quantity = 10
+product = 'I'
+transaction_type = 'BUY'
+price = 1333.4
+
+try:
+ # Brokerage details
+ api_response = api_instance.get_brokerage(instrument_token, quantity, product, transaction_type, price, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+```
diff --git a/examples/expired-instruments/README.md b/examples/expired-instruments/README.md
new file mode 100644
index 0000000..4860d9a
--- /dev/null
+++ b/examples/expired-instruments/README.md
@@ -0,0 +1,19 @@
+# Expired Instruments – Example code
+
+Links to all expired-instruments-related examples in the `code/` folder.
+
+## 1. Get Expiries
+
+- 1.1 [Get Expiries for given instrument](code/get-expiries.md#get-expiries-for-given-instrument)
+
+## 2. Get Expired Option Contracts
+
+- 2.1 [Get Expired Option Contracts for given instrument with expiry date](code/get-expired-option-contracts.md#get-expired-option-contracts-for-given-instrument-with-expiry-date)
+
+## 3. Get Expired Future Contracts
+
+- 3.1 [Get Expired Future Contracts for given instrument with expiry date](code/get-expired-future-contracts.md#get-expired-future-contracts-for-given-instrument-with-expiry-date)
+
+## 4. Get Expired Historical Candle Data
+
+- 4.1 [Get Historical Candle Data for Expired Instruments](code/get-expired-historical-candle-data.md#get-historical-candle-data-for-expired-instruments)
diff --git a/examples/expired-instruments/code/get-expired-future-contracts.md b/examples/expired-instruments/code/get-expired-future-contracts.md
new file mode 100644
index 0000000..1a99521
--- /dev/null
+++ b/examples/expired-instruments/code/get-expired-future-contracts.md
@@ -0,0 +1,15 @@
+## Get Expired Future Contracts for given instrument with expiry date
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+apiInstance = upstox_client.ExpiredInstrumentApi(upstox_client.ApiClient(configuration))
+try:
+ response = apiInstance.get_expired_future_contracts("NSE_INDEX|Nifty 50", "2024-11-27")
+ print(response)
+except ApiException as e:
+ print("Exception when calling expired instrument api: %s\n" % e)
+```
diff --git a/examples/expired-instruments/code/get-expired-historical-candle-data.md b/examples/expired-instruments/code/get-expired-historical-candle-data.md
new file mode 100644
index 0000000..fbe48cf
--- /dev/null
+++ b/examples/expired-instruments/code/get-expired-historical-candle-data.md
@@ -0,0 +1,15 @@
+## Get Historical Candle Data for Expired Instruments
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+apiInstance = upstox_client.ExpiredInstrumentApi(upstox_client.ApiClient(configuration))
+try:
+ response = apiInstance.get_expired_historical_candle_data("NSE_FO|54452|24-04-2025", "1minute", "2025-04-24", "2025-04-24")
+ print(response)
+except ApiException as e:
+ print("Exception when calling expired instrument api: %s\n" % e)
+```
diff --git a/examples/expired-instruments/code/get-expired-option-contracts.md b/examples/expired-instruments/code/get-expired-option-contracts.md
new file mode 100644
index 0000000..971fb31
--- /dev/null
+++ b/examples/expired-instruments/code/get-expired-option-contracts.md
@@ -0,0 +1,15 @@
+## Get Expired Option Contracts for given instrument with expiry date
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+apiInstance = upstox_client.ExpiredInstrumentApi(upstox_client.ApiClient(configuration))
+try:
+ response = apiInstance.get_expired_option_contracts("NSE_INDEX|Nifty 50", "2025-04-30")
+ print(response)
+except ApiException as e:
+ print("Exception when calling expired instrument api: %s\n" % e)
+```
diff --git a/examples/expired-instruments/code/get-expiries.md b/examples/expired-instruments/code/get-expiries.md
new file mode 100644
index 0000000..c3637c3
--- /dev/null
+++ b/examples/expired-instruments/code/get-expiries.md
@@ -0,0 +1,15 @@
+## Get Expiries for given instrument
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+apiInstance = upstox_client.ExpiredInstrumentApi(upstox_client.ApiClient(configuration))
+try:
+ response = apiInstance.get_expiries("NSE_INDEX|Nifty 50")
+ print(response)
+except ApiException as e:
+ print("Exception when calling expired instrument v3 api: %s\n" % e)
+```
diff --git a/examples/gtt-orders/README.md b/examples/gtt-orders/README.md
new file mode 100644
index 0000000..32de840
--- /dev/null
+++ b/examples/gtt-orders/README.md
@@ -0,0 +1,21 @@
+# GTT Orders – Example code
+
+Links to all gtt-orders-related examples in the `code/` folder.
+
+## 1. Place GTT Order
+
+- 1.1 [Place Single Leg GTT Order](code/place-gtt-order.md#place-single-leg-gtt-order)
+- 1.2 [Place Multiple Leg GTT Order](code/place-gtt-order.md#place-multiple-leg-gtt-order)
+
+## 2. Modify GTT Order
+
+- 2.1 [Modify Single Leg GTT Order](code/modify-gtt-order.md#modify-single-leg-gtt-order)
+- 2.2 [Modify Multiple Leg GTT Order](code/modify-gtt-order.md#modify-multiple-leg-gtt-order)
+
+## 3. Cancel GTT Order
+
+- 3.1 [Cancel GTT Order](code/cancel-gtt-order.md#cancel-gtt-order)
+
+## 4. Get GTT Order Details
+
+- 4.1 [Get GTT Order Details](code/get-gtt-order-details.md#get-gtt-order-details)
diff --git a/examples/gtt-orders/code/cancel-gtt-order.md b/examples/gtt-orders/code/cancel-gtt-order.md
new file mode 100644
index 0000000..8231d96
--- /dev/null
+++ b/examples/gtt-orders/code/cancel-gtt-order.md
@@ -0,0 +1,18 @@
+## Cancel GTT Order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+body = upstox_client.GttCancelOrderRequest(gtt_order_id="GTT-C250303008840")
+
+try:
+ api_response = api_instance.cancel_gtt_order(body=body)
+ print("GTT order canceled:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->cancel_gtt_order: %s\n" % e)
+```
diff --git a/examples/gtt-orders/code/get-gtt-order-details.md b/examples/gtt-orders/code/get-gtt-order-details.md
new file mode 100644
index 0000000..37d413e
--- /dev/null
+++ b/examples/gtt-orders/code/get-gtt-order-details.md
@@ -0,0 +1,16 @@
+## Get GTT Order Details
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_gtt_order_details(gtt_order_id="GTT-C25030300128840")
+ print("GTT order details:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get_gtt_order_details: %s\n" % e)
+```
diff --git a/examples/gtt-orders/code/modify-gtt-order.md b/examples/gtt-orders/code/modify-gtt-order.md
new file mode 100644
index 0000000..8f16681
--- /dev/null
+++ b/examples/gtt-orders/code/modify-gtt-order.md
@@ -0,0 +1,55 @@
+## Modify Single Leg GTT Order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="ABOVE", trigger_price=7.3)
+rules = [entry_rule]
+
+body = upstox_client.GttModifyOrderRequest(
+ type="SINGLE",
+ gtt_order_id="GTT-C25270200137952",
+ rules=rules,
+ quantity=1
+)
+
+try:
+ api_response = api_instance.modify_gtt_order(body=body)
+ print("GTT order response:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->modify_gtt_order: %s\n" % e)
+```
+
+## Modify Multiple Leg GTT Order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="ABOVE", trigger_price=7.3)
+target_rule = upstox_client.GttRule(strategy="TARGET", trigger_type="IMMEDIATE", trigger_price=7.64)
+stoploss_rule = upstox_client.GttRule(strategy="STOPLOSS", trigger_type="IMMEDIATE", trigger_price=7.1)
+rules = [entry_rule, target_rule, stoploss_rule]
+
+body = upstox_client.GttModifyOrderRequest(
+ type="MULTIPLE",
+ gtt_order_id="GTT-C25280200137522",
+ rules=rules,
+ quantity=1
+)
+
+try:
+ api_response = api_instance.modify_gtt_order(body=body)
+ print("GTT order response:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->modify_gtt_order: %s\n" % e)
+```
diff --git a/examples/gtt-orders/code/place-gtt-order.md b/examples/gtt-orders/code/place-gtt-order.md
new file mode 100644
index 0000000..2e40cbf
--- /dev/null
+++ b/examples/gtt-orders/code/place-gtt-order.md
@@ -0,0 +1,59 @@
+## Place Single Leg GTT Order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="ABOVE", trigger_price=7)
+rules = [entry_rule]
+
+body = upstox_client.GttPlaceOrderRequest(
+ type="SINGLE",
+ instrument_token="NSE_EQ|INE669E01016",
+ product="D",
+ quantity=1,
+ rules=rules,
+ transaction_type="BUY"
+)
+
+try:
+ api_response = api_instance.place_gtt_order(body=body)
+ print("GTT order response:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->gtt_place_order: %s\n" % e)
+```
+
+## Place Multiple Leg GTT Order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="ABOVE", trigger_price=7)
+target_rule = upstox_client.GttRule(strategy="TARGET", trigger_type="IMMEDIATE", trigger_price=9)
+stoploss_rule = upstox_client.GttRule(strategy="STOPLOSS", trigger_type="IMMEDIATE", trigger_price=5)
+rules = [entry_rule, target_rule, stoploss_rule]
+
+body = upstox_client.GttPlaceOrderRequest(
+ type="MULTIPLE",
+ instrument_token="NSE_EQ|INE669E01016",
+ product="D",
+ quantity=1,
+ rules=rules,
+ transaction_type="BUY"
+)
+
+try:
+ api_response = api_instance.place_gtt_order(body=body)
+ print("GTT order response:", api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->gtt_place_order: %s\n" % e)
+```
diff --git a/examples/historical-data/README.md b/examples/historical-data/README.md
new file mode 100644
index 0000000..263579a
--- /dev/null
+++ b/examples/historical-data/README.md
@@ -0,0 +1,43 @@
+# Historical Data – Example code
+
+Links to all historical-data-related examples in the `code/` folder.
+
+## 1. Historical Candle Data V3
+
+- 1.1 [Get data with a 1-minute interval](code/historical-candle-data-v3.md#get-data-with-a-1-minute-interval)
+- 1.2 [Get data with a 3-minute interval](code/historical-candle-data-v3.md#get-data-with-a-3-minute-interval)
+- 1.3 [Get data with a 15-minute interval](code/historical-candle-data-v3.md#get-data-with-a-15-minute-interval)
+- 1.4 [Get data with a 1-hour interval](code/historical-candle-data-v3.md#get-data-with-a-1-hour-interval)
+- 1.5 [Get data with a 4-hour interval](code/historical-candle-data-v3.md#get-data-with-a-4-hour-interval)
+- 1.6 [Get data with a daily interval](code/historical-candle-data-v3.md#get-data-with-a-daily-interval)
+- 1.7 [Get data with a weekly interval](code/historical-candle-data-v3.md#get-data-with-a-weekly-interval)
+- 1.8 [Get data with a monthly interval](code/historical-candle-data-v3.md#get-data-with-a-monthly-interval)
+
+## 2. Intraday Candle Data V3
+
+- 2.1 [Get data with a 1-minute interval](code/intra-day-candle-data-v3.md#get-data-with-a-1-minute-interval)
+- 2.2 [Get data with a 3-minute interval](code/intra-day-candle-data-v3.md#get-data-with-a-3-minute-interval)
+- 2.3 [Get data with a 5-minute interval](code/intra-day-candle-data-v3.md#get-data-with-a-5-minute-interval)
+- 2.4 [Get data with a 15-minute interval](code/intra-day-candle-data-v3.md#get-data-with-a-15-minute-interval)
+- 2.5 [Get data with a 30-minute interval](code/intra-day-candle-data-v3.md#get-data-with-a-30-minute-interval)
+- 2.6 [Get data with a 1-hour interval](code/intra-day-candle-data-v3.md#get-data-with-a-1-hour-interval)
+- 2.7 [Get data with a 2-hour interval](code/intra-day-candle-data-v3.md#get-data-with-a-2-hour-interval)
+- 2.8 [Get current day data](code/intra-day-candle-data-v3.md#get-current-day-data)
+
+## 3. Historical Candle Data
+
+- 3.1 [Get historical candle data with a 1-minute interval](code/historical-candle-data.md#get-historical-candle-data-with-a-1-minute-interval)
+- 3.2 [Get data with a 30-minute interval](code/historical-candle-data.md#get-data-with-a-30-minute-interval)
+- 3.3 [Get data with a daily interval](code/historical-candle-data.md#get-data-with-a-daily-interval)
+- 3.4 [Get data with a weekly interval](code/historical-candle-data.md#get-data-with-a-weekly-interval)
+- 3.5 [Get data with a monthly interval](code/historical-candle-data.md#get-data-with-a-monthly-interval)
+- 3.6 [Get historical candle data with a 1-minute interval](code/historical-candle-data.md#get-historical-candle-data-with-a-1-minute-interval-1)
+- 3.7 [Get data with a 30-minute interval](code/historical-candle-data.md#get-data-with-a-30-minute-interval-1)
+- 3.8 [Get data with a daily interval](code/historical-candle-data.md#get-data-with-a-daily-interval-1)
+- 3.9 [Get data with a weekly interval](code/historical-candle-data.md#get-data-with-a-weekly-interval-1)
+- 3.10 [Get data with a monthly interval](code/historical-candle-data.md#get-data-with-a-monthly-interval-1)
+
+## 4. Intraday Candle Data
+
+- 4.1 [Get intraday candle data with a 1-minute interval](code/intra-day-candle-data.md#get-intraday-candle-data-with-a-1-minute-interval)
+- 4.2 [Get intraday candle data with a 30-minute interval](code/intra-day-candle-data.md#get-intraday-candle-data-with-a-30-minute-interval)
diff --git a/examples/historical-data/code/historical-candle-data-v3.md b/examples/historical-data/code/historical-candle-data-v3.md
new file mode 100644
index 0000000..954b994
--- /dev/null
+++ b/examples/historical-data/code/historical-candle-data-v3.md
@@ -0,0 +1,95 @@
+## Get data with a 1-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "minutes", "1", "2025-01-02", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a 3-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "minutes", "3", "2025-01-02", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a 15-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "minutes", "15", "2025-01-04", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a 1-hour interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "hours", "1", "2025-02-01", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a 4-hour interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "hours", "4", "2025-02-01", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a daily interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "days", "1", "2025-03-01", "2025-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a weekly interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "weeks", "1", "2025-01-01", "2024-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
+
+## Get data with a monthly interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_historical_candle_data1("NSE_EQ|INE848E01016", "months", "1", "2025-01-01", "2010-01-01")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
+```
diff --git a/examples/historical-data/code/historical-candle-data.md b/examples/historical-data/code/historical-candle-data.md
new file mode 100644
index 0000000..db98444
--- /dev/null
+++ b/examples/historical-data/code/historical-candle-data.md
@@ -0,0 +1,198 @@
+## Get historical candle data with a 1-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '1minute'
+to_date = '2023-11-13'
+from_date = '2023-11-12'
+try:
+ api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get data with a 30-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '30minute'
+to_date = '2023-11-13'
+from_date = '2023-11-12'
+try:
+ api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get data with a daily interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'day'
+to_date = '2023-11-13'
+from_date = '2023-11-12'
+try:
+ api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get data with a weekly interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'week'
+to_date = '2023-11-13'
+from_date = '2023-10-13'
+try:
+ # Historical candle data
+ api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get data with a monthly interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'month'
+to_date = '2023-11-13'
+from_date = '2022-10-13'
+try:
+ api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get historical candle data with a 1-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '1minute'
+to_date = '2023-11-13'
+try:
+ api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+
+```
+
+## Get data with a 30-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '30minute'
+to_date = '2023-11-13'
+try:
+ api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
+
+## Get data with a daily interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'day'
+to_date = '2023-11-13'
+try:
+ api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+
+```
+
+## Get data with a weekly interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'week'
+to_date = '2023-11-13'
+try:
+ api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+
+```
+
+## Get data with a monthly interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = 'month'
+to_date = '2023-11-13'
+try:
+ api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+```
diff --git a/examples/historical-data/code/intra-day-candle-data-v3.md b/examples/historical-data/code/intra-day-candle-data-v3.md
new file mode 100644
index 0000000..ded0efd
--- /dev/null
+++ b/examples/historical-data/code/intra-day-candle-data-v3.md
@@ -0,0 +1,95 @@
+## Get data with a 1-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "minutes", "1")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 3-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "minutes", "3")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 5-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "minutes", "5")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 15-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "minutes", "15")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 30-minute interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "minutes", "30")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 1-hour interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "hours", "1")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get data with a 2-hour interval
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "hours", "2")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
+
+## Get current day data
+
+```python
+import upstox_client
+apiInstance = upstox_client.HistoryV3Api()
+try:
+ response = apiInstance.get_intra_day_candle_data("NSE_EQ|INE848E01016", "days", "1")
+ print(response)
+except Exception as e:
+ print("Exception when calling HistoryV3Api->get_intra_day_candle_data: %s\n" % e)
+```
diff --git a/examples/historical-data/code/intra-day-candle-data.md b/examples/historical-data/code/intra-day-candle-data.md
new file mode 100644
index 0000000..b5cf903
--- /dev/null
+++ b/examples/historical-data/code/intra-day-candle-data.md
@@ -0,0 +1,39 @@
+## Get intraday candle data with a 1-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '1minute'
+try:
+
+ api_response = api_instance.get_intra_day_candle_data(instrument_key,interval,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+
+```
+
+## Get intraday candle data with a 30-minute interval
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_version = '2.0'
+
+api_instance = upstox_client.HistoryApi()
+instrument_key = 'NSE_EQ|INE669E01016'
+interval = '30minute'
+try:
+
+ api_response = api_instance.get_intra_day_candle_data(instrument_key,interval,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
+
+```
diff --git a/examples/login/README.md b/examples/login/README.md
new file mode 100644
index 0000000..4770a5a
--- /dev/null
+++ b/examples/login/README.md
@@ -0,0 +1,15 @@
+# Login – Example code
+
+Links to all login-related examples in the `code/` folder.
+
+## 1. Get Token
+
+- 1.1 [Get access token using auth code](code/get-token.md#get-access-token-using-auth-code)
+
+## 2. Access Token Request
+
+- 2.1 [Access token request](code/access-token-request.md#access-token-request)
+
+## 3. Logout
+
+- 3.1 [Logout Request](code/logout.md#logout-request)
diff --git a/examples/login/code/access-token-request.md b/examples/login/code/access-token-request.md
new file mode 100644
index 0000000..85c1edd
--- /dev/null
+++ b/examples/login/code/access-token-request.md
@@ -0,0 +1,17 @@
+## Access token request
+
+```python
+import upstox_client
+
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+
+api_instance = upstox_client.LoginApi(upstox_client.ApiClient(configuration))
+body = upstox_client.IndieUserTokenRequest(client_secret="****")
+try:
+ api_response = api_instance.init_token_request_for_indie_user(body,client_id="*****")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling indie token request: %s\n" % e)
+```
diff --git a/examples/login/code/get-token.md b/examples/login/code/get-token.md
new file mode 100644
index 0000000..ac6005f
--- /dev/null
+++ b/examples/login/code/get-token.md
@@ -0,0 +1,22 @@
+## Get access token using auth code
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+api_instance = upstox_client.LoginApi()
+api_version = '2.0'
+code = '{your_auth_code}'
+client_id = '{your_client_id}'
+client_secret = '{your_client_secret}'
+redirect_uri = '{your_redirect_url}'
+grant_type = 'grant_type_example'
+
+try:
+ # Get token API
+ api_response = api_instance.token(api_version, code=code, client_id=client_id, client_secret=client_secret,
+ redirect_uri=redirect_uri, grant_type=grant_type)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling LoginApi->token: %s\n" % e)
+```
diff --git a/examples/login/code/logout.md b/examples/login/code/logout.md
new file mode 100644
index 0000000..69e267d
--- /dev/null
+++ b/examples/login/code/logout.md
@@ -0,0 +1,19 @@
+## Logout Request
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.LoginApi(upstox_client.ApiClient(configuration))
+api_version = '2.0'
+
+try:
+ # Logout
+ api_response = api_instance.logout(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling LoginApi->logout: %s\n" % e)
+```
diff --git a/examples/margins/README.md b/examples/margins/README.md
new file mode 100644
index 0000000..d571df4
--- /dev/null
+++ b/examples/margins/README.md
@@ -0,0 +1,11 @@
+# Margins – Example code
+
+Links to all margins-related examples in the `code/` folder.
+
+## 1. Margin Details
+
+- 1.1 [Get margin details for equity delivery orders](code/margin-details.md#get-margin-details-for-equity-delivery-orders)
+- 1.2 [Get margin details for future delivery orders](code/margin-details.md#get-margin-details-for-future-delivery-orders)
+- 1.3 [Get margin details for option delivery orders](code/margin-details.md#get-margin-details-for-option-delivery-orders)
+- 1.4 [Get margin details for MCX delivery orders](code/margin-details.md#get-margin-details-for-mcx-delivery-orders)
+- 1.5 [Get margin details for currency delivery orders](code/margin-details.md#get-margin-details-for-currency-delivery-orders)
diff --git a/examples/margins/code/margin-details.md b/examples/margins/code/margin-details.md
new file mode 100644
index 0000000..dcdf132
--- /dev/null
+++ b/examples/margins/code/margin-details.md
@@ -0,0 +1,94 @@
+## Get margin details for equity delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instruments = [upstox_client.Instrument(instrument_key="NSE_EQ|INE528G01035",quantity=5,product="D",transaction_type="BUY")]
+margin_body = upstox_client.MarginRequest(instruments)
+try:
+ api_response = api_instance.post_margin(margin_body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling Margin API: %s\n" % e.body)
+
+```
+
+## Get margin details for future delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instruments = [upstox_client.Instrument(instrument_key="NSE_FO|35000",quantity=5,product="D",transaction_type="BUY")]
+margin_body = upstox_client.MarginRequest(instruments)
+try:
+ api_response = api_instance.post_margin(margin_body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling Margin API: %s\n" % e.body)
+
+```
+
+## Get margin details for option delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instruments = [upstox_client.Instrument(instrument_key="NSE_FO|54524",quantity=5,product="D",transaction_type="BUY")]
+margin_body = upstox_client.MarginRequest(instruments)
+try:
+ api_response = api_instance.post_margin(margin_body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling Margin API: %s\n" % e.body)
+
+```
+
+## Get margin details for MCX delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instruments = [upstox_client.Instrument(instrument_key="MCX_FO|435356",quantity=5,product="D",transaction_type="BUY")]
+margin_body = upstox_client.MarginRequest(instruments)
+try:
+ api_response = api_instance.post_margin(margin_body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling Margin API: %s\n" % e.body)
+
+```
+
+## Get margin details for currency delivery orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
+instruments = [upstox_client.Instrument(instrument_key="NCD_FO|15758",quantity=5,product="D",transaction_type="BUY")]
+margin_body = upstox_client.MarginRequest(instruments)
+try:
+ api_response = api_instance.post_margin(margin_body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling Margin API: %s\n" % e.body)
+
+```
diff --git a/examples/market-information/README.md b/examples/market-information/README.md
new file mode 100644
index 0000000..5d8c0f4
--- /dev/null
+++ b/examples/market-information/README.md
@@ -0,0 +1,16 @@
+# Market Information – Example code
+
+Links to all market-information-related examples in the `code/` folder.
+
+## 1. Market Holidays
+
+- 1.1 [Get market holidays for current year](code/market-holidays.md#get-market-holidays-for-current-year)
+- 1.2 [Get market holiday status of a date](code/market-holidays.md#get-market-holiday-status-of-a-date)
+
+## 2. Market Timings
+
+- 2.1 [Get market timings of a date](code/market-timings.md#get-market-timings-of-a-date)
+
+## 3. Exchange Status
+
+- 3.1 [Get market status for a particular exchange](code/exchange-status.md#get-market-status-for-a-particular-exchange)
diff --git a/examples/market-information/code/exchange-status.md b/examples/market-information/code/exchange-status.md
new file mode 100644
index 0000000..3fdd8e3
--- /dev/null
+++ b/examples/market-information/code/exchange-status.md
@@ -0,0 +1,16 @@
+## Get market status for a particular exchange
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_market_status("NSE")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
+```
diff --git a/examples/market-information/code/market-holidays.md b/examples/market-information/code/market-holidays.md
new file mode 100644
index 0000000..05148ce
--- /dev/null
+++ b/examples/market-information/code/market-holidays.md
@@ -0,0 +1,34 @@
+## Get market holidays for current year
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+
+api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_holidays()
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
+
+```
+
+## Get market holiday status of a date
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+
+api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_holiday("2024-01-22")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
+
+```
diff --git a/examples/market-information/code/market-timings.md b/examples/market-information/code/market-timings.md
new file mode 100644
index 0000000..a1c651b
--- /dev/null
+++ b/examples/market-information/code/market-timings.md
@@ -0,0 +1,16 @@
+## Get market timings of a date
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+
+api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_exchange_timings("2024-01-22")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
+
+```
diff --git a/examples/market-quote/README.md b/examples/market-quote/README.md
new file mode 100644
index 0000000..b4039c1
--- /dev/null
+++ b/examples/market-quote/README.md
@@ -0,0 +1,33 @@
+# Market Quote – Example code
+
+Links to all market-quote-related examples in the `code/` folder.
+
+## 1. Full Market Quotes
+
+- 1.1 [Get full market quote](code/full-market-quotes.md#get-full-market-quote)
+- 1.2 [Get full market quote for multiple instrument keys](code/full-market-quotes.md#get-full-market-quote-for-multiple-instrument-keys)
+
+## 2. OHLC Quotes V3
+
+- 2.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes)
+- 2.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes-v3.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)
+
+## 3. LTP Quotes V3
+
+- 3.1 [Get ltp (last traded price) market quotes](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes)
+- 3.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes-v3.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)
+
+## 4. Option Greek
+
+- 4.1 [Get Option Greek fields](code/option-greek.md#get-option-greek-fields)
+- 4.2 [Get Option Greek fields for multiple instruments keys](code/option-greek.md#get-option-greek-fields-for-multiple-instruments-keys)
+
+## 5. OHLC Quotes
+
+- 5.1 [Get ohlc (open, high, low, close) market quotes](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes)
+- 5.2 [Get ohlc (open, high, low, close) market quotes for multiple instrument keys](code/ohlc-quotes.md#get-ohlc-open-high-low-close-market-quotes-for-multiple-instrument-keys)
+
+## 6. LTP Quotes
+
+- 6.1 [Get ltp (last traded price) market quotes](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes)
+- 6.2 [Get ltp (last traded price) market quotes for multiple instruments keys](code/ltp-quotes.md#get-ltp-last-traded-price-market-quotes-for-multiple-instruments-keys)
diff --git a/examples/market-quote/code/full-market-quotes.md b/examples/market-quote/code/full-market-quotes.md
new file mode 100644
index 0000000..1359100
--- /dev/null
+++ b/examples/market-quote/code/full-market-quotes.md
@@ -0,0 +1,41 @@
+## Get full market quote
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_full_market_quote(symbol, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+
+```
+
+## Get full market quote for multiple instrument keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016,NSE_EQ|INE848E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_full_market_quote(symbol, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+
+```
diff --git a/examples/market-quote/code/ltp-quotes-v3.md b/examples/market-quote/code/ltp-quotes-v3.md
new file mode 100644
index 0000000..585b0a5
--- /dev/null
+++ b/examples/market-quote/code/ltp-quotes-v3.md
@@ -0,0 +1,35 @@
+## Get ltp (last traded price) market quotes
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For a single instrument
+ response = apiInstance.get_ltp(instrument_key="NSE_EQ|INE848E01016")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_ltp: %s\n" % e)
+```
+
+## Get ltp (last traded price) market quotes for multiple instruments keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For multiple instruments
+ response = apiInstance.get_ltp(instrument_key="NSE_EQ|INE848E01016,NSE_EQ|INE669E01016")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_ltp: %s\n" % e)
+```
diff --git a/examples/market-quote/code/ltp-quotes.md b/examples/market-quote/code/ltp-quotes.md
new file mode 100644
index 0000000..d009030
--- /dev/null
+++ b/examples/market-quote/code/ltp-quotes.md
@@ -0,0 +1,41 @@
+## Get ltp (last traded price) market quotes
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.ltp(symbol,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+
+```
+
+## Get ltp (last traded price) market quotes for multiple instruments keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016,NSE_EQ|INE848E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.ltp(symbol,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+
+```
diff --git a/examples/market-quote/code/ohlc-quotes-v3.md b/examples/market-quote/code/ohlc-quotes-v3.md
new file mode 100644
index 0000000..b274927
--- /dev/null
+++ b/examples/market-quote/code/ohlc-quotes-v3.md
@@ -0,0 +1,35 @@
+## Get ohlc (open, high, low, close) market quotes
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For a single instrument
+ response = apiInstance.get_market_quote_ohlc("1d", instrument_key="NSE_EQ|INE669E01016")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_market_quote_ohlc: %s\n" % e)
+```
+
+## Get ohlc (open, high, low, close) market quotes for multiple instrument keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For multiple instruments
+ response = apiInstance.get_market_quote_ohlc("1d", instrument_key="NSE_EQ|INE669E01016,NSE_EQ|INE848E01016")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_market_quote_ohlc: %s\n" % e)
+```
diff --git a/examples/market-quote/code/ohlc-quotes.md b/examples/market-quote/code/ohlc-quotes.md
new file mode 100644
index 0000000..a0095e3
--- /dev/null
+++ b/examples/market-quote/code/ohlc-quotes.md
@@ -0,0 +1,42 @@
+## Get ohlc (open, high, low, close) market quotes
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+interval='1d'
+
+try:
+ api_response = api_instance.get_market_quote_ohlc(symbol,interval,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+
+```
+
+## Get ohlc (open, high, low, close) market quotes for multiple instrument keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+symbol = 'NSE_EQ|INE669E01016,NSE_EQ|INE848E01016'
+api_instance = upstox_client.MarketQuoteApi(upstox_client.ApiClient(configuration))
+interval='1d'
+
+try:
+ api_response = api_instance.get_market_quote_ohlc(symbol,interval,api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteApi->get_full_market_quote: %s\n" % e)
+```
diff --git a/examples/market-quote/code/option-greek.md b/examples/market-quote/code/option-greek.md
new file mode 100644
index 0000000..67406c3
--- /dev/null
+++ b/examples/market-quote/code/option-greek.md
@@ -0,0 +1,35 @@
+## Get Option Greek fields
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For a single instrument
+ response = apiInstance.get_market_quote_option_greek(instrument_key="NSE_FO|43885")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_market_quote_option_greek: %s\n" % e)
+```
+
+## Get Option Greek fields for multiple instruments keys
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+apiInstance = upstox_client.MarketQuoteV3Api(upstox_client.ApiClient(configuration))
+try:
+ # For multiple instruments
+ response = apiInstance.get_market_quote_option_greek(instrument_key="NSE_FO|38604,NSE_FO|49210")
+ print(response)
+except ApiException as e:
+ print("Exception when calling MarketQuoteV3Api->get_market_quote_option_greek: %s\n" % e)
+```
diff --git a/examples/option-chain/README.md b/examples/option-chain/README.md
new file mode 100644
index 0000000..9b7997c
--- /dev/null
+++ b/examples/option-chain/README.md
@@ -0,0 +1,12 @@
+# Option Chain – Example code
+
+Links to all option-chain-related examples in the `code/` folder.
+
+## 1. Option Contracts
+
+- 1.1 [Get option contracts of an instrument key](code/option-contracts.md#get-option-contracts-of-an-instrument-key)
+- 1.2 [Get option contracts of an instrument key with expiry date](code/option-contracts.md#get-option-contracts-of-an-instrument-key-with-expiry-date)
+
+## 2. Put Call Option Chain
+
+- 2.1 [Get put/call option chain](code/put-call-option-chain.md#get-putcall-option-chain)
diff --git a/examples/option-chain/code/option-contracts.md b/examples/option-chain/code/option-contracts.md
new file mode 100644
index 0000000..b1dce95
--- /dev/null
+++ b/examples/option-chain/code/option-contracts.md
@@ -0,0 +1,40 @@
+## Get option contracts of an instrument key
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+
+api_instance = upstox_client.OptionsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_option_contracts("NSE_INDEX|Nifty 50")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->options apis: %s\n" % e.body)
+
+```
+
+## Get option contracts of an instrument key with expiry date
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+
+api_instance = upstox_client.OptionsApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'expiry_date': "2024-10-31"
+}
+try:
+ api_response = api_instance.get_option_contracts("NSE_INDEX|Nifty 50", **param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->options apis: %s\n" % e.body)
+
+```
diff --git a/examples/option-chain/code/put-call-option-chain.md b/examples/option-chain/code/put-call-option-chain.md
new file mode 100644
index 0000000..85d8590
--- /dev/null
+++ b/examples/option-chain/code/put-call-option-chain.md
@@ -0,0 +1,18 @@
+## Get put/call option chain
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+
+api_instance = upstox_client.OptionsApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_put_call_option_chain("NSE_INDEX|Nifty 50", "2024-10-31")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->options apis: %s\n" % e.body)
+
+```
diff --git a/examples/orders/README.md b/examples/orders/README.md
new file mode 100644
index 0000000..03fcc93
--- /dev/null
+++ b/examples/orders/README.md
@@ -0,0 +1,79 @@
+# Orders – Example code
+
+Links to all order-related examples in the `code/` folder.
+
+## 1. Place Order V3
+
+- 1.1 [Place an order with slicing enabled](code/place-order-v3.md#place-an-order-with-slicing-enabled)
+- 1.2 [Place an order with slicing disabled](code/place-order-v3.md#place-an-order-with-slicing-disabled)
+
+## 2. Place Multi Order
+
+- 2.1 [Place a multi order](code/place-multi-order.md#place-a-multi-order)
+- 2.2 [Place Multiple BUY and SELL Orders](code/place-multi-order.md#place-multiple-buy-and-sell-orders)
+- 2.3 [Place Multiple Orders with Auto Slicing enabled](code/place-multi-order.md#place-multiple-orders-with-auto-slicing-enabled)
+
+## 3. Modify Order V3
+
+- 3.1 [Modify a delivery order](code/modify-order-v3.md#modify-a-delivery-order)
+
+## 4. Cancel Order V3
+
+- 4.1 [Cancel an open order](code/cancel-order-v3.md#cancel-an-open-order)
+
+## 5. Cancel Multi Order
+
+- 5.1 [Cancel all the open orders](code/cancel-multi-order.md#cancel-all-the-open-orders)
+- 5.2 [Cancel all the open orders for a given segment](code/cancel-multi-order.md#cancel-all-the-open-orders-for-a-given-segment)
+- 5.3 [Cancel all the open orders for a given tag](code/cancel-multi-order.md#cancel-all-the-open-orders-for-a-given-tag)
+
+## 6. Exit All Positions
+
+- 6.1 [Exit all the open positions](code/exit-all-positions.md#exit-all-the-open-positions)
+- 6.2 [Exit all the open positions for a given segment](code/exit-all-positions.md#exit-all-the-open-positions-for-a-given-segment)
+- 6.3 [Exit all the open positions for a given tag](code/exit-all-positions.md#exit-all-the-open-positions-for-a-given-tag)
+
+## 7. Get Order Details
+
+- 7.1 [Get order details for an order number](code/get-order-details.md#get-order-details-for-an-order-number)
+
+## 8. Get Order History
+
+- 8.1 [Get order history for an order number](code/get-order-history.md#get-order-history-for-an-order-number)
+
+## 9. Get Order Book
+
+- 9.1 [Get all orders for the day](code/get-order-book.md#get-all-orders-for-the-day)
+
+## 10. Get Trades
+
+- 10.1 [Get all trades for the day](code/get-trades.md#get-all-trades-for-the-day)
+
+## 11. Get Trades for Order
+
+- 11.1 [Get trades for an order number](code/get-order-trades.md#get-trades-for-an-order-number)
+
+## 12. Get Trade History
+
+- 12.1 [Get trade history for equity segment](code/get-historical-trades.md#get-trade-history-for-equity-segment)
+- 12.2 [Get trade history for futures and options segment](code/get-historical-trades.md#get-trade-history-for-futures-and-options-segment)
+
+## 13. Place Order
+
+- 13.1 [Place a delivery market order](code/place-order.md#place-a-delivery-market-order)
+- 13.2 [Place a delivery limit order](code/place-order.md#place-a-delivery-limit-order)
+- 13.3 [Place a delivery stop-loss order](code/place-order.md#place-a-delivery-stop-loss-order)
+- 13.4 [Place a delivery stop-loss order market](code/place-order.md#place-a-delivery-stop-loss-order-market)
+- 13.5 [Place an intraday market order](code/place-order.md#place-an-intraday-market-order)
+- 13.6 [Place an intraday limit order](code/place-order.md#place-an-intraday-limit-order)
+- 13.7 [Place an intraday stop-loss order](code/place-order.md#place-an-intraday-stop-loss-order)
+- 13.8 [Place an intraday stop-loss market order](code/place-order.md#place-an-intraday-stop-loss-market-order)
+- 13.9 [Place a delivery market amo (after market order)](code/place-order.md#place-a-delivery-market-amo-after-market-order)
+
+## 14. Modify Order
+
+- 14.1 [Modify a delivery order](code/modify-order.md#modify-a-delivery-order)
+
+## 15. Cancel Order
+
+- 15.1 [Cancel an open order](code/cancel-order.md#cancel-an-open-order)
diff --git a/examples/orders/code/cancel-multi-order.md b/examples/orders/code/cancel-multi-order.md
new file mode 100644
index 0000000..572f38f
--- /dev/null
+++ b/examples/orders/code/cancel-multi-order.md
@@ -0,0 +1,61 @@
+## Cancel all the open orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.cancel_multi_order()
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
+
+```
+
+## Cancel all the open orders for a given segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'segment': "NSE_FO"
+}
+
+try:
+ api_response = api_instance.cancel_multi_order(**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
+
+```
+
+## Cancel all the open orders for a given tag
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'tag': "xyz"
+}
+
+try:
+ api_response = api_instance.cancel_multi_order(**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
+
+```
diff --git a/examples/orders/code/cancel-order-v3.md b/examples/orders/code/cancel-order-v3.md
new file mode 100644
index 0000000..a146c53
--- /dev/null
+++ b/examples/orders/code/cancel-order-v3.md
@@ -0,0 +1,15 @@
+## Cancel an open order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.cancel_order("2501211050101")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApiV3->cancel_order: %s\n" % e)
+```
diff --git a/examples/orders/code/cancel-order.md b/examples/orders/code/cancel-order.md
new file mode 100644
index 0000000..90e0fe3
--- /dev/null
+++ b/examples/orders/code/cancel-order.md
@@ -0,0 +1,21 @@
+## Cancel an open order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+order_id = '231221011081579'
+api_version = '2.0'
+
+try:
+ # Cancel order
+ api_response = api_instance.cancel_order(order_id, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->cancel_order: %s\n" % e)
+
+```
diff --git a/examples/orders/code/exit-all-positions.md b/examples/orders/code/exit-all-positions.md
new file mode 100644
index 0000000..e167be5
--- /dev/null
+++ b/examples/orders/code/exit-all-positions.md
@@ -0,0 +1,61 @@
+## Exit all the open positions
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.exit_positions()
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->exit all positions: %s\n" % e.body)
+
+```
+
+## Exit all the open positions for a given segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'segment': "NSE_FO"
+}
+
+try:
+ api_response = api_instance.exit_positions(**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->exit all position: %s\n" % e.body)
+
+```
+
+## Exit all the open positions for a given tag
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'tag': "xyz"
+}
+
+try:
+ api_response = api_instance.exit_positions(**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->exit all position: %s\n" % e.body)
+
+```
diff --git a/examples/orders/code/get-historical-trades.md b/examples/orders/code/get-historical-trades.md
new file mode 100644
index 0000000..fb51cb0
--- /dev/null
+++ b/examples/orders/code/get-historical-trades.md
@@ -0,0 +1,41 @@
+## Get trade history for equity segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.PostTradeApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'segment': "EQ"
+}
+
+try:
+ api_response = api_instance.get_trades_by_date_range("2023-04-01", "2025-03-31",1,1000,**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get trades_by_date_range: %s\n" % e.body)
+```
+
+## Get trade history for futures and options segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.PostTradeApi(upstox_client.ApiClient(configuration))
+
+param = {
+ 'segment': "FO"
+}
+
+try:
+ api_response = api_instance.get_trades_by_date_range("2023-04-01", "2025-03-31",1,1000,**param)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get trades_by_date_range: %s\n" % e.body)
+```
diff --git a/examples/orders/code/get-order-book.md b/examples/orders/code/get-order-book.md
new file mode 100644
index 0000000..bb59297
--- /dev/null
+++ b/examples/orders/code/get-order-book.md
@@ -0,0 +1,18 @@
+## Get all orders for the day
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+api_version = '2.0'
+try:
+ # Get order book
+ api_response = api_instance.get_order_book(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get_order_book: %s\n" % e)
+```
diff --git a/examples/orders/code/get-order-details.md b/examples/orders/code/get-order-details.md
new file mode 100644
index 0000000..7f64519
--- /dev/null
+++ b/examples/orders/code/get-order-details.md
@@ -0,0 +1,16 @@
+## Get order details for an order number
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = "{your_access_token}"
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_order_status(order_id="2410170106208487")
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get order status: %s\n" % e.body)
+```
diff --git a/examples/orders/code/get-order-history.md b/examples/orders/code/get-order-history.md
new file mode 100644
index 0000000..2f02262
--- /dev/null
+++ b/examples/orders/code/get-order-history.md
@@ -0,0 +1,20 @@
+## Get order history for an order number
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+api_version = '2.0'
+order_id = '240112010371054'
+
+try:
+ api_response = api_instance.get_order_details(api_version, order_id=order_id)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get_order_details: %s\n" % e)
+
+```
diff --git a/examples/orders/code/get-order-trades.md b/examples/orders/code/get-order-trades.md
new file mode 100644
index 0000000..31c2dc8
--- /dev/null
+++ b/examples/orders/code/get-order-trades.md
@@ -0,0 +1,21 @@
+## Get trades for an order number
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+order_id = '{your_order_id}'
+api_version = '2.0'
+
+try:
+ # Get trades for order
+ api_response = api_instance.get_trades_by_order(order_id, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get_trades_by_order: %s\n" % e)
+
+```
diff --git a/examples/orders/code/get-trades.md b/examples/orders/code/get-trades.md
new file mode 100644
index 0000000..f1acae8
--- /dev/null
+++ b/examples/orders/code/get-trades.md
@@ -0,0 +1,20 @@
+## Get all trades for the day
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+api_version = '2.0'
+
+try:
+ # Get trades
+ api_response = api_instance.get_trade_history(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->get_trade_history: %s\n" % e)
+
+```
diff --git a/examples/orders/code/modify-order-v3.md b/examples/orders/code/modify-order-v3.md
new file mode 100644
index 0000000..c3762a1
--- /dev/null
+++ b/examples/orders/code/modify-order-v3.md
@@ -0,0 +1,16 @@
+## Modify a delivery order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+body = upstox_client.ModifyOrderRequest(1, "DAY", 9.12, "25030310405859", "LIMIT", 0, 0)
+
+try:
+ api_response = api_instance.modify_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApiV3->modify_order: %s\n" % e)
+```
diff --git a/examples/orders/code/modify-order.md b/examples/orders/code/modify-order.md
new file mode 100644
index 0000000..2a96290
--- /dev/null
+++ b/examples/orders/code/modify-order.md
@@ -0,0 +1,20 @@
+## Modify a delivery order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.ModifyOrderRequest(2, "DAY", 0, "231222010275930", "MARKET", 0, 0)
+api_version = '2.0' # str | API Version Header
+
+try:
+ # Modify order
+ api_response = api_instance.modify_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->modify_order: %s\n" % e)
+```
diff --git a/examples/orders/code/place-multi-order.md b/examples/orders/code/place-multi-order.md
new file mode 100644
index 0000000..2dd4623
--- /dev/null
+++ b/examples/orders/code/place-multi-order.md
@@ -0,0 +1,67 @@
+## Place a multi order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = [
+ upstox_client.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44166", "MARKET", "BUY",
+ 0, 0, True, "1")
+]
+
+try:
+ api_response = api_instance.place_multi_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e.body)
+
+```
+
+## Place Multiple BUY and SELL Orders
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = [
+ upstox_client.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44166", "MARKET", "BUY",
+ 0, 0, True, "1"),
+ upstox_client.MultiOrderRequest(25, "D", "DAY", 0, "string", False, "NSE_FO|44122", "MARKET", "SELL",
+ 0, 0, True, "2")
+]
+
+try:
+ api_response = api_instance.place_multi_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e.body)
+
+```
+
+## Place Multiple Orders with Auto Slicing enabled
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = [
+ upstox_client.MultiOrderRequest(25, "D", "DAY", 0, "string", True, "NSE_FO|44166", "MARKET", "BUY",
+ 0, 0, True, "1")
+]
+
+try:
+ api_response = api_instance.place_multi_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e.body)
+
+```
diff --git a/examples/orders/code/place-order-v3.md b/examples/orders/code/place-order-v3.md
new file mode 100644
index 0000000..a7d6f71
--- /dev/null
+++ b/examples/orders/code/place-order-v3.md
@@ -0,0 +1,39 @@
+## Place an order with slicing enabled
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderV3Request(quantity=4000, product="D", validity="DAY",
+ price=0, tag="string", instrument_token="NSE_FO|43919",
+ order_type="MARKET", transaction_type="BUY", disclosed_quantity=0,
+ trigger_price=0.0, is_amo=False, slice=True)
+
+try:
+ api_response = api_instance.place_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApiV3->place_order: %s\n" % e)
+```
+
+## Place an order with slicing disabled
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderV3Request(quantity=75, product="D", validity="DAY",
+ price=0, tag="string", instrument_token="NSE_FO|43919",
+ order_type="MARKET", transaction_type="BUY", disclosed_quantity=0,
+ trigger_price=0.0, is_amo=False, slice=False)
+
+try:
+ api_response = api_instance.place_order(body)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApiV3->place_order: %s\n" % e)
+```
diff --git a/examples/orders/code/place-order.md b/examples/orders/code/place-order.md
new file mode 100644
index 0000000..ce00070
--- /dev/null
+++ b/examples/orders/code/place-order.md
@@ -0,0 +1,154 @@
+## Place a delivery market order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place a delivery limit order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 20.0, "string", "NSE_EQ|INE528G01035", "LIMIT", "BUY", 0, 20.1, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place a delivery stop-loss order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 20, "string", "NSE_EQ|INE528G01035", "SL", "BUY", 0, 19.5, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+
+```
+
+## Place a delivery stop-loss order market
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "SL-M", "BUY", 0, 21.5, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place an intraday market order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "I", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place an intraday limit order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "I", "DAY", 20.0, "string", "NSE_EQ|INE528G01035", "LIMIT", "BUY", 0, 20.1, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place an intraday stop-loss order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "I", "DAY", 20, "string", "NSE_EQ|INE528G01035", "SL", "BUY", 0, 19.5, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+
+```
+
+## Place an intraday stop-loss market order
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "I", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "SL-M", "BUY", 0, 21.5, False)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
+
+## Place a delivery market amo (after market order)
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
+body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, True)
+api_version = '2.0'
+try:
+ api_response = api_instance.place_order(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling OrderApi->place_order: %s\n" % e)
+```
diff --git a/examples/portfolio/README.md b/examples/portfolio/README.md
new file mode 100644
index 0000000..d3a6d9d
--- /dev/null
+++ b/examples/portfolio/README.md
@@ -0,0 +1,20 @@
+# Portfolio – Example code
+
+Links to all portfolio-related examples in the `code/` folder.
+
+## 1. Get Positions
+
+- 1.1 [Get user positions](code/get-positions.md#get-user-positions)
+
+## 2. Get MTF Positions
+
+- 2.1 [Get user MTF positions](code/get-mtf-positions.md#get-user-mtf-positions)
+
+## 3. Convert Positions
+
+- 3.1 [Convert a position from intraday to delivery](code/convert-positions.md#convert-a-position-from-intraday-to-delivery)
+- 3.2 [Convert a position from delivery to intraday](code/convert-positions.md#convert-a-position-from-delivery-to-intraday)
+
+## 4. Get Holdings
+
+- 4.1 [Get user holdings](code/get-holdings.md#get-user-holdings)
diff --git a/examples/portfolio/code/convert-positions.md b/examples/portfolio/code/convert-positions.md
new file mode 100644
index 0000000..1f614d8
--- /dev/null
+++ b/examples/portfolio/code/convert-positions.md
@@ -0,0 +1,43 @@
+## Convert a position from intraday to delivery
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
+body = upstox_client.ConvertPositionRequest(instrument_token= "NSE_EQ|INE528G01035",quantity=1,new_product="D",old_product="I",transaction_type="BUY")
+api_version = '2.0'
+
+try:
+ # Convert Positions
+ api_response = api_instance.convert_positions(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling PortfolioApi->convert_positions: %s\n" % e)
+
+```
+
+## Convert a position from delivery to intraday
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
+body = upstox_client.ConvertPositionRequest(instrument_token= "NSE_EQ|INE528G01035",quantity=1,new_product="I",old_product="D",transaction_type="BUY")
+api_version = '2.0'
+
+try:
+ # Convert Positions
+ api_response = api_instance.convert_positions(body, api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling PortfolioApi->convert_positions: %s\n" % e)
+
+```
diff --git a/examples/portfolio/code/get-holdings.md b/examples/portfolio/code/get-holdings.md
new file mode 100644
index 0000000..0055c5f
--- /dev/null
+++ b/examples/portfolio/code/get-holdings.md
@@ -0,0 +1,18 @@
+## Get user holdings
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_holdings(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+```
diff --git a/examples/portfolio/code/get-mtf-positions.md b/examples/portfolio/code/get-mtf-positions.md
new file mode 100644
index 0000000..84453a4
--- /dev/null
+++ b/examples/portfolio/code/get-mtf-positions.md
@@ -0,0 +1,16 @@
+## Get user MTF positions
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+apiInstance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
+
+try:
+ response = apiInstance.get_mtf_positions()
+ print("MTF positions:", response)
+except ApiException as e:
+ print("Exception when calling PortfolioApi->get_mtf_positions: %s\n" % e)
+```
diff --git a/examples/portfolio/code/get-positions.md b/examples/portfolio/code/get-positions.md
new file mode 100644
index 0000000..95630c6
--- /dev/null
+++ b/examples/portfolio/code/get-positions.md
@@ -0,0 +1,19 @@
+## Get user positions
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
+
+try:
+ api_response = api_instance.get_positions(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling ChargeApi->get_brokerage: %s\n" % e)
+
+```
diff --git a/examples/trade-profit-and-loss/README.md b/examples/trade-profit-and-loss/README.md
new file mode 100644
index 0000000..ed5a02c
--- /dev/null
+++ b/examples/trade-profit-and-loss/README.md
@@ -0,0 +1,16 @@
+# Trade Profit and Loss – Example code
+
+Links to all trade-profit-and-loss-related examples in the `code/` folder.
+
+## 1. Get Report Meta Data
+
+- 1.1 [Get report meta data for equity segment](code/get-report-meta-data.md#get-report-meta-data-for-equity-segment)
+
+## 2. Get Profit Loss Report
+
+- 2.1 [Get profit loss report for futures and options segment](code/get-profit-loss-report.md#get-profit-loss-report-for-futures-and-options-segment)
+
+## 3. Get Trade Charges
+
+- 3.1 [Get trade charges for equity segment](code/get-trade-charges.md#get-trade-charges-for-equity-segment)
+- 3.2 [Get trade charges for futures and options segment](code/get-trade-charges.md#get-trade-charges-for-futures-and-options-segment)
diff --git a/examples/trade-profit-and-loss/code/get-profit-loss-report.md b/examples/trade-profit-and-loss/code/get-profit-loss-report.md
new file mode 100644
index 0000000..f353432
--- /dev/null
+++ b/examples/trade-profit-and-loss/code/get-profit-loss-report.md
@@ -0,0 +1,25 @@
+## Get profit loss report for futures and options segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.TradeProfitAndLossApi(upstox_client.ApiClient(configuration))
+segment = 'FO'
+financial_year = '2324' # str | Financial 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
+page_number = 1
+page_size = 4
+api_version = '2.0' # str | API Version Header
+from_date = '02-04-2023' # str | Date 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 (optional)
+to_date = '20-03-2024' # str | Date 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 (optional)
+
+try:
+ # Get Trade-wise Profit and Loss Report Data
+ api_response = api_instance.get_trade_wise_profit_and_loss_data(segment, financial_year, page_number, page_size, api_version, from_date=from_date, to_date=to_date)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling TradeProfitAndLossApi->get_trade_wise_profit_and_loss_data: %s\n" % e)
+```
diff --git a/examples/trade-profit-and-loss/code/get-report-meta-data.md b/examples/trade-profit-and-loss/code/get-report-meta-data.md
new file mode 100644
index 0000000..0584a67
--- /dev/null
+++ b/examples/trade-profit-and-loss/code/get-report-meta-data.md
@@ -0,0 +1,23 @@
+## Get report meta data for equity segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.TradeProfitAndLossApi(upstox_client.ApiClient(configuration))
+segment = 'EQ'
+financial_year = '2324' # str | Financial 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
+api_version = '2.0' # str | API Version Header
+from_date = '02-04-2023' # str | Date 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 (optional)
+to_date = '20-03-2024' # str | Date 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 (optional)
+
+try:
+ # Get Trade-wise Profit and Loss Report Data
+ api_response = api_instance.get_trade_wise_profit_and_loss_meta_data(segment, financial_year, api_version, from_date=from_date, to_date=to_date)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling TradeProfitAndLossApi->get_trade_wise_profit_and_loss_data: %s\n" % e)
+```
diff --git a/examples/trade-profit-and-loss/code/get-trade-charges.md b/examples/trade-profit-and-loss/code/get-trade-charges.md
new file mode 100644
index 0000000..7e215b8
--- /dev/null
+++ b/examples/trade-profit-and-loss/code/get-trade-charges.md
@@ -0,0 +1,47 @@
+## Get trade charges for equity segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.TradeProfitAndLossApi(upstox_client.ApiClient(configuration))
+segment = 'EQ'
+financial_year = '2324' # str | Financial 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
+api_version = '2.0' # str | API Version Header
+from_date = '02-04-2023' # str | Date 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 (optional)
+to_date = '20-03-2024' # str | Date 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 (optional)
+
+try:
+ # Get Trade-wise Profit and Loss Report Data
+ api_response = api_instance.get_profit_and_loss_charges(segment, financial_year, api_version, from_date=from_date, to_date=to_date)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling TradeProfitAndLossApi->get_trade_wise_profit_and_loss_data: %s\n" % e)
+```
+
+## Get trade charges for futures and options segment
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+
+api_instance = upstox_client.TradeProfitAndLossApi(upstox_client.ApiClient(configuration))
+segment = 'FO'
+financial_year = '2324' # str | Financial 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
+api_version = '2.0' # str | API Version Header
+from_date = '02-04-2023' # str | Date 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 (optional)
+to_date = '20-03-2024' # str | Date 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 (optional)
+
+try:
+ # Get Trade-wise Profit and Loss Report Data
+ api_response = api_instance.get_profit_and_loss_charges(segment, financial_year, api_version, from_date=from_date, to_date=to_date)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling TradeProfitAndLossApi->get_trade_wise_profit_and_loss_data: %s\n" % e)
+```
diff --git a/examples/user/README.md b/examples/user/README.md
new file mode 100644
index 0000000..0809faf
--- /dev/null
+++ b/examples/user/README.md
@@ -0,0 +1,13 @@
+# User – Example code
+
+Links to all user-related examples in the `code/` folder.
+
+## 1. Get Profile
+
+- 1.1 [Get user profile information using access token](code/get-profile.md#get-user-profile-information-using-access-token)
+
+## 2. Get Fund and Margin
+
+- 2.1 [Get equity and commodity funds](code/get-fund-and-margin.md#get-equity-and-commodity-funds)
+- 2.2 [Get equity funds](code/get-fund-and-margin.md#get-equity-funds)
+- 2.3 [Get commodity funds](code/get-fund-and-margin.md#get-commodity-funds)
diff --git a/examples/user/code/get-fund-and-margin.md b/examples/user/code/get-fund-and-margin.md
new file mode 100644
index 0000000..23fcf99
--- /dev/null
+++ b/examples/user/code/get-fund-and-margin.md
@@ -0,0 +1,61 @@
+## Get equity and commodity funds
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
+
+try:
+ # Get User Fund And Margin
+ api_response = api_instance.get_user_fund_margin(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
+```
+
+## Get equity funds
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
+segment = 'SEC'
+try:
+ # Get User Fund And Margin
+ api_response = api_instance.get_user_fund_margin(api_version, segment=segment)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
+
+```
+
+## Get commodity funds
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
+segment = 'COM'
+try:
+ # Get User Fund And Margin
+ api_response = api_instance.get_user_fund_margin(api_version, segment=segment)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
+
+```
diff --git a/examples/user/code/get-profile.md b/examples/user/code/get-profile.md
new file mode 100644
index 0000000..8353597
--- /dev/null
+++ b/examples/user/code/get-profile.md
@@ -0,0 +1,20 @@
+## Get user profile information using access token
+
+```python
+import upstox_client
+from upstox_client.rest import ApiException
+
+configuration = upstox_client.Configuration()
+configuration.access_token = '{your_access_token}'
+api_version = '2.0'
+
+api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
+
+try:
+ # Get User Fund And Margin
+ api_response = api_instance.get_profile(api_version)
+ print(api_response)
+except ApiException as e:
+ print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
+
+```