{"id":51026297,"url":"https://github.com/TheHardeep/fenix","last_synced_at":"2026-07-09T21:00:56.235Z","repository":{"id":207328179,"uuid":"718983165","full_name":"TheHardeep/fenix","owner":"TheHardeep","description":"A Python library for trading in the Indian Finance Sector with support for 15+ broker APIs.","archived":false,"fork":false,"pushed_at":"2026-06-27T07:16:47.000Z","size":2711,"stargazers_count":51,"open_issues_count":0,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-06-27T08:20:15.967Z","etag":null,"topics":["algo-trading","api","banknifty","bot","broker-api","equity-trading","finance","fyers-api","iifl-xts","invest","library","market-data","nse","options-trading","sensex","strategy","trade","trading","upstox-api","zerodha-kite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheHardeep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-15T07:42:01.000Z","updated_at":"2026-06-27T07:15:47.000Z","dependencies_parsed_at":"2023-11-22T05:23:00.037Z","dependency_job_id":"e5ed73cc-779d-48c5-8b96-9dcbb20425f2","html_url":"https://github.com/TheHardeep/fenix","commit_stats":null,"previous_names":["hardeepsingh402/kronos","thehardeep/kronos"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/TheHardeep/fenix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheHardeep%2Ffenix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheHardeep%2Ffenix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheHardeep%2Ffenix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheHardeep%2Ffenix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheHardeep","download_url":"https://codeload.github.com/TheHardeep/fenix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheHardeep%2Ffenix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35312540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"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":["algo-trading","api","banknifty","bot","broker-api","equity-trading","finance","fyers-api","iifl-xts","invest","library","market-data","nse","options-trading","sensex","strategy","trade","trading","upstox-api","zerodha-kite"],"created_at":"2026-06-21T20:00:29.793Z","updated_at":"2026-07-09T21:00:56.188Z","avatar_url":"https://github.com/TheHardeep.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/fenix-logo.png\" alt=\"Fenix\" width=\"180\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eFenix\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eChange one word. Trade any broker.\u003c/b\u003e\u003cbr\u003e\n  One unified Python API across \u003cb\u003e15 Indian brokers\u003c/b\u003e — authentication, instrument tokens,\n  orders, positions, and account data, all returned in one consistent shape.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/TheHardeep/fenix/blob/master/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-GPLv3-blue?color=%234ec820\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/fenix/\"\u003e\u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/fenix\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/projects/fenix\"\u003e\u003cimg src=\"https://static.pepy.tech/personalized-badge/fenix?period=total\u0026units=INTERNATIONAL_SYSTEM\u0026left_color=GREY\u0026right_color=RED\u0026left_text=downloads\" alt=\"PyPI Downloads\"\u003e\u003c/a\u003e\n  \u003cimg alt=\"Python\" src=\"https://img.shields.io/pypi/pyversions/fenix\"\u003e\n  \u003ca href=\"https://fenix.hardeep.tech\"\u003e\u003cimg alt=\"Docs\" src=\"https://img.shields.io/badge/docs-fenix.hardeep.tech-orange\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#install\"\u003eInstall\u003c/a\u003e ·\n  \u003ca href=\"#quickstart\"\u003eQuickstart\u003c/a\u003e ·\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e ·\n  \u003ca href=\"#supported-brokers\"\u003eBrokers\u003c/a\u003e ·\n  \u003ca href=\"#unified-vocabulary\"\u003eConstants\u003c/a\u003e ·\n  \u003ca href=\"#paper-trading\"\u003ePaper Mode\u003c/a\u003e ·\n  \u003ca href=\"https://fenix.hardeep.tech\"\u003eDocumentation\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nEvery Indian broker ships its own REST API with its own URLs, field names, constants for order\nside and product type, error envelope, and rate limits. Writing a strategy against one broker\nmeans re-learning all of that for the next. **Fenix is an adapter library**: each broker is a\nclass that implements the same methods and returns the same dictionaries — a single unified\ninterface purpose-built for the Indian markets (NSE, BSE, NFO, BFO, MCX, CDS).\n\n```python\n# swap one word — the rest never changes\nfrom fenix import Zerodha\nfrom fenix import Side, Product\n\nbroker = Zerodha()\nbroker.authenticate(params=creds)\nbroker.market_order(token_dict=contract, quantity=1, side=Side.BUY, product=Product.MIS, unique_id=\"entry-1\")\n```\n\nIt is built for **coders, quant developers, technically-skilled traders, and data scientists**\nbuilding algorithmic trading systems on top of one stable API.\n\n## Why Fenix\n\n- **Learn it once, ship everywhere.** The same method names, parameters, and return shapes work\n  across every adapter. Porting a strategy to a new broker is a one-line change — not a rewrite.\n- **One vocabulary, not fifteen.** Your code speaks in Fenix constants — `Side.BUY`,\n  `Product.MIS`, `OrderType.SLM` — and each adapter translates to its broker's dialect, with\n  validation.\n- **Backtest with paper mode.** Flip one flag and the same strategy runs against a built-in\n  matching engine — realistic fills, positions, and PnL, with no credentials and zero live calls.\n- **Safe by default.** Token-bucket rate limiting per endpoint, structured errors with\n  HTTP-status mapping, and automatic redaction of secrets from every log line.\n\n## Install\n\nFenix 2.0 requires **Python 3.10 or newer** and runs on Windows, macOS, and Linux.\n\n```shell\npip install fenix\n```\n\nTo install a specific release:\n\n```shell\npip install fenix==2.0.2\n```\n\nVerify the installation and inspect the broker registry:\n\n```python\nimport fenix\n\nprint(fenix.__version__)   # 2.0.2\nprint(fenix.brokers)       # ['AliceBlue', 'AngelOne', 'AnandRathi', ...]\n```\n\n## Quickstart\n\nInstantiate a broker, authenticate, download instrument tokens, place an order, and read it\nback — all through the unified API. The same code runs against any broker.\n\n```python\nfrom fenix import Zerodha, Side, Validity\n\n# 1 · Instantiate\nbroker = Zerodha()\n\n# 2 · Authenticate — each broker declares the credentials it needs in `tokenParams`\ncreds = {\n    \"user_id\":    \"YOUR_USER_ID\",\n    \"password\":   \"YOUR_PASSWORD\",\n    \"totpstr\":    \"YOUR_TOTP_SECRET\",   # the TOTP *seed*, not a 6-digit code\n    \"api_key\":    \"YOUR_API_KEY\",\n    \"api_secret\": \"YOUR_API_SECRET\",\n}\nbroker.authenticate(params=creds)\n\n# 3 · Download instrument tokens (reshaped into a standardized lookup)\nfno, _ = broker.load_fno_tokens()\ncontract = fno[\"Options\"][\"NFO\"][\"NIFTY\"][0]\n\n# 4 · Place an order — returns a unified order record (same keys for every broker)\norder = broker.limit_order(\n    token_dict=contract,\n    side=Side.BUY,\n    price=152.0,\n    quantity=75,\n    unique_id=\"entry-1\",\n)\n\n# 5 · Read it back, then modify or cancel\ndetail = broker.fetch_order(order[\"id\"])\nbroker.modify_order(order_id=order[\"id\"], price=151.5, quantity=75)\nbroker.cancel_order(order_id=order[\"id\"])\n\n# 6 · Inspect positions and account\npositions = broker.fetch_net_positions()\nholdings  = broker.fetch_holdings()\nmargins   = broker.fetch_margin_limits()   # unified RMS record\nprofile   = broker.fetch_profile()\n```\n\n\u003e See the [Quickstart guide](https://fenix.hardeep.tech) for the full walkthrough, including\n\u003e reusing an authenticated session across runs.\n\n### Order \u0026 account methods\n\n| Order entry | Account \u0026 order reads |\n|-------------|-----------------------|\n| `place_order`, `modify_order`, `cancel_order` | `fetch_orderbook`, `fetch_tradebook` |\n| `market_order`, `limit_order`, `sl_order`, `slm_order` | `fetch_order`, `fetch_order_history` |\n| `market_buy_order`, `market_sell_order` | `fetch_net_positions`, `fetch_day_positions` |\n| `limit_buy_order`, `limit_sell_order` | `fetch_holdings`, `fetch_margin_limits` |\n| `sl_buy_order`, `slm_sell_order`, … | `fetch_profile` |\n\n## Features\n\nFenix 2.0 is a ground-up refactor of the broker layer. Highlights:\n\n- 🔁 **Unified, one-line broker swap.** Identical method names, parameters, and return shapes\n  across all 15 adapters — port a strategy by changing a single class name.\n- 🧱 **One shared base class.** Every adapter subclasses `fenix.base.broker.Broker`, which owns\n  the HTTP session, request wrapper, URL building, constant translation, and error mapping. New\n  brokers stay thin and consistent.\n- 📄 **Built-in paper-mode engine.** An in-process matching engine simulates fills, positions,\n  and PnL with no credentials and zero live calls — flip `paper_mode` and the same code runs.\n- 🗣️ **One vocabulary.** Fenix constants (`Side`, `Product`, `OrderType`, `Validity`, `Variety`,\n  `Status`) are translated per broker with validation — see [Constants](#unified-vocabulary).\n- 🚦 **Per-endpoint rate limiting.** Token-bucket throttling defined in each adapter's\n  `rateLimits`; requests self-throttle before hitting the broker.\n- 🔐 **Secret redaction.** Passwords, tokens, API keys, authorization headers, and TOTP values\n  are automatically scrubbed from every log line.\n- 🧾 **Structured errors.** Broker error envelopes are mapped to typed Fenix exceptions with\n  HTTP-status context.\n- 🩺 **Request/response diagnostics.** Every broker keeps the latest HTTP snapshots\n  (`last_request_*`, `last_response_*`) — plus paper-mode equivalents.\n- ⌨️ **Typed.** Ships a PEP 561 `py.typed` marker so downstream type checkers pick up Fenix's\n  annotations.\n\n## Supported Brokers\n\nFenix 2.0 exposes **15 broker adapters**. Each has its own\n[reference page](https://fenix.hardeep.tech) documenting every method it supports.\n\nThe **Class** name is the public identifier — it is exactly what `fenix.brokers` lists and what\n`broker.describe()[\"id\"]` returns.\n\n| | Broker | Class |\n|---|--------|-------|\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/aliceblue.svg\" alt=\"AliceBlue\" height=\"22\"\u003e | AliceBlue | `AliceBlue` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/angelone.svg\" alt=\"Angel One\" height=\"22\"\u003e | Angel One | `AngelOne` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/anandrathi.jpeg\" alt=\"Anand Rathi\" height=\"22\"\u003e | Anand Rathi | `AnandRathi` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/dhan.svg\" alt=\"Dhan\" height=\"22\"\u003e | Dhan | `Dhan` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/finvasia.svg\" alt=\"Finvasia\" height=\"22\"\u003e | Finvasia / Shoonya | `Finvasia` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/fivepaisa.svg\" alt=\"5paisa\" height=\"22\"\u003e | 5paisa | `FivePaisa` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/fyers.svg\" alt=\"Fyers\" height=\"22\"\u003e | Fyers | `Fyers` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/groww.svg\" alt=\"Groww\" height=\"22\"\u003e | Groww | `Groww` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/iifl.svg\" alt=\"IIFL\" height=\"22\"\u003e | IIFL | `Iifl` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/kotakneo.svg\" alt=\"Kotak Neo\" height=\"22\"\u003e | Kotak Neo | `KotakNeo` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/mastertrust.svg\" alt=\"Master Trust\" height=\"22\"\u003e | Master Trust | `MasterTrust` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/motilaloswal.jpeg\" alt=\"Motilal Oswal\" height=\"22\"\u003e | Motilal Oswal | `MotilalOswal` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/symphony.svg\" alt=\"Symphony\" height=\"22\"\u003e | Symphony | `Symphony` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/upstox.svg\" alt=\"Upstox\" height=\"22\"\u003e | Upstox | `Upstox` |\n| \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/brokers/zerodha.svg\" alt=\"Zerodha\" height=\"22\"\u003e | Zerodha | `Zerodha` |\n\n```python\nimport fenix\nprint(fenix.brokers)   # always reflects exactly what your installed version supports\n```\n\n\u003e The deprecated v1 modules `choice`, `kotak`, `kunjee`, and `vpc` were removed in v2.0.\n\n## Unified Vocabulary\n\nYour strategy speaks Fenix constants; each adapter translates them to its broker's dialect and\nvalidates them. The constant classes are top-level exports (`from fenix import Side, Product, …`).\n\n| Constant | Common values |\n|----------|---------------|\n| `Side` | `BUY`, `SELL` |\n| `OrderType` | `MARKET`, `LIMIT`, `SL`, `SLM` |\n| `Product` | `MIS`, `NRML`, `CNC`, `MARGIN`, `MTF`, `BO`, `CO` |\n| `Validity` | `DAY`, `IOC`, `GTD`, `GTC`, `FOK`, `TTL` |\n| `Variety` | `REGULAR`, `STOPLOSS`, `AMO`, `BO`, `CO`, `ICEBERG`, `AUCTION` |\n| `Status` | `PENDING`, `OPEN`, `PARTIALLY_FILLED`, `FILLED`, `REJECTED`, `CANCELLED` |\n| `ExchangeCode` | `NSE`, `NFO`, `BSE`, `BFO`, `MCX`, `CDS`, … |\n| `Root` | `NIFTY`, `BANKNIFTY`, `FINNIFTY`, `SENSEX`, `CRUDEOIL`, … |\n| `Option` | `CE`, `PE` |\n\nReturned records also use a fixed key set (`Order`, `Position`, `Profile`, `RMS`), so the same\nparsing code works for every broker. Full reference at **[fenix.hardeep.tech](https://fenix.hardeep.tech)**.\n\n## Paper Trading\n\nPaper mode routes supported order entry and account reads through Fenix's in-process matching\nengine instead of live broker endpoints — no credentials, zero live calls. Flip one flag and the\nexact same code runs against the simulator.\n\n```python\nfrom fenix import AliceBlue, Side, UniqueID\n\nbroker = AliceBlue({\"paper_mode\": True})\nbroker.authenticate()                      # no-op in paper mode\n\ntoken = {\"Token\": 12345, \"Symbol\": \"TESTSTOCK\", \"Exchange\": \"NSE\"}\n\norder = broker.market_order(\n    token_dict=token, quantity=1, side=Side.BUY, unique_id=UniqueID.MARKET_ORDER,\n)\n\nbroker.on_tick(token=12345, ltp=2500.0)    # feed prices to drive fills\n\nprint(broker.fetch_orderbook())\nprint(broker.fetch_positions())\n```\n\nPaper mode supports order books, trade books, order history, positions, holdings, margin limits,\nprofile data, stop-order validation, and square-off validation.\n\n## How it fits together\n\nEvery adapter — `Zerodha`, `AngelOne`, `Fyers`, … — subclasses `fenix.base.broker.Broker`. The\nbase class owns everything identical across brokers (HTTP session, throttling, the `fetch()`\nrequest wrapper, URL building, constant translation, logging/redaction, error mapping, and the\nembedded paper engine), while each subclass supplies only what is broker-specific.\n\n```\n  Your strategy            Fenix · Unified API           Brokers\n┌────────────────┐          ┌──────────────────────────┐          ┌──────────────────────────┐\n│                │          │  authenticate · login    │          │  Zerodha · Angel One     │\n│  one codebase  │  ──────▶ │  orders · positions      │  ──────▶ │  Fyers · Upstox · Dhan   │\n│                │   call   │  account · paper mode    │   REST   │  … + 10 more brokers     │\n└────────────────┘          └──────────────────────────┘          └──────────────────────────┘\n```\n\n### Operational features\n\n- **Rate limits.** Adapters define token-bucket buckets in `rateLimits`; requests throttle\n  automatically before hitting endpoints. Configure with `enableRateLimit` and\n  `rate_limit_padding`.\n- **Logging \u0026 redaction.** Pass a logger or `verbose=True` to inspect request/response flow.\n  Fenix redacts passwords, tokens, API keys, authorization headers, and TOTP values.\n- **Diagnostics.** Every broker keeps the latest HTTP snapshots (`last_request_*`,\n  `last_response_*`) — and in paper mode, `last_paper_request` / `last_paper_response` /\n  `last_paper_interaction`.\n- **Typed.** Ships a PEP 561 `py.typed` marker so downstream type checkers pick up Fenix's\n  annotations.\n\n## Fenix-Pro — real-time market data\n\n[**Fenix-Pro**](https://fenix.hardeep.tech) is the paid, real-time companion to Fenix. It hides\neach broker's WebSocket transport, payload format, and subscription conventions behind a unified,\ncallback-oriented interface — **LTP, market depth, and order updates**, normalized into one\n`TickData` / `Order` shape across 15 live-feed adapters. It shares Fenix's broker roster and\ninstrument-token shapes, so the two compose cleanly.\n\n## Documentation\n\nFull developer documentation — guides, architecture, the unified API reference, paper mode,\nconstants, and a reference page per broker — lives at **[fenix.hardeep.tech](https://fenix.hardeep.tech)**.\n\n## License\n\nFenix is released under the **GNU General Public License v3.0**. See [LICENSE](https://github.com/TheHardeep/fenix/blob/master/LICENSE) for\ndetails.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://cdn.jsdelivr.net/gh/TheHardeep/fenix@master/assets/fenix-logo-sm.png\" alt=\"Fenix\" width=\"48\"\u003e\u003cbr\u003e\n  \u003csub\u003eBuilt for the Indian markets · \u003ca href=\"https://fenix.hardeep.tech\"\u003efenix.hardeep.tech\u003c/a\u003e\u003c/sub\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheHardeep%2Ffenix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTheHardeep%2Ffenix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheHardeep%2Ffenix/lists"}