Skip to content

About

Pre-trade risk API for crypto — BTC/USD and ETH/USD exposure governance. Spot, perps, and DeFi aware. 30+ signals, 5-level policy engine.

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RiskState

RiskState

Pre-trade risk API for crypto — BTC/USD and ETH/USD exposure governance
For trading agents, open-source systems, and capital desks. Spot and perpetual futures (perps). DeFi borrowing aware.

API Version Status Assets Markets Pricing

Website · API Reference · SKILL.md · X/Twitter


What is RiskState?

A deterministic engine that converts live market state into dynamic risk permissions — exposure limits, leverage caps, and allowed actions — before capital is deployed.

One API call returns position limits, allowed actions, and policy constraints computed from 30+ real-time signals across macro, on-chain, derivatives, and DeFi health. The assessment is USD-denominated: all scoring is based on BTC/USD and ETH/USD price action, derivatives, and macro conditions.

curl -X POST https://api.riskstate.ai/v1/risk-state \
  -H "Authorization: Bearer $RISKSTATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"asset": "BTC"}'
{
  "exposure_policy": {
    "max_size_fraction": 0.42,
    "leverage_allowed": true,
    "allowed_actions": ["DCA", "LONG_SHORT_CONFIRMED"],
    "blocked_actions": ["ALL_IN", "LEVERAGE_GT_2X"]
  },
  "policy_level": 4,
  "risk_flags": {
    "structural_blockers": [],
    "context_risks": ["HIGH_COUPLING"]
  },
  "binding_constraint": {
    "source": "MACRO",
    "reason_codes": ["MACRO_NEUTRAL", "COUPLING_NORMAL"]
  }
}

Read max_size_fraction, check blocked_actions, and act. No parsing. No interpretation.

Why?

Whether you run an AI trading agent, a systematic trading system, or a manual desk — crypto markets have regime shifts that require adaptive risk governance. Static rules fail. RiskState provides a pre-trade risk check that adapts every 60 seconds.

Without governance With RiskState
Position size based on signal confidence alone Capped at max_size_fraction (max notional exposure)
No awareness of macro regime RISK-OFF → blocked_actions: ["AGGRESSIVE_LONG"]
DeFi health factor ignored Wallet health feeds directly into position limit
Leverage unbounded Policy-level constraints enforced
No circuit breaker blocked_actions contains NEW_TRADES → halt

Quick Start

1. Get an API key

Sign up at riskstate.ai — email only, free during beta.

2. Query the API

curl -X POST https://api.riskstate.ai/v1/risk-state \
  -H "Authorization: Bearer $RISKSTATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"asset": "BTC"}'

3. Enforce before execution

In an AI trading agent (Python):

import requests

policy = requests.post(
    "https://api.riskstate.ai/v1/risk-state",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"asset": "BTC"}
).json()

# Hard stop: the engine blocks new trades
if "NEW_TRADES" in policy["exposure_policy"]["blocked_actions"]:
    return  # Do not trade

# Size cap — max notional exposure as fraction of portfolio
max_size = policy["exposure_policy"]["max_size_fraction"]
position_size = min(desired_size, portfolio_value * max_size)

# Action filter
if "LEVERAGE" in policy["exposure_policy"]["blocked_actions"]:
    leverage = 1.0

In a trading system (pre-trade check):

# Before placing a spot or perps order
policy = fetch_riskstate("ETH")

if "NEW_TRADES" in policy["exposure_policy"]["blocked_actions"]:
    log("BLOCKED: new trades not permitted — skipping order")
    return

max_notional = portfolio_value * policy["exposure_policy"]["max_size_fraction"]
# Spot: max_notional is the $ amount to deploy
# Perps: max_notional is the notional exposure cap
#   e.g., at 10x leverage → margin = max_notional / 10

Manual pre-trade check (curl):

# Quick check before placing an order on Binance/Hyperliquid/Aave
curl -s -X POST https://api.riskstate.ai/v1/risk-state \
  -H "Authorization: Bearer $RISKSTATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"asset": "BTC"}' | jq '{
    policy_level, 
    max_size: .exposure_policy.max_size_fraction,
    blocked: .exposure_policy.blocked_actions,
    blockers: .risk_flags.structural_blockers
  }'

Policy Levels

Level Label Max Size What your agent can do
1 BLOCK Survival <15% Reduce exposure, hedge only
2 DEFENSIVE <35% New positions at reduced size, no leverage
3 CAUTIOUS <60% DCA, R:R >2:1 only
4 GREEN Selective <80% Trade with confirmation
5 GREEN Expansion ≥80% Full operations, leverage up to 2x

Supported Assets

  • BTC/USD — Full signal coverage (30+ indicators). Scoring based on BTC/USDT price, derivatives, and macro conditions.
  • ETH/USD — Full coverage including ETH structural score, ETH/BTC ratio analysis, staking dynamics, ETH/NASDAQ correlation.

Note: The assessment is USD-denominated. If you trade non-USD pairs (e.g., BTC/EUR, ETH/BTC), additional cross-rate risk is not covered.

Markets

RiskState evaluates the same underlying market conditions regardless of where you trade. The risk assessment applies to:

Market How to use the output
Spot max_size_fraction = % of portfolio to deploy. Leverage fields are not applicable.
Perpetual futures (perps) max_size_fraction = max notional exposure as % of portfolio. At 10x leverage, your margin is max_size_fraction / 10. Derivatives signals (funding rate, basis, OI, squeeze risk) are especially relevant.
DeFi borrowing Pass your wallet address for health factor and liquidation-aware risk caps. max_leverage reflects borrowing ratio (LTV). The address is optional, is forwarded to our RPC provider for the lookup and is not stored.

The API returns the same response for all markets — the difference is how you interpret the output. See API Reference → How to Use by Context for detailed workflows.

Integration Paths

REST API

Direct HTTP calls. Any language, any framework.

SKILL.md

Drop SKILL.md into your agent's repo. Compatible with Claude Code, Copilot, Cursor, and Gemini via skills.sh.

MCP Server

npm install @riskstate/mcp-server@1.1.0

Or run directly with npx -p @riskstate/mcp-server@1.1.0 riskstate-mcp. Pin the version; review the changelog before upgrading.

Four read-only tools: get_risk_policy (same parameters as the REST API), get_market_structure, get_playbook_status and check_trade. Compatible with Claude Desktop, Claude Code, Cursor, and any MCP-compatible client. See MCP README for full setup.

Listed On

Binding Precedence

When consuming the response, agents must evaluate fields in this order:

  1. exposure_policy.blocked_actions — actions the agent must not take. If it contains NEW_TRADES, abort new entries
  2. risk_flags.structural_blockers — context for the decision, not a stop signal: it names the adverse conditions the engine sees; what is binding is already in blocked_actions and max_size_fraction
  3. exposure_policy.reduce_recommended — reduce exposure if true
  4. exposure_policy.max_size_fraction — maximum position size (0.0–1.0)
  5. exposure_policy.max_leverage — maximum leverage allowed

Data Sources

RiskState ingests 30+ real-time signals from:

  • Price & Derivatives — Binance, OKX, Bybit (funding, OI, basis, L/S ratio)
  • On-chain — MVRV, NUPL, exchange netflow, supply metrics (CoinGlass)
  • Macro — DXY, US yields, S&P 500, Gold, Fed balance sheet (FRED, Yahoo Finance)
  • DeFi — Spark Protocol, Aave V3 health factor and liquidation thresholds
  • Sentiment — Fear & Greed, ETF flows, institutional treasuries
  • ETH-specific — Staking ratio, burn rate, DEX volume, fees, stablecoin TVL

Pricing

Free during beta. Rate limit: 60 requests/minute.

Tier Calls/month Price
Free 100 $0
Builder 5,000 $49/mo
Growth 25,000 $149/mo
Scale 100,000 $399/mo

Paid tiers coming after beta. Sign up now to lock in early access.

Documentation

  • API Reference — Full endpoint documentation, field types, error codes
  • SKILL.md — Agent discovery file with decision rules and failure modes
  • Changelog — Version history and release notes
  • Website — Landing page with interactive examples

Links


Built by RiskState · © 2026 Digital Venture Asset LLC

About

Pre-trade risk API for crypto — BTC/USD and ETH/USD exposure governance. Spot, perps, and DeFi aware. 30+ signals, 5-level policy engine.

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors