# risk-aware-trading-agents [Health: Active]

**Category:** 💰 Finance & Fintech  
**Repository:** https://github.com/jackson-cmd/risk-aware-trading-agents  
**GitHub Stars:** 503  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/risk-aware-trading-agents

## Description
AI trading agents for US stocks with news backtesting that can't see the future: a point-in-time 2026 dataset (prices, VIX, news), a look-ahead check on every run, LLM agents over MCP, FOMC/CPI/VIX-aware regimes, and paper/live trading on 10 brokers. 风险感知美股交易智能体 · 新闻回测

## Tools
Capabilities this server exposes over MCP:

- **market_regime** — The market regime the agents see today (risk-on, neutral, uncertain, risk-off), the readings behind it,
    and the macro events of the next 30 days.
- **scan** — Today's buy and sell signals with their reasons. Scans the configured watchlist unless symbols are given.
- **analyze_stock** — What every agent thinks about one stock: technical setups, earnings quality, verified news, the decision.
- **stock_news** — Cross-verified news for one stock: a story counts when two independent outlets, the company's own press
    release or its SEC filing carry it. Only a severe flag the company itself backs (its 8-K, or its release
    confirming earlier reports) counts as a thesis break; denials clear the stories they refute.
- **list_strategies** — The built-in strategies that backtest and the agents can use, and the strategies saved from backtest_code
    (pass their path as the strategy).
- **backtest** — Backtest a strategy on daily data (signals at the close, fills the next day) against SPY buy and hold.

    news=True replays the news archive: each day the strategy sees only items published before that day's close.
    The research headline files (2026 headlines and SEC filings for the built-in watchlists) are licensed and do not
    ship with the package; news comes from your local archive and from those files if you have a copy.
- **strategy_guide** — How to write a strategy for backtest_code: the Strategy class, what ctx holds (indicators, price history,
    positions, market regime, point-in-time news), the rules the code must follow, a template and a news
    example. Read it before writing code.
- **backtest_code** — Backtest a strategy written as Python code (one Strategy subclass; see strategy_guide).

    The stocks come from symbols or universe (megacap, tech, defensive, core, etf, sectors), never from the code.
    The code is checked first: dates or stock tickers written in the code, files, network and private attributes
    are refused, because they let a backtest see the future or touch the machine. It then runs in a separate
    process, where each day sees only that day's data and news published before the close. Returns metrics,
    SPY and buy-and-hold for comparison, trades and the risk manager's refusals; or the problems to fix, with
    line numbers. save_as='name' keeps the code in ~/.riskaware/strategies/ai/ for backtest and agents_create.
- **agents_leaderboard** — Every paper-trading agent ranked by return since it started, compared with SPY over the same days.
- **agent_detail** — One agent: its settings, cash and positions at cost, equity by day and its latest orders.
- **agent_decisions** — How an agent made its recent decisions: the setups and reasons, whether the risk manager let each one
    through, and the LLM's bull case, bear case and verdict when the agent has an LLM. include_prompts adds the
    exact prompt sent to the model and its raw reply.
- **agents_create** — Create a paper-trading agent: a strategy with its own simulated account that trades every trading day.

    strategy is a built-in name or the path of a strategy saved by backtest_code (list_strategies shows both).
    llm optionally adds an LLM review board, e.g. "openai:gpt-5.6-luna", "ollama:qwen2.5:3b" or "off".
- **agents_run** — Run agents once now on their simulated paper accounts (all active agents when names is empty).
- **research_guide** — Read this first for experiments on the frozen markets: what data ships with the package (three periods:
    2026 to date, the 2022 bear market and the 2020 crash, each with daily bars and the VIX term structure; each
    year's headline file is licensed and not distributed, so news needs your own copy), how a backtest decides and
    fills (after the close,
    at the next open: swing trading), the look-ahead rules and check, how to write a strategy, the five baseline
    swing strategies, what a saved record holds, and advice for papers.
- **market_day** — Everything known at the close of one day of the bundled periods (2018 to 2020, 2020 to 2022, 2024 to
    2026-11-11; news in 2020, 2022 and 2026 when you have a copy of the headline files, which are not distributed):
    the market regime, VIX, VIX9D, VIX3M, VVIX and the term structure, fear & greed, breadth, credit stress, the
    macro events of the next two weeks; and per stock its prices and returns, indicators (EMAs, RSI, MACD, ATR, ADX,
    Bollinger, 52-week high), technical setups and the news published before the close (score, verified status,
    red flags, headlines, last earnings release). Nothing after that close is visible. Without symbols it lists all
    64 stocks in a compact table; name up to 10 symbols for the full detail with headlines. A weekend or holiday
    shows the close before it.
- **run_experiment** — Run an experiment on a frozen period and save a record (see research_guide). period is 2026 (default, a
    rising year), 2022 (the rate-hike bear market) or 2020 (the COVID crash and rebound); start and end default to
    the period's test window. costs='fixed' (default) pays 5 bps on every fill at the open; costs='realistic' adds
    10% of the overnight gap and square-root market impact and fills each order for at most 1% of its 20-day
    average volume. mode (plain execution) is long_only (default), long_short (short positions with a signed
    target_weight, e.g. Signal(sym, Action.SELL, target_weight=-0.1), long plus short at most 100% of equity, each
    short at most 20%, 0.5% a year borrow fee) or margin (Reg T: up to 200% gross, maintenance margin calls, borrowed
    cash pays BIL + 1.5%); mode_params overrides those rules. The rule-based long-short anchors are momentum_ls and
    trend_ls.

    Give either strategy (a built-in name such as swing_rsi2, swing_trend, swing_breakout, swing_pullback,
    swing_news, risk_aware, rsi2, momentum_rotation; or the path of a saved strategy) or code (one Strategy class,
    as in strategy_guide; it is checked and runs in a separate process). Signals at each close, market orders at the
    next open. execution='plain' trades exactly what the strategy says (equal-size positions, at most max_positions);
    'risk_aware' adds the package's risk manager. split='2026-07-01' also reports the parts before and after. The
    leak check re-runs it with a random future after three cut days and compares the decisions. extra_news adds
    headlines ({ts, symbol, headline, source}) for counterfactual or robustness tests. Returns the metrics, SPY and
    the equal-weight universe, beta, alpha, t-statistic and bootstrap intervals, the leak-check verdict, the best and
    worst trades, and the folder of the record (manifest with data hashes, metrics, equity, trades, decisions,
    report.md, chart).
- **list_experiments** — Saved research experiments and trading sessions, newest first: strategy, period, return, Sharpe, SPY and the
    look-ahead verdict, with the folder of each record.
- **experiment_report** — The report (markdown, ready to paste), manifest and file list of one saved experiment.
- **trading_session_start** — Trade the frozen market yourself, one decision at a time (an LLM-agent experiment). Returns the rules and
    the first observation: the market, your portfolio, and per stock the main indicators and the news published
    before that close. Answer with trading_session_step. decide_every=5 decides once a week (about 44 steps for
    2026); 1 decides every day. blind=True hides tickers, company names and dates so that you cannot recall what
    happened. Orders fill at the next open; long only; at most max_positions stocks. period is 2026 (default), 2022
    or 2020. mode='long_short' also allows short positions (no leverage) and mode='margin' a Reg T margin account
    (up to 2x gross, margin calls); the returned rules say what each allows and costs.
- **trading_session_step** — Send the orders for the current step and get the next observation (or, after the last step, the result
    with its saved record). Each order: {"symbol", "action": "buy" | "sell" | "target", "weight" (share of equity
    for buy and target), "fraction" (share of the position for sell, 1 = all), "reason"}. An empty list holds. In a
    long_short or margin session also "short" (weight = size of the short) and "cover" (fraction of a short), and
    target takes a negative weight.
- **trading_session_status** — Settings, steps sent so far and the record folder (when finished) of a trading session.
- **experiment_analysis** — What a saved experiment or a finished trading session made its money on. Decisions: the excess return over
    SPY 1, 5 and 20 trading days after every buy and sell (a sell counts the excess it avoided), with hit rates and
    t-statistics that allow for same-day decisions and overlapping windows, and the rank IC of each decision day
    against the next five days. Factors: daily returns regressed on the market, size, growth and momentum with
    Newey-West t-statistics, the alpha left after them and what each exposure contributed. P&L: by holding period,
    sector, market regime, news-triggered or not, and stock; the best and worst positions; how much of the profit
    rests on one or two trades. Writes analysis.json, analysis.md and analysis.png into the record. run_id is a run
    id or folder from list_experiments, or a trading session id.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "risk-aware-trading-agents": {
    "command": "uvx",
    "args": ["risk-aware-trading-agents","mcp"]
  }
}
```

## Documentation

## What risk-aware-trading-agents does

risk-aware-trading-agents provides MCP access to a US stock research and trading system built around risk checks. LLM clients can describe a strategy, have it converted into code, test it against historical data, and run an agent through market conditions one step at a time. The package also supports paper-trading agents and live trading, with a deterministic risk manager making the final decision on each order.

The system evaluates more than price signals. Its market context includes the macro calendar, VIX and VIX term structure, sector breadth, credit appetite, safe-haven demand, and a fear-and-greed measure. Trading decisions can also use company information, earnings, and cross-verified news.

## How it works

The research kit includes a frozen, point-in-time 2026 dataset covering prices, VIX data, 16,945 headlines and SEC filings for 64 built-in stocks. During a historical run, the agent sees only information available before the relevant market close. A look-ahead check runs on every backtest, and generated strategies are checked for future-data access and side effects before execution.

News can be inspected alongside individual trades, including the headlines available at that close, the news assessment, and the resulting order. This makes the system suitable for examining what an agent could have known at the time rather than evaluating it with a complete hindsight view.

The trading approach uses market regimes and risk profiles to shape decisions. Its stated discipline includes retaining a cash reserve, adding cautiously during high fear when earnings remain sound, trimming extended positions, and avoiding panic-selling into uncertainty.

## Setup and configuration

Install the package with its dashboard and MCP extras from the Git repository:

```bash
pip install "risk-aware-trading-agents[dashboard,mcp] @ git+https://github.com/jackson-cmd/risk-aware-trading-agents"
```

The MCP server can be configured through the package's setup command for supported clients, including Claude Desktop, Claude Code, Codex, and Gemini. The repository also publishes a Docker image for running the dashboard or MCP server without a local Python installation. The dashboard starts with:

```bash
riskaware dashboard
```

It provides an English and Chinese web interface on the local dashboard address shown by the quick-start command.

## Tools and capabilities

- Generate and test strategies described in natural language through an LLM client.
- Run news-aware backtests against the bundled point-in-time 2026 market.
- Check each run for look-ahead bias.
- Replay agent decisions step by step over historical data.
- Inspect the news and order associated with a backtest trade.
- Operate paper-trading agents and support live trading through 10 brokers.
- Review technical, earnings, news, and macro components of signals.

## Limitations and notes

The bundled research market covers 2026 data and a defined set of 64 stocks, so results depend on that dataset and should not be treated as a general forecast. The project describes the trading system as not financial advice. It starts in paper mode; live trading requires three explicit switches. Generated strategies are intended to be checked before execution, but users remain responsible for reviewing code, orders, broker configuration, and risk settings.

_Full upstream README: https://allmcps.com/mcp/risk-aware-trading-agents/readme_

