My-Algo-Trading-Code AGENTS.md

My-Algo-Trading-Code AGENTS.md is an instructions file for Codex, OpenCode from DoRmAmMu1997/My-Algo-Trading-Code. It costs 4,744 tokens per session, scanned A, original, MIT.

A repository instruction file for a NIFTY index-options trading system. It describes how the system gets market data, tests strategies, and can run paper or real trading through a broker.

In plain words
What is it for?
Use it when developing, testing, or reviewing the trading system, its market-data flow, strategies, or live-trading controls.
Why use it?
It gives coding agents the project context and safety rules needed when changing software that can place real trades.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions CLAUDE.md; mentions Claude Code; mentions AGENTS.md.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/dormammu1997/my-algo-trading-code/agents-md
Clone the repo
git clone --depth 1 https://github.com/DoRmAmMu1997/My-Algo-Trading-Code

Made for: Codex, OpenCode.

Wrote 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.

agentmods badge for My-Algo-Trading-Code AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/dormammu1997/my-algo-trading-code/agents-md.svg)](https://agentmods.dev/instructions/dormammu1997/my-algo-trading-code/agents-md)
Your own site
<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="Measured on agentmods" height="20"></a>
Per session 4,744 This file is loaded in full into every session.
When invoked 4,744 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.04744 $0.04744
Opus 5 $0.02372 $0.02372
Sonnet 5 $0.00949 $0.00949
Haiku 4.5 $0.00474 $0.00474

Measured 2d ago against content hash 1602d56dec9d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

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 2d 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

AGENTS.md · 226 lines

How it starts

The opening of the file, as written. The whole thing — 226 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 27-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-guarded SharedMarketDataStore (1-min OHLC + LTPs). Setting MARKET_DATA_SOURCE=WEBSOCKET (fails closed to REST on any other value; needs the paid Dhan Data API subscription) swaps in WebSocketMarketDataFetcher: Dhan marketfeed ticks build the bars/LTPs (pure helpers in Dependencies/tick_bar_builder.py), with REST kept for warmup and a once-per-minute true-up against official candles.
  • Approximately 27 core strategy worker threads read that store and decide trades: the AtmSingleLegStrategyWorker family (Renko / EMA / Heikin-Ashi / Profit-Shooter / Goldmine / Money-Machine / CPR / CPR Algo 3 (multi-instrument: spot + ITM CE + ITM PE) / 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-licensed workratananmol-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 in Signal Generators/Regime Adaptive Strategy/regime_candidates.py as 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's REGIME_PORTING_NOTES.md before 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_entry reads top_bid_price/top_ask_price off the /optionchain response 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). An optional, opt-in CPR Codex AI Agent is an independent five-minute SRSI/VWAP worker. It freezes completed-bar context behind four frozen no-argument MCP tools; Codex judges regime, setup, and premise exits, while the host owns deterministic entry/risk gates and execution. It is disabled by default, live-disabled by default, and uses the normal global-plus-strategy double gate. Accepted SIDEWAYS setups sell naked current-expiry ATM premium (bullish PE, bearish CE); TRENDING setups retain the existing option buys and expiry. Spot stops trigger exits but cannot guarantee fills. Ordinary CPR, CPR Algo 3, 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 via claude-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 ATM enter_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 beyond SL_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 EXIT exit_leg selector (NIFTY|BNF|BOTH). 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_MINUTES blocks 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 into lessons.json, injected into the prompt only when SL_HUNTING_LESSONS_ENABLED (human-gated, paper-first, off by default). Its knowledge also carries a curated BankNIFTY live-trading layer (v3a, knowledge-only): a BNF_SPECIFIC section (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 in sl_hunting_doc.md). With both optional agents enabled, the configured roster can reach approximately 29 workers, but enable and virtual-trading gates keep the running roster configuration-dependent.
  • Each entry/exit is published to a queue.Queue consumed by a single TelegramMessageWorker (best-effort alerts; never blocks trading). That same publish_trade_event choke 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. 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. See docs/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.

Read the full file on GitHub · 226 lines

Changes

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.

  1. 2d ago Changed · +1 lines · +14 tokens per session 1602d56dec9d
  2. 6d ago First seen · 225 lines · 4,730 tokens per session scan A c12732c13f5f

Subscribe to this mod's changes

My-Algo-Trading-Code AGENTS.md is an instructions file published in the GitHub repository DoRmAmMu1997/My-Algo-Trading-Code (12 stars, last pushed 2d ago), licensed MIT. It adds 4,744 tokens to every session, about $0.0237 per session on Opus 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.

Related

Other instructions, from other repositories

polymarket-paper-trader CLAUDE.md

Instructions for agent-next/polymarket-paper-trader, covering claude.md, polymarket-paper-trader, commands, install and tests (620 non-live + 42 live = 662 total, 100% coverage).

agent-next/polymarket-paper-trader · 1,257 tokens

lumibot AGENTS.md

AGENTS.md instructions for Lumiwealth/lumibot, covering public repo secret hygiene (critical), express authorization required for lumibot changes, botspot integration release qualification, broker data ownership and lumibot agent instructions (theta / downloader focus).

Lumiwealth/lumibot · 7,304 tokens

lumibot copilot-instructions.md

Copilot instructions for Lumiwealth/lumibot: Important: remember to add unit tests for any new functionality you add. This is mission critical code, so we need to ensure that it works as expected and doesn't break anything.

Lumiwealth/lumibot · 115 tokens

martex-quant CLAUDE.md

Instructions for martex-dev/martex-quant, covering session start — read these first, project instructions, ai trading bot project - master instructions, role and project objective.

martex-dev/martex-quant · 6,161 tokens

varrd CLAUDE.md

Claude Code instructions for varrdinc/varrd, covering claude.md — varrd and ⭐ how we ship — sdlc etiquette (read before any commit).

varrdinc/varrd · 243 tokens

backtrader AGENTS.md

AGENTS.md instructions for cloudQuant/backtrader, covering agents.md, project overview, branch context, implementation status / reality checks and development commands.

cloudQuant/backtrader · 3,824 tokens