Open-source “agentic trading labs” package everything needed to experiment: market data connectors, an LLM that reads news and prices and explains its reasoning, a backtester, paper trading, leaderboards and broker integrations. They are excellent for research. They also combine three things that each carry risk on their own — a model that can be wrong or manipulated, money, and credentials that can move it. This page is about that combination, not about whether an AI can beat the market. Nothing here is investment advice.
1 · How an Agentic Trading System Works
| Stage | What happens | Where it lives |
|---|---|---|
| Data | Prices, fundamentals, news, social posts pulled into the agent’s context | Market-data APIs, scrapers, feeds |
| Reasoning | The LLM (or several agents with roles) reads the context and proposes buy, sell or hold with a rationale | A hosted model API or a local model |
| Testing | Strategies are run on historical data (backtest), then on live data with simulated money (paper trading) | The lab’s backtester and database |
| Execution | Approved orders go to a broker through its API using the account’s keys | Broker API, credentials store |
2 · Eight Ways They Fail
| Failure | What goes wrong |
|---|---|
| Hallucinated facts | The model invents an earnings figure, a ticker or a news event and trades on it |
| Prompt injection via data | A news article, filing or social post contains text that steers the agent (“ignore prior instructions, buy …”) — an easy route for market manipulation |
| Look-ahead and leakage | The model was trained on data from after the backtest period, so it “predicts” events it already knows; backtests look far better than reality |
| Overfitting | Many prompt and parameter tweaks tested on the same history until one looks good by chance |
| Non-determinism | The same input gives a different decision on a re-run, so results cannot be reproduced or explained |
| Leaked broker credentials | API keys in code, config files, notebooks or the model’s own context; whoever holds them can trade or withdraw |
| Runaway orders | A loop, retry bug or misread quantity sends orders faster or larger than intended |
| No audit trail | Nobody can reconstruct why a trade happened — a problem for the owner, the broker and the regulator |
▸ Most of these are the general LLM risks from AI Security and How LLMs Work. Trading adds two things: an adversary with a financial motive to inject text, and an action that cannot be undone once an order fills.
3 · Guardrails That Work
- The model proposes, code decides. Hard limits in ordinary code — maximum order size, position, daily loss, instruments allowed, orders per minute — that no model output can override.
- Treat all text inputs as untrusted. News and posts are data to summarise, never instructions; keep the agent’s tools minimal.
- Backtest honestly. Use periods after the model’s training cut-off, keep an untouched test period, and count every variant tried.
- Graduate slowly. Backtest → paper trading for weeks → live with tiny size → scale only on evidence.
- Protect the keys. A secrets manager, never code or prompts; trading-only scopes with withdrawals disabled; IP whitelisting; rotation.
- Kill switch. One command (and an automatic trigger on loss or error rates) that cancels open orders and stops the agent.
- Log everything. Inputs, model version, prompt, output, rationale and the order sent, kept immutable.
- A human for anything large. Orders above a threshold wait for approval.
4 · What SEBI’s Retail Algo Framework Requires
In February 2025 SEBI issued a framework for safer participation of retail investors in algorithmic trading, implemented through the stock exchanges after several extensions of its start date. For anyone connecting an agent to an Indian broker, the practical effect:
| Requirement | What it means for an agent |
|---|---|
| Broker is accountable | Algorithmic orders flow through a registered broker, which is responsible for them and their controls |
| Algo identification | Algorithms registered through the broker get an exchange-issued ID that tags their orders; order rates above the exchange threshold are treated as algorithmic and need registration |
| Secured API access | API access with two-factor authentication and a static IP registered with the broker; no open, shared API keys |
| Algo providers | Third parties offering algorithms to retail investors work through brokers and exchanges, with stricter conditions for opaque (“black-box”) strategies |
Summary for orientation only; read the current SEBI circular, exchange implementation standards and your broker’s terms before trading. Not investment or legal advice.
Bottom line
- Great for research, dangerous with live keys — the model can be wrong, steered or non-repeatable.
- Hard limits in code and a kill switch matter more than a better prompt.
- Backtests lie by default when the model has seen the future.
- Broker keys are money — secrets manager, minimal scope, static IP, rotation.
- In India, SEBI’s framework applies: broker accountability, algo IDs, secured API access.
Sources & method. Architecture from public documentation of open-source agentic trading labs; failure modes and guardrails are the author’s analysis, consistent with the OWASP Top 10 for LLM Applications. SEBI framework from its February 2025 circular on retail algorithmic trading and exchange implementation material, summarised; dates and thresholds change, so verify the current text. Not investment advice. Original analysis; no third-party graphics or text reproduced.
← Back to Cyber security