System R Risk Intelligence MCP Server

Pre-trade risk validation and position sizing for AI trading agents.

README.md

systemr

Python SDK for agents.systemr.ai — Trading & Investment Operating System for AI agents.

48 tools: position sizing, risk validation, regime detection, Greeks analysis, equity curves, signal scoring, trade planning, compliance checks, and more.

Install

pip install systemr

Quick Start

from systemr import SystemRClient

client = SystemRClient(api_key="sr_agent_...")

# Pre-trade gate: sizing + risk + health in one call ($0.01)
gate = client.pre_trade_gate(
    symbol="AAPL",
    direction="long",
    entry_price="185.50",
    stop_price="180.00",
    equity="100000",
)
if gate["gate_passed"]:
    print(f"Buy {gate['sizing']['shares']} shares")

Three Ways to Use Tools

1. Named Methods (common operations)

# Position sizing ($0.003)
size = client.calculate_position_size(
    equity="100000", entry_price="185.50",
    stop_price="180.00", direction="long",
)

# Risk validation ($0.004)
risk = client.check_risk(
    symbol="AAPL", direction="long",
    entry_price="185.50", stop_price="180.00",
    quantity="100", equity="100000",
)

# Pre-trade gate ($0.01)
gate = client.pre_trade_gate(
    symbol="AAPL", direction="long",
    entry_price="185.50", stop_price="180.00",
    equity="100000", r_multiples=["1.5", "-1.0", "2.0"],
)

# System assessment ($2.00)
assessment = client.assess_system(
    r_multiples=["1.5", "-1.0", "2.0", "-0.5", "1.8",
                 "0.8", "-0.3", "2.5", "-1.0", "1.2"],
)
print(assessment["verdict"])  # STRONG_SYSTEM, VIABLE_SYSTEM, etc.

2. Generic Tool Call (all 48 tools)

# Equity curve from R-multiples ($0.004)
curve = client.call_tool("calculate_equity_curve",
    r_multiples=["1.5", "-1.0", "2.0", "-0.5", "1.8"],
    starting_equity="100000",
)
print(curve["total_return"], curve["max_drawdown_pct"])

# Signal quality scoring ($0.003)
signal = client.call_tool("score_signal",
    conditions_met=4, total_conditions=5,
    regime_aligned=True, indicator_confluence=3,
    volume_confirmed=True, risk_reward_ratio="2.5",
)
print(signal["confidence"], signal["quality_score"])

# Margin calculation ($0.002)
margin = client.call_tool("calculate_margin",
    notional="50000", asset_class="STOCK",
    direction="LONG",
)
print(margin["margin_required"])

# Regime detection ($0.006)
regime = client.call_tool("detect_regime",
    prices=["180", "182", "179", "185", "188", "186"],
)

# Greeks analysis ($0.006)
greeks = client.call_tool("analyze_greeks",
    chain=[{
        "symbol": "AAPL240315C00185000",
        "underlying_symbol": "AAPL",
        "strike": "185", "expiration": "2024-03-15",
        "option_type": "CALL", "bid": "5.20", "ask": "5.50",
        "last": "5.35", "volume": 1000, "open_interest": 5000,
        "implied_volatility": "0.25",
    }],
    underlying_price="185.50",
)

# List all available tools
tools = client.list_tools()
print(f"{tools['tool_count']} tools available")

3. Workflow Chains (multi-tool sequences)

# Full backtest diagnostic (6 tools, ~$0.032)
diag = client.run_backtest_diagnostic(
    r_multiples=["1.5", "-1.0", "2.0", "-0.5", "1.8",
                 "0.8", "-0.3", "2.5", "-1.0", "1.2"],
    starting_equity="100000",
)
print(diag["system_r_score"]["grade"])       # A, B, C, D, F
print(diag["equity_curve"]["total_return"])   # total return
print(diag["monte_carlo"]["median_final_equity"])
print(diag["variance_killers"])              # what's hurting G

# Post-trade analysis (2 tools, $0.006)
post = client.run_post_trade_analysis(
    realized_pnl="500.00", realized_r="1.50",
    mfe="800.00", one_r_dollars="333.33",
    entry_price="180.00", exit_price="185.00",
    quantity=100, direction="LONG",
)
print(post["outcome"]["outcome"])            # WIN/LOSS/BREAKEVEN
print(post["outcome"]["efficiency_score"])   # how much R captured

# Market scan + signal scoring (2+ tools, $0.005+)
scan = client.run_market_scan(
    symbols=["AAPL", "MSFT", "GOOGL"],
    conditions=["rsi_oversold", "volume_spike"],
    market_data={
        "AAPL": {"indicators": {"rsi_14": "25", "relative_volume": "2.0"},
                 "current_price": "180.00", "regime": "RANGING", "atr": "3.50"},
        "MSFT": {"indicators": {"rsi_14": "55", "relative_volume": "0.8"},
                 "current_price": "400.00", "regime": "TRENDING_UP", "atr": "5.00"},
    },
)
for signal in scan["scored_signals"]:
    print(f"{signal['symbol']}: confidence={signal['signal_confidence']}")

All 48 Tools

Category Tools Cost Range
Core (4) position_sizing, risk_check, evaluate_performance, get_pricing $0.003-$1.00
Analysis (18) drawdown, monte_carlo, kelly, variance_killers, win_loss, what_if, confidence, consistency, correlation, distribution, recovery, risk_adjusted, segmentation, execution_quality, peak_valley, rolling_g, system_r_score, equity_curve $0.004-$0.008
Intelligence (11) detect_

Tools 8

pre_trade_gatePerforms sizing, risk validation, and health checks in one call.
calculate_position_sizeCalculates the appropriate position size based on equity and risk parameters.
check_riskValidates trade risk parameters.
assess_systemEvaluates a trading system based on a series of R-multiples.
calculate_equity_curveGenerates an equity curve from a list of R-multiples.
score_signalScores the quality of a trading signal.
detect_regimeDetects the current market regime based on price history.
analyze_greeksPerforms options Greeks analysis.

Environment Variables

SYSTEMR_API_KEYrequiredAPI key for accessing the System R trading services.

Try it

Calculate the position size for a long trade on AAPL with $100,000 equity, entry at $185.50, and stop at $180.00.
Run a pre-trade gate check for a long position on AAPL at $185.50 with a stop at $180.00 and $100,000 equity.
Assess my trading system performance based on these R-multiples: [1.5, -1.0, 2.0, -0.5, 1.8, 0.8, -0.3, 2.5, -1.0, 1.2].
Detect the market regime for the following price sequence: [180, 182, 179, 185, 188, 186].

Frequently Asked Questions

What are the key features of System R Risk Intelligence?

Pre-trade risk validation and position sizing. Market regime detection and Greeks analysis. Performance assessment and equity curve generation. Workflow chains for backtest diagnostics and post-trade analysis. Signal quality scoring based on technical indicators.

What can I use System R Risk Intelligence for?

Automating pre-trade risk checks for AI-driven trading bots.. Backtesting trading strategies to determine system viability and risk-adjusted returns.. Analyzing post-trade performance to identify efficiency and variance killers.. Scanning multiple market symbols to score signal confidence before execution..

How do I install System R Risk Intelligence?

Install System R Risk Intelligence by running: pip install systemr

What MCP clients work with System R Risk Intelligence?

System R Risk Intelligence works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep System R Risk Intelligence docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare