{"id":22956861,"url":"https://github.com/marketcalls/openalgo-python-library","last_synced_at":"2026-05-29T07:26:49.116Z","repository":{"id":260468240,"uuid":"850190516","full_name":"marketcalls/openalgo-python-library","owner":"marketcalls","description":"OpenAlgo Python API Wrapper","archived":false,"fork":false,"pushed_at":"2025-07-18T08:39:14.000Z","size":234,"stargazers_count":8,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-18T12:31:29.844Z","etag":null,"topics":["algotrading","api","automation","openalgo","python","trade","wrapper-api"],"latest_commit_sha":null,"homepage":"https://docs.openalgo.in/trading-platform/python","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marketcalls.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audit/audit_hybrid.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-31T05:16:54.000Z","updated_at":"2025-07-18T08:39:18.000Z","dependencies_parsed_at":"2025-01-10T14:38:42.968Z","dependency_job_id":"08199883-168e-409f-9e89-950b6828396f","html_url":"https://github.com/marketcalls/openalgo-python-library","commit_stats":null,"previous_names":["marketcalls/openalgo-python-library"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marketcalls/openalgo-python-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marketcalls%2Fopenalgo-python-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marketcalls%2Fopenalgo-python-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marketcalls%2Fopenalgo-python-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marketcalls%2Fopenalgo-python-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marketcalls","download_url":"https://codeload.github.com/marketcalls/openalgo-python-library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marketcalls%2Fopenalgo-python-library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270175826,"owners_count":24540093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algotrading","api","automation","openalgo","python","trade","wrapper-api"],"created_at":"2024-12-14T17:12:17.602Z","updated_at":"2026-05-29T07:26:49.093Z","avatar_url":"https://github.com/marketcalls.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAlgo Python Library\n\nA Python library for algorithmic trading using OpenAlgo's REST APIs and WebSocket feeds, with **100+ high-performance technical indicators powered by a Rust core**.\n\n- Python Library Docs: https://docs.openalgo.in/trading-platform/python\n- Technical Indicators (100+): https://docs.openalgo.in/trading-platform/python/indicators\n- WebSocket \u0026 Verbose Control: https://docs.openalgo.in/trading-platform/python/websockets-verbose-control\n- API Reference: https://docs.openalgo.in/api-documentation/v1\n- General Documentation: https://docs.openalgo.in\n- Source: https://github.com/marketcalls/openalgo-python-library\n\n## What's New in 2.0.0\n\nVersion 2.0.0 replaces the old Numba/JIT indicator engine with a **Rust core** (via PyO3):\n\n- **No optional extra, no Numba.** Indicators are compiled into the wheel. The legacy\n  `pip install openalgo[indicators]` extra and the `numba`/`llvmlite` dependencies are\n  removed; `pip install openalgo` is all you need.\n- **Python 3.12, 3.13 and 3.14** are all supported (abi3 wheels). Numba previously\n  blocked newer Python/NumPy versions.\n- **New TA-Lib-compatible indicators:** `mom`, `rocp`, `rocr`, `rocr100`, `apo`,\n  `midpoint`, `midprice`, `avgprice`, `medprice`, `typprice`, `wclprice`, `plus_dm`,\n  `minus_dm`, `dx`, `adxr`, `stochf`, `linregangle`, `linregintercept`.\n- **Performance:** every indicator is O(n). Benchmarked head-to-head with TA-Lib on\n  924k bars, the regression/statistics family (`linreg`, `tsf`, `stddev`, `cci`,\n  `macd`, ...) runs faster than TA-Lib; the rest are on par. See the\n  [performance comparison](https://github.com/marketcalls/openalgo-python-library/blob/master/benchmark/TALIB_PERF_COMPARE.md)\n  and [TA-Lib compatibility notes](https://github.com/marketcalls/openalgo-python-library/blob/master/docs/TALIB_COMPATIBILITY.md).\n- **Backward compatible:** the `from openalgo import ta` API is unchanged - existing\n  code keeps working without modification.\n\n## Installation\n\nTo install the OpenAlgo Python library, use pip:\n\n```bash\npip install openalgo\n```\n\nThe 100+ technical indicators are built in (powered by a Rust core); no extra install\nstep or optional dependency is required.\n\n## Get the OpenAlgo apikey\n\nMake sure that your OpenAlgo Application is running. Login to OpenAlgo Application with valid credentials and get the OpenAlgo apikey.\n\nFor detailed function parameters refer to the [API Documentation](https://docs.openalgo.in/api-documentation/v1).\n\n## Getting Started with OpenAlgo\n\nFirst, import the `api` class from the OpenAlgo library and initialize it with your API key:\n\n```python\nfrom openalgo import api\n\n# Replace 'your_api_key_here' with your actual API key\n# Specify the host URL with your hosted domain or ngrok domain.\n# If running locally in windows then use the default host value.\nclient = api(api_key='your_api_key_here', host='http://127.0.0.1:5000')\n```\n\n## Check OpenAlgo Version\n\n```python\nimport openalgo\nopenalgo.__version__\n```\n\n## Technical Indicators (100+)\n\nOpenAlgo ships **100+ technical indicators** powered by a Rust core (via PyO3) —\nincluding trend, momentum, volatility, volume, oscillators, statistics, and hybrid\nindicators. They are built in; no optional dependency or extra install step:\n\n```bash\npip install openalgo\n```\n\nQuick example:\n\n```python\nimport numpy as np\nfrom openalgo import ta\n\nclose = np.array([100, 101, 102, 103, 104, 105, 106, 107, 108, 109], dtype=float)\nhigh  = close + 0.5\nlow   = close - 0.5\n\n# Trend\nsma   = ta.sma(close, period=5)\nema   = ta.ema(close, period=5)\nsupertrend, direction = ta.supertrend(high, low, close, period=7, multiplier=3.0)\n\n# Momentum\nrsi   = ta.rsi(close, period=14)\nmacd_line, signal_line, hist = ta.macd(close, fast=12, slow=26, signal=9)\n\n# Volatility\natr   = ta.atr(high, low, close, period=14)\nupper, middle, lower = ta.bbands(close, period=20, std=2.0)\n```\n\nMany indicators are value-compatible with TA-Lib; where OpenAlgo intentionally follows\nTradingView/Pine conventions instead (EMA/ATR/ADX seeding, etc.), the differences are\ndocumented in the\n[TA-Lib compatibility notes](https://github.com/marketcalls/openalgo-python-library/blob/master/docs/TALIB_COMPATIBILITY.md).\n\nFull indicator catalog and parameter reference: https://docs.openalgo.in/trading-platform/python/indicators\n\n## WebSocket Verbose Control\n\nThe streaming feed supports verbosity levels (`0` silent, `1` connection/auth/subscription info, `2` full debug with every tick):\n\n```python\nclient = api(\n    api_key=\"your_api_key\",\n    host=\"http://127.0.0.1:5000\",\n    ws_url=\"ws://127.0.0.1:8765\",\n    verbose=1,                 # 0 / 1 / True / 2\n)\n```\n\nDetails: https://docs.openalgo.in/trading-platform/python/websockets-verbose-control\n\n## Examples\n\nPlease refer to the documentation on [order constants](https://docs.openalgo.in/api-documentation/v1/order-constants), and consult the API reference for details on optional parameters.\n\n### PlaceOrder example\n\nTo place a new market order:\n\n```python\nresponse = client.placeorder(\n    strategy=\"Python\",\n    symbol=\"NHPC\",\n    action=\"BUY\",\n    exchange=\"NSE\",\n    price_type=\"MARKET\",\n    product=\"MIS\",\n    quantity=1\n)\nprint(response)\n```\n\nPlace Market Order Response:\n\n```json\n{\"orderid\": \"250408000989443\", \"status\": \"success\"}\n```\n\nTo place a new limit order:\n\n```python\nresponse = client.placeorder(\n    strategy=\"Python\",\n    symbol=\"YESBANK\",\n    action=\"BUY\",\n    exchange=\"NSE\",\n    price_type=\"LIMIT\",\n    product=\"MIS\",\n    quantity=\"1\",\n    price=\"16\",\n    trigger_price=\"0\",\n    disclosed_quantity=\"0\",\n)\nprint(response)\n```\n\nPlace Limit Order Response:\n\n```json\n{\"orderid\": \"250408001003813\", \"status\": \"success\"}\n```\n\n### PlaceSmartOrder Example\n\nTo place a smart order considering the current position size:\n\n```python\nresponse = client.placesmartorder(\n    strategy=\"Python\",\n    symbol=\"TATAMOTORS\",\n    action=\"SELL\",\n    exchange=\"NSE\",\n    price_type=\"MARKET\",\n    product=\"MIS\",\n    quantity=1,\n    position_size=5\n)\nprint(response)\n```\n\nPlace Smart Market Order Response:\n\n```json\n{\"orderid\": \"250408000997543\", \"status\": \"success\"}\n```\n\n### OptionsOrder Example\n\nTo place an ATM options order:\n\n```python\nresponse = client.optionsorder(\n    strategy=\"python\",\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"28OCT25\",\n    offset=\"ATM\",\n    option_type=\"CE\",\n    action=\"BUY\",\n    quantity=75,\n    pricetype=\"MARKET\",\n    product=\"NRML\",\n    splitsize=0\n)\nprint(response)\n```\n\nPlace Options Order Response:\n\n```json\n{\n  \"exchange\": \"NFO\",\n  \"offset\": \"ATM\",\n  \"option_type\": \"CE\",\n  \"orderid\": \"25102800000006\",\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY28OCT2525950CE\",\n  \"underlying\": \"NIFTY28OCT25FUT\",\n  \"underlying_ltp\": 25966.05\n}\n```\n\nTo place an ITM options order:\n\n```python\nresponse = client.optionsorder(\n    strategy=\"python\",\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"28OCT25\",\n    offset=\"ITM4\",\n    option_type=\"PE\",\n    action=\"BUY\",\n    quantity=75,\n    pricetype=\"MARKET\",\n    product=\"NRML\",\n    splitsize=0\n)\nprint(response)\n```\n\nPlace Options Order Response:\n\n```json\n{\n  \"exchange\": \"NFO\",\n  \"offset\": \"ITM4\",\n  \"option_type\": \"PE\",\n  \"orderid\": \"25102800000007\",\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY28OCT2526150PE\",\n  \"underlying\": \"NIFTY28OCT25FUT\",\n  \"underlying_ltp\": 25966.05\n}\n```\n\nTo place an OTM options order:\n\n```python\nresponse = client.optionsorder(\n    strategy=\"python\",\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"28OCT25\",\n    offset=\"OTM5\",\n    option_type=\"CE\",\n    action=\"BUY\",\n    quantity=75,\n    pricetype=\"MARKET\",\n    product=\"NRML\",\n    splitsize=0\n)\nprint(response)\n```\n\nPlace Options Order Response:\n\n```json\n{\n  \"exchange\": \"NFO\",\n  \"mode\": \"analyze\",\n  \"offset\": \"OTM5\",\n  \"option_type\": \"CE\",\n  \"orderid\": \"25102800000008\",\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY28OCT2526200CE\",\n  \"underlying\": \"NIFTY28OCT25FUT\",\n  \"underlying_ltp\": 25966.05\n}\n```\n\n### OptionsMultiOrder Example\n\nTo place an Iron Condor (same expiry):\n\n```python\nresponse = client.optionsmultiorder(\n    strategy=\"Iron Condor Test\",\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"25NOV25\",\n    legs=[\n        {\"offset\": \"OTM6\", \"option_type\": \"CE\", \"action\": \"BUY\", \"quantity\": 75},\n        {\"offset\": \"OTM6\", \"option_type\": \"PE\", \"action\": \"BUY\", \"quantity\": 75},\n        {\"offset\": \"OTM4\", \"option_type\": \"CE\", \"action\": \"SELL\", \"quantity\": 75},\n        {\"offset\": \"OTM4\", \"option_type\": \"PE\", \"action\": \"SELL\", \"quantity\": 75}\n    ]\n)\nprint(response)\n```\n\nPlace OptionsMultiOrder Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"underlying\": \"NIFTY\",\n  \"underlying_ltp\": 26050.45,\n  \"results\": [\n    {\n      \"action\": \"BUY\",\n      \"leg\": 1,\n      \"mode\": \"analyze\",\n      \"offset\": \"OTM6\",\n      \"option_type\": \"CE\",\n      \"orderid\": \"25111996859688\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY25NOV2526350CE\"\n    },\n    {\n      \"action\": \"BUY\",\n      \"leg\": 2,\n      \"mode\": \"analyze\",\n      \"offset\": \"OTM6\",\n      \"option_type\": \"PE\",\n      \"orderid\": \"25111996042210\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY25NOV2525750PE\"\n    },\n    {\n      \"action\": \"SELL\",\n      \"leg\": 3,\n      \"mode\": \"analyze\",\n      \"offset\": \"OTM4\",\n      \"option_type\": \"CE\",\n      \"orderid\": \"25111922189638\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY25NOV2526250CE\"\n    },\n    {\n      \"action\": \"SELL\",\n      \"leg\": 4,\n      \"mode\": \"analyze\",\n      \"offset\": \"OTM4\",\n      \"option_type\": \"PE\",\n      \"orderid\": \"25111919252668\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY25NOV2525850PE\"\n    }\n  ]\n}\n```\n\nTo place a Diagonal Spread (different expiry):\n\n```python\nresponse = client.optionsmultiorder(\n    strategy=\"Diagonal Spread Test\",\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    legs=[\n        {\"offset\": \"ITM2\", \"option_type\": \"CE\", \"action\": \"BUY\", \"quantity\": 75, \"expiry_date\": \"30DEC25\"},\n        {\"offset\": \"OTM2\", \"option_type\": \"CE\", \"action\": \"SELL\", \"quantity\": 75, \"expiry_date\": \"25NOV25\"}\n    ]\n)\nprint(response)\n```\n\nPlace OptionsMultiOrder Response:\n\n```json\n{\n  \"results\": [\n    {\n      \"action\": \"BUY\",\n      \"leg\": 1,\n      \"mode\": \"analyze\",\n      \"offset\": \"ITM2\",\n      \"option_type\": \"CE\",\n      \"orderid\": \"25111933337854\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY30DEC2525950CE\"\n    },\n    {\n      \"action\": \"SELL\",\n      \"leg\": 2,\n      \"mode\": \"analyze\",\n      \"offset\": \"OTM2\",\n      \"option_type\": \"CE\",\n      \"orderid\": \"25111957475473\",\n      \"status\": \"success\",\n      \"symbol\": \"NIFTY25NOV2526150CE\"\n    }\n  ],\n  \"status\": \"success\",\n  \"underlying\": \"NIFTY\",\n  \"underlying_ltp\": 26052.65\n}\n```\n\n### BasketOrder example\n\nTo place a new basket order:\n\n```python\nbasket_orders = [\n    {\n        \"symbol\": \"BHEL\",\n        \"exchange\": \"NSE\",\n        \"action\": \"BUY\",\n        \"quantity\": 1,\n        \"pricetype\": \"MARKET\",\n        \"product\": \"MIS\"\n    },\n    {\n        \"symbol\": \"ZOMATO\",\n        \"exchange\": \"NSE\",\n        \"action\": \"SELL\",\n        \"quantity\": 1,\n        \"pricetype\": \"MARKET\",\n        \"product\": \"MIS\"\n    }\n]\nresponse = client.basketorder(orders=basket_orders)\nprint(response)\n```\n\nBasket Order Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"results\": [\n    {\"symbol\": \"BHEL\", \"status\": \"success\", \"orderid\": \"250408000999544\"},\n    {\"symbol\": \"ZOMATO\", \"status\": \"success\", \"orderid\": \"250408000997545\"}\n  ]\n}\n```\n\n### SplitOrder example\n\nTo place a new split order:\n\n```python\nresponse = client.splitorder(\n    symbol=\"YESBANK\",\n    exchange=\"NSE\",\n    action=\"SELL\",\n    quantity=105,\n    splitsize=20,\n    price_type=\"MARKET\",\n    product=\"MIS\"\n)\nprint(response)\n```\n\nSplitOrder Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"split_size\": 20,\n  \"total_quantity\": 105,\n  \"results\": [\n    {\"order_num\": 1, \"orderid\": \"250408001021467\", \"quantity\": 20, \"status\": \"success\"},\n    {\"order_num\": 2, \"orderid\": \"250408001021459\", \"quantity\": 20, \"status\": \"success\"},\n    {\"order_num\": 3, \"orderid\": \"250408001021466\", \"quantity\": 20, \"status\": \"success\"},\n    {\"order_num\": 4, \"orderid\": \"250408001021470\", \"quantity\": 20, \"status\": \"success\"},\n    {\"order_num\": 5, \"orderid\": \"250408001021471\", \"quantity\": 20, \"status\": \"success\"},\n    {\"order_num\": 6, \"orderid\": \"250408001021472\", \"quantity\": 5, \"status\": \"success\"}\n  ]\n}\n```\n\n### ModifyOrder Example\n\nTo modify an existing order:\n\n```python\nresponse = client.modifyorder(\n    order_id=\"250408001002736\",\n    strategy=\"Python\",\n    symbol=\"YESBANK\",\n    action=\"BUY\",\n    exchange=\"NSE\",\n    price_type=\"LIMIT\",\n    product=\"CNC\",\n    quantity=1,\n    price=16.5\n)\nprint(response)\n```\n\nModify Order Response:\n\n```json\n{\"orderid\": \"250408001002736\", \"status\": \"success\"}\n```\n\n### CancelOrder Example\n\nTo cancel an existing order:\n\n```python\nresponse = client.cancelorder(\n    order_id=\"250408001002736\",\n    strategy=\"Python\"\n)\nprint(response)\n```\n\nCancelorder Response:\n\n```json\n{\"orderid\": \"250408001002736\", \"status\": \"success\"}\n```\n\n### CancelAllOrder Example\n\nTo cancel all open orders and trigger pending orders:\n\n```python\nresponse = client.cancelallorder(strategy=\"Python\")\nprint(response)\n```\n\nCancelallorder Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"message\": \"Canceled 5 orders. Failed to cancel 0 orders.\",\n  \"canceled_orders\": [\n    \"250408001042620\",\n    \"250408001042667\",\n    \"250408001042642\",\n    \"250408001043015\",\n    \"250408001043386\"\n  ],\n  \"failed_cancellations\": []\n}\n```\n\n### ClosePosition Example\n\nTo close all open positions across various exchanges:\n\n```python\nresponse = client.closeposition(strategy=\"Python\")\nprint(response)\n```\n\nClosePosition Response:\n\n```json\n{\"message\": \"All Open Positions Squared Off\", \"status\": \"success\"}\n```\n\n### OrderStatus Example\n\nTo get the current order status:\n\n```python\nresponse = client.orderstatus(\n    order_id=\"250828000185002\",\n    strategy=\"Test Strategy\"\n)\nprint(response)\n```\n\nOrderstatus Response:\n\n```json\n{\n  \"data\": {\n    \"action\": \"BUY\",\n    \"average_price\": 18.95,\n    \"exchange\": \"NSE\",\n    \"order_status\": \"complete\",\n    \"orderid\": \"250828000185002\",\n    \"price\": 0,\n    \"pricetype\": \"MARKET\",\n    \"product\": \"MIS\",\n    \"quantity\": \"1\",\n    \"symbol\": \"YESBANK\",\n    \"timestamp\": \"28-Aug-2025 09:59:10\",\n    \"trigger_price\": 0\n  },\n  \"status\": \"success\"\n}\n```\n\n### OpenPosition Example\n\nTo get the current open position:\n\n```python\nresponse = client.openposition(\n    strategy=\"Test Strategy\",\n    symbol=\"YESBANK\",\n    exchange=\"NSE\",\n    product=\"MIS\"\n)\nprint(response)\n```\n\nOpenPosition Response:\n\n```json\n{\"quantity\": \"-10\", \"status\": \"success\"}\n```\n\n### Quotes Example\n\n```python\nresponse = client.quotes(symbol=\"RELIANCE\", exchange=\"NSE\")\nprint(response)\n```\n\nQuotes Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"open\": 1172.0,\n    \"high\": 1196.6,\n    \"low\": 1163.3,\n    \"ltp\": 1187.75,\n    \"ask\": 1188.0,\n    \"bid\": 1187.85,\n    \"prev_close\": 1165.7,\n    \"volume\": 14414545\n  }\n}\n```\n\n### MultiQuotes Example\n\n```python\nresponse = client.multiquotes(symbols=[\n    {\"symbol\": \"RELIANCE\", \"exchange\": \"NSE\"},\n    {\"symbol\": \"TCS\", \"exchange\": \"NSE\"},\n    {\"symbol\": \"INFY\", \"exchange\": \"NSE\"}\n])\nprint(response)\n```\n\nMultiQuotes Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"results\": [\n    {\n      \"symbol\": \"RELIANCE\",\n      \"exchange\": \"NSE\",\n      \"data\": {\n        \"open\": 1542.3, \"high\": 1571.6, \"low\": 1540.5, \"ltp\": 1569.9,\n        \"prev_close\": 1539.7, \"ask\": 1569.9, \"bid\": 0, \"oi\": 0, \"volume\": 14054299\n      }\n    },\n    {\n      \"symbol\": \"TCS\",\n      \"exchange\": \"NSE\",\n      \"data\": {\n        \"open\": 3118.8, \"high\": 3178, \"low\": 3117, \"ltp\": 3162.9,\n        \"prev_close\": 3119.2, \"ask\": 0, \"bid\": 3162.9, \"oi\": 0, \"volume\": 2508527\n      }\n    },\n    {\n      \"symbol\": \"INFY\",\n      \"exchange\": \"NSE\",\n      \"data\": {\n        \"open\": 1532.1, \"high\": 1560.3, \"low\": 1532.1, \"ltp\": 1557.9,\n        \"prev_close\": 1530.6, \"ask\": 0, \"bid\": 1557.9, \"oi\": 0, \"volume\": 7575038\n      }\n    }\n  ]\n}\n```\n\n### Depth Example\n\n```python\nresponse = client.depth(symbol=\"SBIN\", exchange=\"NSE\")\nprint(response)\n```\n\nDepth Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"open\": 760.0,\n    \"high\": 774.0,\n    \"low\": 758.15,\n    \"ltp\": 769.6,\n    \"ltq\": 205,\n    \"prev_close\": 746.9,\n    \"volume\": 9362799,\n    \"oi\": 161265750,\n    \"totalbuyqty\": 591351,\n    \"totalsellqty\": 835701,\n    \"asks\": [\n      {\"price\": 769.6,  \"quantity\": 767},\n      {\"price\": 769.65, \"quantity\": 115},\n      {\"price\": 769.7,  \"quantity\": 162},\n      {\"price\": 769.75, \"quantity\": 1121},\n      {\"price\": 769.8,  \"quantity\": 430}\n    ],\n    \"bids\": [\n      {\"price\": 769.4,  \"quantity\": 886},\n      {\"price\": 769.35, \"quantity\": 212},\n      {\"price\": 769.3,  \"quantity\": 351},\n      {\"price\": 769.25, \"quantity\": 343},\n      {\"price\": 769.2,  \"quantity\": 399}\n    ]\n  }\n}\n```\n\n### History Example\n\nDownload data directly from broker API:\n\n```python\nresponse = client.history(\n    symbol=\"SBIN\",\n    exchange=\"NSE\",\n    interval=\"5m\",\n    start_date=\"2025-04-01\",\n    end_date=\"2025-04-08\",\n    source=\"api\"\n)\nprint(response)\n```\n\nDownload data from Historify DuckDB (stored data):\n\n```python\nresponse = client.history(\n    symbol=\"SBIN\",\n    exchange=\"NSE\",\n    interval=\"5m\",\n    start_date=\"2025-04-01\",\n    end_date=\"2025-04-08\",\n    source=\"db\"\n)\nprint(response)\n```\n\nHistory Response:\n\n```text\n                            close    high     low    open  volume\ntimestamp\n2025-04-01 09:15:00+05:30  772.50  774.00  763.20  766.50  318625\n2025-04-01 09:20:00+05:30  773.20  774.95  772.10  772.45  197189\n2025-04-01 09:25:00+05:30  775.15  775.60  772.60  773.20  227544\n2025-04-01 09:30:00+05:30  777.35  777.50  774.85  775.15  134596\n2025-04-01 09:35:00+05:30  778.00  778.00  776.25  777.50  145385\n...                           ...     ...     ...     ...     ...\n2025-04-08 14:00:00+05:30  768.25  770.70  767.85  768.50  142478\n2025-04-08 14:05:00+05:30  769.10  769.80  766.60  768.15  128283\n2025-04-08 14:10:00+05:30  769.05  769.85  768.40  769.10  119084\n2025-04-08 14:15:00+05:30  770.05  770.50  769.05  769.05  158299\n2025-04-08 14:20:00+05:30  769.95  770.50  769.40  770.05  125485\n\n[437 rows x 5 columns]\n```\n\n### Intervals Example\n\n```python\nresponse = client.intervals()\nprint(response)\n```\n\nIntervals Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"months\": [],\n    \"weeks\": [],\n    \"days\": [\"D\"],\n    \"hours\": [\"1h\"],\n    \"minutes\": [\"10m\", \"15m\", \"1m\", \"30m\", \"3m\", \"5m\"],\n    \"seconds\": []\n  }\n}\n```\n\n### OptionChain Example\n\nNote: To fetch the entire option chain for an expiry, omit the `strike_count` parameter.\n\n```python\nchain = client.optionchain(\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"30DEC25\",\n    strike_count=10\n)\n```\n\nOptionChain Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"underlying\": \"NIFTY\",\n  \"underlying_ltp\": 26215.55,\n  \"expiry_date\": \"30DEC25\",\n  \"atm_strike\": 26200.0,\n  \"chain\": [\n    {\n      \"strike\": 26100.0,\n      \"ce\": {\n        \"symbol\": \"NIFTY30DEC2526100CE\", \"label\": \"ITM2\",\n        \"ltp\": 490, \"bid\": 490, \"ask\": 491,\n        \"open\": 540, \"high\": 571, \"low\": 444.75,\n        \"prev_close\": 496.8, \"volume\": 1195800, \"oi\": 0,\n        \"lotsize\": 75, \"tick_size\": 0.05\n      },\n      \"pe\": {\n        \"symbol\": \"NIFTY30DEC2526100PE\", \"label\": \"OTM2\",\n        \"ltp\": 193, \"bid\": 191.2, \"ask\": 193,\n        \"open\": 204.1, \"high\": 229.95, \"low\": 175.6,\n        \"prev_close\": 215.95, \"volume\": 1832700, \"oi\": 0,\n        \"lotsize\": 75, \"tick_size\": 0.05\n      }\n    },\n    {\n      \"strike\": 26200.0,\n      \"ce\": {\n        \"symbol\": \"NIFTY30DEC2526200CE\", \"label\": \"ATM\",\n        \"ltp\": 427, \"bid\": 425.05, \"ask\": 427,\n        \"open\": 449.95, \"high\": 503.5, \"low\": 384,\n        \"prev_close\": 433.2, \"volume\": 2994000, \"oi\": 0,\n        \"lotsize\": 75, \"tick_size\": 0.05\n      },\n      \"pe\": {\n        \"symbol\": \"NIFTY30DEC2526200PE\", \"label\": \"ATM\",\n        \"ltp\": 227.4, \"bid\": 227.35, \"ask\": 228.5,\n        \"open\": 251.9, \"high\": 269.15, \"low\": 205.95,\n        \"prev_close\": 251.9, \"volume\": 3745350, \"oi\": 0,\n        \"lotsize\": 75, \"tick_size\": 0.05\n      }\n    }\n  ]\n}\n```\n\n### Symbol Example\n\n```python\nresponse = client.symbol(\n    symbol=\"NIFTY30DEC25FUT\",\n    exchange=\"NFO\"\n)\nprint(response)\n```\n\nSymbol Response:\n\n```json\n{\n  \"data\": {\n    \"brexchange\": \"NSE_FO\",\n    \"brsymbol\": \"NIFTY FUT 30 DEC 25\",\n    \"exchange\": \"NFO\",\n    \"expiry\": \"30-DEC-25\",\n    \"freeze_qty\": 1800,\n    \"id\": 57900,\n    \"instrumenttype\": \"FUT\",\n    \"lotsize\": 75,\n    \"name\": \"NIFTY\",\n    \"strike\": 0,\n    \"symbol\": \"NIFTY30DEC25FUT\",\n    \"tick_size\": 10,\n    \"token\": \"NSE_FO|49543\"\n  },\n  \"status\": \"success\"\n}\n```\n\n### Search Example\n\n```python\nresponse = client.search(query=\"NIFTY 26000 DEC CE\", exchange=\"NFO\")\nprint(response)\n```\n\nSearch Response:\n\n```json\n{\n  \"data\": [\n    {\n      \"brexchange\": \"NSE_FO\",\n      \"brsymbol\": \"NIFTY 26000 CE 30 DEC 25\",\n      \"exchange\": \"NFO\",\n      \"expiry\": \"30-DEC-25\",\n      \"freeze_qty\": 1800,\n      \"instrumenttype\": \"CE\",\n      \"lotsize\": 75,\n      \"name\": \"NIFTY\",\n      \"strike\": 26000,\n      \"symbol\": \"NIFTY30DEC2526000CE\",\n      \"tick_size\": 5,\n      \"token\": \"NSE_FO|71399\"\n    }\n  ],\n  \"message\": \"Found 7 matching symbols\",\n  \"status\": \"success\"\n}\n```\n\n### OptionSymbol Example\n\nATM Option:\n\n```python\nresponse = client.optionsymbol(\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"30DEC25\",\n    offset=\"ATM\",\n    option_type=\"CE\"\n)\nprint(response)\n```\n\nOptionSymbol Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY30DEC2525950CE\",\n  \"exchange\": \"NFO\",\n  \"lotsize\": 75,\n  \"tick_size\": 5,\n  \"freeze_qty\": 1800,\n  \"underlying_ltp\": 25966.4\n}\n```\n\nITM Option:\n\n```python\nresponse = client.optionsymbol(\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"30DEC25\",\n    offset=\"ITM3\",\n    option_type=\"PE\"\n)\nprint(response)\n```\n\nOptionSymbol Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY30DEC2526100PE\",\n  \"exchange\": \"NFO\",\n  \"lotsize\": 75,\n  \"tick_size\": 5,\n  \"freeze_qty\": 1800,\n  \"underlying_ltp\": 25966.4\n}\n```\n\nOTM Option:\n\n```python\nresponse = client.optionsymbol(\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"30DEC25\",\n    offset=\"OTM4\",\n    option_type=\"CE\"\n)\nprint(response)\n```\n\nOptionSymbol Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"symbol\": \"NIFTY30DEC2526150CE\",\n  \"exchange\": \"NFO\",\n  \"lotsize\": 75,\n  \"tick_size\": 5,\n  \"freeze_qty\": 1800,\n  \"underlying_ltp\": 25966.4\n}\n```\n\n### SyntheticFuture Example\n\n```python\nresponse = client.syntheticfuture(\n    underlying=\"NIFTY\",\n    exchange=\"NSE_INDEX\",\n    expiry_date=\"25NOV25\"\n)\nprint(response)\n```\n\nSyntheticFuture Response:\n\n```json\n{\n  \"atm_strike\": 25900.0,\n  \"expiry\": \"25NOV25\",\n  \"status\": \"success\",\n  \"synthetic_future_price\": 25980.05,\n  \"underlying\": \"NIFTY\",\n  \"underlying_ltp\": 25910.05\n}\n```\n\n### OptionGreeks Example\n\n```python\nresponse = client.optiongreeks(\n    symbol=\"NIFTY25NOV2526000CE\",\n    exchange=\"NFO\",\n    interest_rate=0.00,\n    underlying_symbol=\"NIFTY\",\n    underlying_exchange=\"NSE_INDEX\"\n)\nprint(response)\n```\n\nOptionGreeks Response:\n\n```json\n{\n  \"days_to_expiry\": 28.5071,\n  \"exchange\": \"NFO\",\n  \"expiry_date\": \"25-Nov-2025\",\n  \"greeks\": {\n    \"delta\": 0.4967,\n    \"gamma\": 0.000352,\n    \"rho\": 9.733994,\n    \"theta\": -7.919,\n    \"vega\": 28.9489\n  },\n  \"implied_volatility\": 15.6,\n  \"interest_rate\": 0.0,\n  \"option_price\": 435,\n  \"option_type\": \"CE\",\n  \"spot_price\": 25966.05,\n  \"status\": \"success\",\n  \"strike\": 26000.0,\n  \"symbol\": \"NIFTY25NOV2526000CE\",\n  \"underlying\": \"NIFTY\"\n}\n```\n\n### Expiry Example\n\n```python\nresponse = client.expiry(\n    symbol=\"NIFTY\",\n    exchange=\"NFO\",\n    instrumenttype=\"options\"\n)\nprint(response)\n```\n\nExpiry Response:\n\n```json\n{\n  \"data\": [\n    \"10-JUL-25\", \"17-JUL-25\", \"24-JUL-25\", \"31-JUL-25\",\n    \"07-AUG-25\", \"28-AUG-25\", \"25-SEP-25\", \"24-DEC-25\",\n    \"26-MAR-26\", \"25-JUN-26\", \"31-DEC-26\", \"24-JUN-27\",\n    \"30-DEC-27\", \"29-JUN-28\", \"28-DEC-28\", \"28-JUN-29\",\n    \"27-DEC-29\", \"25-JUN-30\"\n  ],\n  \"message\": \"Found 18 expiry dates for NIFTY options in NFO\",\n  \"status\": \"success\"\n}\n```\n\n### Instruments Example\n\n```python\nresponse = client.instruments(exchange=\"NSE\")\nprint(response.tail())\n```\n\nInstruments Response:\n\n```text\n     brexchange           brsymbol exchange expiry instrumenttype  lotsize  \\\n3041        NSE      NSE:NEOGEN-EQ      NSE   None             EQ        1\n3042        NSE     NSE:ALANKIT-EQ      NSE   None             EQ        1\n3043        NSE  NSE:EVERESTIND-EQ      NSE   None             EQ        1\n3044        NSE   NSE:VIKASLIFE-EQ      NSE   None             EQ        1\n3045        NSE    NSE:ONEPOINT-EQ      NSE   None             EQ        1\n\n                          name  strike      symbol  tick_size           token\n3041  NEOGEN CHEMICALS LIMITED    -1.0      NEOGEN       0.10  10100000009917\n3042           ALANKIT LIMITED    -1.0     ALANKIT       0.01  10100000009921\n3043    EVEREST INDUSTRIES LTD    -1.0  EVERESTIND       0.05   1010000000993\n3044    VIKAS LIFECARE LIMITED    -1.0   VIKASLIFE       0.01  10100000009931\n3045     ONE POINT ONE SOL LTD    -1.0    ONEPOINT       0.01  10100000009939\n```\n\n### Telegram Alert Example\n\n```python\nresponse = client.telegram(\n    username=\"\u003copenalgo_loginid\u003e\",\n    message=\"NIFTY crossed 26000!\"\n)\nprint(response)\n```\n\nTelegram Alert Response:\n\n```json\n{\n  \"message\": \"Notification sent successfully\",\n  \"status\": \"success\"\n}\n```\n\n### Funds Example\n\n```python\nresponse = client.funds()\nprint(response)\n```\n\nFunds Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"availablecash\": \"320.66\",\n    \"collateral\": \"0.00\",\n    \"m2mrealized\": \"3.27\",\n    \"m2munrealized\": \"-7.88\",\n    \"utiliseddebits\": \"679.34\"\n  }\n}\n```\n\n### Margin Example\n\n```python\nresponse = client.margin(positions=[\n    {\n        \"symbol\": \"NIFTY25NOV2525000CE\",\n        \"exchange\": \"NFO\",\n        \"action\": \"BUY\",\n        \"product\": \"NRML\",\n        \"pricetype\": \"MARKET\",\n        \"quantity\": \"75\"\n    },\n    {\n        \"symbol\": \"NIFTY25NOV2525500CE\",\n        \"exchange\": \"NFO\",\n        \"action\": \"SELL\",\n        \"product\": \"NRML\",\n        \"pricetype\": \"MARKET\",\n        \"quantity\": \"75\"\n    }\n])\n```\n\nMargin Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"total_margin_required\": 91555.7625,\n    \"span_margin\": 0.0,\n    \"exposure_margin\": 91555.7625\n  }\n}\n```\n\n### OrderBook Example\n\n```python\nresponse = client.orderbook()\nprint(response)\n```\n\nOrderBook Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"orders\": [\n      {\n        \"action\": \"BUY\",\n        \"symbol\": \"RELIANCE\",\n        \"exchange\": \"NSE\",\n        \"orderid\": \"250408000989443\",\n        \"product\": \"MIS\",\n        \"quantity\": \"1\",\n        \"price\": 1186.0,\n        \"pricetype\": \"MARKET\",\n        \"order_status\": \"complete\",\n        \"trigger_price\": 0.0,\n        \"timestamp\": \"08-Apr-2025 13:58:03\"\n      },\n      {\n        \"action\": \"BUY\",\n        \"symbol\": \"YESBANK\",\n        \"exchange\": \"NSE\",\n        \"orderid\": \"250408001002736\",\n        \"product\": \"MIS\",\n        \"quantity\": \"1\",\n        \"price\": 16.5,\n        \"pricetype\": \"LIMIT\",\n        \"order_status\": \"cancelled\",\n        \"trigger_price\": 0.0,\n        \"timestamp\": \"08-Apr-2025 14:13:45\"\n      }\n    ],\n    \"statistics\": {\n      \"total_buy_orders\": 2.0,\n      \"total_sell_orders\": 0.0,\n      \"total_completed_orders\": 1.0,\n      \"total_open_orders\": 0.0,\n      \"total_rejected_orders\": 0.0\n    }\n  }\n}\n```\n\n### TradeBook Example\n\n```python\nresponse = client.tradebook()\nprint(response)\n```\n\nTradeBook Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": [\n    {\n      \"action\": \"BUY\",\n      \"symbol\": \"RELIANCE\",\n      \"exchange\": \"NSE\",\n      \"orderid\": \"250408000989443\",\n      \"product\": \"MIS\",\n      \"quantity\": 0.0,\n      \"average_price\": 1180.1,\n      \"timestamp\": \"13:58:03\",\n      \"trade_value\": 1180.1\n    },\n    {\n      \"action\": \"SELL\",\n      \"symbol\": \"NHPC\",\n      \"exchange\": \"NSE\",\n      \"orderid\": \"250408001086129\",\n      \"product\": \"MIS\",\n      \"quantity\": 0.0,\n      \"average_price\": 83.74,\n      \"timestamp\": \"14:28:49\",\n      \"trade_value\": 83.74\n    }\n  ]\n}\n```\n\n### PositionBook Example\n\n```python\nresponse = client.positionbook()\nprint(response)\n```\n\nPositionBook Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": [\n    {\n      \"symbol\": \"NHPC\",\n      \"exchange\": \"NSE\",\n      \"product\": \"MIS\",\n      \"quantity\": \"-1\",\n      \"average_price\": \"83.74\",\n      \"ltp\": \"83.72\",\n      \"pnl\": \"0.02\"\n    },\n    {\n      \"symbol\": \"RELIANCE\",\n      \"exchange\": \"NSE\",\n      \"product\": \"MIS\",\n      \"quantity\": \"0\",\n      \"average_price\": \"0.0\",\n      \"ltp\": \"1189.9\",\n      \"pnl\": \"5.90\"\n    },\n    {\n      \"symbol\": \"YESBANK\",\n      \"exchange\": \"NSE\",\n      \"product\": \"MIS\",\n      \"quantity\": \"-104\",\n      \"average_price\": \"17.2\",\n      \"ltp\": \"17.31\",\n      \"pnl\": \"-10.44\"\n    }\n  ]\n}\n```\n\n### Holdings Example\n\n```python\nresponse = client.holdings()\nprint(response)\n```\n\nHoldings Response:\n\n```json\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"holdings\": [\n      {\"symbol\": \"RELIANCE\",  \"exchange\": \"NSE\", \"product\": \"CNC\", \"quantity\": 1, \"pnl\": -149.0, \"pnlpercent\": -11.10},\n      {\"symbol\": \"TATASTEEL\", \"exchange\": \"NSE\", \"product\": \"CNC\", \"quantity\": 1, \"pnl\": -15.0,  \"pnlpercent\": -10.41},\n      {\"symbol\": \"CANBK\",     \"exchange\": \"NSE\", \"product\": \"CNC\", \"quantity\": 5, \"pnl\": -69.0,  \"pnlpercent\": -13.43}\n    ],\n    \"statistics\": {\n      \"totalholdingvalue\": 1768.0,\n      \"totalinvvalue\": 2001.0,\n      \"totalprofitandloss\": -233.15,\n      \"totalpnlpercentage\": -11.65\n    }\n  }\n}\n```\n\n### Holidays Example\n\n```python\nresponse = client.holidays(year=2026)\nprint(response)\n```\n\nHolidays Response:\n\n```json\n{\n  \"data\": [\n    {\n      \"closed_exchanges\": [\"NSE\", \"BSE\", \"NFO\", \"BFO\", \"CDS\", \"BCD\", \"MCX\"],\n      \"date\": \"2026-01-26\",\n      \"description\": \"Republic Day\",\n      \"holiday_type\": \"TRADING_HOLIDAY\",\n      \"open_exchanges\": []\n    },\n    {\n      \"closed_exchanges\": [],\n      \"date\": \"2026-02-19\",\n      \"description\": \"Chhatrapati Shivaji Maharaj Jayanti\",\n      \"holiday_type\": \"SETTLEMENT_HOLIDAY\",\n      \"open_exchanges\": []\n    },\n    {\n      \"closed_exchanges\": [\"NSE\", \"BSE\", \"NFO\", \"BFO\", \"CDS\", \"BCD\"],\n      \"date\": \"2026-03-10\",\n      \"description\": \"Holi\",\n      \"holiday_type\": \"TRADING_HOLIDAY\",\n      \"open_exchanges\": [\n        {\"end_time\": 1741677900000, \"exchange\": \"MCX\", \"start_time\": 1741624200000}\n      ]\n    }\n  ]\n}\n```\n\n### Timings Example\n\n```python\nresponse = client.timings(date=\"2025-12-19\")\nprint(response)\n```\n\nTimings Response:\n\n```json\n{\n  \"data\": [\n    {\"end_time\": 1766138400000, \"exchange\": \"NSE\", \"start_time\": 1766115900000},\n    {\"end_time\": 1766138400000, \"exchange\": \"BSE\", \"start_time\": 1766115900000},\n    {\"end_time\": 1766138400000, \"exchange\": \"NFO\", \"start_time\": 1766115900000},\n    {\"end_time\": 1766138400000, \"exchange\": \"BFO\", \"start_time\": 1766115900000},\n    {\"end_time\": 1766168700000, \"exchange\": \"MCX\", \"start_time\": 1766115000000},\n    {\"end_time\": 1766143800000, \"exchange\": \"BCD\", \"start_time\": 1766115000000},\n    {\"end_time\": 1766143800000, \"exchange\": \"CDS\", \"start_time\": 1766115000000}\n  ],\n  \"status\": \"success\"\n}\n```\n\n### Analyzer Status Example\n\n```python\nresponse = client.analyzerstatus()\nprint(response)\n```\n\nAnalyzer Status Response:\n\n```json\n{\n  \"data\": {\"analyze_mode\": true, \"mode\": \"analyze\", \"total_logs\": 2},\n  \"status\": \"success\"\n}\n```\n\n### Analyzer Toggle Example\n\n```python\n# Switch to analyze mode (simulated responses)\nresponse = client.analyzertoggle(mode=True)\nprint(response)\n```\n\nAnalyzer Toggle Response:\n\n```json\n{\n  \"data\": {\n    \"analyze_mode\": true,\n    \"message\": \"Analyzer mode switched to analyze\",\n    \"mode\": \"analyze\",\n    \"total_logs\": 2\n  },\n  \"status\": \"success\"\n}\n```\n\n### LTP Data (Streaming WebSocket)\n\n```python\nfrom openalgo import api\nimport time\n\n# Initialize OpenAlgo client\nclient = api(\n    api_key=\"your_api_key\",                  # Replace with your actual OpenAlgo API key\n    host=\"http://127.0.0.1:5000\",            # REST API host\n    ws_url=\"ws://127.0.0.1:8765\"             # WebSocket host\n)\n\n# Define instruments to subscribe for LTP\ninstruments = [\n    {\"exchange\": \"NSE\", \"symbol\": \"RELIANCE\"},\n    {\"exchange\": \"NSE\", \"symbol\": \"INFY\"}\n]\n\n# Callback function for LTP updates\ndef on_ltp(data):\n    print(\"LTP Update Received:\")\n    print(data)\n\n# Connect and subscribe\nclient.connect()\nclient.subscribe_ltp(instruments, on_data_received=on_ltp)\n\n# Run for a few seconds to receive data\ntry:\n    time.sleep(10)\nfinally:\n    client.unsubscribe_ltp(instruments)\n    client.disconnect()\n```\n\n### Quotes (Streaming WebSocket)\n\n```python\nfrom openalgo import api\nimport time\n\nclient = api(\n    api_key=\"your_api_key\",\n    host=\"http://127.0.0.1:5000\",\n    ws_url=\"ws://127.0.0.1:8765\"\n)\n\ninstruments = [\n    {\"exchange\": \"NSE\", \"symbol\": \"RELIANCE\"},\n    {\"exchange\": \"NSE\", \"symbol\": \"INFY\"}\n]\n\ndef on_quote(data):\n    print(\"Quote Update Received:\")\n    print(data)\n\nclient.connect()\nclient.subscribe_quote(instruments, on_data_received=on_quote)\n\ntry:\n    time.sleep(10)\nfinally:\n    client.unsubscribe_quote(instruments)\n    client.disconnect()\n```\n\n### Depth (Streaming WebSocket)\n\n```python\nfrom openalgo import api\nimport time\n\nclient = api(\n    api_key=\"your_api_key\",\n    host=\"http://127.0.0.1:5000\",\n    ws_url=\"ws://127.0.0.1:8765\"\n)\n\ninstruments = [\n    {\"exchange\": \"NSE\", \"symbol\": \"RELIANCE\"},\n    {\"exchange\": \"NSE\", \"symbol\": \"INFY\"}\n]\n\ndef on_depth(data):\n    print(\"Market Depth Update Received:\")\n    print(data)\n\nclient.connect()\nclient.subscribe_depth(instruments, on_data_received=on_depth)\n\ntry:\n    time.sleep(10)\nfinally:\n    client.unsubscribe_depth(instruments)\n    client.disconnect()\n```\n\n## More Examples\n\nThe `examples/` directory in the source repository contains runnable scripts:\n\n- `account_test.py` — account-related functions\n- `margin_example.py` — margin calculation for single and multiple positions\n- `order_test.py` — order management\n- `data_examples.py` — market data\n- `feed_examples.py` — WebSocket LTP feeds\n- `quote_example.py` — WebSocket quote feeds\n- `depth_example.py` — WebSocket market depth feeds\n- `options_examples.py` — Options API (Greeks, symbol resolution, orders)\n- `telegram_examples.py` — Telegram notification API\n\n## License\n\nMIT — see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarketcalls%2Fopenalgo-python-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarketcalls%2Fopenalgo-python-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarketcalls%2Fopenalgo-python-library/lists"}