Skip to main content

ICICI Connect Breeze

Project description

Breeze Connect SDK

This is a package to integrate streaming stocks for subscribed users & call APIs through which you can fetch live/historical data, automate your trading strategies, and monitor your portfolio in real time.

Installing the client

You can install the 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.0

Websocket Usage

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
breeze.ws_connect()

# Callback to receive ticks.
def on_ticks(ticks):
    "Ticks: {}".format(ticks)

# Assign the callbacks.
breeze.on_ticks = on_ticks

# subscribe stocks feeds
breeze.subscribe_feeds(exchange_code="NFO", stock_code="ZEEENT", product_type="options", expiry_date="27-Jan-2022", strike_price="425", right="call", get_exchange_quotes=True, get_market_depth=False)

# subscribe stocks feeds by stock-token
breeze.subscribe_feeds(stock_token="1.1!500780")

# unsubscribe stocks feeds
breeze.unsubscribe_feeds(exchange_code="NFO", stock_code="ZEEENT", product_type="options", expiry_date="27-Jan-2022", strike_price="425", right="call", get_exchange_quotes=True, get_market_depth=False)

# unsubscribe stocks feeds by stock-token
breeze.unsubscribe_feeds(stock_token="1.1!500780")

API Usage

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
iso_date_string = datetime.datetime.strptime("31/12/2021","%d/%m/%Y").isoformat()[:10] + 'T05:30:00.000Z'
iso_date_time_string = datetime.datetime.strptime("31/12/2021 23:59:59","%d/%m/%Y %H:%M:%S").isoformat()[:19] + '.000Z'

# Following are the complete list of API method:

# Get Demat Holding details of your account.
breeze.get_demat_holdings()

# Get Funds details of your account.
breeze.get_funds()

# Set Funds of your account by transaction-type as "Credit" or "Debit" with amount in numeric string as rupees and segment-type as "Equity" or "FNO".
breeze.set_funds(transaction_type="debit", 
                    amount="200",
                    segment="Equity")

# Get Historical Data for specific stock-code by mentioned interval either as "minute", "5minute", "30minutes" or as "day".
breeze.get_historical_data(interval="1minute",
                            from_date= "2021-11-15T07:00:00.000Z",
                            to_date= "2021-11-17T07:00:00.000Z",
                            stock_code="AXIBAN",
                            exchange_code="NFO",
                            product_type="futures",
                            expiry_date="2021-11-25T07:00:00.000Z",
                            option_type="others",
                            strike_price="0")

# Add Margin to your account.
breeze.add_margin(exchange_code="BSE",
                    product_type="margin",
                    stock_code="TCS",
                    order_settlement="2021220",
                    add_amount="100",
                    margin_amount="3817.10",
                    open_quantity="10",
                    cover_quantity="0",
                    category_INDSTK="",
                    add_margin_amount="",
                    expiry_date="",
                    option_type="")

# Get Margin of your account.
breeze.get_margin(exchange_code="NSE")

# Place an order from your account.
breeze.place_order(stock_code="AXIBAN",
                    exchange_code="NFO",
                    product="futures",
                    action="buy",
                    order_type="limit",
                    stoploss="0",
                    quantity="1200",
                    price="712.00",
                    validity="day",
                    validity_date="2021-12-16T06:00:00.000Z",
                    disclosed_quantity="0",
                    expiry_date="2021-12-25T06:00:00.000Z",
                    right="others",
                    strike_price="0",
                    user_remark="Test")

# Get an order details by exchange-code and order-id from your account.
breeze.get_order_detail(exchange_code="NSE",
                            order_id="20211116N100000023")

# Get order list of your account.
breeze.get_order_list(exchange_code="NSE",
                          from_date="2021-11-01T10:00:00.000Z",
                          to_date="2021-11-30T10:00:00.000Z")

# Cancel an order from your account whose status are not Executed. 
breeze.cancel_order(exchange_code="NSE",
                              order_id="20211116N100000022")

# Modify an order from your account whose status are not Executed. 
breeze.modify_order(order_id="202111241100000002",
                              exchange_code="NFO",
                              order_type="limit",
                              stoploss="0",
                              quantity="250",
                              price="290100",
                              validity="day",
                              disclosed_quantity="0",
                              validity_date="2021-12-30T06:00:00.000Z")

# Get Portfolio Holdings of your account.
breeze.get_portfolio_holdings(exchange_code="NFO",
                                  from_date="2021-11-01T06:00:00.000Z",
                                  to_date="2021-11-30T06:00:00.000Z",
                                  underlying="",
                                  portfolio_type="")

# Get Portfolio Positions from your account.
breeze.get_portfolio_positions()

# Get quotes of mentioned stock-code
breeze.get_quotes(stock_code="AXIBAN",
                      exchange_code="NFO",
                      expiry_date="2021-12-30T06:00:00.000Z",
                      product_type="futures",
                      right="others",
                      strike_price="0")

# Sqauare off an order
breeze.square_off(source_flag="",
                 stock_code="NIFTY",
                 exchange_code="NFO",
                 quantity="50",
                 price="0",
                 order_flow="sell",
                 order_type="market",
                 validity="day",
                 stoploss="0",
                 disclosed_quantity="0",
                 protection_percentage="",
                 segment_code="",
                 order_settlement="",
                 margin_amount="",
                 open_quantity="",
                 cover_quantity="",
                 product="futures",
                 expiry_date="2021-12-30T06:00:00.000Z",
                 exercise_type="",
                 option_type="",
                 strike_price="0",
                 trade_date="2021-12-16T06:00:00.000Z",
                 trade_password="",
                 option_exercise_type="*E")

# Get trade list of your account.
breeze.get_trade_list(from_date="2021-09-28T06:00:00.000Z",
                          to_date="2021-11-15T06:00:00.000Z",
                          exchange_code="NSE",
                          product_type="",
                          action="",
                          stock_code="")

# Get trade detail of your account.
breeze.get_trade_detail(exchange_code="NSE",
                            order_id="20210928N100000067")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

breeze_connect-1.0.11.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

breeze_connect-1.0.11-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file breeze_connect-1.0.11.tar.gz.

File metadata

  • Download URL: breeze_connect-1.0.11.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for breeze_connect-1.0.11.tar.gz
Algorithm Hash digest
SHA256 a5e416a6e95291ee588f7c091829ef08295d5c6a3ba47f28a638b12ca2cadb12
MD5 c25cc71d7d6431beb02d96d599257b4e
BLAKE2b-256 bef6e926d041836e2d1e45aaad98f29697f9e40765b9958f2eee0aacbb83d266

See more details on using hashes here.

File details

Details for the file breeze_connect-1.0.11-py3-none-any.whl.

File metadata

  • Download URL: breeze_connect-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for breeze_connect-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c0a6bf160904a9a54f7cb8119e7f478710f71cac2f237fd22af27102a6d291
MD5 0cd7c31aa4cf09869bd949313ce59cd6
BLAKE2b-256 0140ef869e9a638e2b68a3ebfcbfb384c28f383e67db9e41d5fb5597b6ca0bad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page