@bitget-ai/getagent-skill 0.2.1
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.
- package/.claude-plugin/marketplace.json +28 -0
- package/.claude-plugin/plugin.json +12 -0
- package/README.md +99 -0
- package/VERSION +1 -0
- package/bin/getagent-skill.js +140 -0
- package/package.json +45 -0
- package/skills/getagent/SKILL.md +129 -0
- package/skills/getagent/examples/btc-ema-cross-demo/README.md +61 -0
- package/skills/getagent/examples/btc-ema-cross-demo/backtest.yaml +33 -0
- package/skills/getagent/examples/btc-ema-cross-demo/manifest.yaml +94 -0
- package/skills/getagent/examples/btc-ema-cross-demo/src/main.py +88 -0
- package/skills/getagent/examples/btc-ema-cross-demo/src/strategy.py +118 -0
- package/skills/getagent/references/api/enable.md +95 -0
- package/skills/getagent/references/api/error-responses.md +77 -0
- package/skills/getagent/references/api/index.md +38 -0
- package/skills/getagent/references/api/list.md +80 -0
- package/skills/getagent/references/api/my-playbooks.md +41 -0
- package/skills/getagent/references/api/publish.md +76 -0
- package/skills/getagent/references/api/run.md +149 -0
- package/skills/getagent/references/api/upload.md +76 -0
- package/skills/getagent/references/backtest-engine.md +438 -0
- package/skills/getagent/references/package-schema.md +552 -0
- package/skills/getagent/references/sandbox-runtime.md +201 -0
- package/skills/getagent/references/sdk/backtest/catalog.md +208 -0
- package/skills/getagent/references/sdk/data/arxiv.md +41 -0
- package/skills/getagent/references/sdk/data/catalog.md +56 -0
- package/skills/getagent/references/sdk/data/commodity.md +226 -0
- package/skills/getagent/references/sdk/data/coverage.md +82 -0
- package/skills/getagent/references/sdk/data/crypto.md +2906 -0
- package/skills/getagent/references/sdk/data/currency.md +123 -0
- package/skills/getagent/references/sdk/data/derivatives.md +269 -0
- package/skills/getagent/references/sdk/data/economy.md +1348 -0
- package/skills/getagent/references/sdk/data/equity.md +2120 -0
- package/skills/getagent/references/sdk/data/etf.md +372 -0
- package/skills/getagent/references/sdk/data/famafrench.md +201 -0
- package/skills/getagent/references/sdk/data/fixedincome.md +804 -0
- package/skills/getagent/references/sdk/data/imf_utils.md +225 -0
- package/skills/getagent/references/sdk/data/index.md +216 -0
- package/skills/getagent/references/sdk/data/news.md +149 -0
- package/skills/getagent/references/sdk/data/playbook-supported.md +9871 -0
- package/skills/getagent/references/sdk/data/regulators.md +299 -0
- package/skills/getagent/references/sdk/data/sentiment.md +323 -0
- package/skills/getagent/references/sdk/data/uscongress.md +126 -0
- package/skills/getagent/references/sdk/data/web_search.md +68 -0
- package/skills/getagent/references/sdk/data/wikipedia.md +97 -0
- package/skills/getagent/references/sdk/llm/catalog.md +117 -0
- package/skills/getagent/references/sdk/runtime/catalog.md +195 -0
- package/skills/getagent/references/sdk/trade/account.md +61 -0
- package/skills/getagent/references/sdk/trade/catalog.md +35 -0
- package/skills/getagent/references/sdk/trade/contract.md +331 -0
- package/skills/getagent/references/sdk/trade/helpers.md +466 -0
- package/skills/getagent/references/sdk/trade/market.md +28 -0
- package/skills/getagent/references/sdk/trade/patterns.md +102 -0
- package/skills/getagent/references/sdk/trade/spot.md +165 -0
- package/skills/getagent/references/sdk.md +198 -0
- package/skills/getagent/scripts/validate.py +965 -0
- package/skills/getagent/scripts/version_check.sh +62 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Sandbox Runtime
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- [Execution Model](#execution-model)
|
|
6
|
+
- [State and Persistence](#state-and-persistence)
|
|
7
|
+
- [Runtime Profiles](#runtime-profiles)
|
|
8
|
+
- [Pre-installed Dependencies](#pre-installed-dependencies)
|
|
9
|
+
- [Allowed Standard Library Modules](#allowed-standard-library-modules)
|
|
10
|
+
- [Blocked Modules](#blocked-modules)
|
|
11
|
+
- [Network Restrictions](#network-restrictions)
|
|
12
|
+
- [Output Conventions](#output-conventions)
|
|
13
|
+
- [Environment Variables](#environment-variables)
|
|
14
|
+
|
|
15
|
+
## Execution Model
|
|
16
|
+
|
|
17
|
+
- **Engine:** Python 3.12
|
|
18
|
+
- **Entry point:** package executes as `python -m src.main`
|
|
19
|
+
- **Working directory:** `/workspace/`
|
|
20
|
+
- **Timeout:** 180 seconds
|
|
21
|
+
- **Memory:** 2GB
|
|
22
|
+
- **Fresh workspace:** Each run starts in a fresh workspace snapshot.
|
|
23
|
+
- **Executable runtime profiles:** `deterministic`, plus deployment-enabled `llm_bounded`
|
|
24
|
+
- **No built-in agent loop:** Do not assume planner / reflection / tool-orchestration loops are provided by the platform.
|
|
25
|
+
|
|
26
|
+
## State and Persistence
|
|
27
|
+
|
|
28
|
+
The workspace is ephemeral by default, but the runner may optionally hydrate and
|
|
29
|
+
sync `.state/` on behalf of the Playbook.
|
|
30
|
+
|
|
31
|
+
- Treat `.state/` as the only supported persisted path across runs.
|
|
32
|
+
- Do not rely on files outside `.state/` surviving between runs.
|
|
33
|
+
- If `.state/` hydrate fails, the runner may abort instead of silently running
|
|
34
|
+
with missing state.
|
|
35
|
+
- Agent memory is **not** part of the default sandbox contract. If a future
|
|
36
|
+
runtime introduces agent memory, it should live behind an explicit runtime
|
|
37
|
+
profile and policy.
|
|
38
|
+
|
|
39
|
+
## Runtime Profiles
|
|
40
|
+
|
|
41
|
+
The product direction is to separate package shape from runtime capability.
|
|
42
|
+
|
|
43
|
+
- `deterministic`
|
|
44
|
+
- Current default executable profile
|
|
45
|
+
- No built-in general-purpose agent loop
|
|
46
|
+
- Best fit for `backtest_support: full`
|
|
47
|
+
- `llm_bounded`
|
|
48
|
+
- Executable only when the deployment enables managed Playbook LLM access
|
|
49
|
+
- Use through `getagent.llm`, not direct HTTP clients
|
|
50
|
+
- Fixed call-count, prompt-size, output-token, and timeout budgets
|
|
51
|
+
- Best fit for `backtest_support: none`
|
|
52
|
+
- `agentic`
|
|
53
|
+
- Declared contract only for now; current sandbox rejects it at runtime
|
|
54
|
+
- Should not be assumed in the default Playbook sandbox
|
|
55
|
+
|
|
56
|
+
### Agent loop guidance
|
|
57
|
+
|
|
58
|
+
Do **not** assume a full general-purpose agent runtime is available in the
|
|
59
|
+
default Playbook sandbox.
|
|
60
|
+
|
|
61
|
+
`llm_bounded` is intentionally narrower than a general-purpose agent loop. If
|
|
62
|
+
the platform later introduces `agentic`, it should still require:
|
|
63
|
+
|
|
64
|
+
- an explicit runtime profile or separate image
|
|
65
|
+
- fixed tool allowlists
|
|
66
|
+
- `max_steps`
|
|
67
|
+
- `max_runtime_ms`
|
|
68
|
+
- `max_model_tokens`
|
|
69
|
+
- trace persistence
|
|
70
|
+
- an explicit memory policy
|
|
71
|
+
|
|
72
|
+
## Pre-installed Dependencies
|
|
73
|
+
|
|
74
|
+
These are the packages present in the image. This is **not** the same as the
|
|
75
|
+
author-facing import contract: some entries below exist only so managed SDKs can
|
|
76
|
+
work internally.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
| Package | Version | Purpose |
|
|
80
|
+
| ----------------- | ------------------- | ----------------------------------------------------------------------------- |
|
|
81
|
+
| `getagent` | 0.1.1 | SDK (data, trade, backtest, runtime, llm) |
|
|
82
|
+
| `getall` | repo source | Internal managed runtime used by `getagent.llm` |
|
|
83
|
+
| `litellm` | 1.83.7 | Internal provider bridge behind `getagent.llm` |
|
|
84
|
+
| `trade-sdk` | vendored source | Internal implementation behind `getagent.trade` (not a public Playbook import) |
|
|
85
|
+
| `pandas` | ≥2.0 | Data manipulation |
|
|
86
|
+
| `numpy` | ≥1.24 | Numerical computation |
|
|
87
|
+
| `nautilus_trader` | current image build | Backtest engine (used by SDK and author strategy classes) |
|
|
88
|
+
| `pydantic` | 2.13.2 | Internal config/runtime models |
|
|
89
|
+
| `pyyaml` | ≥6.0 | YAML parsing |
|
|
90
|
+
| `matplotlib` | ≥3.7 | Chart rendering (used by SDK internally) |
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
**No pip install.** PyPI is network-blocked. Only pre-installed packages are available.
|
|
94
|
+
|
|
95
|
+
### Public author imports
|
|
96
|
+
|
|
97
|
+
Playbook source code should import from the public surface only:
|
|
98
|
+
|
|
99
|
+
- `getagent`
|
|
100
|
+
- `nautilus_trader`
|
|
101
|
+
- `pandas`
|
|
102
|
+
- `numpy`
|
|
103
|
+
- safe standard-library modules listed below
|
|
104
|
+
|
|
105
|
+
Do not import implementation details such as `getall`, `litellm`, `httpx`, or
|
|
106
|
+
`trade_sdk` even when they exist in the image.
|
|
107
|
+
|
|
108
|
+
## Allowed Standard Library Modules
|
|
109
|
+
|
|
110
|
+
`json`, `math`, `datetime`, `pathlib`, `asyncio`, `typing`, `dataclasses`,
|
|
111
|
+
`collections`, `functools`, `re`, `decimal`, `statistics`, `itertools`,
|
|
112
|
+
`operator`, `copy`, `enum`, `abc`, `numbers`, `fractions`
|
|
113
|
+
|
|
114
|
+
## Blocked Author Imports
|
|
115
|
+
|
|
116
|
+
### Security model
|
|
117
|
+
|
|
118
|
+
The sandbox uses **defense in depth** — no single layer is relied on alone:
|
|
119
|
+
|
|
120
|
+
1. **AST static check (best-effort):** Upload and local validation reject
|
|
121
|
+
direct `import os`, `__import__()`, `eval()`, `exec()`, `__builtins__`
|
|
122
|
+
access, and similar patterns. This catches accidental misuse and obvious
|
|
123
|
+
violations, but **cannot prevent all dynamic import bypasses** due to
|
|
124
|
+
Python's runtime flexibility.
|
|
125
|
+
2. **Container image (hard boundary for the public contract):** Only
|
|
126
|
+
pre-installed packages are available. Some blocked libraries may exist as
|
|
127
|
+
internal dependencies of managed SDKs (for example `getagent.trade` is backed
|
|
128
|
+
by `trade-sdk`, and `getagent.llm` is backed by `getall` + `litellm`, which
|
|
129
|
+
use `httpx` internally), but Playbook source code is still rejected if it
|
|
130
|
+
imports those libraries directly.
|
|
131
|
+
3. **Managed capability access (hard boundary):** Strategy code must fetch data
|
|
132
|
+
through `getagent.data` and place trades through `getagent.trade`. Direct HTTP
|
|
133
|
+
clients remain blocked even if the managed SDK talks to upstream services on
|
|
134
|
+
the strategy's behalf.
|
|
135
|
+
4. **Container isolation (hard boundary):** The sandbox runs in an isolated
|
|
136
|
+
Docker container with resource limits. Process execution, file access,
|
|
137
|
+
and environment variable reads are confined to the container.
|
|
138
|
+
|
|
139
|
+
**Standard library modules** like `os`, `subprocess`, and `importlib` are
|
|
140
|
+
present in the Python runtime and cannot be removed. The AST check blocks
|
|
141
|
+
direct imports, but determined bypass attempts using `getattr`/`globals()`
|
|
142
|
+
are theoretically possible. These modules are considered **low risk** because
|
|
143
|
+
network egress is blocked and the container is isolated.
|
|
144
|
+
|
|
145
|
+
### Blocked categories
|
|
146
|
+
|
|
147
|
+
**Network:** `requests`, `httpx`, `trade_sdk`, `urllib`, `aiohttp`, `socket`, `http`, `ftplib`, `smtplib`
|
|
148
|
+
|
|
149
|
+
**System:** `subprocess`, `os`, `shutil`, `importlib`, `ctypes`, `multiprocessing`
|
|
150
|
+
|
|
151
|
+
**Database:** `sqlalchemy`, `redis`, `pymongo`
|
|
152
|
+
|
|
153
|
+
**Frameworks:** `fastapi`, `flask`, `django`
|
|
154
|
+
|
|
155
|
+
**Messaging:** `telegram`, `slack_sdk`, `discord`
|
|
156
|
+
|
|
157
|
+
## Network Restrictions
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
| Allowed | Blocked |
|
|
161
|
+
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
162
|
+
| Managed SDK data access via `getagent.data` | PyPI (`pypi.org`, `files.pythonhosted.org`) |
|
|
163
|
+
| Trade-proxy requests via `getagent.trade` when runner context is injected | Direct `requests` / `httpx` / `urllib` calls from Playbook code |
|
|
164
|
+
| Managed LLM calls via `getagent.llm` when `runtime_profile: llm_bounded` is injected | |
|
|
165
|
+
| | All private networks, localhost, and arbitrary public addresses from Playbook code |
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
**All data fetching must go through `getagent.data`, all trade-proxy access must go through `getagent.trade`, and bounded model calls must go through `getagent.llm`.** Do not make direct HTTP requests.
|
|
169
|
+
|
|
170
|
+
## Output Conventions
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
| Output Type | Mechanism | Available |
|
|
174
|
+
| --------------- | ----------------------------------------------------------------------- | --------- |
|
|
175
|
+
| Trading signals | `runtime.emit_signal()` → stdout JSON + `/workspace/output/signal.json` | Yes |
|
|
176
|
+
| Backtest charts | `backtest.generate_chart()` → `/workspace/output/*.png` (matplotlib) | Yes |
|
|
177
|
+
| Debug output | `print()` → stdout (Runner collects first 5000 chars) | Yes |
|
|
178
|
+
| Errors | `print(..., file=sys.stderr)` → stderr | Yes |
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
The Runner collects all `.png`, `.json`, `.csv` files from `/workspace/output/`
|
|
182
|
+
as artifacts after execution completes.
|
|
183
|
+
|
|
184
|
+
## Environment Variables
|
|
185
|
+
|
|
186
|
+
These variables are injected by the Runner **inside the sandbox at execution time**. They are not the same as the shell variables the operator sets to call the HTTP control plane (see `references/api/upload.md`). In particular, `GETAGENT_PRINCIPAL_ID` is server-side execution context only and is **not** an HTTP auth credential — prod OpenAPI client calls must use `ACCESS-KEY`, never `X-Principal-Id`.
|
|
187
|
+
|
|
188
|
+
| Variable | Description |
|
|
189
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
190
|
+
| `GETAGENT_WORKSPACE` | Working directory path (default `/workspace`) |
|
|
191
|
+
| `GETAGENT_RUN_ID` | Unique run identifier |
|
|
192
|
+
| `GETAGENT_PLAYBOOK_ID` | Playbook ID |
|
|
193
|
+
| `GETAGENT_PRINCIPAL_ID` | Execution principal for the current run (sandbox-injected; **not** for HTTP client auth) |
|
|
194
|
+
| `GETAGENT_CHAT_ID` | Delivery target for manual or scheduled results |
|
|
195
|
+
| `GETAGENT_DATA_BASE_URL` | Preferred data API base URL for `getagent.data` |
|
|
196
|
+
| `OPENBB_BASE_URL` | Legacy compatibility alias for `getagent.data` |
|
|
197
|
+
| `GETAGENT_TRADE_BG_UID` | Trade-proxy subaccount identifier used by `getagent.trade` |
|
|
198
|
+
| `GETAGENT_TRADE_PROXY_BASE_URL` | Trade-proxy base URL injected by the runner |
|
|
199
|
+
| `GETAGENT_TRADE_CHANNEL` | Trade-proxy channel label injected by the runner |
|
|
200
|
+
| `GETAGENT_RUNTIME_PROFILE` | Runner-selected runtime profile for the current execution |
|
|
201
|
+
| `GETAGENT_LLM_`* | Internal bounded LLM config injected only for `runtime_profile: llm_bounded`; prefer `getagent.llm` instead of reading these directly |
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# `getagent.backtest`
|
|
2
|
+
|
|
3
|
+
Author-facing replay and charting surface for backtestable Playbooks.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use `getagent.backtest` when the core trading decision can be fairly
|
|
8
|
+
reconstructed from historical data and expressed as a NautilusTrader strategy.
|
|
9
|
+
|
|
10
|
+
Typical fit:
|
|
11
|
+
|
|
12
|
+
- `runtime_profile: deterministic`
|
|
13
|
+
- `backtest_support: full`
|
|
14
|
+
- strategy logic implemented as a `nautilus_trader.trading.strategy.Strategy`
|
|
15
|
+
subclass under `src/**`
|
|
16
|
+
- historical metrics intended for public evidence
|
|
17
|
+
|
|
18
|
+
Do not use `getagent.backtest` to justify strategies whose trade decision
|
|
19
|
+
depends on open-ended LLM reasoning or unreplayable live context.
|
|
20
|
+
|
|
21
|
+
## Public API
|
|
22
|
+
|
|
23
|
+
### Prepare one dataset
|
|
24
|
+
|
|
25
|
+
- `backtest.prepare_frame(source, datetime_index=None, rename_columns=None) -> pandas.DataFrame`
|
|
26
|
+
|
|
27
|
+
Behavior:
|
|
28
|
+
|
|
29
|
+
- accepts `OBBject`, `pandas.DataFrame`, one mapping, or a list of mappings
|
|
30
|
+
- normalizes column names to lowercase
|
|
31
|
+
- parses the time column into a UTC `DatetimeIndex`
|
|
32
|
+
|
|
33
|
+
### Describe one feature source
|
|
34
|
+
|
|
35
|
+
- `backtest.FeatureSource(...)`
|
|
36
|
+
|
|
37
|
+
Useful fields:
|
|
38
|
+
|
|
39
|
+
- `data` — one historical dataset returned by `getagent.data` or already prepared locally
|
|
40
|
+
- `datetime_index` — time field name when the source is not already indexed
|
|
41
|
+
- `rename_columns` — rename raw source fields into replay-field names such as
|
|
42
|
+
`taker_buy_volume`
|
|
43
|
+
- `include_columns` — keep only the columns you want to attach to the replay frame
|
|
44
|
+
- `prefix` — add a prefix to every attached feature column
|
|
45
|
+
- `mode` — `"asof"` for time alignment or `"exact"` for exact index joins
|
|
46
|
+
- `join` — `"left"` (default) or `"inner"`
|
|
47
|
+
- `direction` / `tolerance` — `merge_asof` controls for time-series joins
|
|
48
|
+
|
|
49
|
+
### Build one replay frame
|
|
50
|
+
|
|
51
|
+
- `backtest.build_feature_frame(base, base_datetime_index=None, base_rename_columns=None, features=None) -> pandas.DataFrame`
|
|
52
|
+
|
|
53
|
+
Behavior:
|
|
54
|
+
|
|
55
|
+
- starts from a base bar dataset, usually K lines / candles
|
|
56
|
+
- aligns arbitrary historical feature datasets onto the base timestamps
|
|
57
|
+
- returns one replay-ready DataFrame that still contains core OHLCV plus your
|
|
58
|
+
added feature columns
|
|
59
|
+
|
|
60
|
+
### Run a backtest
|
|
61
|
+
|
|
62
|
+
- `backtest.run(ohlcv_data, spec=None) -> BacktestResult`
|
|
63
|
+
|
|
64
|
+
Parameters:
|
|
65
|
+
|
|
66
|
+
- `ohlcv_data`
|
|
67
|
+
- dict of `{instrument-key: pandas.DataFrame}`
|
|
68
|
+
- each frame should have a `DatetimeIndex` plus OHLCV columns
|
|
69
|
+
- additional normalized columns are preserved for strategy feature access
|
|
70
|
+
- keys should match the instrument IDs or symbols declared in `backtest.yaml`
|
|
71
|
+
|
|
72
|
+
- `spec`
|
|
73
|
+
- usually `runtime.backtest_spec`
|
|
74
|
+
- explicit Nautilus backtest spec with:
|
|
75
|
+
- `venue`
|
|
76
|
+
- `instrument` or `instruments`
|
|
77
|
+
- `strategy`
|
|
78
|
+
- optional `execution`
|
|
79
|
+
- optional `data_requirements.required_bar_fields`
|
|
80
|
+
|
|
81
|
+
### Generate a chart
|
|
82
|
+
|
|
83
|
+
- `backtest.generate_chart(result, save_dir=None) -> str`
|
|
84
|
+
|
|
85
|
+
Behavior:
|
|
86
|
+
|
|
87
|
+
- writes a PNG to `/workspace/output/` by default
|
|
88
|
+
- returns the saved path as a string
|
|
89
|
+
- returns `""` when chart generation fails
|
|
90
|
+
|
|
91
|
+
## Result shape
|
|
92
|
+
|
|
93
|
+
`BacktestResult` exposes normalized account-level summary metrics directly:
|
|
94
|
+
|
|
95
|
+
- `total_return_pct` (account return, using `backtest.yaml` starting balance)
|
|
96
|
+
- `sharpe_ratio`
|
|
97
|
+
- `max_drawdown_pct`
|
|
98
|
+
- `win_rate`
|
|
99
|
+
- `profit_factor`
|
|
100
|
+
- `total_trades`
|
|
101
|
+
- `summary`
|
|
102
|
+
- `raw`
|
|
103
|
+
|
|
104
|
+
User-facing return % is computed by the platform on a per-strategy basis
|
|
105
|
+
(`net_pnl / manifest.strategy_config.margin_budget`). The author should emit
|
|
106
|
+
the engine summary as-is; `service.build_run_record` rewrites
|
|
107
|
+
`total_return_pct` and `max_drawdown_pct` before storing them, preserving the
|
|
108
|
+
account-level numbers as `account_total_return_pct` /
|
|
109
|
+
`account_max_drawdown_pct` for analysts. Just remember to declare a positive
|
|
110
|
+
`margin_budget` in `manifest.strategy_config` (validation requires it for
|
|
111
|
+
`backtest_support: full` and `execution_mode: follow_trade`).
|
|
112
|
+
|
|
113
|
+
`result.raw` is Nautilus-native output with stable top-level sections:
|
|
114
|
+
|
|
115
|
+
- `summary` — normalized key metrics
|
|
116
|
+
- `stats` — analyzer outputs grouped by returns / general / pnls
|
|
117
|
+
- `reports` — account / orders / fills / positions / equity curve
|
|
118
|
+
- `config` — the resolved venue, instrument IDs, bar types, and strategy entry
|
|
119
|
+
|
|
120
|
+
## Example
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from getagent import backtest, data, runtime
|
|
124
|
+
|
|
125
|
+
bars = data.crypto.futures.kline(symbol="BTCUSDT", interval="1h", exchange="binance")
|
|
126
|
+
taker_volume = data.crypto.futures.taker_volume(symbol="BTCUSDT", period="1h")
|
|
127
|
+
open_interest = data.crypto.futures.open_interest_history(symbol="BTCUSDT", period="1h")
|
|
128
|
+
|
|
129
|
+
replay_frame = backtest.build_feature_frame(
|
|
130
|
+
bars,
|
|
131
|
+
base_datetime_index="date",
|
|
132
|
+
features=[
|
|
133
|
+
backtest.FeatureSource(
|
|
134
|
+
data=taker_volume,
|
|
135
|
+
datetime_index="timestamp",
|
|
136
|
+
include_columns=("buy_vol", "sell_vol"),
|
|
137
|
+
rename_columns={
|
|
138
|
+
"buy_vol": "taker_buy_volume",
|
|
139
|
+
"sell_vol": "taker_sell_volume",
|
|
140
|
+
},
|
|
141
|
+
),
|
|
142
|
+
backtest.FeatureSource(
|
|
143
|
+
data=open_interest,
|
|
144
|
+
datetime_index="date",
|
|
145
|
+
include_columns=("open_interest",),
|
|
146
|
+
),
|
|
147
|
+
],
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
result = backtest.run(
|
|
151
|
+
ohlcv_data={"BTCUSDT.BINANCE": replay_frame},
|
|
152
|
+
spec=runtime.backtest_spec,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
chart_path = backtest.generate_chart(result)
|
|
156
|
+
summary = result.summary
|
|
157
|
+
net_pnl = float(summary.get("net_pnl", 0) or 0)
|
|
158
|
+
|
|
159
|
+
runtime.emit_signal(
|
|
160
|
+
action="long" if net_pnl > 0 else "hold",
|
|
161
|
+
symbol="BTCUSDT",
|
|
162
|
+
confidence=result.win_rate,
|
|
163
|
+
metrics={
|
|
164
|
+
"total_return_pct": result.total_return_pct,
|
|
165
|
+
"net_pnl": net_pnl,
|
|
166
|
+
"starting_balance": summary.get("starting_balance"),
|
|
167
|
+
"sharpe_ratio": result.sharpe_ratio,
|
|
168
|
+
"max_drawdown_pct": result.max_drawdown_pct,
|
|
169
|
+
"win_rate": result.win_rate,
|
|
170
|
+
"total_trades": result.total_trades,
|
|
171
|
+
"profit_factor": result.profit_factor,
|
|
172
|
+
},
|
|
173
|
+
meta={"chart_path": chart_path},
|
|
174
|
+
)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Hard rules
|
|
178
|
+
|
|
179
|
+
- Use `runtime.backtest_spec` as the default source of replay configuration
|
|
180
|
+
- Keep public backtest claims tied to deterministic strategy logic
|
|
181
|
+
- Declare enriched replay column dependencies in
|
|
182
|
+
`backtest.yaml -> data_requirements.required_bar_fields`
|
|
183
|
+
- Use `prepare_frame()` / `build_feature_frame()` to standardize multi-endpoint
|
|
184
|
+
replay assembly instead of open-coded timestamp joins
|
|
185
|
+
- Expect `backtest.run()` to fail fast when declared replay columns are missing
|
|
186
|
+
or all-null in the effective execution window
|
|
187
|
+
- Before making a backtest claim, verify the replay frame covers the claimed
|
|
188
|
+
window and contains every decision feature. Record row count, first/last
|
|
189
|
+
timestamp, and returned fields during probing.
|
|
190
|
+
- Do not silently replace missing decision features with constants such as
|
|
191
|
+
`0`, `0.5`, or `False`. Missing `taker_buy_ratio`, open interest, funding, or
|
|
192
|
+
liquidation data should either fail the run or be reported as degraded, not
|
|
193
|
+
hidden inside the performance metrics.
|
|
194
|
+
- Strategy classes may import `nautilus_trader`; Playbook code must not import
|
|
195
|
+
legacy backtest engines directly
|
|
196
|
+
- Do not use `backtest.run()` as fake evidence for `llm_bounded` strategies
|
|
197
|
+
- Treat `result.total_trades == 0` as a diagnostic case, not a success story
|
|
198
|
+
- Prefer `generate_chart(result)` over writing ad hoc chart files yourself
|
|
199
|
+
- Do not emit `metrics=result.summary` directly for user-visible backtest
|
|
200
|
+
results when the strategy has a configured budget. Convert `net_pnl` to
|
|
201
|
+
strategy-budget return and keep account return under `account_return_pct`.
|
|
202
|
+
|
|
203
|
+
## Related docs
|
|
204
|
+
|
|
205
|
+
- [`../../backtest-engine.md`](../../backtest-engine.md)
|
|
206
|
+
- [`../../package-schema.md`](../../package-schema.md)
|
|
207
|
+
- [`../../sandbox-runtime.md`](../../sandbox-runtime.md)
|
|
208
|
+
- [`../runtime/catalog.md`](../runtime/catalog.md)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Arxiv Data Reference
|
|
2
|
+
|
|
3
|
+
Use this file when an agent needs detailed signatures and parameter
|
|
4
|
+
rules for one DataSDK domain. All generated `getagent.data` endpoints
|
|
5
|
+
are callable through the DataSDK wrapper.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
- [`arxiv.search`](#arxivsearch)
|
|
9
|
+
|
|
10
|
+
## Endpoint reference
|
|
11
|
+
|
|
12
|
+
### `arxiv.search`
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
data.arxiv.search(query=None, max_results=10, page=1, sort_by='relevance', sort_order='descending', search_field='all', category=None, provider='arxiv')
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Summary: Search
|
|
19
|
+
|
|
20
|
+
| Field | Value |
|
|
21
|
+
|---|---|
|
|
22
|
+
| Endpoint ID | `arxiv.search` |
|
|
23
|
+
| HTTP | `GET` |
|
|
24
|
+
| Path | `/inner/v1/agent-data/arxiv/search` |
|
|
25
|
+
| Default provider | `arxiv` |
|
|
26
|
+
| SDK | `supported` |
|
|
27
|
+
| Host | `supported` |
|
|
28
|
+
| Notes | - |
|
|
29
|
+
|
|
30
|
+
#### Query parameters
|
|
31
|
+
|
|
32
|
+
| Param | Required | Type | Default | Notes |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| `query` | `no` | `string | null` | `-` | Search query string. (provider: arxiv) |
|
|
35
|
+
| `max_results` | `no` | `integer` | `10` | Maximum number of results. (provider: arxiv) |
|
|
36
|
+
| `page` | `no` | `integer` | `1` | Page number, starting at 1. (provider: arxiv) |
|
|
37
|
+
| `sort_by` | `no` | `string` | `relevance` | Sort by relevance, last updated date, or submitted date. (provider: arxiv) |
|
|
38
|
+
| `sort_order` | `no` | `string` | `descending` | Sort direction. (provider: arxiv) |
|
|
39
|
+
| `search_field` | `no` | `string` | `all` | Field to search: all, ti (title), au (author), abs (abstract), cat (category). (provider: arxiv) |
|
|
40
|
+
| `category` | `no` | `string | null` | `-` | Filter by arXiv subject category, e.g. 'cs.AI', 'q-fin.TR'. (provider: arxiv) |
|
|
41
|
+
| `provider` | `no` | `string` | `arxiv` | - |
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Data Reference Catalog
|
|
2
|
+
|
|
3
|
+
This catalog is the self-contained runtime reference for `getagent.data`.
|
|
4
|
+
All links in this directory stay inside the packaged runtime skill so an
|
|
5
|
+
agent can inspect DataSDK endpoint contracts without depending on the
|
|
6
|
+
Playbook creator source tree.
|
|
7
|
+
|
|
8
|
+
## Read order
|
|
9
|
+
|
|
10
|
+
1. Start with [`playbook-supported.md`](playbook-supported.md) for the full
|
|
11
|
+
Playbook-callable `getagent.data` surface.
|
|
12
|
+
2. Use the domain files below for exact signatures, defaults, enums,
|
|
13
|
+
provider notes, and parameter details.
|
|
14
|
+
|
|
15
|
+
## Domain index
|
|
16
|
+
|
|
17
|
+
| Domain | File | Endpoints |
|
|
18
|
+
|---|---|---:|
|
|
19
|
+
| `Coverage` | [coverage.md](coverage.md) | 3 |
|
|
20
|
+
| `arxiv` | [arxiv.md](arxiv.md) | 1 |
|
|
21
|
+
| `commodity` | [commodity.md](commodity.md) | 7 |
|
|
22
|
+
| `crypto` | [crypto.md](crypto.md) | 97 |
|
|
23
|
+
| `currency` | [currency.md](currency.md) | 4 |
|
|
24
|
+
| `derivatives` | [derivatives.md](derivatives.md) | 8 |
|
|
25
|
+
| `economy` | [economy.md](economy.md) | 42 |
|
|
26
|
+
| `equity` | [equity.md](equity.md) | 68 |
|
|
27
|
+
| `etf` | [etf.md](etf.md) | 12 |
|
|
28
|
+
| `famafrench` | [famafrench.md](famafrench.md) | 6 |
|
|
29
|
+
| `fixedincome` | [fixedincome.md](fixedincome.md) | 25 |
|
|
30
|
+
| `imf_utils` | [imf_utils.md](imf_utils.md) | 8 |
|
|
31
|
+
| `index` | [index.md](index.md) | 7 |
|
|
32
|
+
| `news` | [news.md](news.md) | 3 |
|
|
33
|
+
| `regulators` | [regulators.md](regulators.md) | 10 |
|
|
34
|
+
| `sentiment` | [sentiment.md](sentiment.md) | 11 |
|
|
35
|
+
| `uscongress` | [uscongress.md](uscongress.md) | 4 |
|
|
36
|
+
| `web_search` | [web_search.md](web_search.md) | 2 |
|
|
37
|
+
| `wikipedia` | [wikipedia.md](wikipedia.md) | 3 |
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
- Status rows are generated from the same availability registry used by
|
|
42
|
+
the SDK tests and runtime metadata.
|
|
43
|
+
- Playbook sandboxes are expected to support the complete generated
|
|
44
|
+
`getagent.data` namespace. Do not treat data endpoints as having a
|
|
45
|
+
separate sandbox allowlist.
|
|
46
|
+
- For backtests, verify the endpoint returns the fields and time axis your
|
|
47
|
+
strategy needs before declaring those fields in `backtest.yaml`.
|
|
48
|
+
- `provider` may be shown with a default even when the upstream OpenAPI
|
|
49
|
+
marks it as required. That reflects the managed `getagent.data` wrapper,
|
|
50
|
+
which auto-injects the default provider when one is defined.
|
|
51
|
+
- Time ranges use millisecond Unix-epoch `start_time` / `end_time` and the
|
|
52
|
+
canonical datetime column is `time`. The SDK still accepts the legacy
|
|
53
|
+
`start_date` / `end_date` parameters (and exposes a derived `date` field)
|
|
54
|
+
with a `DeprecationWarning` until upstream removes the legacy surface.
|
|
55
|
+
Call `data.to_dataframe(bars)` without `datetime_index` to let the SDK
|
|
56
|
+
pick the canonical column.
|