systemr 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- systemr-1.0.0/PKG-INFO +98 -0
- systemr-1.0.0/README.md +74 -0
- systemr-1.0.0/pyproject.toml +35 -0
- systemr-1.0.0/setup.cfg +4 -0
- systemr-1.0.0/systemr/__init__.py +30 -0
- systemr-1.0.0/systemr/client.py +257 -0
- systemr-1.0.0/systemr.egg-info/PKG-INFO +98 -0
- systemr-1.0.0/systemr.egg-info/SOURCES.txt +9 -0
- systemr-1.0.0/systemr.egg-info/dependency_links.txt +1 -0
- systemr-1.0.0/systemr.egg-info/requires.txt +1 -0
- systemr-1.0.0/systemr.egg-info/top_level.txt +1 -0
systemr-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: systemr
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python SDK for agents.systemr.ai - AI-native risk intelligence for trading agents
|
|
5
|
+
Author-email: System R AI <agents@systemr.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://systemr.ai
|
|
8
|
+
Project-URL: Documentation, https://agents.systemr.ai/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/systemr-ai/systemr-python
|
|
10
|
+
Keywords: trading,risk-management,position-sizing,ai-agents,mcp
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: httpx>=0.24.0
|
|
24
|
+
|
|
25
|
+
# systemr
|
|
26
|
+
|
|
27
|
+
Python SDK for [agents.systemr.ai](https://agents.systemr.ai) — AI-native risk intelligence for trading agents.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install systemr
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from systemr import SystemRClient
|
|
39
|
+
|
|
40
|
+
client = SystemRClient(api_key="sr_agent_...")
|
|
41
|
+
|
|
42
|
+
# Position sizing ($0.003)
|
|
43
|
+
result = client.calculate_position_size(
|
|
44
|
+
equity="100000",
|
|
45
|
+
entry_price="185.50",
|
|
46
|
+
stop_price="180.00",
|
|
47
|
+
direction="long",
|
|
48
|
+
)
|
|
49
|
+
print(result["shares"], result["risk_amount"])
|
|
50
|
+
|
|
51
|
+
# Risk validation ($0.004)
|
|
52
|
+
risk = client.check_risk(
|
|
53
|
+
symbol="AAPL",
|
|
54
|
+
direction="long",
|
|
55
|
+
entry_price="185.50",
|
|
56
|
+
stop_price="180.00",
|
|
57
|
+
quantity="100",
|
|
58
|
+
equity="100000",
|
|
59
|
+
)
|
|
60
|
+
print(risk["approved"], risk["score"])
|
|
61
|
+
|
|
62
|
+
# Strategy evaluation ($0.10 - $1.00)
|
|
63
|
+
eval_result = client.basic_eval(r_multiples=["1.5", "-1.0", "2.3", "-0.5", "1.8"])
|
|
64
|
+
print(eval_result["g_score"], eval_result["verdict"])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### Agent Management
|
|
70
|
+
- `client.get_info()` — Get agent info
|
|
71
|
+
- `client.list_agents()` — List owner's agents
|
|
72
|
+
- `client.update_mode(mode)` — Change mode (sandbox/live/suspended/terminated)
|
|
73
|
+
|
|
74
|
+
### Position Sizing
|
|
75
|
+
- `client.calculate_position_size(equity, entry_price, stop_price, direction)` — G-formula sizing ($0.003)
|
|
76
|
+
|
|
77
|
+
### Risk Validation
|
|
78
|
+
- `client.check_risk(symbol, direction, entry_price, stop_price, quantity, equity)` — Iron Fist validation ($0.004)
|
|
79
|
+
|
|
80
|
+
### Evaluation
|
|
81
|
+
- `client.basic_eval(r_multiples)` — G metric + verdict ($0.10)
|
|
82
|
+
- `client.full_eval(r_multiples)` — G + rolling G + System R Score ($0.50)
|
|
83
|
+
- `client.comprehensive_eval(r_multiples)` — Full analysis + impact ($1.00)
|
|
84
|
+
|
|
85
|
+
### Billing
|
|
86
|
+
- `client.get_pricing()` — Operation prices (no auth)
|
|
87
|
+
- `client.get_balance()` — Current USDC balance
|
|
88
|
+
- `client.deposit(amount)` — Record deposit
|
|
89
|
+
- `client.get_transactions()` — Transaction history
|
|
90
|
+
- `client.get_usage()` — Usage summary
|
|
91
|
+
|
|
92
|
+
## Authentication
|
|
93
|
+
|
|
94
|
+
Register at [agents.systemr.ai](https://agents.systemr.ai) to get an API key. All paid operations are billed in USDC.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
systemr-1.0.0/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# systemr
|
|
2
|
+
|
|
3
|
+
Python SDK for [agents.systemr.ai](https://agents.systemr.ai) — AI-native risk intelligence for trading agents.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install systemr
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from systemr import SystemRClient
|
|
15
|
+
|
|
16
|
+
client = SystemRClient(api_key="sr_agent_...")
|
|
17
|
+
|
|
18
|
+
# Position sizing ($0.003)
|
|
19
|
+
result = client.calculate_position_size(
|
|
20
|
+
equity="100000",
|
|
21
|
+
entry_price="185.50",
|
|
22
|
+
stop_price="180.00",
|
|
23
|
+
direction="long",
|
|
24
|
+
)
|
|
25
|
+
print(result["shares"], result["risk_amount"])
|
|
26
|
+
|
|
27
|
+
# Risk validation ($0.004)
|
|
28
|
+
risk = client.check_risk(
|
|
29
|
+
symbol="AAPL",
|
|
30
|
+
direction="long",
|
|
31
|
+
entry_price="185.50",
|
|
32
|
+
stop_price="180.00",
|
|
33
|
+
quantity="100",
|
|
34
|
+
equity="100000",
|
|
35
|
+
)
|
|
36
|
+
print(risk["approved"], risk["score"])
|
|
37
|
+
|
|
38
|
+
# Strategy evaluation ($0.10 - $1.00)
|
|
39
|
+
eval_result = client.basic_eval(r_multiples=["1.5", "-1.0", "2.3", "-0.5", "1.8"])
|
|
40
|
+
print(eval_result["g_score"], eval_result["verdict"])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Reference
|
|
44
|
+
|
|
45
|
+
### Agent Management
|
|
46
|
+
- `client.get_info()` — Get agent info
|
|
47
|
+
- `client.list_agents()` — List owner's agents
|
|
48
|
+
- `client.update_mode(mode)` — Change mode (sandbox/live/suspended/terminated)
|
|
49
|
+
|
|
50
|
+
### Position Sizing
|
|
51
|
+
- `client.calculate_position_size(equity, entry_price, stop_price, direction)` — G-formula sizing ($0.003)
|
|
52
|
+
|
|
53
|
+
### Risk Validation
|
|
54
|
+
- `client.check_risk(symbol, direction, entry_price, stop_price, quantity, equity)` — Iron Fist validation ($0.004)
|
|
55
|
+
|
|
56
|
+
### Evaluation
|
|
57
|
+
- `client.basic_eval(r_multiples)` — G metric + verdict ($0.10)
|
|
58
|
+
- `client.full_eval(r_multiples)` — G + rolling G + System R Score ($0.50)
|
|
59
|
+
- `client.comprehensive_eval(r_multiples)` — Full analysis + impact ($1.00)
|
|
60
|
+
|
|
61
|
+
### Billing
|
|
62
|
+
- `client.get_pricing()` — Operation prices (no auth)
|
|
63
|
+
- `client.get_balance()` — Current USDC balance
|
|
64
|
+
- `client.deposit(amount)` — Record deposit
|
|
65
|
+
- `client.get_transactions()` — Transaction history
|
|
66
|
+
- `client.get_usage()` — Usage summary
|
|
67
|
+
|
|
68
|
+
## Authentication
|
|
69
|
+
|
|
70
|
+
Register at [agents.systemr.ai](https://agents.systemr.ai) to get an API key. All paid operations are billed in USDC.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "systemr"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Python SDK for agents.systemr.ai - AI-native risk intelligence for trading agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "System R AI", email = "agents@systemr.ai"},
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
]
|
|
27
|
+
keywords = ["trading", "risk-management", "position-sizing", "ai-agents", "mcp"]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"httpx>=0.24.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://systemr.ai"
|
|
34
|
+
Documentation = "https://agents.systemr.ai/docs"
|
|
35
|
+
Repository = "https://github.com/systemr-ai/systemr-python"
|
systemr-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
System R Python SDK - AI-native risk intelligence for trading agents.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from systemr import SystemRClient
|
|
6
|
+
|
|
7
|
+
client = SystemRClient(api_key="sr_agent_...")
|
|
8
|
+
result = client.calculate_position_size(
|
|
9
|
+
equity="100000",
|
|
10
|
+
entry_price="150.00",
|
|
11
|
+
stop_price="145.00",
|
|
12
|
+
direction="long",
|
|
13
|
+
)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from systemr.client import (
|
|
17
|
+
AuthenticationError,
|
|
18
|
+
InsufficientBalanceError,
|
|
19
|
+
SystemRClient,
|
|
20
|
+
SystemRError,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"SystemRClient",
|
|
25
|
+
"SystemRError",
|
|
26
|
+
"AuthenticationError",
|
|
27
|
+
"InsufficientBalanceError",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"""
|
|
2
|
+
System R Python SDK client.
|
|
3
|
+
|
|
4
|
+
A simple, ergonomic client for agents to call System R services.
|
|
5
|
+
Uses httpx for HTTP requests with proper error handling.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
client = SystemRClient(api_key="sr_agent_...")
|
|
9
|
+
result = client.calculate_position_size(...)
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import httpx
|
|
13
|
+
from typing import Dict, List, Optional
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SystemRError(Exception):
|
|
17
|
+
"""Base exception for System R SDK errors."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, message: str, status_code: int = 0, detail: str = ""):
|
|
20
|
+
super().__init__(message)
|
|
21
|
+
self.status_code = status_code
|
|
22
|
+
self.detail = detail
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InsufficientBalanceError(SystemRError):
|
|
26
|
+
"""Raised when the agent's balance is too low for an operation."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AuthenticationError(SystemRError):
|
|
31
|
+
"""Raised when the API key is invalid or agent is inactive."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SystemRClient:
|
|
36
|
+
"""
|
|
37
|
+
Python SDK client for agents.systemr.ai.
|
|
38
|
+
|
|
39
|
+
All methods return dicts with string values for financial amounts
|
|
40
|
+
to preserve Decimal precision.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
DEFAULT_BASE_URL = "https://agents.systemr.ai"
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
api_key: str,
|
|
48
|
+
base_url: Optional[str] = None,
|
|
49
|
+
timeout: float = 30.0,
|
|
50
|
+
):
|
|
51
|
+
"""
|
|
52
|
+
Initialize the System R client.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
api_key: Agent API key (starts with 'sr_agent_').
|
|
56
|
+
base_url: API base URL. Defaults to https://agents.systemr.ai.
|
|
57
|
+
timeout: Request timeout in seconds.
|
|
58
|
+
"""
|
|
59
|
+
self._base_url = (base_url or self.DEFAULT_BASE_URL).rstrip("/")
|
|
60
|
+
self._client = httpx.Client(
|
|
61
|
+
base_url=self._base_url,
|
|
62
|
+
headers={"X-API-Key": api_key},
|
|
63
|
+
timeout=timeout,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def _request(self, method: str, path: str, **kwargs) -> dict:
|
|
67
|
+
"""Make an API request with error handling."""
|
|
68
|
+
resp = self._client.request(method, path, **kwargs)
|
|
69
|
+
|
|
70
|
+
if resp.status_code == 401:
|
|
71
|
+
raise AuthenticationError(
|
|
72
|
+
"Authentication failed", status_code=401,
|
|
73
|
+
detail=resp.json().get("detail", ""),
|
|
74
|
+
)
|
|
75
|
+
if resp.status_code == 402:
|
|
76
|
+
raise InsufficientBalanceError(
|
|
77
|
+
"Insufficient balance", status_code=402,
|
|
78
|
+
detail=resp.json().get("detail", ""),
|
|
79
|
+
)
|
|
80
|
+
if resp.status_code == 403:
|
|
81
|
+
raise AuthenticationError(
|
|
82
|
+
"Agent is not active", status_code=403,
|
|
83
|
+
detail=resp.json().get("detail", ""),
|
|
84
|
+
)
|
|
85
|
+
if resp.status_code >= 400:
|
|
86
|
+
detail = resp.json().get("detail", resp.text)
|
|
87
|
+
raise SystemRError(
|
|
88
|
+
f"API error: {detail}",
|
|
89
|
+
status_code=resp.status_code,
|
|
90
|
+
detail=detail,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
return resp.json()
|
|
94
|
+
|
|
95
|
+
# === Agent Management ===
|
|
96
|
+
|
|
97
|
+
def get_info(self) -> dict:
|
|
98
|
+
"""Get current agent information."""
|
|
99
|
+
return self._request("GET", "/v1/agents/me")
|
|
100
|
+
|
|
101
|
+
def list_agents(self) -> dict:
|
|
102
|
+
"""List all agents owned by the same owner."""
|
|
103
|
+
return self._request("GET", "/v1/agents/list")
|
|
104
|
+
|
|
105
|
+
def update_mode(self, mode: str) -> dict:
|
|
106
|
+
"""Change agent mode (sandbox, live, suspended, terminated)."""
|
|
107
|
+
return self._request("PUT", "/v1/agents/mode", json={"mode": mode})
|
|
108
|
+
|
|
109
|
+
# === Billing ===
|
|
110
|
+
|
|
111
|
+
def get_balance(self) -> dict:
|
|
112
|
+
"""Get current USDC balance."""
|
|
113
|
+
return self._request("GET", "/v1/billing/balance")
|
|
114
|
+
|
|
115
|
+
def deposit(
|
|
116
|
+
self,
|
|
117
|
+
amount: str,
|
|
118
|
+
funding_path: str = "direct_transfer",
|
|
119
|
+
on_chain_tx_hash: Optional[str] = None,
|
|
120
|
+
) -> dict:
|
|
121
|
+
"""Record a USDC deposit."""
|
|
122
|
+
payload: Dict[str, str] = {
|
|
123
|
+
"amount": amount,
|
|
124
|
+
"funding_path": funding_path,
|
|
125
|
+
}
|
|
126
|
+
if on_chain_tx_hash:
|
|
127
|
+
payload["on_chain_tx_hash"] = on_chain_tx_hash
|
|
128
|
+
return self._request("POST", "/v1/billing/deposit", json=payload)
|
|
129
|
+
|
|
130
|
+
def get_transactions(self, limit: int = 100) -> dict:
|
|
131
|
+
"""Get recent billing transactions."""
|
|
132
|
+
return self._request("GET", f"/v1/billing/transactions?limit={limit}")
|
|
133
|
+
|
|
134
|
+
def get_usage(self) -> dict:
|
|
135
|
+
"""Get usage summary grouped by operation."""
|
|
136
|
+
return self._request("GET", "/v1/billing/usage")
|
|
137
|
+
|
|
138
|
+
def get_pricing(self) -> dict:
|
|
139
|
+
"""Get current operation pricing (no auth required)."""
|
|
140
|
+
return self._request("GET", "/v1/billing/pricing")
|
|
141
|
+
|
|
142
|
+
# === Position Sizing ===
|
|
143
|
+
|
|
144
|
+
def calculate_position_size(
|
|
145
|
+
self,
|
|
146
|
+
equity: str,
|
|
147
|
+
entry_price: str,
|
|
148
|
+
stop_price: str,
|
|
149
|
+
direction: str,
|
|
150
|
+
risk_percent: Optional[str] = None,
|
|
151
|
+
instrument: Optional[str] = None,
|
|
152
|
+
) -> dict:
|
|
153
|
+
"""
|
|
154
|
+
Calculate optimal position size using G-formula.
|
|
155
|
+
|
|
156
|
+
Cost: $0.003 USDC.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
equity: Account equity in USD.
|
|
160
|
+
entry_price: Planned entry price.
|
|
161
|
+
stop_price: Stop loss price.
|
|
162
|
+
direction: 'long' or 'short'.
|
|
163
|
+
risk_percent: Risk as decimal (e.g. '0.02'). Optional.
|
|
164
|
+
instrument: Instrument symbol. Optional.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Dict with shares, risk_amount, risk_percent, notional, one_r_dollars.
|
|
168
|
+
"""
|
|
169
|
+
payload: Dict[str, str] = {
|
|
170
|
+
"equity": equity,
|
|
171
|
+
"entry_price": entry_price,
|
|
172
|
+
"stop_price": stop_price,
|
|
173
|
+
"direction": direction,
|
|
174
|
+
}
|
|
175
|
+
if risk_percent:
|
|
176
|
+
payload["risk_percent"] = risk_percent
|
|
177
|
+
if instrument:
|
|
178
|
+
payload["instrument"] = instrument
|
|
179
|
+
return self._request("POST", "/v1/sizing/calculate", json=payload)
|
|
180
|
+
|
|
181
|
+
# === Risk Check ===
|
|
182
|
+
|
|
183
|
+
def check_risk(
|
|
184
|
+
self,
|
|
185
|
+
symbol: str,
|
|
186
|
+
direction: str,
|
|
187
|
+
entry_price: str,
|
|
188
|
+
stop_price: str,
|
|
189
|
+
quantity: str,
|
|
190
|
+
equity: str,
|
|
191
|
+
daily_pnl: str = "0",
|
|
192
|
+
) -> dict:
|
|
193
|
+
"""
|
|
194
|
+
Validate trade risk using Iron Fist rules.
|
|
195
|
+
|
|
196
|
+
Cost: $0.004 USDC.
|
|
197
|
+
|
|
198
|
+
Returns:
|
|
199
|
+
Dict with approved (bool), score (0-100), errors, warnings.
|
|
200
|
+
"""
|
|
201
|
+
return self._request("POST", "/v1/risk/check", json={
|
|
202
|
+
"symbol": symbol,
|
|
203
|
+
"direction": direction,
|
|
204
|
+
"entry_price": entry_price,
|
|
205
|
+
"stop_price": stop_price,
|
|
206
|
+
"quantity": quantity,
|
|
207
|
+
"equity": equity,
|
|
208
|
+
"daily_pnl": daily_pnl,
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
# === Evaluation ===
|
|
212
|
+
|
|
213
|
+
def basic_eval(self, r_multiples: List[str]) -> dict:
|
|
214
|
+
"""
|
|
215
|
+
Basic evaluation -- G metric and verdict.
|
|
216
|
+
|
|
217
|
+
Cost: $0.10 USDC.
|
|
218
|
+
"""
|
|
219
|
+
return self._request("POST", "/v1/eval/basic", json={
|
|
220
|
+
"r_multiples": r_multiples,
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
def full_eval(
|
|
224
|
+
self, r_multiples: List[str], window_size: int = 10
|
|
225
|
+
) -> dict:
|
|
226
|
+
"""
|
|
227
|
+
Full evaluation -- G + rolling G + System R Score.
|
|
228
|
+
|
|
229
|
+
Cost: $0.50 USDC.
|
|
230
|
+
"""
|
|
231
|
+
return self._request("POST", "/v1/eval/full", json={
|
|
232
|
+
"r_multiples": r_multiples,
|
|
233
|
+
"window_size": window_size,
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
def comprehensive_eval(
|
|
237
|
+
self, r_multiples: List[str], window_size: int = 10
|
|
238
|
+
) -> dict:
|
|
239
|
+
"""
|
|
240
|
+
Comprehensive evaluation -- all metrics + impact analysis.
|
|
241
|
+
|
|
242
|
+
Cost: $1.00 USDC.
|
|
243
|
+
"""
|
|
244
|
+
return self._request("POST", "/v1/eval/comprehensive", json={
|
|
245
|
+
"r_multiples": r_multiples,
|
|
246
|
+
"window_size": window_size,
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
def close(self):
|
|
250
|
+
"""Close the HTTP client."""
|
|
251
|
+
self._client.close()
|
|
252
|
+
|
|
253
|
+
def __enter__(self):
|
|
254
|
+
return self
|
|
255
|
+
|
|
256
|
+
def __exit__(self, *args):
|
|
257
|
+
self.close()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: systemr
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python SDK for agents.systemr.ai - AI-native risk intelligence for trading agents
|
|
5
|
+
Author-email: System R AI <agents@systemr.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://systemr.ai
|
|
8
|
+
Project-URL: Documentation, https://agents.systemr.ai/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/systemr-ai/systemr-python
|
|
10
|
+
Keywords: trading,risk-management,position-sizing,ai-agents,mcp
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: httpx>=0.24.0
|
|
24
|
+
|
|
25
|
+
# systemr
|
|
26
|
+
|
|
27
|
+
Python SDK for [agents.systemr.ai](https://agents.systemr.ai) — AI-native risk intelligence for trading agents.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install systemr
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from systemr import SystemRClient
|
|
39
|
+
|
|
40
|
+
client = SystemRClient(api_key="sr_agent_...")
|
|
41
|
+
|
|
42
|
+
# Position sizing ($0.003)
|
|
43
|
+
result = client.calculate_position_size(
|
|
44
|
+
equity="100000",
|
|
45
|
+
entry_price="185.50",
|
|
46
|
+
stop_price="180.00",
|
|
47
|
+
direction="long",
|
|
48
|
+
)
|
|
49
|
+
print(result["shares"], result["risk_amount"])
|
|
50
|
+
|
|
51
|
+
# Risk validation ($0.004)
|
|
52
|
+
risk = client.check_risk(
|
|
53
|
+
symbol="AAPL",
|
|
54
|
+
direction="long",
|
|
55
|
+
entry_price="185.50",
|
|
56
|
+
stop_price="180.00",
|
|
57
|
+
quantity="100",
|
|
58
|
+
equity="100000",
|
|
59
|
+
)
|
|
60
|
+
print(risk["approved"], risk["score"])
|
|
61
|
+
|
|
62
|
+
# Strategy evaluation ($0.10 - $1.00)
|
|
63
|
+
eval_result = client.basic_eval(r_multiples=["1.5", "-1.0", "2.3", "-0.5", "1.8"])
|
|
64
|
+
print(eval_result["g_score"], eval_result["verdict"])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API Reference
|
|
68
|
+
|
|
69
|
+
### Agent Management
|
|
70
|
+
- `client.get_info()` — Get agent info
|
|
71
|
+
- `client.list_agents()` — List owner's agents
|
|
72
|
+
- `client.update_mode(mode)` — Change mode (sandbox/live/suspended/terminated)
|
|
73
|
+
|
|
74
|
+
### Position Sizing
|
|
75
|
+
- `client.calculate_position_size(equity, entry_price, stop_price, direction)` — G-formula sizing ($0.003)
|
|
76
|
+
|
|
77
|
+
### Risk Validation
|
|
78
|
+
- `client.check_risk(symbol, direction, entry_price, stop_price, quantity, equity)` — Iron Fist validation ($0.004)
|
|
79
|
+
|
|
80
|
+
### Evaluation
|
|
81
|
+
- `client.basic_eval(r_multiples)` — G metric + verdict ($0.10)
|
|
82
|
+
- `client.full_eval(r_multiples)` — G + rolling G + System R Score ($0.50)
|
|
83
|
+
- `client.comprehensive_eval(r_multiples)` — Full analysis + impact ($1.00)
|
|
84
|
+
|
|
85
|
+
### Billing
|
|
86
|
+
- `client.get_pricing()` — Operation prices (no auth)
|
|
87
|
+
- `client.get_balance()` — Current USDC balance
|
|
88
|
+
- `client.deposit(amount)` — Record deposit
|
|
89
|
+
- `client.get_transactions()` — Transaction history
|
|
90
|
+
- `client.get_usage()` — Usage summary
|
|
91
|
+
|
|
92
|
+
## Authentication
|
|
93
|
+
|
|
94
|
+
Register at [agents.systemr.ai](https://agents.systemr.ai) to get an API key. All paid operations are billed in USDC.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.24.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
systemr
|