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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file systemr-1.0.1.tar.gz.
File metadata
- Download URL: systemr-1.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fcb41ec65b9e397e1ec49ac9b8ae3eaa0e7040b447ec9e1c9def6d076413520
|
|
| MD5 |
e9251719392403974fa89e97c0ef16be
|
|
| BLAKE2b-256 |
29cce5bc7c4e9b42002d5b7b97c6e10c8ae0028c67692ac7f70e1798f1e1c556
|
File details
Details for the file systemr-1.0.1-py3-none-any.whl.
File metadata
- Download URL: systemr-1.0.1-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.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a53a47d8af46c8ee930379fc020257cd03a102f760045a7c86242d145fd14d1
|
|
| MD5 |
19398fa35b804e9e73b307d2ee44b324
|
|
| BLAKE2b-256 |
2fc4361cc51e66b3d92e454c5713f4f13c398dcf2a50edb3955ed5df0623f783
|