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
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ Samples are grouped by API area. Each `.md` file contains one or more Python sni
| [**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, 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. |
| [**gtt-orders/**](gtt-orders/) | Place, modify, cancel, and get details for GTT (Good Till Triggered) orders. |
| [**margins/**](margins/) | Margin details. |
| [**charges/**](charges/) | Brokerage details. |
| [**mutual-funds-api/**](mutual-funds-api/) | Mutual fund holdings, orders, order details, and SIPs. |
| [**payments-api/**](payments-api/) | Payin and payout history. |
| [**payout/**](payout/) | Payout history, payout modes, and initiate/modify/cancel payout. |
| [**news/**](news/) | News articles by instrument keys, positions, or holdings. |
| [**fundamentals/**](fundamentals/) | Company profile, balance sheet, cash flow, income statement, key ratios, share holdings, corporate actions, and competitors. |
| [**trade-profit-and-loss/**](trade-profit-and-loss/) | P&L report, report metadata, trade charges. |
Expand Down
12 changes: 12 additions & 0 deletions examples/ipo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IPO – Example code

Links to all IPO-related examples in the `code/` folder.

## 1. Get IPO Listing

- 1.1 [Get IPO listing](code/get-ipo.md#get-ipo-listing)
- 1.2 [Get IPO listing with filters and pagination](code/get-ipo.md#get-ipo-listing-with-filters-and-pagination)

## 2. Get IPO Details

- 2.1 [Get IPO details by id](code/get-ipo.md#get-ipo-details-by-id)
63 changes: 63 additions & 0 deletions examples/ipo/code/get-ipo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Get IPO listing

```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_listing()
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_listing: %s\n" % e)
```

## Get IPO listing with filters and 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:
# status: open | closed | listed | upcoming
# issue_type: regular | sme
api_response = api_instance.get_ipo_listing(
status='open',
issue_type='regular',
page_number=1,
records=20
)
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_listing: %s\n" % e)
```

## Get IPO details by 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))

# `id` is the IPO slug id returned by get_ipo_listing
ipo_id = '{ipo_slug_id}'

try:
api_response = api_instance.get_ipo_details(ipo_id)
print(api_response)
except ApiException as e:
print("Exception when calling IpoApi->get_ipo_details: %s\n" % e)
```
18 changes: 18 additions & 0 deletions examples/payout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Payout – Example code

Links to all payout-related examples in the `code/` folder. Payout endpoints are
exposed on `UserApi`.

> ⚠️ `initiate_payout`, `modify_payout`, and `cancel_payout` move real funds. Test
> against a sandbox/test account before using in production.

## 1. Payout History & Modes

- 1.1 [Get payout history](code/payout.md#get-payout-history)
- 1.2 [Get payout modes](code/payout.md#get-payout-modes)

## 2. Initiate / Modify / Cancel Payout

- 2.1 [Initiate payout](code/payout.md#initiate-payout)
- 2.2 [Modify payout](code/payout.md#modify-payout)
- 2.3 [Cancel payout](code/payout.md#cancel-payout)
97 changes: 97 additions & 0 deletions examples/payout/code/payout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
## Get payout history

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

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

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

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

## Get payout modes

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

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

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

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

## Initiate payout

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

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

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

# mode is one of the values returned by get_payout_modes (e.g. IMPS)
body = upstox_client.InitiatePayoutRequest(mode='IMPS', amount=1000.0)

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

## Modify payout

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

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

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

transaction_id = '{transaction_id}'
body = upstox_client.ModifyPayoutRequest(amount=2000.0)

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

## Cancel payout

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

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

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

transaction_id = '{transaction_id}'

try:
api_response = api_instance.cancel_payout(transaction_id)
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->cancel_payout: %s\n" % e)
```
16 changes: 16 additions & 0 deletions examples/smartlist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Smartlist – Example code

Links to all smartlist-related examples in the `code/` folder. Smartlist endpoints
return analytics-enriched lists and are exposed on `MarketApi`.

## 1. Smartlist Options

- 1.1 [Get smartlist options](code/get-smartlist.md#get-smartlist-options)

## 2. Smartlist Futures

- 2.1 [Get smartlist futures](code/get-smartlist.md#get-smartlist-futures)

## 3. Smartlist MTF

- 3.1 [Get smartlist MTF](code/get-smartlist.md#get-smartlist-mtf)
70 changes: 70 additions & 0 deletions examples/smartlist/code/get-smartlist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Get smartlist options

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

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

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

try:
# asset_type: INDEX | STOCK | COMMODITY
# category: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS, PRICE_GAINERS,
# PRICE_LOSERS, IV_GAINERS, IV_LOSERS, UNDER_5000, UNDER_10000
api_response = api_instance.get_smartlist_options(
asset_type='INDEX',
category='TOP_TRADED',
page_number=1,
page_size=50
)
print(api_response)
except ApiException as e:
print("Exception when calling MarketApi->get_smartlist_options: %s\n" % e)
```

## Get smartlist futures

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

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

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

try:
# asset_type: INDEX | STOCK | COMMODITY
# category: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS, PRICE_GAINERS,
# PRICE_LOSERS, PREMIUM, DISCOUNT
api_response = api_instance.get_smartlist_futures(
asset_type='STOCK',
category='MOST_ACTIVE',
page_number=1,
page_size=50
)
print(api_response)
except ApiException as e:
print("Exception when calling MarketApi->get_smartlist_futures: %s\n" % e)
```

## Get smartlist MTF

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

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

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

try:
# MTF (Margin Trade Funding) stocks, enriched with live LTP
api_response = api_instance.get_smartlist_mtf(page_number=1, page_size=50)
print(api_response)
except ApiException as e:
print("Exception when calling MarketApi->get_smartlist_mtf: %s\n" % e)
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
long_description = (this_directory / "README.md").read_text()

NAME = "upstox-python-sdk"
VERSION = "2.27.0"
VERSION = "2.28.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
Loading
Loading