Skip to main content

Python SDK for agents.systemr.ai - AI-native risk intelligence for trading agents

Project description

systemr

Python SDK for agents.systemr.ai — AI-native risk intelligence for trading agents.

PyPI Python License: MIT

Install

pip install systemr

Quick Start

from systemr import SystemRClient

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

# Position sizing ($0.003)
result = client.calculate_position_size(
    equity="100000",
    entry_price="185.50",
    stop_price="180.00",
    direction="long",
)
print(result["shares"], result["risk_amount"])

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

# Strategy evaluation ($0.10 - $1.00)
eval_result = client.basic_eval(r_multiples=["1.5", "-1.0", "2.3", "-0.5", "1.8"])
print(eval_result["g_score"], eval_result["verdict"])

Get an API Key

import httpx

resp = httpx.post("https://agents.systemr.ai/v1/agents/register", json={
    "owner_id": "your-id",
    "agent_name": "my-trading-agent",
    "agent_type": "trading",
})
data = resp.json()
print(data["api_key"])  # sr_agent_... (save this, shown only once)

API Reference

Agent Management

Method Description
client.get_info() Get agent info
client.list_agents() List owner's agents
client.update_mode(mode) Change mode (sandbox/live/suspended/terminated)

Position Sizing

Method Cost
client.calculate_position_size(equity, entry_price, stop_price, direction) $0.003

Risk Validation

Method Cost
client.check_risk(symbol, direction, entry_price, stop_price, quantity, equity) $0.004

Evaluation

Method Cost Description
client.basic_eval(r_multiples) $0.10 G metric + verdict
client.full_eval(r_multiples) $0.50 G + rolling G + System R Score
client.comprehensive_eval(r_multiples) $1.00 Full analysis + impact

Billing

Method Description
client.get_pricing() Operation prices (no auth)
client.get_balance() Current USDC balance
client.deposit(amount) Record deposit
client.get_transactions() Transaction history
client.get_usage() Usage summary

Error Handling

from systemr import SystemRClient, AuthenticationError, InsufficientBalanceError, SystemRError

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

try:
    result = client.calculate_position_size(...)
except AuthenticationError:
    print("Invalid API key or agent inactive")
except InsufficientBalanceError:
    print("Deposit USDC to continue")
except SystemRError as e:
    print(f"API error {e.status_code}: {e.detail}")

Context Manager

with SystemRClient(api_key="sr_agent_...") as client:
    result = client.check_risk(...)
# connection automatically closed

MCP (Model Context Protocol)

System R is also available as an MCP server for AI assistants like Claude and ChatGPT. See the MCP documentation for configuration.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

systemr-1.0.2.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

systemr-1.0.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file systemr-1.0.2.tar.gz.

File metadata

  • Download URL: systemr-1.0.2.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for systemr-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a23b46069a1cc5d6a5182bcaceb6df016db71fff12bb1f6383ead8666ed79377
MD5 efac66907e00568e9c8b92d477cb6eb7
BLAKE2b-256 33051fe1e9d09de9cc8faade990b865a75fcd96de70bec2fb9c089a1995f21a0

See more details on using hashes here.

File details

Details for the file systemr-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: systemr-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for systemr-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3560555a53224de3f0273b1ff10069891fa0ad7f63c478418442fb006438991
MD5 77aa00d9ed6c9b3f100d9ed7235537d1
BLAKE2b-256 a2dfcdd808145c76259c638bf9060edd05eca90662d085ac2a45597344317a6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page