Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Samples are grouped by API area. Each `.md` file contains one or more Python sni
| [**expired-instruments/**](expired-instruments/) | Expiries, expired future/option contracts, expired historical candle data. |
| [**market-information/**](market-information/) | Exchange status, market timings, market holidays, OI, change in OI, PCR, max pain, FII, and DII. |
| [**smartlist/**](smartlist/) | Analytics-enriched smartlists for options, futures, and MTF stocks. |
| [**ipo/**](ipo/) | IPO listing (by status/issue type) and IPO details by id. |
| [**ipo/**](ipo/) | IPO listing (by status/issue type), IPO details by id, and IPO orders — apply, list, fetch by order id and cancel. |
| [**gtt-orders/**](gtt-orders/) | Place, modify, cancel, and get details for GTT (Good Till Triggered) orders. |
| [**margins/**](margins/) | Margin details. |
| [**charges/**](charges/) | Brokerage details. |
Expand Down
22 changes: 22 additions & 0 deletions examples/ipo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,25 @@ Links to all IPO-related examples in the `code/` folder.
## 2. Get IPO Details

- 2.1 [Get IPO details by id](code/get-ipo.md#get-ipo-details-by-id)

## 3. Apply for IPO

- 3.1 [Apply for an IPO](code/apply-for-ipo.md#apply-for-an-ipo)
- 3.2 [Apply for an IPO with multiple bids](code/apply-for-ipo.md#apply-for-an-ipo-with-multiple-bids)

## 4. Get IPO Orders

- 4.1 [Get IPO orders](code/get-ipo-orders.md#get-ipo-orders)
- 4.2 [Get IPO orders with pagination](code/get-ipo-orders.md#get-ipo-orders-with-pagination)
- 4.3 [Iterate over IPO orders and their bids](code/get-ipo-orders.md#iterate-over-ipo-orders-and-their-bids)

## 5. Get IPO Order Details

- 5.1 [Get IPO order details by order id](code/get-ipo-order-details.md#get-ipo-order-details-by-order-id)
- 5.2 [Read the order and payment status of an IPO order](code/get-ipo-order-details.md#read-the-order-and-payment-status-of-an-ipo-order)
- 5.3 [Look up the most recent IPO order](code/get-ipo-order-details.md#look-up-the-most-recent-ipo-order)

## 6. Cancel IPO Order

- 6.1 [Cancel an IPO order](code/cancel-ipo-order.md#cancel-an-ipo-order)
- 6.2 [Apply, then cancel the same IPO order](code/cancel-ipo-order.md#apply-then-cancel-the-same-ipo-order)
65 changes: 65 additions & 0 deletions examples/ipo/code/apply-for-ipo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Apply for an IPO

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.IpoApi(upstox_client.ApiClient(configuration))

# `id` is the IPO slug id returned by get_ipo_listing
# `category`: IND (Individual) | HNI (High Net-worth Individual)
# `bids`: at least one bid, maximum of 3
body = upstox_client.IpoApplyRequest(
id='{ipo_slug_id}',
upi='{your_upi_id}',
category='IND',
bids=[
upstox_client.IpoBidRequest(quantity=10, price=150.0)
]
)

try:
api_response = api_instance.apply_for_ipo(body)
print(api_response)
print('IPO order id:', api_response.data.order_id)
except ApiException as e:
print("Exception when calling IpoApi->apply_for_ipo: %s\n" % e)
```

## Apply for an IPO with multiple bids

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.IpoApi(upstox_client.ApiClient(configuration))

# Up to 3 bids may be submitted in a single application.
# Use the cut-off price / lot size from get_ipo_details to build valid bids.
body = upstox_client.IpoApplyRequest(
id='{ipo_slug_id}',
upi='{your_upi_id}',
category='HNI',
bids=[
upstox_client.IpoBidRequest(quantity=10, price=150.0),
upstox_client.IpoBidRequest(quantity=20, price=155.0),
upstox_client.IpoBidRequest(quantity=30, price=160.0)
]
)

try:
api_response = api_instance.apply_for_ipo(body)
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->apply_for_ipo: %s\n" % e)
```

> Note: after a successful application, approve the UPI mandate request in your
> UPI app to block the funds. Until the mandate is approved, the order remains
> pending.
57 changes: 57 additions & 0 deletions examples/ipo/code/cancel-ipo-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Cancel an IPO 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.IpoApi(upstox_client.ApiClient(configuration))

# `order_id` is returned by apply_for_ipo or get_ipo_orders
order_id = '{ipo_order_id}'

try:
api_response = api_instance.cancel_ipo_order(order_id)
print(api_response)
print('cancelled order id:', api_response.data.order_id)
print('status:', api_response.data.status)
except ApiException as e:
print("Exception when calling IpoApi->cancel_ipo_order: %s\n" % e)
```

## Apply, then cancel the same IPO 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.IpoApi(upstox_client.ApiClient(configuration))

body = upstox_client.IpoApplyRequest(
id='{ipo_slug_id}',
upi='{your_upi_id}',
category='IND',
bids=[
upstox_client.IpoBidRequest(quantity=10, price=150.0)
]
)

try:
apply_response = api_instance.apply_for_ipo(body)
order_id = apply_response.data.order_id
print('applied, order id:', order_id)

cancel_response = api_instance.cancel_ipo_order(order_id)
print('cancelled:', cancel_response.data.status)
except ApiException as e:
print("Exception when calling IpoApi ipo order write ops: %s\n" % e)
```

> Note: cancellation is only accepted while the IPO bidding window is still
> open. Once the issue closes, the order can no longer be withdrawn — check
> `bidding_end_date` from get_ipo_details before cancelling.
70 changes: 70 additions & 0 deletions examples/ipo/code/get-ipo-order-details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Get IPO order details by order id

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.IpoApi(upstox_client.ApiClient(configuration))

# `order_id` is returned by apply_for_ipo or get_ipo_orders
order_id = '{ipo_order_id}'

try:
api_response = api_instance.get_ipo_order_by_id(order_id)
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_order_by_id: %s\n" % e)
```

## Read the order and payment status of an IPO 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.IpoApi(upstox_client.ApiClient(configuration))

order_id = '{ipo_order_id}'

try:
api_response = api_instance.get_ipo_order_by_id(order_id)
order = api_response.data
print('symbol: ', order.symbol)
print('exchange: ', order.exchange)
print('order status: ', order.order_status)
print('payment status: ', order.payment_status)
print('units allotted: ', order.units_allotted)
for bid in order.bids or []:
print(' bid:', bid['quantity'], '@', bid['price'], '=', bid['amount'])
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_order_by_id: %s\n" % e)
```

## Look up the most recent IPO 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.IpoApi(upstox_client.ApiClient(configuration))

try:
orders = api_instance.get_ipo_orders(page_number=1, records=1)
if orders.data:
order_id = orders.data[0]['order_id']
api_response = api_instance.get_ipo_order_by_id(order_id)
print(api_response)
else:
print('no IPO orders found')
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_order_by_id: %s\n" % e)
```
60 changes: 60 additions & 0 deletions examples/ipo/code/get-ipo-orders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Get IPO 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.IpoApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_ipo_orders()
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_orders: %s\n" % e)
```

## Get IPO orders with pagination

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.IpoApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_ipo_orders(
page_number=1,
records=20
)
print(api_response)
print('page:', api_response.meta_data.page)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_orders: %s\n" % e)
```

## Iterate over IPO orders and their bids

```python
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'

api_instance = upstox_client.IpoApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_ipo_orders(page_number=1, records=50)
for order in api_response.data or []:
print(order['order_id'], order['symbol'], order['order_status'], order['payment_status'])
for bid in order.get('bids') or []:
print(' bid:', bid['quantity'], '@', bid['price'], '=', bid['amount'])
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_orders: %s\n" % e)
```
25 changes: 24 additions & 1 deletion interactive_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,28 @@ python market_information/pcr_data.py --token <TOKEN> --expiry 2026-05-29 --buc

---

### IPO
*Uses the [Upstox IPO API](https://upstox.com/developer/api-documentation/). Read-only: these examples cover the GET endpoints only — applying for and cancelling an IPO are not included.*

| Script | What it does |
|---|---|
| `ipo/ipo_listing.py` | Lists IPOs filtered by status (open / closed / listed / upcoming) and issue type |
| `ipo/ipo_details.py` | Full profile for one IPO — price band, timeline, registrar, investor categories |
| `ipo/ipo_orders.py` | Your IPO applications, or a single application by order ID |

```bash
python ipo/ipo_listing.py --token <TOKEN> --status open
python ipo/ipo_listing.py --token <TOKEN> --status upcoming --issue-type sme --records 30
python ipo/ipo_details.py --token <TOKEN>
python ipo/ipo_details.py --token <TOKEN> --id <IPO_SLUG_ID>
python ipo/ipo_orders.py --token <TOKEN> --records 5
python ipo/ipo_orders.py --token <TOKEN> --order-id <ORDER_ID>
```

> `ipo/ipo_orders.py` reads **your own** applications, so it needs a full access token — a read-only analytics token will not work. The other two work with either.

---


## 🌐 Deploy the Streamlit App

Expand Down Expand Up @@ -310,7 +332,8 @@ interactive_examples/
├── portfolio_screening/ # 3 scripts
├── market_data/ # 8 scripts
├── fundamentals/ # 8 scripts
└── market_information/ # 6 scripts
├── market_information/ # 6 scripts
└── ipo/ # 3 scripts
```

---
Expand Down
Loading
Loading