uat-breeze-connect 1.0.14rc62
UAT Breeze Connect
Requires Python: >=3.6

# Table Of Content

<ul>
 <li><a href="#client">Breeze API Python Client</a></li>
 <li><a href="#docslink">API Documentation</a></li>
 <li><a href="#virtualenv">Set Up Virtual Environment</a></li>
 <li><a href="#clientinstall">Installing Client</a></li>
 <li><a href="#apiusage">API Usage</a></li>
 <li><a href="#websocket">Websocket Usage</a></li>
 <li><a href="#index_title">List Of APIs</a></li>
 <li><a href="#version_history">Version History</a></li>

</ul>

<h3 id="client"><b>Breeze API Python Client</b></h3>

breezeapi@icicisecurities.com

The official Python client library for the ICICI Securities trading APIs. BreezeConnect is a set of REST-like APIs that allows one to build a complete investment and trading platform. Following are some notable features of Breeze APIs:

1. Execute orders in real time
2. Manage Portfolio
3. Access to 10 years of historical market data including 1 sec OHLCV
4. Streaming live OHLC (websockets)
5. Option Chain API

To install breeze strategies :<a href="https://pypi.org/project/breeze-strategies/"> Click here </a>

<h3 id="docslink"><b>API Documentation</b></h3>

<div class="sticky" >
<ul>
 <li><a href="https://api.icicidirect.com/breezeapi/documents/index.html">Breeze HTTP API Documentation</a></li>
 <li><a href="https://pypi.org/project/breeze-connect/">Python client documentation</a></li>
</ul>
</div>

<h3 id="virtualenv"><b>Setup virtual environment in your Machine</b></h3>

You must install the virtualenv package via pip
```
pip install virtualenv
```

You should create breeze virtual environment via virtualenv
```
virtualenv -p python3 breeze_venv
```

And then, You can activate virtual environment via source
```
source breeze_venv/bin/activate
```

<h3 id="clientinstall"><b>Installing the client</b></h3>

You can install the latest release via pip

```
pip install --upgrade breeze-connect
```

Or, You can also install the specific release version via pip

```
pip install breeze-connect==1.0.65
```
<hr>

<h4 id="apiusage"> API Usage</h4>

```python
from breeze_connect import BreezeConnect

# Initialize SDK
breeze = BreezeConnect(api_key="your_api_key")

# Obtain your session key from https://api.icicidirect.com/apiuser/login?api_key=YOUR_API_KEY
# Incase your api-key has special characters(like +,=,!) then encode the api key before using in the url as shown below.
import urllib
print("https://api.icicidirect.com/apiuser/login?api_key="+urllib.parse.quote_plus("your_api_key"))

# Generate Session
breeze.generate_session(api_secret="your_secret_key",
                        session_token="your_api_session")

# Generate ISO8601 Date/DateTime String
import datetime
iso_date_string = datetime.datetime.strptime("28/02/2021","%d/%m/%Y").isoformat()[:10] + 'T05:30:00.000Z'
iso_date_time_string = datetime.datetime.strptime("28/02/2021 23:59:59","%d/%m/%Y %H:%M:%S").isoformat()[:19] + '.000Z'
```
<br>

<hr>


<h3 id="websocket"><b> Websocket Usage </b></h3>

```python
from breeze_connect import BreezeConnect

# Initialize SDK
breeze = BreezeConnect(api_key="your_api_key")

# Obtain your session key from https://api.icicidirect.com/apiuser/login?api_key=YOUR_API_KEY
# Incase your api-key has special characters(like +,=,!) then encode the api key before using in the url as shown below.
import urllib
print("https://api.icicidirect.com/apiuser/login?api_key="+urllib.parse.quote_plus("your_api_key"))

# Generate Session
breeze.generate_session(api_secret="your_secret_key",
                        session_token="your_api_session")

# Connect to websocket(it will connect to tick-by-tick data server)
breeze.ws_connect()

# Callback to receive ticks.
def on_ticks(ticks):
    print("Ticks: {}".format(ticks))

# Assign the callbacks.
breeze.on_ticks = on_ticks

# ws_disconnect (it will disconnect from all actively connected servers)
breeze.ws_disconnect()
```
<hr>

<h2>Subscribing to Real Time Streaming OHLCV Data of stocks by stock-token</h2>

```python
breeze.subscribe_feeds(stock_token="4.1!2885", 
                      interval="1minute")
```
<br>
<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock 4.1!2885 subscribed successfully'}
Ticks: {'interval': '1minute', 'exchange_code': 'NSE', 'stock_code': 'RELIND', 'low': '1199.5', 'high': '1200.15', 'open': '1199.95', 'close': '1200.0', 'volume': '40752', 'datetime': '2025-02-12 10:04:00'}
Ticks: {'interval': '1minute', 'exchange_code': 'NSE', 'stock_code': 'RELIND', 'low': '1199.3', 'high': '1201.0', 'open': '1200.0', 'close': '1200.2', 'volume': '113253', 'datetime': '2025-02-12 10:05:00'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(stock_token="4.1!2885", 
                      interval="1minute")</p>

<h2>Subscribe equity stocks by stock-token (Exchange Quotes)</h2>

```python 
    breeze.subscribe_feeds(stock_token="4.1!2885")
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock 4.1!2885 subscribed successfully'}
Ticks: {'symbol': '4.1!2885', 'open': 1219.45, 'last': 1209.05, 'high': 1226.9, 'low': 1193.35, 'change': -2.09, 'bPrice': 1209.05, 'bQty': 13, 'sPrice': 1209.35, 'sQty': 34, 'ltq': 1, 'avgPrice': 1208.86, 'quotes': 'Quotes Data', 'ttq': 10991550, 'totalBuyQt': 762919, 'totalSellQ': 619405, 'ttv': '1328.72C', 'trend': '', 'lowerCktLm': 1111.4, 'upperCktLm': 1358.3, 'ltt': 'Wed Feb 12 11:12:20 2025', 'close': 1234.85, 'exchange': 'NSE Equity', 'stock_name': 'RELIANCE INDUSTRIES'}
Ticks: {'symbol': '4.1!2885', 'open': 1219.45, 'last': 1209.05, 'high': 1226.9, 'low': 1193.35, 'change': -2.09, 'bPrice': 1209.05, 'bQty': 13, 'sPrice': 1209.35, 'sQty': 34, 'ltq': 1, 'avgPrice': 1208.86, 'quotes': 'Quotes Data', 'ttq': 10991550, 'totalBuyQt': 762919, 'totalSellQ': 619405, 'ttv': '1328.72C', 'trend': '', 'lowerCktLm': 1111.4, 'upperCktLm': 1358.3, 'ltt': 'Wed Feb 12 11:12:20 2025', 'close': 1234.85, 'exchange': 'NSE Equity', 'stock_name': 'RELIANCE INDUSTRIES'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(stock_token="4.1!2885")</p>

<h2>Subscribe to Real Time Streaming of NSE stock</h2>

```python
breeze.subscribe_feeds(exchange_code="NSE",
                        stock_code="NIFTY",
                        product_type="cash",
                        get_market_depth=False,
                        get_exchange_quotes=True)
```
<br>

<details>
  <summary><b>View Response</b></summary>
 
```json
{'message': 'Stock NIFTY subscribed successfully'}
Ticks: {'symbol': '4.1!NIFTY 50', 'open': 24748.7, 'last': 25006.2, 'high': 25029.5, 'low': 24671.45, 'change': 1.03, 'bPrice': None, 'bQty': None, 'sPrice': None, 'sQty': None, 'ltq': None, 'avgPrice': None, 'quotes': 'Quotes Data', 'ttq': None, 'totalBuyQt': None, 'totalSellQ': None, 'ttv': None, 'trend': '+', 'lowerCktLm': None, 'upperCktLm': None, 'ltt': 'Fri Jun  6 15:10:48 2025', 'close': 24750.9, 'exchange': 'NSE Equity', 'stock_name': 'NIFTY 50'}
Ticks: {'symbol': '4.1!NIFTY 50', 'open': 24748.7, 'last': 25006.05, 'high': 25029.5, 'low': 24671.45, 'change': 1.03, 'bPrice': None, 'bQty': None, 'sPrice': None, 'sQty': None, 'ltq': None, 'avgPrice': None, 'quotes': 'Quotes Data', 'ttq': None, 'totalBuyQt': None, 'totalSellQ': None, 'ttv': None, 'trend': '-', 'lowerCktLm': None, 'upperCktLm': None, 'ltt': 'Fri Jun  6 15:10:48 2025', 'close': 24750.9, 'exchange': 'NSE Equity', 'stock_name': 'NIFTY 50'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code="NSE",
                              stock_code="NIFTY",
                              product_type="cash",
                              get_market_depth=False,
                              get_exchange_quotes=True)</p>


<h2>Subscribe to Real Time Streaming OHLCV Data of NFO stocks</h2>

```python 
breeze.subscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False ,
                  get_exchange_quotes=True,
                  interval="1minute")
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock NIFTY subscribed successfully'}
Ticks: {'interval': '1minute', 'exchange_code': 'NFO', 'stock_code': 'NIFTY', 'expiry_date': '13-Feb-2025', 'strike_price': '23550.0', 'right_type': 'CE', 'low': '7.4', 'high': '8.25', 'open': '7.55', 'close': '8.2', 'volume': '354975', 'oi': '4763100', 'datetime': '2025-02-12 12:10:00'}
Ticks: {'interval': '1minute', 'exchange_code': 'NFO', 'stock_code': 'NIFTY', 'expiry_date': '13-Feb-2025', 'strike_price': '23550.0', 'right_type': 'CE', 'low': '7.75', 'high': '8.85', 'open': '8.2', 'close': '7.8', 'volume': '412950', 'oi': '4763100', 'datetime': '2025-02-12 12:11:00'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False ,
                  get_exchange_quotes=True,
                  interval="1minute")</p>

<h2>Subscribe stocks feeds (NFO Exchange Quotes)</h2>

```python 
breeze.subscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False ,
                  get_exchange_quotes=True)
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock NIFTY subscribed successfully'}
Ticks: {'symbol': '4.1!51219', 'open': 11.4, 'last': 8.5, 'high': 11.4, 'low': 3.1, 'change': -28.27, 'bPrice': 8.5, 'bQty': 9300, 'sPrice': 8.6, 'sQty': 8700, 'ltq': 75, 'avgPrice': 5.41, 'quotes': 'Quotes Data', 'OI': 4763100, 'CHNGOI': None, 'ttq': 70816125, 'totalBuyQt': 1974300, 'totalSellQ': 548625, 'ttv': '38.31C', 'trend': '', 'lowerCktLm': 0.05, 'upperCktLm': 39.15, 'ltt': 'Wed Feb 12 12:12:55 2025', 'close': 11.85, 'exchange': 'NSE Futures & Options', 'stock_name': 'NIFTY 50', 'product_type': 'Options', 'expiry_date': '13-Feb-2025', 'strike_price': '23550', 'right': 'Call'}
Ticks: {'symbol': '4.1!51219', 'open': 11.4, 'last': 8.5, 'high': 11.4, 'low': 3.1, 'change': -28.27, 'bPrice': 8.4, 'bQty': 14475, 'sPrice': 8.5, 'sQty': 6750, 'ltq': 75, 'avgPrice': 5.41, 'quotes': 'Quotes Data', 'OI': 4763100, 'CHNGOI': None, 'ttq': 70818150, 'totalBuyQt': 1962375, 'totalSellQ': 558750, 'ttv': '38.31C', 'trend': '', 'lowerCktLm': 0.05, 'upperCktLm': 39.15, 'ltt': 'Wed Feb 12 12:12:54 2025', 'close': 11.85, 'exchange': 'NSE Futures & Options', 'stock_name': 'NIFTY 50', 'product_type': 'Options', 'expiry_date': '13-Feb-2025', 'strike_price': '23550', 'right': 'Call'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False ,
                  get_exchange_quotes=True)</p>


<h2>Subscribe stocks feeds (NFO Market Depth)</h2>

```python 
breeze.subscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=True ,
                  get_exchange_quotes=False)
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock NIFTY subscribed successfully'}
Ticks: {'symbol': '4.2!51219', 'time': 'Wed Feb 12 12:16:18 2025', 'depth': [{'BestBuyRate-1': 7.25, 'BestBuyQty-1': 8475, 'BuyNoOfOrders-1': 17, 'BuyFlag-1': '', 'BestSellRate-1': 7.3, 'BestSellQty-1': 4350, 'SellNoOfOrders-1': 7, 'SellFlag-1': ''}, {'BestBuyRate-2': 7.2, 'BestBuyQty-2': 9675, 'BuyNoOfOrders-2': 17, 'BuyFlag-2': '', 'BestSellRate-2': 7.35, 'BestSellQty-2': 6900, 'SellNoOfOrders-2': 13, 'SellFlag-2': ''}, {'BestBuyRate-3': 7.15, 'BestBuyQty-3': 4800, 'BuyNoOfOrders-3': 10, 'BuyFlag-3': '', 'BestSellRate-3': 7.4, 'BestSellQty-3': 11700, 'SellNoOfOrders-3': 21, 'SellFlag-3': ''}, {'BestBuyRate-4': 7.1, 'BestBuyQty-4': 12825, 'BuyNoOfOrders-4': 19, 'BuyFlag-4': '', 'BestSellRate-4': 7.45, 'BestSellQty-4': 9300, 'SellNoOfOrders-4': 15, 'SellFlag-4': ''}, {'BestBuyRate-5': 7.05, 'BestBuyQty-5': 6300, 'BuyNoOfOrders-5': 9, 'BuyFlag-5': '', 'BestSellRate-5': 7.5, 'BestSellQty-5': 13200, 'SellNoOfOrders-5': 20, 'SellFlag-5': ''}], 'quotes': 'Market Depth', 'stock_name': 'NIFTY 50', 'product_type': 'Options', 'expiry_date': '13-Feb-2025', 'strike_price': '23550', 'right': 'Call'}
Ticks: {'symbol': '4.2!51219', 'time': 'Wed Feb 12 12:16:19 2025', 'depth': [{'BestBuyRate-1': 7.3, 'BestBuyQty-1': 10950, 'BuyNoOfOrders-1': 22, 'BuyFlag-1': '', 'BestSellRate-1': 7.35, 'BestSellQty-1': 3150, 'SellNoOfOrders-1': 3, 'SellFlag-1': ''}, {'BestBuyRate-2': 7.25, 'BestBuyQty-2': 9675, 'BuyNoOfOrders-2': 17, 'BuyFlag-2': '', 'BestSellRate-2': 7.4, 'BestSellQty-2': 10050, 'SellNoOfOrders-2': 18, 'SellFlag-2': ''}, {'BestBuyRate-3': 7.2, 'BestBuyQty-3': 7275, 'BuyNoOfOrders-3': 14, 'BuyFlag-3': '', 'BestSellRate-3': 7.45, 'BestSellQty-3': 12300, 'SellNoOfOrders-3': 19, 'SellFlag-3': ''}, {'BestBuyRate-4': 7.15, 'BestBuyQty-4': 4050, 'BuyNoOfOrders-4': 8, 'BuyFlag-4': '', 'BestSellRate-4': 7.5, 'BestSellQty-4': 15000, 'SellNoOfOrders-4': 21, 'SellFlag-4': ''}, {'BestBuyRate-5': 7.1, 'BestBuyQty-5': 12975, 'BuyNoOfOrders-5': 20, 'BuyFlag-5': '', 'BestSellRate-5': 7.55, 'BestSellQty-5': 6150, 'SellNoOfOrders-5': 12, 'SellFlag-5': ''}], 'quotes': 'Market Depth', 'stock_name': 'NIFTY 50', 'product_type': 'Options', 'expiry_date': '13-Feb-2025', 'strike_price': '23550', 'right': 'Call'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "NFO", 
                  stock_code="NIFTY", 
                  expiry_date="13-Feb-2025", 
                  strike_price="23550", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=True ,
                  get_exchange_quotes=False)</p> 


<h2>Subscribe to Real Time Streaming OHLCV Data of BFO stocks</h2>

```python 
breeze.subscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False,
                  get_exchange_quotes=True,
                  interval="1minute")
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock BSESEN subscribed successfully'}
Ticks: {'interval': '1minute', 'exchange_code': 'BFO', 'stock_code': 'BSESEN', 'expiry_date': '18-Feb-2025', 'strike_price': '78200.0', 'right_type': 'CE', 'low': '83.6', 'high': '89.6', 'open': '89.6', 'close': '83.8', 'volume': '4420', 'oi': '0', 'datetime': '2025-02-12 12:54:00'}
Ticks: {'interval': '1minute', 'exchange_code': 'BFO', 'stock_code': 'BSESEN', 'expiry_date': '18-Feb-2025', 'strike_price': '78200.0', 'right_type': 'CE', 'low': '82.0', 'high': '86.0', 'open': '82.0', 'close': '84.2', 'volume': '3200', 'oi': '0', 'datetime': '2025-02-12 12:55:00'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False,
                  get_exchange_quotes=True,
                  interval="1minute)
                  </p>

<h2>Subscribe stocks feeds (BFO Exchange Quotes)</h2>

```python 
breeze.subscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False,
                  get_exchange_quotes=True)
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock BSESEN subscribed successfully'}
Ticks: {'symbol': '8.1!844663', 'open': 96, 'last': 98, 'high': 105.8, 'low': 35.25, 'change': -2.05, 'bPrice': 96.8, 'bQty': 40, 'sPrice': 97.25, 'sQty': 120, 'ltq': 20, 'avgPrice': 61.87, 'quotes': 'Quotes Data', 'OI': 37020, 'CHNGOI': 12880, 'ttq': 809940, 'totalBuyQt': 30800, 'totalSellQ': 12360, 'ttv': 6338.74, 'trend': '', 'lowerCktLm': 0.05, 'upperCktLm': 505.8, 'ltt': 'Wed Feb 12 12:53:33 2025', 'close': 100.05}
Ticks: {'symbol': '8.1!844663', 'open': 96, 'last': 98, 'high': 105.8, 'low': 35.25, 'change': -2.05, 'bPrice': 96.8, 'bQty': 40, 'sPrice': 97.25, 'sQty': 120, 'ltq': 20, 'avgPrice': 61.87, 'quotes': 'Quotes Data', 'OI': 37020, 'CHNGOI': 12880, 'ttq': 809940, 'totalBuyQt': 30800, 'totalSellQ': 12360, 'ttv': 6338.74, 'trend': '', 'lowerCktLm': 0.05, 'upperCktLm': 505.8, 'ltt': 'Wed Feb 12 12:53:33 2025', 'close': 100.05}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=False,
                  get_exchange_quotes=True)</p>

<h2>Subscribe stocks feeds (BFO Market Depth)</h2>

```python 
breeze.subscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=True ,
                  get_exchange_quotes=False )
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Stock BSESEN subscribed successfully'}
Ticks: {'symbol': '8.2!844663', 'time': 'Wed Feb 12 12:49:50 2025', 'depth': [{'BestBuyRate-1': 87.3, 'BestBuyQty-1': 20, 'BuyNoOfOrders-1': 1, 'BestSellRate-1': 87.8, 'BestSellQty-1': 20, 'SellNoOfOrders-1': 1}, {'BestBuyRate-2': 87.25, 'BestBuyQty-2': 480, 'BuyNoOfOrders-2': 4, 'BestSellRate-2': 87.85, 'BestSellQty-2': 100, 'SellNoOfOrders-2': 2}, {'BestBuyRate-3': 87.2, 'BestBuyQty-3': 520, 'BuyNoOfOrders-3': 2, 'BestSellRate-3': 87.9, 'BestSellQty-3': 500, 'SellNoOfOrders-3': 3}, {'BestBuyRate-4': 87.05, 'BestBuyQty-4': 20, 'BuyNoOfOrders-4': 1, 'BestSellRate-4': 88, 'BestSellQty-4': 100, 'SellNoOfOrders-4': 2}, {'BestBuyRate-5': 86.9, 'BestBuyQty-5': 80, 'BuyNoOfOrders-5': 1, 'BestSellRate-5': 88.1, 'BestSellQty-5': 200, 'SellNoOfOrders-5': 2}], 'quotes': 'Market Depth'}
Ticks: {'symbol': '8.2!844663', 'time': 'Wed Feb 12 12:49:50 2025', 'depth': [{'BestBuyRate-1': 87.3, 'BestBuyQty-1': 20, 'BuyNoOfOrders-1': 1, 'BestSellRate-1': 87.8, 'BestSellQty-1': 20, 'SellNoOfOrders-1': 1}, {'BestBuyRate-2': 87.25, 'BestBuyQty-2': 480, 'BuyNoOfOrders-2': 4, 'BestSellRate-2': 87.85, 'BestSellQty-2': 100, 'SellNoOfOrders-2': 2}, {'BestBuyRate-3': 87.2, 'BestBuyQty-3': 520, 'BuyNoOfOrders-3': 2, 'BestSellRate-3': 87.9, 'BestSellQty-3': 500, 'SellNoOfOrders-3': 3}, {'BestBuyRate-4': 87.05, 'BestBuyQty-4': 20, 'BuyNoOfOrders-4': 1, 'BestSellRate-4': 88, 'BestSellQty-4': 100, 'SellNoOfOrders-4': 2}, {'BestBuyRate-5': 86.9, 'BestBuyQty-5': 80, 'BuyNoOfOrders-5': 1, 'BestSellRate-5': 88.1, 'BestSellQty-5': 200, 'SellNoOfOrders-5': 2}], 'quotes': 'Market Depth'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(exchange_code= "BFO", 
                  stock_code="BSESEN", 
                  expiry_date="18-Feb-2025", 
                  strike_price="78200", 
                  right="call", 
                  product_type="options", 
                  get_market_depth=True ,
                  get_exchange_quotes=False )</p>

<h2>Subscribe oneclick strategy stream</h2>

```python 
breeze.subscribe_feeds(stock_token="one_click_fno")
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
Ticks: {'strategy_date': '2025-02-07 14:29:29', 'modification_date': '2025-02-07 14:29:29', 'portfolio_id': '133444', 'call_action': 'Call Initiated', 'portfolio_name': 'Index Long Call', 'exchange_code': 'NFO', 'product_type': 'options', 'underlying': 'NIFTY ', 'expiry_date': '2025-02-13 00:00:00', 'option_type': 'call', 'strike_price': '23450', 'action': 'buy', 'recommended_price_from': '175', 'recommended_price_to': '178', 'minimum_lot_quantity': '75', 'last_traded_price': '181.45', 'best_bid_price': '181.5', 'best_offer_price': '181.9', 'last_traded_quantity': '23461.65', 'target_price': '240', 'expected_profit_per_lot': '4762.5', 'stop_loss_price': '144.9', 'expected_loss_per_lot': '2370', 'total_margin': '13350', 'leg_no': '1', 'status': 'active'}
Ticks: {'strategy_date': '2025-02-07 14:43:07', 'modification_date': '2025-02-07 14:43:07', 'portfolio_id': '133451', 'call_action': 'Call Initiated', 'portfolio_name': 'Weekly Future Short', 'exchange_code': 'NFO', 'product_type': 'futures', 'underlying': 'INFEDG', 'expiry_date': '2025-02-27 00:00:00', 'option_type': 'others', 'strike_price': '0', 'action': 'sell', 'recommended_price_from': '7830', 'recommended_price_to': '7860', 'minimum_lot_quantity': '75', 'last_traded_price': '7826.45', 'best_bid_price': '7825.4', 'best_offer_price': '7831', 'last_traded_quantity': '7806.65', 'target_price': '7400', 'expected_profit_per_lot': '33375', 'stop_loss_price': '8100.1', 'expected_loss_per_lot': '19132.5', 'total_margin': '133131.2', 'leg_no': '1', 'status': 'active'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(stock_token = "one_click_fno")</p>

<h2>Subscribe oneclick equity strategy stream(i_click_2_gain)</h2>

```python
breeze.subscribe_feeds(stock_token="i_click_2_gain") 
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'i_click_2_gain streaming subscribed successfully.'}
Tick Data: {'stock_name': 'MAHINDRA & MAHINDRA LIMITED(MAHMAH)Margin-Buy', 'stock_code': 'MAHMAH', 'action_type': 'buy', 'expiry_date': '', 'strike_price': '', 'option_type': '', 'stock_description': 'Margin', 'recommended_price_and_date': '3065-3068,2025-01-02 08:55:02', 'recommended_price_from': '3065', 'recommended_price_to': '3068', 'recommended_date': '2025-01-02 08:55:02', 'target_price': '3098', 'sltp_price': '3050', 'part_profit_percentage': '0,0', 'profit_price': '0', 'exit_price': '0', 'recommended_update': '     ', 'iclick_status': 'open', 'subscription_type': 'iclick_2_gain                 '}
Tick Data: {'stock_name': 'POWER FINANCE CORPORATION LTD(POWFIN)Margin-Buy', 'stock_code': 'POWFIN', 'action_type': 'buy', 'expiry_date': '', 'strike_price': '', 'option_type': '', 'stock_description': 'Margin', 'recommended_price_and_date': '450-451,2025-01-02 09:37:01', 'recommended_price_from': '450', 'recommended_price_to': '451', 'recommended_date': '2025-01-02 09:37:01', 'target_price': '456', 'sltp_price': '447', 'part_profit_percentage': '0,0', 'profit_price': '0', 'exit_price': '0', 'recommended_update': '     ', 'iclick_status': 'open', 'subscription_type': 'iclick_2_gain'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(stock_token = "i_click_2_gain")</p>


<h2>Subscribe to multiple stock tokens</h2>

```python 
breeze.subscribe_feeds(stock_token=['4.1!3499','4.1!2885'])
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': "Stock ['4.1!3499', '4.1!2885'] subscribed successfully"}

Ticks: {'symbol': '4.1!3499', 'open': 146.79, 'last': 148.32, 'high': 149.49, 'low': 146.2, 'change': 1.52, 'bPrice': 148.3, 'bQty': 2880, 'sPrice': 148.32, 'sQty': 5480, 'ltq': 20, 'avgPrice': 148.23, 'quotes': 'Quotes Data', 'ttq': 21831757, 'totalBuyQt': 2187011, 'totalSellQ': 3921071, 'ttv': '323.61C', 'trend': '', 'lowerCktLm': 131.49, 'upperCktLm': 160.71, 'ltt': 'Thu Mar  6 09:56:18 2025', 'close': 146.1, 'exchange': 'NSE Equity', 'stock_name': 'TATA STEEL LIMITED'}
Ticks: {'symbol': '4.1!2885', 'open': 1197, 'last': 1189.05, 'high': 1200.5, 'low': 1185.15, 'change': 1.16, 'bPrice': 1189.05, 'bQty': 92, 'sPrice': 1189.2, 'sQty': 175, 'ltq': 308, 'avgPrice': 1194.59, 'quotes': 'Quotes Data', 'ttq': 4073591, 'totalBuyQt': 512163, 'totalSellQ': 661691, 'ttv': '486.63C', 'trend': '', 'lowerCktLm': 1058.05, 'upperCktLm': 1293.15, 'ltt': 'Thu Mar  6 09:56:19 2025', 'close': 1175.6, 'exchange': 'NSE Equity', 'stock_name': 'RELIANCE INDUSTRIES'}
Ticks: {'symbol': '4.1!3499', 'open': 146.79, 'last': 148.32, 'high': 149.49, 'low': 146.2, 'change': 1.52, 'bPrice': 148.3, 'bQty': 2880, 'sPrice': 148.32, 'sQty': 5480, 'ltq': 20, 'avgPrice': 148.23, 'quotes': 'Quotes Data', 'ttq': 21831757, 'totalBuyQt': 2187011, 'totalSellQ': 3921071, 'ttv': '323.61C', 'trend': '', 'lowerCktLm': 131.49, 'upperCktLm': 160.71, 'ltt': 'Thu Mar  6 09:56:19 2025', 'close': 146.1, 'exchange': 'NSE Equity', 'stock_name': 'TATA STEEL LIMITED'}
Ticks: {'symbol': '4.1!2885', 'open': 1197, 'last': 1189.2, 'high': 1200.5, 'low': 1185.15, 'change': 1.16, 'bPrice': 1189.05, 'bQty': 223, 'sPrice': 1189.2, 'sQty': 262, 'ltq': 2, 'avgPrice': 1194.58, 'quotes': 'Quotes Data', 'ttq': 4073999, 'totalBuyQt': 515067, 'totalSellQ': 662343, 'ttv': '486.67C', 'trend': '', 'lowerCktLm': 1058.05, 'upperCktLm': 1293.15, 'ltt': 'Thu Mar  6 09:56:19 2025', 'close': 1175.6, 'exchange': 'NSE Equity', 'stock_name': 'RELIANCE INDUSTRIES'}

```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(stock_token=['4.1!3499','4.1!2885'])</p>

<h2>Subscribe to order notifications</h2>

```python 
breeze.subscribe_feeds(get_order_notification=True)
```
<br>

<details>
  <summary><b>View Response</b></summary>

```json
{'message': 'Order Notification subscribed successfully'}
```
</details>
<h4> NOTE : </h4>
<p>For unsubscribe : breeze.unsubscribe_feeds(get_order_notification=True)</p>

<br>
<hr>
<h3> ADDITIONAL NOTES </h3>
<hr>
<ol>
<li>Examples for stock_token are "4.1!38071" or "1.1!500780".</li>
<li>Template for stock_token : X.Y! 
    <ul>
    <li>X : exchange code </li>
    <li>Y : Market Level data </li>
    <li>Token : ISEC stock code</li>
    </ul>
        
<li>Value of X can be : 
    <ul>
        <li> 1 for BSE(equity) </li>
        <li> 2 for BFO OHLC Data </li>
        <li> 4 for NSE </li> 
        <li> 4 for NFO </li>
        <li> 8 for BFO live Data </li>
    </ul>
</li>      
<li>Value of Y can be : 
    <ul>
        <li> 1 for Exchange Quote data </li>
        <li> 2 for Market Depth data </li></ul></li>
<li>Token number can be obtained via get_names() function or downloading master security file via 
    https://api.icicidirect.com/breezeapi/documents/index.html#instruments</li>
<li>Exchange_code must be 
    <ul>
        <li>BSE </li>
        <li>NSE</li> 
        <li>BFO </li>
        <li>NFO </li>
      </ul>
</li>
<li>Stock Code Validation: The stock_code field cannot be left empty. Valid examples include "WIPRO" or "ZEEENT".</li>
<li>Product_type Requirements: Acceptable values are 'Futures', 'Options', or a non-empty string. For exchanges NFO, this field must not be left empty.
</li>
<li>Expiry_date Format: Should be in DD-MMM-YYYY format (e.g., 01-Jan-2022), and cannot be empty for NFO exchanges.</li>
<li>Strike_price Format: Must be a float value represented as a string or remain empty. For Options under product_type, this field must not be empty.</li>
<li>Right Field Requirements: Acceptable values are 'Put', 'Call', or an empty string. For Options, this field cannot be left empty.</li>
<li>get_exchange_quotes and get_market_depth Validation: At least one must be set to True. Both can be True, but both cannot be False.
</li>
<li>OHLCV Streaming Interval: The interval field cannot be empty and must be one of the following values: "1second", "1minute", "5minute", or "30minute".</li>

</ol>
<br>

<hr>
<h2> List of other APIs:</h2>

<h3 id="index_title" >Index</h3>

<div class="sticky" id="index">
<ul>
 <li><a href="#customer_detail">get_customer_details</a></li>
 <li><a href="#demat_holding">get_demat_holdings</a></li>
 <li><a href="#get_funds">get_funds</a></li>
 <li><a href="#set_funds">set_funds</a></li>
 <li><a href="#historical_data1">get_historical_data</a></li>
 <li><a href="#historical_data_v21">get_historical_data_v2</a></li>
 <!-- <li><a href="#add_margin">add_margin</a></li> -->
 <li><a href="#get_margin">get_margin</a></li>
 <li><a href="#place_order">place_order</a></li>
 <li><a href="#order_detail">order_detail</a></li>
 <li><a href="#order_list">order_list</a></li>
 <li><a href="#cancel_order">cancel_order</a></li>
 <li><a href="#modify_order">modify_order</a></li>
 <li><a href="#portfolio_holding">get_portfolio_holding</a></li>
 <li><a href="#portfolio_position">get_portfolio_position</a></li>
 <li><a href="#get_quotes">get_quotes</a></li>
 <li><a href="#get_option_chain">get_option_chain_quotes</a></li>
 <li><a href="#square_off2">square_off</a></li>
 <li><a href="#trade_list">get_trade_list</a></li>
 <li><a href="#trade_detail">get_trade_detail</a></li>
 <li><a href="#get_names"> get_names </a></li>
 <li><a href="#preview_order"> preview_order </a></li>
 <li><a href="#limit_calculator"> limit_calculator </a></li>
 <li><a href="#margin_calculator"> margin_calculator </a></li>
 <li><a href="#gtt_three_leg_place_order"> gtt_three_leg_place_order </a></li>
 <li><a href="#gtt_three_leg_modify_order"> gtt_three_leg_modify_order </a></li>
 <li><a href="#gtt_three_leg_cancel_order"> gtt_three_leg_cancel_order </a></li>
 <li><a href="#gtt_single_leg_place_order"> gtt_single_leg_place_order </a></li>
 <li><a href="#gtt_single_leg_modify_order"> gtt_single_leg_modify_order </a></li>
 <li><a href="#gtt_single_leg_cancel_order"> gtt_single_leg_cancel_order </a></li>
  <li><a href="#gtt_order_book"> gtt_order_book </a></li>


 <!--<li><a href="#limit_calculator"> limit calculator </a></li>-->
</ul>
</div>

<br>
<h3 id="customer_detail" >Get Customer details by api-session value</h3>

```python
breeze.get_customer_details(api_session="your_api_session") 
```
<br>

<!-- ### API Response: -->
<details>
  <summary><b>View API Response</b></summary>

  ```json
  {
    "Success": {
        "exg_trade_date": {
            "NSE": "04-Feb-2025",
            "BSE": "04-Feb-2025",
            "FNO": "04-Feb-2025",
            "NDX": "12-Feb-2025"
        },
        "exg_status": {
            "NSE": "O",
            "BSE": "O",
            "FNO": "Y",
            "NDX": "X"
        },
        "segments_allowed": {
            "Trading": "Y",
            "Equity": "Y",
            "Derivatives": "Y",
            "Currency": "Z"
        },
        "idirect_userid": "XY604721",
        "session_token": "SNjhweuihjndmsbdhjqgy*",
        "idirect_user_name": "JOHN SMITH",
        "idirect_ORD_TYP": "N",
        "idirect_lastlogin_time": "04-Feb-2025 15:07:17",
        "mf_holding_mode_popup_flg": "N",
        "commodity_exchange_status": "Y",
        "commodity_trade_date": "04-Feb-2025",
        "commodity_allowed": "O"
    },
    "Status": 200,
    "Error": null
}

  ```
</details>

<br>
<a href="#index">Back to Index</a> 
<hr>


<h3 id="demat_holding">Get Demat Holding details</h3>

```python
breeze.get_demat_holdings()
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': 
    [{'stock_code': 'UNITEC',
    'stock_ISIN': 'INE694A01020',
    'quantity': '1',
    'demat_total_bulk_quantity': '1',
    'demat_avail_quantity': '0',
    'blocked_quantity': '0',
    'demat_allocated_quantity': '1'
    }],
 'Status': 200,
 'Error': None}

  ```
</details>

<br>
<a href="#index">Back to Index</a>
<hr>


<h3 id="get_funds">Get Funds</h3>


```python
breeze.get_funds()
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': 
    {'bank_account': '123456789012',
    'total_bank_balance': 800000000.0,
    'allocated_equity': 200000000.0,
    'allocated_fno': 200000000.0,
    'allocated_commodity': 200000000.0,
    'allocated_currency': 200000000.0,
    'block_by_trade_equity': 0.0,
    'block_by_trade_fno': 12500000.53,
    'block_by_trade_commodity': 0.0,
    'block_by_trade_currency': 0.0,
    'block_by_trade_balance': 15500000,
    'unallocated_balance': '87500000'},
 'Status': 200,
 'Error': None}

  ```
</details>

<br>
<a href="#index">Back to Index</a>
<hr>

<h3 id="set_funds">Set Funds</h3>

```python
breeze.set_funds(transaction_type="debit", 
                    amount="200",
                    segment="Equity")
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': {'status': 'Success'},
         'Status': 200, 'Error': None}

  ```
</details>

<h4> NOTE: </h4>
<p> <ol> <li>For adding fund, transaction_type="credit", amount="200", segment="Equity".</li>
       <li>Segment can be Equity, FNO, Commodity </li> </ol></p>
<a href="#index">Back to Index</a>
<hr>


<h3 id="historical_data1">Historical Data : Futures</h3>


```python
breeze.get_historical_data(interval="1minute",
                  from_date= "2025-02-03T09:21:00.000Z",
                  to_date= "2025-02-03T09:21:00.000Z",
                  stock_code="NIFTY",
                  exchange_code="NFO",
                  product_type="futures",
                  expiry_date="2025-02-27T07:00:00.000Z",
                  right="others",
                  strike_price="0")                    
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': [
    {'datetime': '2025-02-03 09:21:00',
     'stock_code': 'NIFTY',
     'exchange_code': 'NFO',
     'product_type': 'Futures',
     'expiry_date': '27-FEB-25',
     'right': 'Others',
     'strike_price': '0',
     'open': '23346.6',
     'high': '23350.9',
     'low': '23338.6',
     'close': '23338.6',
     'volume': '81600',
     'open_interest': '17543475',
     'count': 6},
    {'datetime': '2025-02-03 09:22:00',
     'stock_code': 'NIFTY',
     'exchange_code': 'NFO',
     'product_type': 'Futures',
     'expiry_date': '27-FEB-25',
     'right': 'Others',
     'strike_price': '0',
     'open': '23338.3',
     'high': '23347.95',
     'low': '23337.1',
     'close': '23342',
     'volume': '56025',
     'open_interest': '17543475',
     'count': 7}],
 'Status': 200,
 'Error': None}

  ```
</details>

<h4> NOTE: </h4>
<p><ol><li>The historical data provided does not account for corporate adjusted data. </li></ol></p>

<br>
<a href="#index">Back to Index</a>
<hr>

<h3 id="historical_data2">Historical Data : Equity</h3>

```python
breeze.get_historical_data(interval="1minute",
                  from_date= "2025-02-03T09:20:00.000Z",
                  to_date= "2025-02-03T09:22:00.000Z",
                  stock_code="RELIND",
                  exchange_code="NSE",
                  product_type="cash")
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': [
    {'datetime': '2025-02-03 09:21:00',
   'stock_code': 'RELIND',
   'exchange_code': 'NSE',
   'product_type': None,
   'expiry_date': None,
   'right': None,
   'strike_price': None,
   'open': '1249.85',
   'high': '1250.75',
   'low': '1248.95',
   'close': '1249.95',
   'volume': '1951',
   'open_interest': None,
   'count': 7},
  {'datetime': '2025-02-03 09:22:00',
   'stock_code': 'RELIND',
   'exchange_code': 'NSE',
   'product_type': None,
   'expiry_date': None,
   'right': None,
   'strike_price': None,
   'open': '1249.75',
   'high': '1250.5',
   'low': '1247.95',
   'close': '1249',
   'volume': '1810',
   'open_interest': None,
   'count': 8}],
 'Status': 200,
 'Error': None}

  ```
</details>

<h4> NOTE: </h4>
<p><ol><li>The historical data provided does not account for corporate adjusted data. </li></ol></p>

<br>
<a href="#index">Back to Index</a>

<hr>

<h3 id="historical_data3">Historical Data : Options</h3>

```python
breeze.get_historical_data(interval="1minute",
                  from_date= "2025-02-03T09:20:00.000Z",
                  to_date= "2025-02-03T09:22:00.000Z",
                  stock_code="NIFTY",
                  exchange_code="NFO",
                  product_type="options",
                  expiry_date="2025-02-06T07:00:00.000Z",
                  right="call",
                  strike_price="23200")
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Success': [
    {'datetime': '2025-02-03 09:21:00',
      'stock_code': 'NIFTY',
      'exchange_code': 'NFO',
      'product_type': 'Options',
      'expiry_date': '06-FEB-25',
      'right': 'Call',
      'strike_price': '23200',
      'open': '201.15',
      'high': '203.9',
      'low': '195.5',
      'close': '197.55',
      'volume': '304575',
      'open_interest': '2435175',
      'count': 6},
    {'datetime': '2025-02-03 09:22:00',
      'stock_code': 'NIFTY',
      'exchange_code': 'NFO',
      'product_type': 'Options',
      'expiry_date': '06-FEB-25',
      'right': 'Call',
      'strike_price': '23200',
      'open': '196.85',
      'high': '201.8',
      'low': '196.5',
      'close': '200.3',
      'volume': '249000',
      'open_interest': '2435175',
      'count': 7}],
 'Status': 200,
 'Error': None}

  ```
</details>
<h4> NOTE: </h4>
<p> <ol><li>Get Historical Data for specific stock-code by mentioned interval either as "1minute", "5minute", "30minute" or as "1day" </li>
<li>The historical data provided does not account for corporate adjusted data. </li></ol></p>


<a href="#index">Back to Index</a>
<hr>

<h3 id="historical_data_v21">Historical Data V2 : FUTURES</h3>


```python
breeze.get_historical_data_v2(interval="1minute",
                  from_date= "2025-02-03T09:21:00.000Z",
                  to_date= "2025-02-03T09:21:00.000Z",
                  stock_code="NIFTY",
                  exchange_code="NFO",
                  product_type="futures",
                  expiry_date="2025-02-27T07:00:00.000Z",
                  right="others",
                  strike_price="0")                      
```
<br>

<details>
  <summary><b>View API Response</b></summary>

  ```json
  {'Error': None,
 'Status': 200,
 'Success': [{'close': 23338.6,
   'datetime': '2025-02-03 09:21:00',
   'exchange_code': 'NFO',
   'expiry_date': '27-FEB-2025',
   'high': 23352.15,
   'low': 23337.95,
   'open': 23348.0,
   'open_interest': 17543475,
   'product_type': 'Futures',
   'stock_code': 'NIFTY',
   'volume': 88800}]}

  ```
</details>

<h4> NOTE: </h4>
<ol><li>Prod