Skip to content

docs: simplify and restructure docs site (37 → 22 pages)#62

Draft
Apurv-Salunke wants to merge 1 commit intomainfrom
chore/simplify-docs
Draft

docs: simplify and restructure docs site (37 → 22 pages)#62
Apurv-Salunke wants to merge 1 commit intomainfrom
chore/simplify-docs

Conversation

@Apurv-Salunke
Copy link
Copy Markdown
Collaborator

@Apurv-Salunke Apurv-Salunke commented Mar 27, 2026

Summary

  • Merged overlapping content: auth (2→1), portfolio (3→1), websocket (3→1), errors (2→1), broker-differences (3→1), models+enums (2→1), clients+instrument-store (2→1)
  • Broker-agnostic examples: replaced hardcoded "zerodha" / "angelone" with generic broker_id variable; broker-specific notes use collapsible admonitions
  • Dual sync/async tabs: every code example now shows both TTConnect and AsyncTTConnect usage via pymdownx.tabbed
  • Material for MkDocs: switched from readthedocs theme — deep purple/amber palette, dark mode toggle, code copy, instant navigation, JetBrains Mono
  • Deleted 20 obsolete files, updated all remaining pages

Test plan

  • poetry run mkdocs build --strict passes (no broken links)
  • Local preview verified at localhost:8002
  • Verify deployed site renders correctly after merge

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Restructured documentation with clearer organization and navigation
    • Added new guides on authentication, error handling, and getting started
    • Consolidated portfolio-related documentation with improved examples
    • Modernized WebSocket streaming documentation
    • Improved documentation theme and user interface
  • Chores

    • Updated documentation theme and build dependencies

Merge overlapping content (auth, portfolio, websocket, errors),
make all examples broker-agnostic with dual sync/async tabs,
switch to Material for MkDocs theme, and delete 20 obsolete files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This PR restructures the documentation for tt-connect by consolidating multiple guides into coherent sections, removing redundant pages, adding new guides (getting-started, authentication, error-handling, portfolio, websocket), updating code examples to show sync/async variants, switching the MkDocs theme to Material, and reorganizing the navigation structure.

Changes

Cohort / File(s) Summary
New consolidated guides
docs_site/getting-started.md, docs_site/authentication.md, docs_site/error-handling.md, docs_site/portfolio.md, docs_site/websocket.md
Added five new documentation pages covering: getting started with trading concepts and sync/async clients; authentication modes (manual/auto) and configuration; error taxonomy and retry patterns; portfolio operations (positions/holdings/funds/trades) with sync/async examples; and live tick streaming via WebSocket with feed health callbacks and reconnect behavior.
Removed consolidated/replaced pages
docs_site/basics.md, docs_site/login-and-session.md, docs_site/config-and-env.md, docs_site/holdings-and-funds.md, docs_site/positions.md, docs_site/trades.md, docs_site/errors-and-retries.md, docs_site/realtime-websocket.md, docs_site/safety-and-good-practices.md, docs_site/start-here.md, docs_site/glossary.md
Deleted eleven pages whose content has been reorganized, consolidated into new guides, or redistributed across updated pages (e.g., holdings/positions/trades merged into portfolio.md; errors-and-retries merged into error-handling.md).
Updated guide pages
docs_site/broker-differences.md, docs_site/gtt.md, docs_site/instruments.md, docs_site/market-data.md, docs_site/orders.md
Restructured examples to show labeled Sync/Async variants; refined broker-specific guidance; updated function names and variable references (e.g., broker_id vs hardcoded strings); reformatted tables and sections for clarity.
Updated recipe pages
docs_site/recipes/first-order.md, docs_site/recipes/cancel-all-open-orders.md, docs_site/recipes/close-all-open-positions.md, docs_site/recipes/stream-and-store-live-ticks.md
Restructured code examples into Sync/Async tabs; replaced explicit client lifecycle (close()) with context managers; updated navigation links to reflect reorganized docs.
Removed recipe/reference pages
docs_site/recipes/index.md, docs_site/recipes/recover-from-reconnect.md, docs_site/reference/index.md, docs_site/reference/capabilities.md, docs_site/reference/enums.md, docs_site/reference/instrument-store.md, docs_site/reference/operation-notes.md, docs_site/troubleshooting/index.md, docs_site/troubleshooting/websocket-reconnect.md
Deleted nine index, reference, and troubleshooting pages; content consolidated into primary guides or redistributed to updated reference pages.
Updated reference pages
docs_site/reference/clients.md, docs_site/reference/models.md
Extended clients.md with new InstrumentStore/AsyncInstrumentStore sections; merged enums documentation into models.md under "Public enums" and "Internal enums"; updated parameter formatting and error lists.
Updated troubleshooting pages
docs_site/troubleshooting/auth-failures.md, docs_site/troubleshooting/instrument-not-found.md, docs_site/troubleshooting/duplicate-orders.md, docs_site/troubleshooting/order-rejected.md
Added Sync/Async code examples; refined wording and formatting; updated cross-references to reflect reorganized docs (e.g., "Errors & Retries" → "Error Handling").
Updated navigation/index
docs_site/index.md
Renamed section headings to lowercase; replaced navigation links to reflect new guide structure (getting-started, authentication, first-order recipe); updated common-tasks and help links.
Build configuration
mkdocs.yml, pyproject.toml
Switched theme from readthedocs to material with explicit palettes, fonts, and extensions; reorganized navigation structure under "Getting Started", "Guides", "Operations", and "Reference"; added mkdocs-material dev dependency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

documentation

Poem

🐰 Hops through the docs with glee,
New guides spring forth, clear as can be!
Sync and async in tandem dance,
Auth, errors, portfolios—all advance.
One Material theme binds them tight,
The trader's path now gleams just right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: a comprehensive restructuring and simplification of the documentation site from 37 to 22 pages.
Description check ✅ Passed The description covers the problem (overlapping/obsolete docs), changes (merging, broker-agnostic examples, dual sync/async tabs, theme migration), and test evidence (mkdocs build passed, local preview verified).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/simplify-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs_site/recipes/stream-and-store-live-ticks.md (1)

19-27: ⚠️ Potential issue | 🟡 Minor

Undefined broker_id variable.

The broker_id variable at line 26 is not defined in this example. Since this is a complete, runnable recipe, users will encounter a NameError.

📝 Suggested fix
 async def main() -> None:
     config = {"api_key": "...", "access_token": "..."}
+    broker_id = "zerodha"  # or "angelone"
     watch = [
         Equity(exchange=Exchange.NSE, symbol="RELIANCE"),
         Equity(exchange=Exchange.NSE, symbol="SBIN"),
     ]

     async with AsyncTTConnect(broker_id, config) as broker:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/recipes/stream-and-store-live-ticks.md` around lines 19 - 27, The
example calls AsyncTTConnect(broker_id, config) but broker_id is not defined,
causing a NameError; update the example in main to define a broker_id variable
(e.g., broker_id = "<your_broker_id>" or broker_id = "demo") before the async
with line or pass the intended literal string directly to AsyncTTConnect; ensure
the symbol broker_id is declared in the same scope as main() so AsyncTTConnect
and the await broker.subscribe(watch, on_tick) call use a valid identifier.
🧹 Nitpick comments (3)
pyproject.toml (1)

28-28: Inconsistent version constraint style.

All other dev dependencies use >= constraints, but mkdocs-material uses ^. Consider using >=9.7.6 for consistency, or confirm the stricter caret constraint is intentional to avoid major version upgrades.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` at line 28, The mkdocs-material dependency uses a caret
constraint (^9.7.6) which is inconsistent with other dev dependencies that use
>= style; update the mkdocs-material entry (the dependency named
"mkdocs-material" and its version string "^9.7.6") to use the same constraint
style by changing the version to ">=9.7.6", or if you intend to lock to caret
semantics, add a comment in the PR explaining why the stricter ^9.7.6 constraint
is required so reviewers know the deviation is intentional.
docs_site/troubleshooting/auth-failures.md (1)

11-14: Optional: Consider varying the sentence structure.

The checklist uses "Confirm" to start three consecutive items (lines 11-14). While functionally clear, varying the sentence structure could improve readability. For example:

  • Line 11: "Verify the broker ID is correct"
  • Line 12: "Ensure required config keys are present..."
  • Line 13: "Check that token/session is still valid..."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/troubleshooting/auth-failures.md` around lines 11 - 14, The three
consecutive checklist items that all start with the word "Confirm" should be
rewritten to vary sentence structure for readability: change the first "Confirm
broker ID is correct" to "Verify the broker ID is correct", change the second
"Confirm required config keys are present for your broker and auth mode" to
"Ensure required config keys are present for your broker and auth mode", and
change the third "Confirm token/session is still valid (tokens expire daily per
SEBI rules)" to "Check that the token/session is still valid (tokens expire
daily per SEBI rules)"; leave the fourth item unchanged.
docs_site/authentication.md (1)

14-24: Consider defining broker_id placeholder explicitly.

The code examples use broker_id without defining it, which may confuse readers. Consider adding a comment or assignment to make the placeholder explicit.

📝 Suggested improvement
 === "Sync"

     ```python
     from tt_connect import TTConnect

+    broker_id = "zerodha"  # or "angelone"
     config = {
         "api_key": "YOUR_API_KEY",
         "access_token": "YOUR_ACCESS_TOKEN",
     }

     with TTConnect(broker_id, config) as broker:
         print(broker.get_profile().name)
     ```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/authentication.md` around lines 14 - 24, The example uses an
undefined broker_id which can confuse readers; add an explicit placeholder
assignment or comment before using TTConnect (e.g., set broker_id = "zerodha" or
similar) so the TTConnect(broker_id, config) call is clear; update the snippet
near the TTConnect import and config to define broker_id and/or add an inline
comment indicating acceptable values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs_site/instruments.md`:
- Around line 50-59: The async example in the docs uses undefined broker_id and
config; add definitions before using AsyncTTConnect: declare a broker_id (e.g.
"zerodha" or "angelone") and a config dict with the required keys (e.g.
"api_key" and "access_token") so AsyncTTConnect(broker_id, config) and the
subsequent call to search_instruments(...) work; update the snippet around
AsyncTTConnect, broker_id, and config to mirror the sync example's setup.

In `@docs_site/portfolio.md`:
- Around line 25-30: The example uses an undefined variable broker_id causing a
NameError; update the snippet around TTConnect(...) to either declare broker_id
(e.g., set to an example string or show how to obtain it) or add a clear inline
comment explaining where to get/replace broker_id (reference TTConnect and
broker.get_positions() so readers know which examples rely on it); ensure the
change is minimal and preserves the example flow.

In `@docs_site/recipes/cancel-all-open-orders.md`:
- Around line 7-16: The example uses an undefined broker_id when constructing
TTConnect; define broker_id before the with-block (e.g., broker_id =
"<your_broker_id>" or obtain it via environment/config) or add a one-line
comment referencing the getting-started guide for where to get the broker ID so
the TTConnect(...) call and subsequent broker.cancel_all_orders() call work
as-is.

In `@docs_site/reference/models.md`:
- Around line 52-65: Documentation claims FeedState can be imported from
tt_connect.enums but FeedState is not exported there (it's defined in
tt_connect.core.models.enums), so either add "FeedState" to the __all__ list in
tt_connect/enums.py so consumers can import FeedState from tt_connect.enums, or
update docs_site/reference/models.md and docs_site/websocket.md to reference
tt_connect.core.models.enums.FeedState; locate the enum symbol FeedState and the
export list __all__ in tt_connect/enums.py (and the original definition in
tt_connect/core/models/enums.py) and apply one consistent fix across code/docs.

In `@docs_site/troubleshooting/instrument-not-found.md`:
- Around line 17-30: The examples call TTConnect(broker_id, config) but never
define broker_id; add a clear definition (e.g., broker_id = "<your_broker_id>"
or an integer ID) before using TTConnect in both the sync and the other example
so TTConnect and broker_id are defined (look for TTConnect(...) usages and
define broker_id above them).

In `@docs_site/websocket.md`:
- Around line 57-65: The docs example imports FeedState from tt_connect.enums
but that symbol isn't exported there; update the import to the module that
actually exports FeedState (e.g., change the import line to use the module that
exposes FeedState as noted in models.md) so the example works; ensure the
example keeps using FeedState and broker.feed_state as shown and adjust the
import path to the correct public export (or re-export FeedState from
tt_connect.enums and then keep the existing import).

In `@mkdocs.yml`:
- Around line 1-2: Add an entry to CHANGELOG.md documenting the documentation
restructure: mention that site_name "tt-connect" docs were simplified (pages
reduced from 37 to 22) and include a short note about what changed (docs
consolidation/reorganization) and the PR/author reference; update the Unreleased
section (or create one) with this concise changelog line so the CI
changelog-check passes.

---

Outside diff comments:
In `@docs_site/recipes/stream-and-store-live-ticks.md`:
- Around line 19-27: The example calls AsyncTTConnect(broker_id, config) but
broker_id is not defined, causing a NameError; update the example in main to
define a broker_id variable (e.g., broker_id = "<your_broker_id>" or broker_id =
"demo") before the async with line or pass the intended literal string directly
to AsyncTTConnect; ensure the symbol broker_id is declared in the same scope as
main() so AsyncTTConnect and the await broker.subscribe(watch, on_tick) call use
a valid identifier.

---

Nitpick comments:
In `@docs_site/authentication.md`:
- Around line 14-24: The example uses an undefined broker_id which can confuse
readers; add an explicit placeholder assignment or comment before using
TTConnect (e.g., set broker_id = "zerodha" or similar) so the
TTConnect(broker_id, config) call is clear; update the snippet near the
TTConnect import and config to define broker_id and/or add an inline comment
indicating acceptable values.

In `@docs_site/troubleshooting/auth-failures.md`:
- Around line 11-14: The three consecutive checklist items that all start with
the word "Confirm" should be rewritten to vary sentence structure for
readability: change the first "Confirm broker ID is correct" to "Verify the
broker ID is correct", change the second "Confirm required config keys are
present for your broker and auth mode" to "Ensure required config keys are
present for your broker and auth mode", and change the third "Confirm
token/session is still valid (tokens expire daily per SEBI rules)" to "Check
that the token/session is still valid (tokens expire daily per SEBI rules)";
leave the fourth item unchanged.

In `@pyproject.toml`:
- Line 28: The mkdocs-material dependency uses a caret constraint (^9.7.6) which
is inconsistent with other dev dependencies that use >= style; update the
mkdocs-material entry (the dependency named "mkdocs-material" and its version
string "^9.7.6") to use the same constraint style by changing the version to
">=9.7.6", or if you intend to lock to caret semantics, add a comment in the PR
explaining why the stricter ^9.7.6 constraint is required so reviewers know the
deviation is intentional.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c0aa3076-2ac4-499a-9226-761107afca7c

📥 Commits

Reviewing files that changed from the base of the PR and between 6036b58 and 4a076c6.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (44)
  • docs_site/authentication.md
  • docs_site/basics.md
  • docs_site/broker-differences.md
  • docs_site/config-and-env.md
  • docs_site/error-handling.md
  • docs_site/errors-and-retries.md
  • docs_site/getting-started.md
  • docs_site/glossary.md
  • docs_site/gtt.md
  • docs_site/holdings-and-funds.md
  • docs_site/index.md
  • docs_site/instruments.md
  • docs_site/login-and-session.md
  • docs_site/market-data.md
  • docs_site/orders.md
  • docs_site/portfolio.md
  • docs_site/positions.md
  • docs_site/realtime-websocket.md
  • docs_site/recipes/cancel-all-open-orders.md
  • docs_site/recipes/close-all-open-positions.md
  • docs_site/recipes/first-order.md
  • docs_site/recipes/index.md
  • docs_site/recipes/recover-from-reconnect.md
  • docs_site/recipes/stream-and-store-live-ticks.md
  • docs_site/reference/capabilities.md
  • docs_site/reference/clients.md
  • docs_site/reference/enums.md
  • docs_site/reference/exceptions.md
  • docs_site/reference/index.md
  • docs_site/reference/instrument-store.md
  • docs_site/reference/models.md
  • docs_site/reference/operation-notes.md
  • docs_site/safety-and-good-practices.md
  • docs_site/start-here.md
  • docs_site/trades.md
  • docs_site/troubleshooting/auth-failures.md
  • docs_site/troubleshooting/duplicate-orders.md
  • docs_site/troubleshooting/index.md
  • docs_site/troubleshooting/instrument-not-found.md
  • docs_site/troubleshooting/order-rejected.md
  • docs_site/troubleshooting/websocket-reconnect.md
  • docs_site/websocket.md
  • mkdocs.yml
  • pyproject.toml
💤 Files with no reviewable changes (20)
  • docs_site/glossary.md
  • docs_site/start-here.md
  • docs_site/reference/capabilities.md
  • docs_site/positions.md
  • docs_site/troubleshooting/index.md
  • docs_site/config-and-env.md
  • docs_site/reference/index.md
  • docs_site/recipes/index.md
  • docs_site/reference/enums.md
  • docs_site/login-and-session.md
  • docs_site/errors-and-retries.md
  • docs_site/holdings-and-funds.md
  • docs_site/basics.md
  • docs_site/reference/instrument-store.md
  • docs_site/realtime-websocket.md
  • docs_site/trades.md
  • docs_site/troubleshooting/websocket-reconnect.md
  • docs_site/safety-and-good-practices.md
  • docs_site/reference/operation-notes.md
  • docs_site/recipes/recover-from-reconnect.md

Comment on lines +50 to +59
=== "Async"

futures = broker.get_futures(underlying)
print("Futures count:", len(futures))
```python
from tt_connect import AsyncTTConnect

if expiries:
chain = broker.get_options(underlying, expiry=expiries[0])
print("Options for first expiry:", len(chain))
```
async with AsyncTTConnect(broker_id, config) as broker:
results = await broker.search_instruments("RELIANCE", exchange="NSE")
for i in results:
print(i.exchange, i.symbol)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing config definition in async example.

The async "Search instruments" example at lines 50-59 uses broker_id and config but neither is defined, unlike the sync example which at least shows the config dictionary. This inconsistency will confuse users.

📝 Suggested fix
 === "Async"

     ```python
     from tt_connect import AsyncTTConnect

+    config = {"api_key": "...", "access_token": "..."}
+    broker_id = "zerodha"  # or "angelone"
+
     async with AsyncTTConnect(broker_id, config) as broker:
         results = await broker.search_instruments("RELIANCE", exchange="NSE")
         for i in results:
             print(i.exchange, i.symbol)
     ```
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 52-52: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/instruments.md` around lines 50 - 59, The async example in the docs
uses undefined broker_id and config; add definitions before using
AsyncTTConnect: declare a broker_id (e.g. "zerodha" or "angelone") and a config
dict with the required keys (e.g. "api_key" and "access_token") so
AsyncTTConnect(broker_id, config) and the subsequent call to
search_instruments(...) work; update the snippet around AsyncTTConnect,
broker_id, and config to mirror the sync example's setup.

Comment on lines +25 to +30
config = {"api_key": "...", "access_token": "..."}

with TTConnect(broker_id, config) as broker:
for p in broker.get_positions():
print(p.instrument.symbol, "qty=", p.qty, "pnl=", p.pnl)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Undefined broker_id variable in code examples.

The broker_id variable is used throughout the examples but never defined. Users copying these snippets will encounter a NameError. Consider adding a definition or a comment showing expected usage:

📝 Suggested fix
     config = {"api_key": "...", "access_token": "..."}
+    broker_id = "zerodha"  # or "angelone", etc.

     with TTConnect(broker_id, config) as broker:

Alternatively, add a note at the top of the page directing users to see the getting-started guide for broker_id setup.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
config = {"api_key": "...", "access_token": "..."}
with TTConnect(broker_id, config) as broker:
for p in broker.get_positions():
print(p.instrument.symbol, "qty=", p.qty, "pnl=", p.pnl)
```
config = {"api_key": "...", "access_token": "..."}
broker_id = "zerodha" # or "angelone", etc.
with TTConnect(broker_id, config) as broker:
for p in broker.get_positions():
print(p.instrument.symbol, "qty=", p.qty, "pnl=", p.pnl)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/portfolio.md` around lines 25 - 30, The example uses an undefined
variable broker_id causing a NameError; update the snippet around TTConnect(...)
to either declare broker_id (e.g., set to an example string or show how to
obtain it) or add a clear inline comment explaining where to get/replace
broker_id (reference TTConnect and broker.get_positions() so readers know which
examples rely on it); ensure the change is minimal and preserves the example
flow.

Comment on lines +7 to +16
```python
from tt_connect import TTConnect

with TTConnect("zerodha", config) as broker:
cancelled, failed = broker.cancel_all_orders()
print("Cancelled:", cancelled)
print("Failed:", failed)
```
config = {"api_key": "...", "access_token": "..."}

with TTConnect(broker_id, config) as broker:
cancelled, failed = broker.cancel_all_orders()
print("Cancelled:", cancelled)
print("Failed:", failed)
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Undefined broker_id variable in examples.

Same issue as other updated docs - broker_id is used but not defined. Consider adding a definition or a cross-reference to getting-started docs.

📝 Suggested fix
     from tt_connect import TTConnect

     config = {"api_key": "...", "access_token": "..."}
+    broker_id = "zerodha"  # or "angelone"

     with TTConnect(broker_id, config) as broker:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```python
from tt_connect import TTConnect
with TTConnect("zerodha", config) as broker:
cancelled, failed = broker.cancel_all_orders()
print("Cancelled:", cancelled)
print("Failed:", failed)
```
config = {"api_key": "...", "access_token": "..."}
with TTConnect(broker_id, config) as broker:
cancelled, failed = broker.cancel_all_orders()
print("Cancelled:", cancelled)
print("Failed:", failed)
```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/recipes/cancel-all-open-orders.md` around lines 7 - 16, The example
uses an undefined broker_id when constructing TTConnect; define broker_id before
the with-block (e.g., broker_id = "<your_broker_id>" or obtain it via
environment/config) or add a one-line comment referencing the getting-started
guide for where to get the broker ID so the TTConnect(...) call and subsequent
broker.cancel_all_orders() call work as-is.

Comment on lines +52 to +65
## Public enums

## Related guides
- [Instruments](../instruments.md)
- [Orders](../orders.md)
- [Market Data](../market-data.md)
- [GTT](../gtt.md)
Import from `tt_connect.enums`:

| Enum | Values | Typical usage |
|---|---|---|
| `Exchange` | `NSE`, `BSE`, `NFO`, `BFO`, `CDS`, `MCX` | Instrument exchange/segment |
| `OptionType` | `CE`, `PE` | Option side |
| `ProductType` | `CNC`, `MIS`, `NRML` | Order product/margin type |
| `OrderType` | `MARKET`, `LIMIT`, `SL`, `SL_M` | Order execution style |
| `Side` | `BUY`, `SELL` | Order direction |
| `OrderStatus` | `PENDING`, `OPEN`, `COMPLETE`, `CANCELLED`, `REJECTED` | Normalized order state |
| `FeedState` | `connecting`, `connected`, `reconnecting`, `stale`, `closed` | WebSocket feed health |
| `CandleInterval` | `1minute`, `3minute`, `5minute`, `10minute`, `15minute`, `30minute`, `60minute`, `day` | Historical candle interval |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify FeedState export status
echo "=== Checking tt_connect/enums.py __all__ ==="
cat tt_connect/enums.py | grep -A 15 "__all__"

echo ""
echo "=== Checking if FeedState is re-exported anywhere ==="
rg -n "FeedState" tt_connect/__init__.py tt_connect/enums.py 2>/dev/null || echo "No re-export found"

Repository: Tiny-Trader/connect

Length of output: 579


🏁 Script executed:

# Check where FeedState is defined and if it's used elsewhere
echo "=== Finding FeedState definition ==="
rg -n "class FeedState\|FeedState\s*=" --type py 2>/dev/null | head -20

echo ""
echo "=== Checking for FeedState imports in codebase ==="
rg -n "from.*FeedState\|import.*FeedState" --type py 2>/dev/null | head -10

echo ""
echo "=== Checking if FeedState is referenced in docs ==="
rg -n "FeedState" docs_site/reference/models.md

Repository: Tiny-Trader/connect

Length of output: 310


🏁 Script executed:

# Broader search for FeedState in all files
echo "=== Searching for FeedState in all files ==="
rg "FeedState" --type py --type md 2>/dev/null

echo ""
echo "=== Check if FeedState ever existed in git history (recent commits only) ==="
git log --oneline -20 -- "*enums*" 2>/dev/null | head -10

echo ""
echo "=== List all Python files that might contain enum definitions ==="
fd -e py "enums|enum" tt_connect 2>/dev/null

Repository: Tiny-Trader/connect

Length of output: 2810


FeedState is not exported from tt_connect.enums.

Line 64 documents FeedState as importable from tt_connect.enums, but the __all__ list in tt_connect/enums.py only exports 7 enums and FeedState is not among them. Users following this documentation will get an ImportError. Additionally, docs_site/websocket.md contains the same incorrect import statement. The enum is defined in tt_connect/core/models/enums.py and used internally throughout the codebase.

Either:

  1. Add FeedState to the __all__ export list in tt_connect/enums.py, or
  2. Update all documentation to reference the correct internal import path: tt_connect.core.models.enums
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/reference/models.md` around lines 52 - 65, Documentation claims
FeedState can be imported from tt_connect.enums but FeedState is not exported
there (it's defined in tt_connect.core.models.enums), so either add "FeedState"
to the __all__ list in tt_connect/enums.py so consumers can import FeedState
from tt_connect.enums, or update docs_site/reference/models.md and
docs_site/websocket.md to reference tt_connect.core.models.enums.FeedState;
locate the enum symbol FeedState and the export list __all__ in
tt_connect/enums.py (and the original definition in
tt_connect/core/models/enums.py) and apply one consistent fix across code/docs.

Comment on lines +17 to +30
=== "Sync"

```python
from tt_connect import TTConnect
from tt_connect.instruments import Equity
from tt_connect.enums import Exchange

config = {"api_key": "...", "access_token": "..."}

with TTConnect(broker_id, config) as broker:
print(broker.search_instruments("SBIN", exchange="NSE"))
underlying = Equity(exchange=Exchange.NSE, symbol="SBIN")
print(broker.get_expiries(underlying))
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Undefined broker_id variable.

The broker_id variable is used at lines 26 and 41 but not defined in either example.

📝 Suggested fix for sync example
     config = {"api_key": "...", "access_token": "..."}
+    broker_id = "zerodha"  # or "angelone"

     with TTConnect(broker_id, config) as broker:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/troubleshooting/instrument-not-found.md` around lines 17 - 30, The
examples call TTConnect(broker_id, config) but never define broker_id; add a
clear definition (e.g., broker_id = "<your_broker_id>" or an integer ID) before
using TTConnect in both the sync and the other example so TTConnect and
broker_id are defined (look for TTConnect(...) usages and define broker_id above
them).

Comment on lines +57 to +65
```python
from tt_connect.enums import FeedState

if broker.feed_state == FeedState.STALE:
print("No data — market may be closed or connection degraded")

if broker.feed_state == FeedState.CONNECTED:
print("Stream is healthy")
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Import path inconsistency with models.md.

Line 58 shows importing FeedState from tt_connect.enums, but as noted in the models.md review, FeedState is not currently exported from that module. This example will fail with an ImportError.

Once the FeedState export issue is resolved (either by adding it to tt_connect.enums or by documenting the correct internal path), update this import accordingly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs_site/websocket.md` around lines 57 - 65, The docs example imports
FeedState from tt_connect.enums but that symbol isn't exported there; update the
import to the module that actually exports FeedState (e.g., change the import
line to use the module that exposes FeedState as noted in models.md) so the
example works; ensure the example keeps using FeedState and broker.feed_state as
shown and adjust the import path to the correct public export (or re-export
FeedState from tt_connect.enums and then keep the existing import).

Comment on lines +1 to +2
site_name: tt-connect
site_description: Unified broker API for Indian markets
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Pipeline failure: CHANGELOG.md not updated.

The CI changelog-check failed because CHANGELOG.md was not updated for this documentation restructuring PR. Consider adding an entry documenting the docs simplification from 37 to 22 pages.

🧰 Tools
🪛 GitHub Actions: changelog-check

[error] 1-1: Documentation-related files and changelog requirement triggered failure because CHANGELOG.md was not updated.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mkdocs.yml` around lines 1 - 2, Add an entry to CHANGELOG.md documenting the
documentation restructure: mention that site_name "tt-connect" docs were
simplified (pages reduced from 37 to 22) and include a short note about what
changed (docs consolidation/reorganization) and the PR/author reference; update
the Unreleased section (or create one) with this concise changelog line so the
CI changelog-check passes.

@Apurv-Salunke Apurv-Salunke marked this pull request as draft March 27, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant