### Installation and Session Initialization Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Install the library via pip and generate a session by logging in through the ICICI Direct API login URL, then passing the obtained session token to `generate_session()`. This process downloads the security master, authenticates credentials, and initializes all API handlers. ```APIDOC ## Installation and Session Initialization Install via pip and generate a session by logging in through the ICICI Direct API login URL, then passing the obtained session token to `generate_session()`. This downloads the security master, authenticates credentials, and initializes all API handlers. ```python # pip install breeze-connect==1.0.68 import urllib from breeze_connect import BreezeConnect API_KEY = "your_api_key" API_SECRET = "your_secret_key" # Step 1: Visit this URL in a browser and copy the session_token from the redirect login_url = "https://api.icicidirect.com/apiuser/login?api_key=" + urllib.parse.quote_plus(API_KEY) print("Login URL:", login_url) # Step 2: Initialize and authenticate breeze = BreezeConnect(api_key=API_KEY) breeze.generate_session( api_secret=API_SECRET, session_token="your_session_token_from_redirect" ) # generate_session() internally: # - Validates credentials via GET /customerdetails # - Decodes base64 user_id and session_key # - Downloads and parses SecurityMaster.zip for all exchanges # - Creates the ApificationBreeze HTTP handler print("Session initialized for user:", breeze.user_id) ``` ``` -------------------------------- ### Install Latest Breeze Connect Client Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Install the latest stable release of the breeze-connect Python package using pip. Ensure your virtual environment is activated. ```bash pip install --upgrade breeze-connect ``` -------------------------------- ### Install and Initialize BreezeConnect Session Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Install the library via pip and generate a session by logging in through the ICICI Direct API login URL. Pass the obtained session token to generate_session() to download the security master, authenticate credentials, and initialize API handlers. ```python # pip install breeze-connect==1.0.68 import urllib from breeze_connect import BreezeConnect API_KEY = "your_api_key" API_SECRET = "your_secret_key" # Step 1: Visit this URL in a browser and copy the session_token from the redirect login_url = "https://api.icicidirect.com/apiuser/login?api_key=" + urllib.parse.quote_plus(API_KEY) print("Login URL:", login_url) # Step 2: Initialize and authenticate breeze = BreezeConnect(api_key=API_KEY) breeze.generate_session( api_secret=API_SECRET, session_token="your_session_token_from_redirect" ) # generate_session() internally: # - Validates credentials via GET /customerdetails # - Decodes base64 user_id and session_key # - Downloads and parses SecurityMaster.zip for all exchanges # - Creates the ApificationBreeze HTTP handler print("Session initialized for user:", breeze.user_id) ``` -------------------------------- ### Install virtualenv Package Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Install the virtualenv package using pip. This is a prerequisite for creating virtual environments. ```bash pip install virtualenv ``` -------------------------------- ### Install Specific Breeze Connect Version Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Install a specific version of the breeze-connect Python package, such as 1.0.68, using pip. This is useful for maintaining compatibility. ```bash pip install breeze-connect==1.0.68 ``` -------------------------------- ### API Response Example Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md This JSON structure represents a successful API response for margin calculations and order details. ```json { "Success": { "margin_calulation": [ { "strike_price": "0", "quantity": "30", "right": "Others", "product": "Futures", "action": "Buy", "price": "49500", "expiry_date": "27-Feb-2025", "stock_code": "CNXBAN" }, { "strike_price": "50000", "quantity": "30", "right": "Call", "product": "Options", "action": "Buy", "price": "1150", "expiry_date": "27-Feb-2025", "stock_code": "CNXBAN" }, { "strike_price": "0", "quantity": "75", "right": "Others", "product": "Futures", "action": "Buy", "price": "23400", "expiry_date": "27-Feb-2025", "stock_code": "NIFTY " }, { "strike_price": "23400", "quantity": "75", "right": "Call", "product": "Options", "action": "Buy", "price": "577", "expiry_date": "27-Feb-2025", "stock_code": "NIFTY " } ], "non_span_margin_required": "0", "order_value": "493011.26", "order_margin": "0", "trade_margin": null, "block_trade_margin": "0", "span_margin_required": "493011.26" }, "Status": 200, "Error": null } ``` -------------------------------- ### Get Order List with Breeze Python SDK Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Fetch a list of orders within a specified date range. Provide the exchange code and the start and end dates for the query. Similar to order details, use 'NFO' for exchange code when querying F&O orders. ```python breeze.get_order_list(exchange_code="NSE", from_date="2025-02-05T10:00:00.000Z", to_date="2025-02-05T10:00:00.000Z") ``` -------------------------------- ### Get Portfolio Positions - Python Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieve the user's current portfolio positions. This function does not require any parameters. ```python breeze.get_portfolio_positions() ``` -------------------------------- ### GTT Order Details Example Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md This snippet displays the structure of a GTT order, including leg type, action, prices, and status. It also shows the associated order details like exchange, product type, and stock information. ```python { 'gtt_leg_type': 'Stoploss', 'action': 'Sell', 'trigger_price': 5.0, 'limit_price': 4.0, 'status': 'Cancelled', 'gtt_order_id': '2025020500001234' }], 'exchange_code': 'NFO', 'product_type': 'Options', 'stock_code': 'NIFTY', 'expiry_date': '06-Feb-2025', 'strike_price': 24000.0, 'right': 'Call', 'quantity': 75, 'index_or_stock': 'Index', 'gtt_type': 'Cover OCO', 'fresh_order_id': '202502052500001234', 'order_datetime': '05-FEB-2025 11:14:38' }], 'Status': 200, 'Error': None } ``` -------------------------------- ### Get Portfolio Positions Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the user's current open positions across all segments. ```APIDOC ## Get Portfolio Positions ### Description Retrieves a list of the user's current open positions, including details like segment, product type, and P&L. ### Method `get_portfolio_positions` ### Parameters This method does not require any parameters. ### Request Example ```python breeze.get_portfolio_positions() ``` ### Response #### Success Response - **Success** (array) - An array of position objects, each containing: - **segment** (string) - The trading segment (e.g., "fno"). - **product_type** (string) - The type of product (e.g., "Options"). - **exchange_code** (string) - The exchange code (e.g., "NFO"). - **stock_code** (string) - The stock symbol. - **expiry_date** (string) - Expiry date if applicable. - **strike_price** (string) - Strike price if applicable. - **right** (string) - Option right (e.g., "Call"). - **action** (string) - Action taken (e.g., "NA"). - **quantity** (string) - The number of units held. - **average_price** (string) - The average purchase price. - **settlement_id** (null) - Settlement ID. - **margin_amount** (null) - Margin amount. - **ltp** (string) - Last Traded Price. - **price** (string) - The order price. - **stock_index_indicator** (string) - Indicator for stock/index. - **cover_quantity** (string) - Cover order quantity. - **stoploss_trigger** (string) - Stoploss trigger price. - **stoploss** (null) - Stoploss price. - **take_profit** (null) - Take profit price. - **available_margin** (null) - Available margin. - **squareoff_mode** (null) - Squareoff mode. - **mtf_sell_quantity** (null) - MTF sell quantity. - **mtf_net_amount_payable** (null) - MTF net amount payable. - **mtf_expiry_date** (null) - MTF expiry date. - **order_id** (string) - Order ID. - **cover_order_flow** (null) - Cover order flow details. - **cover_order_executed_quantity** (null) - Executed quantity for cover order. - **pledge_status** (null) - Pledge status. - **pnl** (null) - Profit or Loss. - **underlying** (string) - Underlying asset. - **order_segment_code** (null) - Order segment code. - **Status** (integer) - HTTP status code, expected to be 200. - **Error** (null) - Should be null on success. ``` -------------------------------- ### Get Portfolio Holdings - Python Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieve a user's portfolio holdings for a specified date range and exchange. For Equity holdings, set exchange_code to 'NSE'. ```python breeze.get_portfolio_holdings(exchange_code="NFO", from_date="2024-08-01T06:00:00.000Z", to_date="2024-09-19T06:00:00.000Z", stock_code="", portfolio_type="") ``` -------------------------------- ### Get 1-minute historical data for Equity, Futures, and Options Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Fetches historical OHLCV data for specified instruments. Ensure correct exchange, product type, and date parameters are provided. For futures and options, expiry date and strike price are also required. ```python equity_hist = 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" ) futures_hist = 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" ) options_hist = 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" ) # Response structure for each candle: # {"datetime": "2025-02-03 09:21:00", "stock_code": "NIFTY", "exchange_code": "NFO", # "open": "201.15", "high": "203.9", "low": "195.5", "close": "197.55", # "volume": "304575", "open_interest": "2435175", "count": 6} for candle in options_hist.get("Success", []): print(candle["datetime"], candle["open"], candle["close"]) ``` -------------------------------- ### Get Customer Details Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves customer details using an API session token. Ensure you have a valid api_session value. ```python breeze.get_customer_details(api_session="your_api_session") ``` -------------------------------- ### Get Portfolio Holdings and Positions Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Retrieves settled P&L and charges for a date range using `get_portfolio_holdings()`. `get_portfolio_positions()` returns current open positions with LTP, unrealized P&L, and margin info. ```python # Holdings for NFO segment over a date range holdings = breeze.get_portfolio_holdings( exchange_code="NFO", from_date="2024-08-01T06:00:00.000Z", to_date="2024-09-19T06:00:00.000Z", stock_code="", portfolio_type="" ) for h in holdings.get("Success", []): print(f"{h['stock_code']} {h['product_type']}: realized={h['realized_profit']}") # All open positions positions = breeze.get_portfolio_positions() for pos in positions.get("Success", []): print(f"{pos['stock_code']} {pos.get('product_type','')} lp={pos['ltp']}qty={pos['quantity']}") ``` -------------------------------- ### Get Historical Data V2 for Equity Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Fetches historical data for equity instruments. Requires interval, date range, stock code, exchange code, and product type (set to 'cash'). ```python breeze.get_historical_data_v2(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") ``` -------------------------------- ### Get Margin Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the margin details for your account. You can specify the exchange code to get specific margin details, for example, 'NFO' for F&O margin. ```APIDOC ## Get Margin ### Description Retrieves the margin details for your account. You can specify the exchange code to get specific margin details, for example, 'NFO' for F&O margin. ### Method ```python breeze.get_margin(exchange_code="NSE") ``` ### Parameters #### Query Parameters - **exchange_code** (string) - Required - The code of the exchange (e.g., "NSE", "NFO"). ### Response #### Success Response (200) - **Success** (object) - Contains margin details like cash_limit, amount_allocated, etc. - **Status** (integer) - The status code of the response. - **Error** (null) - Null if the request was successful. ### Response Example ```json { "Success": { "limit_list": [], "cash_limit": 1000000.00, "amount_allocated": 100000.00, "block_by_trade": 0.0, "isec_margin": 0.0 }, "Status": 200, "Error": null } ``` ``` -------------------------------- ### Place Equity Order - Buy Limit Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Places a buy limit order for an equity cash product. ```python breeze.place_order(stock_code="ITC", exchange_code="NSE", product="cash", action="buy", order_type="limit", stoploss="", quantity="1", price="420", validity="day" ) ``` -------------------------------- ### Initialize BreezeConnect and Generate Session Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Initialize the BreezeConnect client with your API key and generate a session using your secret key and session token. Includes a helper to generate the login URL with an encoded API key. ```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") ``` -------------------------------- ### Estimate Order Charges with preview_order Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Provides a breakdown of charges (brokerage, STT, GST, etc.) before an order is placed. Requires stock details, order type, and quantity. ```python charges = breeze.preview_order( stock_code="ITC", exchange_code="NSE", product="margin", order_type="limit", price="440", action="buy", quantity="1", specialflag="N" ) # {"Success": {"brokerage": 0.31, "exchange_turnover_charges": 0.01, # "stamp_duty": 0.07, "stt": 0.44, "gst": 0.06, # "total_brokerage": 0.89}, "Status": 200} print("Total charges:", charges["Success"]["total_brokerage"]) ``` -------------------------------- ### Get Quotes Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Fetches real-time market quotes for a given instrument. ```APIDOC ## Get Quotes ### Description Retrieves real-time market data, including LTP, bid/offer prices, and circuit breakers, for a specified financial instrument. ### Method `get_quotes` ### Parameters - **stock_code** (string) - Required - The stock symbol (e.g., "NIFTY"). - **exchange_code** (string) - Required - The exchange code (e.g., "NFO"). - **expiry_date** (string) - Required - The expiry date in ISO format (e.g., "2025-02-27T06:00:00.000Z"). - **product_type** (string) - Required - The type of product (e.g., "futures"). - **right** (string) - Required - The option right (e.g., "others"). - **strike_price** (string) - Required - The strike price (e.g., "0"). ### Request Example ```python breeze.get_quotes(stock_code="NIFTY", exchange_code="NFO", expiry_date="2025-02-27T06:00:00.000Z", product_type="futures", right="others", strike_price="0") ``` ### Response #### Success Response - **Success** (array) - An array of quote objects, each containing: - **exchange_code** (string) - The exchange code. - **product_type** (string) - The type of product. - **stock_code** (string) - The stock symbol. - **expiry_date** (string) - The expiry date. - **right** (string) - The option right. - **strike_price** (float) - The strike price. - **ltp** (float) - Last Traded Price. - **ltt** (string) - Last Traded Time. - **best_bid_price** (float) - The best bid price. - **best_bid_quantity** (string) - The best bid quantity. - **best_offer_price** (float) - The best offer price. - **best_offer_quantity** (string) - The best offer quantity. - **open** (float) - The opening price. - **high** (float) - The highest price. - **low** (float) - The lowest price. - **previous_close** (float) - The previous closing price. - **ltp_percent_change** (float) - Percentage change in LTP. - **upper_circuit** (float) - Upper circuit price. - **lower_circuit** (float) - Lower circuit price. - **total_quantity_traded** (string) - Total quantity traded. ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Activate the created virtual environment. Subsequent commands will use the Python interpreter and packages within this environment. ```bash source breeze_venv/bin/activate ``` -------------------------------- ### Get Trade List Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves a list of trades based on specified criteria. ```APIDOC ## get_trade_list ### Description Retrieves a list of trades. ### Method `breeze.get_trade_list` ### Parameters - `from_date` (string) - Required - Start date for the trade list (ISO format, e.g., "2025-02-05T06:00:00.000Z") - `to_date` (string) - Required - End date for the trade list (ISO format, e.g., "2025-02-05T06:00:00.000Z") - `exchange_code` (string) - Required - Exchange code (e.g., "NSE") - `product_type` (string) - Optional - Product type (e.g., "Margin") - `action` (string) - Optional - Trade action (e.g., "Buy", "Sell") - `stock_code` (string) - Optional - Stock symbol (e.g., "ITC") ### Response Example ```json { "Success": [ { "book_type": "Trade-Book", "trade_date": "05-Feb-2025", "stock_code": "ITC", "action": "Buy", "quantity": "1", "average_cost": "452.20", "brokerage_amount": "0.00", "product_type": "Margin", "exchange_code": "NSE", "order_id": "20250205N300012345", "segment": "M", "settlement_code": "2025027", "dp_id": "IN1234566", "client_id": "12345678", "ltp": "451.95", "eatm_withheld_amount": "0.00", "cash_withheld_amount": "0.00", "total_taxes": "0.00", "order_type": "Market", "expiry_date": null, "right": null, "strike_price": null } ], "Status": 200, "Error": null } ``` ``` -------------------------------- ### Create Breeze Virtual Environment Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Create a new virtual environment named 'breeze_venv' using Python 3. This isolates project dependencies. ```bash virtualenv -p python3 breeze_venv ``` -------------------------------- ### Get Names Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves stock-related information using the exchange code and stock code. ```APIDOC ## Get Names ### Description Retrieves stock-specific details such as exchange stock code, ICICI specific codes, and company name using the provided exchange and stock codes. This method is useful for finding ICICI specific stock codes. ### Method `breeze.get_names(exchange_code: str, stock_code: str)` ### Parameters #### Path Parameters - `exchange_code` (str) - Required - The exchange code (e.g., 'NSE'). - `stock_code` (str) - Required - The stock symbol (e.g., 'TATASTEEL'). ### Request Example ```python breeze.get_names(exchange_code = 'NSE',stock_code = 'TATASTEEL') ``` ### Response #### Success Response - `exchange_code` (str) - The exchange code. - `exchange_stock_code` (str) - The stock code on the exchange. - `isec_stock_code` (str) - The ICICI specific stock code. - `isec_token` (str) - The ICICI specific token. - `company name` (str) - The full company name. - `isec_token_level1` (str) - Level 1 ICICI token. - `isec_token_level2` (str) - Level 2 ICICI token. #### Response Example ```json { "exchange_code": "NSE", "exchange_stock_code": "TATASTEEL", "isec_stock_code": "TATSTE", "isec_token": "3499", "company name": "TATA STEEL LIMITED", "isec_token_level1": "4.1!3499", "isec_token_level2": "4.2!3499" } ``` ``` -------------------------------- ### Establish Websocket Connection and Subscribe to Feeds Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Establishes a persistent Socket.IO connection for real-time data. Requires API key, secret, and session token for authentication. Call `ws_connect()` first, then `subscribe_feeds()`. ```python from breeze_connect import BreezeConnect import time breeze = BreezeConnect(api_key="your_api_key") breeze.generate_session(api_secret="your_secret", session_token="your_session") # Connect to live stream websocket breeze.ws_connect() # Define tick callback def on_ticks(ticks): print("Tick received:", ticks) breeze.on_ticks = on_ticks # Subscribe to exchange quotes for Reliance (NSE) by stock token breeze.subscribe_feeds(stock_token="4.1!2885") # Ticks: {'symbol': '4.1!2885', 'open': 1219.45, 'last': 1209.05, ...} # Subscribe to OHLCV stream (1-minute candles) for NIFTY 50 breeze.subscribe_feeds(stock_token="4.1!2885", interval="1minute") ``` -------------------------------- ### Get trade detail Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the details of a specific trade using the order ID and exchange code. ```APIDOC ## Get trade detail ### Description Retrieves the details of a specific trade using the order ID and exchange code. This function is useful for tracking executed trades. ### Method `breeze.get_trade_detail(exchange_code: str, order_id: str)` ### Parameters #### Path Parameters - `exchange_code` (str) - Required - The exchange code (e.g., 'NSE', 'NFO'). - `order_id` (str) - Required - The unique identifier for the order. ### Request Example ```python breeze.get_trade_detail(exchange_code="NSE", order_id="20250205N300012345") ``` ### Response #### Success Response (200) - `Success` (list) - A list of trade details including settlement ID, exchange trade ID, executed quantity, action, costs, and execution price. - `Status` (int) - The status code of the response. - `Error` (any) - Contains error details if the request failed. #### Response Example ```json { "Success": [ { "settlement_id": "1234567", "exchange_trade_id": "123456789", "executed_quantity": "1", "action": "B", "total_transaction_cost": "0", "brokerage_amount": "0", "taxes": "0", "eatm_withheld_amount": "0", "cash_withheld_amount": "0", "execution_price": "452.2", "stock_code": "ITC", "exchange_code": "NSE", "trade_id": "2025/1234/12345678", "exchange_trade_time": "05-Feb-2025 10:41:24" } ], "Status": 200, "Error": null } ``` ``` -------------------------------- ### Get Portfolio Holdings Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the user's portfolio holdings for a specified exchange and date range. ```APIDOC ## Get Portfolio Holdings ### Description Retrieves a list of the user's portfolio holdings, including details like stock code, quantity, and P&L. ### Method `get_portfolio_holdings` ### Parameters - **exchange_code** (string) - Required - The exchange code (e.g., "NFO", "NSE"). - **from_date** (string) - Required - The start date for the holdings data in ISO format (e.g., "2024-08-01T06:00:00.000Z"). - **to_date** (string) - Required - The end date for the holdings data in ISO format (e.g., "2024-09-19T06:00:00.000Z"). - **stock_code** (string) - Optional - Filter by a specific stock code. - **portfolio_type** (string) - Optional - Filter by portfolio type. ### Request Example ```python breeze.get_portfolio_holdings(exchange_code="NFO", from_date="2024-08-01T06:00:00.000Z", to_date="2024-09-19T06:00:00.000Z", stock_code="", portfolio_type="") ``` ### Response #### Success Response - **Success** (array) - An array of holding objects, each containing: - **stock_code** (string) - The stock symbol. - **exchange_code** (string) - The exchange where the stock is traded. - **quantity** (string) - The number of units held. - **average_price** (string) - The average purchase price. - **booked_profit_loss** (null) - Booked profit or loss. - **current_market_price** (string) - The current market price. - **change_percentage** (null) - Percentage change in price. - **answer_flag** (null) - Flag indicating answer status. - **product_type** (string) - Type of product (e.g., "Options"). - **expiry_date** (string) - Expiry date if applicable. - **strike_price** (string) - Strike price if applicable. - **right** (string) - Option right (e.g., "Call"). - **category_index_per_stock** (string) - Category of the stock. - **action** (string) - Action taken (e.g., "NA"). - **realized_profit** (string) - Realized profit or loss. - **unrealized_profit** (string) - Unrealized profit or loss. - **open_position_value** (string) - Value of open positions. - **portfolio_charges** (string) - Charges associated with the portfolio. - **Status** (integer) - HTTP status code, expected to be 200. - **Error** (null) - Should be null on success. ``` -------------------------------- ### Preview Order Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Previews an order to calculate associated charges before placing it. Ensure all order parameters are correctly specified. ```python breeze.preview_order(stock_code = "ITC", exchange_code = "NSE", product = "margin", order_type = "limit", price = "440", action = "buy", quantity = "1", specialflag = "N") ``` -------------------------------- ### Get Demat Holdings Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Fetches the details of the user's demat holdings. No specific parameters are required. ```python breeze.get_demat_holdings() ``` -------------------------------- ### Subscribe to Real-time OHLCV Data (BFO) Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Subscribe to real-time streaming OHLCV data for BFO stocks. This includes interval data and requires specifying exchange, stock, expiry, strike price, right, and product type. ```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") ``` -------------------------------- ### get_quotes Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Fetches a real-time market snapshot for any instrument. ```APIDOC ## get_quotes — Live Snapshot Quote ### Description Fetches a real-time market snapshot (LTP, bid/ask, OI, circuit limits) for any instrument. ### Method Signature `breeze.get_quotes(stock_code: str, exchange_code: str, expiry_date: str, product_type: str, right: str, strike_price: str)` ### Parameters - **stock_code** (str) - The stock code (e.g., "NIFTY", "RELIND"). - **exchange_code** (str) - The exchange code (e.g., "NFO", "NSE"). - **expiry_date** (str) - The expiry date (empty for cash products). - **product_type** (str) - The product type (e.g., "futures", "cash"). - **right** (str) - The option right (e.g., "others" for futures, empty for cash). - **strike_price** (str) - The strike price (empty for futures and cash). ### Request Example (Futures) ```python # NIFTY Feb futures quote quote = breeze.get_quotes( stock_code="NIFTY", exchange_code="NFO", expiry_date="2025-02-27T06:00:00.000Z", product_type="futures", right="others", strike_price="0" ) q = quote["Success"][0] print(f"LTP: {q['ltp']} Bid: {q['best_bid_price']} Ask: {q['best_offer_price']} OI: N/A") ``` ### Request Example (Equity) ```python # NSE equity quote eq_quote = breeze.get_quotes( stock_code="RELIND", exchange_code="NSE", expiry_date="", product_type="cash", right="", strike_price="" ) ``` ### Response Example (Assumed structure based on usage) ```json { "Success": [ { "ltp": "string", "best_bid_price": "string", "best_offer_price": "string", "open_interest": "string" // May be N/A } ], "Status": 200, "Error": null } ``` ``` -------------------------------- ### Get Trade Detail Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves details of a specific trade using its order ID. Change exchange_code to 'NFO' for F&O details. ```python breeze.get_trade_detail(exchange_code="NSE", order_id="20250205N300012345") ``` -------------------------------- ### Subscribe to Equity Stock Data by Stock Token Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Subscribe to real-time equity stock data using a stock token. This provides general quote information. ```python breeze.subscribe_feeds(stock_token="4.1!2885") ``` -------------------------------- ### Get Funds Information Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the current fund information, including balances and allocations across different segments. No parameters are needed. ```python breeze.get_funds() ``` -------------------------------- ### Place Order: OPTIONS Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Places an options order. Specify the correct stock code, exchange, product type, action, order type, and option-specific details like expiry date, right, and strike price. ```APIDOC ## Place Order: OPTIONS ### Description Places an options order. Specify the correct stock code, exchange, product type, action, order type, and option-specific details like expiry date, right, and strike price. ### Method ```python breeze.place_order(stock_code="NIFTY", exchange_code="NFO", product="options", action="buy", order_type="limit", stoploss="", quantity="75", price="0.20", validity="day", validity_date="2025-02-05T06:00:00.000Z", disclosed_quantity="0", expiry_date="2025-02-27T06:00:00.000Z", right="call", strike_price="24800") ``` ### Parameters #### Path Parameters - **stock_code** (string) - Required - The stock ticker symbol. - **exchange_code** (string) - Required - The exchange code (e.g., "NFO"). - **product** (string) - Required - The product type, should be "options". - **action** (string) - Required - The action to perform, either "buy" or "sell". - **order_type** (string) - Required - The type of order, e.g., "limit". Market orders are not permitted and will be treated as aggressive limit orders. - **stoploss** (string) - Optional - The stoploss price for the order. - **quantity** (string) - Required - The number of units to trade. - **price** (string) - Required - The price at which to execute the order. - **validity** (string) - Required - The validity of the order, e.g., "day". - **validity_date** (string) - Optional - The date until which the order is valid. Note: This parameter has no impact on order execution. - **disclosed_quantity** (string) - Optional - The disclosed quantity for the order. - **expiry_date** (string) - Required for futures/options - The expiry date of the contract. - **right** (string) - Required for options - The right of the option ('call' or 'put'). - **strike_price** (string) - Required for options - The strike price of the option. ### Response #### Success Response (200) - **Success** (object) - Contains order details like order_id, message, and user_remark. - **Status** (integer) - The status code of the response. - **Error** (null) - Null if the request was successful. ### Response Example ```json { "Success": { "order_id": "202502051400001234", "message": "Successfully Placed the order", "user_remark": "" }, "Status": 200, "Error": null } ``` ``` -------------------------------- ### Get Account Margin - NSE Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves the margin details for your account on the NSE exchange. Change exchange_code to 'NFO' for F&O margin details. ```python breeze.get_margin(exchange_code="NSE") ``` -------------------------------- ### Subscribe to One-Click Equity Strategy Stream Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Subscribe to a one-click equity strategy stream by providing the 'i_click_2_gain' stock token. ```python breeze.subscribe_feeds(stock_token="i_click_2_gain") ``` -------------------------------- ### Subscribe to One-Click Equity Strategy Stream (i_click_2_gain) Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Subscribes to a specific 'one-click' equity strategy stream identified by 'i_click_2_gain'. ```APIDOC ## subscribe_feeds (One-Click Equity Strategy - i_click_2_gain) ### Description Subscribes to a one-click equity strategy stream. ### Method `breeze.subscribe_feeds()` ### Parameters - **stock_token** (string) - Required - Identifier for the equity strategy (e.g., "i_click_2_gain"). ### Request Example ```python breeze.subscribe_feeds(stock_token="i_click_2_gain") ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message (e.g., 'i_click_2_gain streaming subscribed successfully.'). ``` -------------------------------- ### Get Order List Source: https://github.com/idirect-tech/breeze-python-sdk/blob/main/README.md Retrieves a list of orders based on the provided date range and exchange code. This is useful for reviewing historical order activity. ```APIDOC ## GET /order/list ### Description Retrieves a list of orders within a specified date range. ### Method GET ### Endpoint /order/list ### Parameters #### Query Parameters - **exchange_code** (string) - Required - The code of the exchange for which to retrieve orders (e.g., "NSE", "NFO"). - **from_date** (string) - Required - The start date and time for the order list in ISO 8601 format (e.g., "2025-02-05T10:00:00.000Z"). - **to_date** (string) - Required - The end date and time for the order list in ISO 8601 format (e.g., "2025-02-05T10:00:00.000Z"). ### Request Example ```python breeze.get_order_list(exchange_code="NSE", from_date="2025-02-05T10:00:00.000Z", to_date="2025-02-05T10:00:00.000Z") ``` ### Response #### Success Response (200) Returns a dictionary containing a list of orders that match the query parameters. The 'Success' key holds a list of order objects, and 'Status' indicates the success code. 'Error' will be null on success. - **Success** (list) - A list of order objects. - **order_id** (string) - The order ID. - **exchange_order_id** (string) - The exchange's order ID. - **exchange_code** (string) - The exchange code. - **stock_code** (string) - The stock symbol. - **product_type** (string) - The type of product (e.g., "Cash"). - **action** (string) - The action taken (e.g., "Buy"). - **order_type** (string) - The type of order (e.g., "Limit"). - **stoploss** (string) - The stoploss price. - **quantity** (string) - The order quantity. - **price** (string) - The order price. - **validity** (string) - The order validity period (e.g., "Day"). - **disclosed_quantity** (string) - The disclosed quantity. - **expiry_date** (string) - The expiry date. - **right** (string) - The option right (e.g., "call"). - **strike_price** (float) - The strike price. - **average_price** (string) - The average execution price. - **cancelled_quantity** (string) - The quantity cancelled. - **pending_quantity** (string) - The pending quantity. - **status** (string) - The order status. - **user_remark** (string) - User-defined remark. - **order_datetime** (string) - The date and time the order was placed. - **parent_order_id** (string) - The parent order ID. - **modification_number** (string) - The modification number. - **exchange_acknowledgement_date** (string) - The exchange acknowledgement date. - **SLTP_price** (string) - The Stop Loss Trigger Price. - **exchange_acknowledge_number** (string) - The exchange acknowledgement number. - **initial_limit** (string) - The initial limit price. - **intial_sltp** (string) - The initial Stop Loss Trigger Price. - **LTP** (string) - The Last Traded Price. - **limit_offset** (string) - The limit offset. - **mbc_flag** (string) - MBC flag. - **cutoff_price** (string) - The cutoff price. - **validity_date** (string) - The specific validity date. - **Status** (integer) - The HTTP status code (e.g., 200 for success). - **Error** (string) - Error message if the request failed, null otherwise. #### Response Example ```json { "Success": [ { "order_id": "20250205N300001234", "exchange_order_id": null, "exchange_code": "NSE", "stock_code": "ITC", "product_type": "Cash", "action": "Buy", "order_type": "Limit", "stoploss": "0.00", "quantity": "1", "price": "420.00", "validity": "Day", "disclosed_quantity": "0", "expiry_date": null, "right": null, "strike_price": 0.0, "average_price": "0", "cancelled_quantity": "0", "pending_quantity": "1", "status": "Ordered", "user_remark": "", "order_datetime": "05-Feb-2025 09:26", "parent_order_id": null, "modification_number": null, "exchange_acknowledgement_date": null, "SLTP_price": null, "exchange_acknowledge_number": null, "initial_limit": null, "intial_sltp": null, "LTP": null, "limit_offset": null, "mbc_flag": null, "cutoff_price": null, "validity_date": "" } ], "Status": 200, "Error": null } ``` #### NOTE: - Please change `exchange_code`="NFO" to get details about F&O. ``` -------------------------------- ### Subscribe to Multiple Stock Tokens Source: https://context7.com/idirect-tech/breeze-python-sdk/llms.txt Subscribe to real-time data for multiple instruments simultaneously by providing a list of stock tokens. ```python breeze.subscribe_feeds(stock_token=["4.1!3499", "4.1!2885"]) ```