Borrowing it
Nothing to install: this file belongs to DoRmAmMu1997/My-Algo-Trading-Code. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/DoRmAmMu1997/My-Algo-Trading-Code/main/AGENTS.mdgit clone --depth 1 https://github.com/DoRmAmMu1997/My-Algo-Trading-CodeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/dormammu1997/my-algo-trading-code/agents-md)<a href="https://agentmods.dev/instructions/dormammu1997/my-algo-trading-code/agents-md"><img src="https://agentmods.dev/badge/instructions/dormammu1997/my-algo-trading-code/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/dormammu1997/my-algo-trading-code/agents-md"><img src="https://agentmods.dev/badge/instructions/dormammu1997/my-algo-trading-code/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.07064 | $0.07064 |
| Opus 5.5 | $0.02826 | $0.02826 |
| Sonnet 5.5 | $0.01413 | $0.01413 |
| Haiku 4.5 | $0.00706 | $0.00706 |
Grade A, and why
My-Algo-Trading-Code AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
1 near-identical copy found in the catalogue:
- My-Algo-Trading-Code CLAUDE.md — 92% identical, 10 lines differ
How it starts
The opening of the file, as written. The whole thing — 335 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md — My-Algo-Trading-Code
Working principles for ANY coding agent in this repo: simplicity first, surgical changes, surface tradeoffs, and verify before claiming done. This is live-money trading code — bias toward caution. (Claude Code additionally loads its skills per
CLAUDE.md; everything from "What this project is" down is kept identical in both files — edit them together.)
What this project is
A NIFTY index-options, multi-strategy trading system. The flow is: fetch 1-minute OHLC history from the DhanHQ API → backtest strategies on it → run a multithreaded "front test" whose approximately 28-strategy core roster and independently opt-in agents execute together — on paper by default, and live through a real broker when explicitly enabled. Running live since May 2026; daily per-strategy results are tracked in a Google Sheet.
Architecture (runtime)
One process, cooperating threads:
CentralMarketDataFetcher(one thread) polls DhanHQ and writes into a lock-guardedSharedMarketDataStore(1-min OHLC + LTPs). SettingMARKET_DATA_SOURCE=WEBSOCKET(fails closed to REST on any other value; needs the paid Dhan Data API subscription) swaps inWebSocketMarketDataFetcher: Dhan marketfeed ticks build the bars/LTPs (pure helpers inDependencies/tick_bar_builder.py), with REST kept for warmup and a once-per-minute true-up against official candles.- Approximately 28 core strategy worker threads read that store and decide trades: the
AtmSingleLegStrategyWorkerfamily (Renko / EMA / Heikin-Ashi / Profit-Shooter / Goldmine / Money-Machine / CPR / CPR Algo 3 (multi-instrument: spot + ITM CE + ITM PE) / CPR Algo 4 (deterministic Intraday SRSI VWAP) / Opening-Strike + 13 ported TradingBot strategies + the Regime Adaptive router), two hedged-puts workers, one Delta-0.2 hedged-spread worker, and one long-strangle worker (time-based dual-leg BUY of OTM1 CE+PE, with momentum re-entry). Regime Adaptive (ported from the MIT-licensedworkratananmol-hub/nifty-options-paper-trading-bot) is one worker that switches RULE on ADX: opening-range breakout when trending, VWAP fade when ranging, no trade when ADX is missing. Its two candidate rules live inSignal Generators/Regime Adaptive Strategy/regime_candidates.pyas library code with NO worker of their own — deliberately, so the router and a candidate can never take the same signal twice. Read that folder'sREGIME_PORTING_NOTES.mdbefore enabling it live: the feed carries no volume so its VWAP is an equal-weight proxy. It is also the first user of the shared bid/ask spread gate (<PREFIX>_MAX_SPREAD_PCT, default 0 = off for every other strategy):_spread_gate_allows_entryreadstop_bid_price/top_ask_priceoff the/optionchainresponse and refuses an entry wider than the cap in paper AND live, while an unreadable quote refuses LIVE only. The source's VIX and breadth vetoes remain unimplemented — absent by choice, not for want of data (the source runs on Dhan too). CPR Algo 4 (CPRAlgo4StrategyWorker,CPR_ALGO4_*) is the deterministic version of the SRSI/VWAP playbook CPR AI traded before its Trend-Day Rider (below): the 09:25 5-min close against [MIN(S1,PDL), MAX(R1,PDH)] fixes a SIDEWAYS day (Stochastic RSI 20/80 reversals, swing stop) or a TRENDING day (VWAP pullbacks with RSI/EMA filters that flip on LH+LL / HH+HL structure and re-enter via a reversal sequence); every signal BUYS the ATM CE/PE. Its broker-free engine (Signal Generators/CPR Strategy/cpr_algo4_signal_generator.py) is driven identically by the worker andcpr_algo4_backtest.py. It is its own worker, NOT a fourth algo insideCPRStrategyWorker(that worker has one position slot, one live gate and one Sheet row) -- seedocs/adr/0018. Its R1 add and two-leg exit began as a copy of CPR AI's former mechanics; CPR AI no longer has an add, so Algo 4 now holds the only copy. An optional, opt-in CPR Codex AI Agent runs the Trend-Day Rider (docs/adr/0019, chosen from a five-year study on real weekly option premiums). On a completed 5-min bar starting 11:00-13:30 the host flags a candidate when the session range exceeds ATR5 and the close sits in the outer 15% of that range on the trend side of VWAP (bullish also needs 2 of 3 confluence factors: beyond R1, a gap up, more than 0.35 x ATR5 from VWAP). That gate lives incpr_ai_trend_day.pyand is shared withcpr_ai_trend_day_backtest.py. Codex, behind four frozen no-argument MCP tools, is consulted only on a candidate (accept or veto -- never reverse it) and, while a position is open, for premise exits; the host owns every price, gate and order. Every entry SELLS the opposite current-week ATM option (bullish PE, bearish CE) with a fixed VWAP spot stop, no target, and one entry per session. It is disabled and live-disabled by default under the normal global-plus-strategy double gate. Spot stops trigger exits but cannot guarantee fills. Ordinary CPR, CPR Algo 3, CPR Algo 4, Regime Adaptive, and CPR AI may coexist with independent positions and P&L. Another optional, opt-in worker is LLM-driven: the SL Hunting AI Agent (a Claude agent viaclaude-agent-sdk) — off by default (SL_HUNTING_ENABLED), it decides once per completed 1-min bar (with BankNIFTY cross-confirmation, fetched per bar like CPR Algo 3, and dynamic ~₹2500 risk-based sizing) and acts through the same ATMenter_position/exit_position; its deps are lazily imported so a missing dep just disables it. Every NIFTY entry is mechanically MIRRORED with an equal-lot BankNIFTY ATM leg (SL_HUNTING_BNF_MIRROR, default true) — NOTE: the mirror roughly DOUBLES the basket's rupee risk beyondSL_HUNTING_RISK_BUDGET(operator-accepted; the daily max-loss kill-switch still caps the day): the legs are TIED for hard risk (stop/target, max-loss, 15:15 square-off close both) but the agent evaluates each leg's premise INDEPENDENTLY and can cut one alone via the EXITexit_legselector (NIFTY|BNF|BOTH). The NIFTY stop fires on a completed 1-min candle's CLOSE beyond it, plus an intrabar backstop at 1.5x its distance (SLH-027,SL_HUNTING_STOP_ON_CLOSE/_STOP_BACKSTOP_MULTIPLE). Entry stays NIFTY-only (the mirror copies it). It stops opening NEW positions after 10:30 (SL_HUNTING_NO_NEW_ENTRY_HOUR/_MINUTE, default 10:30) — not a square-off (exits + the 15:15 square-off still run; when flat past the cutoff it skips the LLM call entirely). After a target, stop, or premise-invalidating exit,SL_HUNTING_POST_EXIT_COOLDOWN_MINUTESblocks re-entry from the moment the WHOLE NIFTY/BankNIFTY basket is confirmed flat; a lone or partly closed leg does not run the timer down, exits never wait for it, and corrupt guard state rejects new LIVE entries. It can also learn from its own trades (v3): a per-trade journal feeds an off-loop reflection coach (sl_hunting_coach.py) that proposes lessons; the operator promotes approved ones intolessons.json, injected into the prompt only whenSL_HUNTING_LESSONS_ENABLED(human-gated, paper-first, off by default). Its knowledge also carries a curated BankNIFTY live-trading layer (v3a, knowledge-only): aBNF_SPECIFICsection (triple-index BNF+NIFTY+Sensex read, BankNIFTY as the "major index", expiry-day priority, round-number magnets) that is advisory context for the cross-index read — execution stays NIFTY-only — plus general lessons merged into the existing sections (distilled from Intraday Hunter videos; provenance insl_hunting_doc.md). With both optional agents enabled, the configured roster can reach approximately 30 workers, but enable and virtual-trading gates keep the running roster configuration-dependent. - An optional, opt-in read-only monitoring dashboard (
DASHBOARD_ENABLED, default false) serves a browser page on127.0.0.1answering "where do I stand right now": open trades with live marks and running P&L, today's closed trades grouped by strategy, per-strategy realized/open/total, and a live NIFTY candle chart. Read-only by construction — GET is the only method (anything else is 405), routes are a frozen whitelist, and nothing it calls can reach the broker. One daemon builder thread publishes an immutable JSON blob that HTTP threads hand out, so no browser tab ever touches a worker. It must never callmarket_data_health.snapshot()(which MUTATES the liquidation clock's state),_get_open_position_pnl/_get_option_ltp(broker fallback), orSessionStateStore.snapshot()on a tick; a test asserts all three.DASHBOARD_BIND_HOSTis a module constant with deliberately NO.envknob. Stopped LAST, after the session is flat and results are published. Pure shaping inDependencies/dashboard_snapshot.py, chart indicators indashboard_indicators.py, transport indashboard_server.py, the collector in the master beside_worker_session_state_snapshot; seedocs/adr/0016. One opt-in exception to read-only:DASHBOARD_LIVE_TOGGLE_ENABLED(default false) adds a per-strategy LIVE/PAPER button and exactly one POST,/api/live-mode. That POST is guarded by Origin, a per-process token and a typed strategy name, and it only QUEUES a request (Dependencies/live_mode_control.py). ALiveModeControllerthread runs_live_promotion_refusal, the runtime twin of the startup gate. Paper -> live still needsLIVE_TRADING_ENABLEDat startup, a clean_live_config_errorsand a broker login, plus the flat-account audit (via the shared_live_broker_login_ok+_preload_and_audit_live_account) when nothing is live yet. The controller NEVER writeslive_trading; the worker applies the request itself in_apply_pending_live_mode_if_safe(called from_run_shutdown_cycle_if_requested), and only when flat, because the order path reads that flag more than once per order. Session-only;.envis never written. Toggle alerts bypasspublish_trade_eventso they never touch the trade books. Seedocs/adr/0021. The chart carries CPR, a session VWAP and a stochastic %K/%D sub-pane, with a 1m/5m/D toggle (the two minute timeframes ride in ONE/api/chartpayload, so switching between them needs no fetch). It also switches INSTRUMENT between NIFTY and, whenDASHBOARD_BANKNIFTY_ENABLEDis on (default false), BankNIFTY. That is whySharedMarketDataStore's OHLC pool is keyed(instrument, timeframe)--instrumentis keyword-only and defaults toPRIMARY_INSTRUMENT, so every worker'sstore.get("1")is unchanged.SecondaryIndexPublisherfetches BankNIFTY over REST in BOTH feed modes on its own slow cadence, strictly after the feed-health gate and in its own try/except;record_market_data_refreshreads the PRIMARY frame hard-coded and must stay that way, because it drives the 30-second liquidation clock. Nothing trades off the secondary frame and the tick path never builds bars for it. Each instrument has its own chart cache, publisher slot, CPR ladder and scroll-back. The chart also carries an indicator menu (EMA/SMA/Bollinger/ Supertrend as overlays, RSI/MACD/ATR/ADX in their own panes, with editable periods, several instances allowed, persisted inlocalStorage). Those are computed in the BROWSER fromdashboard_assets/dashboard_indicators.js, because the history pages are immutable bytes rendered once at startup -- so a server-side indicator could not survive a scroll-back. They are CHART-ONLY and no strategy reads them; a node-backed drift test pins every one of them againstmisc_strategy_common's TA-Lib helpers. The operator can also DRAW support and resistance on it -- horizontal lines and shaded zones, click to place, drag to move, editable to an exact price -- kept inlocalStorageunder their own key, per instrument and shared across timeframes. They persist in the browser because the server implements GET and nothing but GET; that is a safety property, so there is no endpoint to save them to. Seedocs/adr/0020. It also scrolls back through years of history:Dependencies/dashboard_history.pyreads the CSValgo.py fetch-datawrites and serves it from/api/historyin pages of 2,000 bars, loaded once on a thread of its own (~29.5s, ~63 MB for five years) and never on the trading path. A missing CSV is not an error -- the chart shows the live session alone. CPR is drawn as one band per day, spanning that day only, from that day's predecessor; the Daily timeframe takes a monthly ladder instead, and hides VWAP, which means nothing on a daily candle. VWAP and the stochastic are the strategies' OWN objects, reached throughload_moduleunder BARE names sosys.modulesreturns the already-loaded instance rather than a second copy. CPR is the one deliberate divergence and is labelled CHART-ONLY everywhere: it reads the prior session 09:15-15:15 inclusive (high, low AND close) while CPR / CPR Algo 3 / CPR Algo 4 / CPR AI keep using the full session and its last intraday close -- those strategies are untouched, only the input WINDOW differs, and a test feeds an untruncated session through both to prove the algebra has not forked. Seedocs/adr/0017. - Each entry/exit is published to a
queue.Queueconsumed by a singleTelegramMessageWorker(best-effort alerts; never blocks trading). That samepublish_trade_eventchoke point also mirrors every event into the crash-durable session state (Dependencies/session_state.py,SESSION_STATE_*, on by default): an atomically-written JSON file holding each closed trade's P&L immediately, plus every OPEN position — entry fill price, stop, target, quantity, contract ids and last cached LTP — snapshotted every 30s from the supervisor thread. Before a replacement run writes anything, it archives the exact prior file and carries same-day realized P&L into every matching worker so a restart cannot reset a daily max-loss budget. It exists because the Sheet is written ONCE at a clean end-of-day, so a mid-session crash (2026-08-10's machine hang) otherwise loses the whole day's books. Every worker enumerates its open positions through_owned_open_positions(), so the marks file'sowned_positionskey covers the three families whose exposure never lived inworker.pos(Delta-0.2 CE/PE, the strangle legs, the SL-Hunting BankNIFTY mirror) — a class overriding_paper_positions_activewithout that hook fails a policy test.open_positionkeeps its exact prior shape because it is the only key resume reads, and NOTEupdate_worker_snapshotcopies a FIXED key list: a new snapshot key not named there is silently dropped. Resuming OPEN exposure remains opt-in (SESSION_STATE_RESUME_ENABLED, default false) and deliberately narrow — today's date, an unclean shutdown, PAPER, single-leg only; live positions are never restored because the broker account is the authority there. After a natural end of day whose Sheet write SUCCEEDED, shutdown deletes the state file, its marks and every recovery archive (_remove_published_session_state); a Ctrl+C or a Sheet outage keeps them as the only durable record. Seedocs/adr/0012. - Real orders go through ONE shared, lock-guarded broker session via a broker-agnostic
execution_client(see Broker layer). On a clean end-of-day, per-strategy P&L is written to a Google Sheet with separate PAPER/LIVE/MIXED row labels. All behaviour is driven by a single.env— nothing is hard-coded per run.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago Changed · +13 lines · +264 tokens per session 0932201e0184
- 7d ago Changed · +2 lines · +51 tokens per session 7efcf3580f22
- 9d ago Changed · +21 tokens per session 6ee8ec7f19f3
- 17d ago Changed · +25 lines · +496 tokens per session f7a3485551b4
- 1mo ago Changed 2bdc59d42803
- 1mo ago Changed · +6 lines · +171 tokens per session 2503318931f8
- 1mo ago Changed · +11 lines · +280 tokens per session f16f363d637f
- 1mo ago Changed · +3 lines · +63 tokens per session 8d6d91de8353
- 1mo ago Changed · +7 lines · +150 tokens per session fda677a2e45c
- 1mo ago First seen · 268 lines · 5,568 tokens per session scan A 2a7476ad5bde
My-Algo-Trading-Code AGENTS.md is an instructions file published in the GitHub repository DoRmAmMu1997/My-Algo-Trading-Code (18 stars, last pushed today), licensed MIT. It adds 7,064 tokens to every session, about $0.0283 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
My-Algo-Trading-Code AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| My-Algo-Trading-Code AGENTS.mdDoRmAmMu1997/My-Algo-Trading-Code | Instructions file | 18 | today | MIT | A | 7,064 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | today | MIT | A | 7,461 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 5,516 | GitHub Copilot |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | today | MIT | A | 4,680 | Codex, OpenCode |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 3,093 | GitHub Copilot |
| vscode ai-customization.instructions.mdmicrosoft/vscode | Instructions file | 195k | today | MIT | A | 1,907 | GitHub Copilot |