@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.
Files changed (57) hide show
  1. package/.claude-plugin/marketplace.json +28 -0
  2. package/.claude-plugin/plugin.json +12 -0
  3. package/README.md +99 -0
  4. package/VERSION +1 -0
  5. package/bin/getagent-skill.js +140 -0
  6. package/package.json +45 -0
  7. package/skills/getagent/SKILL.md +129 -0
  8. package/skills/getagent/examples/btc-ema-cross-demo/README.md +61 -0
  9. package/skills/getagent/examples/btc-ema-cross-demo/backtest.yaml +33 -0
  10. package/skills/getagent/examples/btc-ema-cross-demo/manifest.yaml +94 -0
  11. package/skills/getagent/examples/btc-ema-cross-demo/src/main.py +88 -0
  12. package/skills/getagent/examples/btc-ema-cross-demo/src/strategy.py +118 -0
  13. package/skills/getagent/references/api/enable.md +95 -0
  14. package/skills/getagent/references/api/error-responses.md +77 -0
  15. package/skills/getagent/references/api/index.md +38 -0
  16. package/skills/getagent/references/api/list.md +80 -0
  17. package/skills/getagent/references/api/my-playbooks.md +41 -0
  18. package/skills/getagent/references/api/publish.md +76 -0
  19. package/skills/getagent/references/api/run.md +149 -0
  20. package/skills/getagent/references/api/upload.md +76 -0
  21. package/skills/getagent/references/backtest-engine.md +438 -0
  22. package/skills/getagent/references/package-schema.md +552 -0
  23. package/skills/getagent/references/sandbox-runtime.md +201 -0
  24. package/skills/getagent/references/sdk/backtest/catalog.md +208 -0
  25. package/skills/getagent/references/sdk/data/arxiv.md +41 -0
  26. package/skills/getagent/references/sdk/data/catalog.md +56 -0
  27. package/skills/getagent/references/sdk/data/commodity.md +226 -0
  28. package/skills/getagent/references/sdk/data/coverage.md +82 -0
  29. package/skills/getagent/references/sdk/data/crypto.md +2906 -0
  30. package/skills/getagent/references/sdk/data/currency.md +123 -0
  31. package/skills/getagent/references/sdk/data/derivatives.md +269 -0
  32. package/skills/getagent/references/sdk/data/economy.md +1348 -0
  33. package/skills/getagent/references/sdk/data/equity.md +2120 -0
  34. package/skills/getagent/references/sdk/data/etf.md +372 -0
  35. package/skills/getagent/references/sdk/data/famafrench.md +201 -0
  36. package/skills/getagent/references/sdk/data/fixedincome.md +804 -0
  37. package/skills/getagent/references/sdk/data/imf_utils.md +225 -0
  38. package/skills/getagent/references/sdk/data/index.md +216 -0
  39. package/skills/getagent/references/sdk/data/news.md +149 -0
  40. package/skills/getagent/references/sdk/data/playbook-supported.md +9871 -0
  41. package/skills/getagent/references/sdk/data/regulators.md +299 -0
  42. package/skills/getagent/references/sdk/data/sentiment.md +323 -0
  43. package/skills/getagent/references/sdk/data/uscongress.md +126 -0
  44. package/skills/getagent/references/sdk/data/web_search.md +68 -0
  45. package/skills/getagent/references/sdk/data/wikipedia.md +97 -0
  46. package/skills/getagent/references/sdk/llm/catalog.md +117 -0
  47. package/skills/getagent/references/sdk/runtime/catalog.md +195 -0
  48. package/skills/getagent/references/sdk/trade/account.md +61 -0
  49. package/skills/getagent/references/sdk/trade/catalog.md +35 -0
  50. package/skills/getagent/references/sdk/trade/contract.md +331 -0
  51. package/skills/getagent/references/sdk/trade/helpers.md +466 -0
  52. package/skills/getagent/references/sdk/trade/market.md +28 -0
  53. package/skills/getagent/references/sdk/trade/patterns.md +102 -0
  54. package/skills/getagent/references/sdk/trade/spot.md +165 -0
  55. package/skills/getagent/references/sdk.md +198 -0
  56. package/skills/getagent/scripts/validate.py +965 -0
  57. package/skills/getagent/scripts/version_check.sh +62 -0
@@ -0,0 +1,165 @@
1
+ # Trade Spot Reference
2
+
3
+ Spot query, place, cancel, and modify flows.
4
+
5
+ These signatures are written against the `getagent.trade` public contract.
6
+ Runner-managed identity kwargs (`user_id`, `channel`, `trace_id`) are
7
+ intentionally omitted from the author-facing signatures below.
8
+
9
+ ## Contents
10
+ - [`trade.spot.pending_orders`](#tradespotpending-orders)
11
+ - [`trade.spot.fills`](#tradespotfills)
12
+ - [`trade.spot.place_order`](#tradespotplace-order)
13
+ - [`trade.spot.market_buy`](#tradespotmarket-buy)
14
+ - [`trade.spot.market_sell`](#tradespotmarket-sell)
15
+ - [`trade.spot.limit_order`](#tradespotlimit-order)
16
+ - [`trade.spot.cancel_order`](#tradespotcancel-order)
17
+ - [`trade.spot.modify_limit_order`](#tradespotmodify-limit-order)
18
+
19
+ ## Method reference
20
+
21
+ ### `trade.spot.pending_orders`
22
+
23
+ ```python
24
+ trade.spot.pending_orders(symbol="", limit=None)
25
+ ```
26
+
27
+ Summary: List live (unfilled) spot orders, optionally filtered by ``symbol``.
28
+
29
+ | Param | Required | Type | Default |
30
+ |---|---|---|---|
31
+ | `symbol` | `no` | `str` | `""` |
32
+ | `limit` | `no` | `int | None` | `None` |
33
+
34
+ Returns: `SpotPendingOrdersResult`
35
+
36
+ ---
37
+
38
+ ### `trade.spot.fills`
39
+
40
+ ```python
41
+ trade.spot.fills(symbol="", order_id="", limit=None)
42
+ ```
43
+
44
+ Summary: List recent spot trade fills, optionally scoped to one order.
45
+
46
+ | Param | Required | Type | Default |
47
+ |---|---|---|---|
48
+ | `symbol` | `no` | `str` | `""` |
49
+ | `order_id` | `no` | `str` | `""` |
50
+ | `limit` | `no` | `int | None` | `None` |
51
+
52
+ Returns: `SpotFillsResult`
53
+
54
+ ---
55
+
56
+ ### `trade.spot.place_order`
57
+
58
+ ```python
59
+ trade.spot.place_order(symbol, side, order_type, qty, price="", time_in_force='GTC')
60
+ ```
61
+
62
+ Summary: Place a spot order with an explicit base-asset ``qty``.
63
+
64
+ | Param | Required | Type | Default |
65
+ |---|---|---|---|
66
+ | `symbol` | `yes` | `str` | - |
67
+ | `side` | `yes` | `SideLiteral` | - |
68
+ | `order_type` | `yes` | `OrderTypeLiteral` | - |
69
+ | `qty` | `yes` | `Any` | - |
70
+ | `price` | `no` | `Any` | `""` |
71
+ | `time_in_force` | `no` | `TimeInForceLiteral` | `GTC` |
72
+
73
+ Returns: `OrderPlacedResult`
74
+
75
+ ---
76
+
77
+ ### `trade.spot.market_buy`
78
+
79
+ ```python
80
+ trade.spot.market_buy(symbol, qty)
81
+ ```
82
+
83
+ Summary: Spot market buy with base-asset ``qty`` (shorthand for place_order).
84
+
85
+ | Param | Required | Type | Default |
86
+ |---|---|---|---|
87
+ | `symbol` | `yes` | `str` | - |
88
+ | `qty` | `yes` | `Any` | - |
89
+
90
+ Returns: `OrderPlacedResult`
91
+
92
+ ---
93
+
94
+ ### `trade.spot.market_sell`
95
+
96
+ ```python
97
+ trade.spot.market_sell(symbol, qty)
98
+ ```
99
+
100
+ Summary: Spot market sell with base-asset ``qty`` (shorthand for place_order).
101
+
102
+ | Param | Required | Type | Default |
103
+ |---|---|---|---|
104
+ | `symbol` | `yes` | `str` | - |
105
+ | `qty` | `yes` | `Any` | - |
106
+
107
+ Returns: `OrderPlacedResult`
108
+
109
+ ---
110
+
111
+ ### `trade.spot.limit_order`
112
+
113
+ ```python
114
+ trade.spot.limit_order(symbol, side, qty, price, time_in_force='GTC')
115
+ ```
116
+
117
+ Summary: Spot limit order (shorthand for place_order with order_type='limit').
118
+
119
+ | Param | Required | Type | Default |
120
+ |---|---|---|---|
121
+ | `symbol` | `yes` | `str` | - |
122
+ | `side` | `yes` | `SideLiteral` | - |
123
+ | `qty` | `yes` | `Any` | - |
124
+ | `price` | `yes` | `Any` | - |
125
+ | `time_in_force` | `no` | `TimeInForceLiteral` | `GTC` |
126
+
127
+ Returns: `OrderPlacedResult`
128
+
129
+ ---
130
+
131
+ ### `trade.spot.cancel_order`
132
+
133
+ ```python
134
+ trade.spot.cancel_order(symbol, order_id)
135
+ ```
136
+
137
+ Summary: Cancel a live spot order by ``order_id``.
138
+
139
+ | Param | Required | Type | Default |
140
+ |---|---|---|---|
141
+ | `symbol` | `yes` | `str` | - |
142
+ | `order_id` | `yes` | `str` | - |
143
+
144
+ Returns: `OrderPlacedResult`
145
+
146
+ ---
147
+
148
+ ### `trade.spot.modify_limit_order`
149
+
150
+ ```python
151
+ trade.spot.modify_limit_order(symbol, order_id, price, qty)
152
+ ```
153
+
154
+ Summary: Modify a live spot limit order's ``price`` and ``qty`` atomically.
155
+
156
+ | Param | Required | Type | Default |
157
+ |---|---|---|---|
158
+ | `symbol` | `yes` | `str` | - |
159
+ | `order_id` | `yes` | `str` | - |
160
+ | `price` | `yes` | `Any` | - |
161
+ | `qty` | `yes` | `Any` | - |
162
+
163
+ Returns: `OrderPlacedResult`
164
+
165
+ ---
@@ -0,0 +1,198 @@
1
+ # GetAgent SDK
2
+
3
+ This is the stable authoring entrypoint for the Python SDK surface available to
4
+ Playbook code. Use this file before writing `src/main.py`.
5
+
6
+ This folder separates:
7
+
8
+ - `sdk/` — Python modules imported by Playbook code
9
+ - `api/` — HTTP control plane used to upload, publish, run, and manage Playbooks
10
+
11
+ ## Read order
12
+
13
+ 1. Start with `[package-schema.md](package-schema.md)` to understand the package
14
+ contract.
15
+ 2. Read the relevant SDK section below:
16
+ - market data → `[sdk/data/playbook-supported.md](sdk/data/playbook-supported.md)`
17
+ - replay / charting → `[sdk/backtest/catalog.md](sdk/backtest/catalog.md)`
18
+ - trading → `[sdk/trade/patterns.md](sdk/trade/patterns.md)`
19
+ - runtime protocol / signal output → `[sdk/runtime/catalog.md](sdk/runtime/catalog.md)`
20
+ - bounded LLM/live-only logic → `[sdk/llm/catalog.md](sdk/llm/catalog.md)`
21
+ 3. Read `[backtest-engine.md](backtest-engine.md)` for replay and metrics rules.
22
+ 4. Read `[sandbox-runtime.md](sandbox-runtime.md)` for execution limits and
23
+ blocked imports.
24
+
25
+ ## Quick start
26
+
27
+ ```python
28
+ from getagent import backtest, data, runtime
29
+
30
+ bars = data.crypto.futures.kline(symbol="BTCUSDT", interval="1h", exchange="binance")
31
+ taker_volume = data.crypto.futures.taker_volume(symbol="BTCUSDT", period="1h")
32
+ replay_frame = backtest.build_feature_frame(
33
+ bars,
34
+ base_datetime_index="date",
35
+ features=[
36
+ backtest.FeatureSource(
37
+ data=taker_volume,
38
+ datetime_index="timestamp",
39
+ include_columns=("buy_vol", "sell_vol"),
40
+ rename_columns={
41
+ "buy_vol": "taker_buy_volume",
42
+ "sell_vol": "taker_sell_volume",
43
+ },
44
+ )
45
+ ],
46
+ )
47
+ result = backtest.run(
48
+ ohlcv_data={"BTCUSDT.BINANCE": replay_frame},
49
+ spec=runtime.backtest_spec,
50
+ )
51
+ summary = result.summary
52
+ # Author code emits raw account-level numbers; the platform rewrites
53
+ # total_return_pct / max_drawdown_pct to per-strategy basis
54
+ # (net_pnl / margin_budget) before persisting them.
55
+ runtime.emit_signal(
56
+ action="long" if float(summary.get("net_pnl", 0) or 0) > 0 else "hold",
57
+ symbol="BTCUSDT",
58
+ confidence=result.win_rate,
59
+ metrics={
60
+ "total_return_pct": result.total_return_pct,
61
+ "net_pnl": float(summary.get("net_pnl", 0) or 0),
62
+ "starting_balance": summary.get("starting_balance"),
63
+ "sharpe_ratio": result.sharpe_ratio,
64
+ "max_drawdown_pct": result.max_drawdown_pct,
65
+ "win_rate": result.win_rate,
66
+ "total_trades": result.total_trades,
67
+ "profit_factor": result.profit_factor,
68
+ },
69
+ )
70
+ ```
71
+
72
+ ## Modules
73
+
74
+ Use this file and the linked catalogs as the SDK source of truth. Do not invent
75
+ modules, namespaces, methods, endpoint ids, or keyword arguments by combining
76
+ plausible names. If the needed capability is absent from the listed surfaces,
77
+ report missing SDK coverage instead of importing a direct client or guessing a
78
+ fallback.
79
+
80
+ Authoritative public surfaces:
81
+
82
+ - DataSDK: `getagent.data` generated endpoint methods listed under
83
+ `sdk/data/`
84
+ - TradeSDK: `getagent.trade` namespaces and helpers listed under `sdk/trade/`
85
+ - BacktestSDK: `getagent.backtest` helpers listed in `sdk/backtest/catalog.md`
86
+ - RuntimeSDK: `getagent.runtime` context and signal helpers listed in
87
+ `sdk/runtime/catalog.md`
88
+ - LLMSDK: `getagent.llm` bounded `chat` / `complete` surface listed in
89
+ `sdk/llm/catalog.md`
90
+
91
+ ### `getagent.data`
92
+
93
+ The only supported market data module.
94
+
95
+ Read order:
96
+
97
+ 1. `[sdk/data/playbook-supported.md](sdk/data/playbook-supported.md)` —
98
+ full Playbook-callable `getagent.data` endpoint surface
99
+ 2. `[sdk/data/catalog.md](sdk/data/catalog.md)` — full domain index
100
+ 3. domain files under `[sdk/data/](sdk/data/catalog.md)` — exact signatures,
101
+ defaults, enums, and parameter notes
102
+
103
+ Hard rules:
104
+
105
+ - Never import direct clients such as `ccxt`, `httpx`, `requests`,
106
+ `yfinance`, or `akshare`
107
+ - Convert `OBBject` responses with `data.to_dataframe()`, `data.to_dict()`, or
108
+ `data.to_records()`
109
+ - When several endpoints need to land in one replay frame, normalize them first
110
+ and join them through `backtest.prepare_frame()` / `backtest.build_feature_frame()`
111
+ - Treat all generated `getagent.data` endpoints as callable from Playbooks; for
112
+ backtests, verify the response fields and time axis match the replay contract
113
+ before declaring required fields in `backtest.yaml`
114
+
115
+ ### `getagent.trade`
116
+
117
+ The managed trading surface. Playbook code must import `getagent.trade`, not
118
+ `trade_sdk`.
119
+
120
+ Read order:
121
+
122
+ 1. `[sdk/trade/patterns.md](sdk/trade/patterns.md)` — safe execution flows
123
+ 2. `[sdk/trade/catalog.md](sdk/trade/catalog.md)` — namespace index
124
+ 3. namespace files under `[sdk/trade/](sdk/trade/catalog.md)` — exact method
125
+ signatures and parameters
126
+
127
+ Hard rules:
128
+
129
+ - Never hardcode runner-managed identity such as `user_id`, `base_url`, or
130
+ `channel`
131
+ - Always size quote or margin budgets via `trade.helpers.compute_qty(...)`
132
+ - For contract opens, derive TP/SL via `trade.helpers.resolve_contract_tpsl(...)`
133
+ - Do not pass percentage override kwargs to `resolve_contract_tpsl(...)`; compute
134
+ concrete `tp_trigger_price` / `sl_trigger_price` values first
135
+ - For cancel / close / modify flows, follow `PRE-CHECK -> EXECUTE -> POST-CHECK`
136
+ - Always check envelopes with `trade.is_success(result)`
137
+
138
+ ### `getagent.backtest`
139
+
140
+ Backtest and charting helpers for replayable strategies.
141
+
142
+ Read `[sdk/backtest/catalog.md](sdk/backtest/catalog.md)` for the concrete
143
+ author-facing API surface, result shape, and basic examples.
144
+
145
+ - `backtest.run(...)`
146
+ - `backtest.prepare_frame(...)`
147
+ - `backtest.FeatureSource(...)`
148
+ - `backtest.build_feature_frame(...)`
149
+ - `backtest.generate_chart(...)`
150
+
151
+ Read `[backtest-engine.md](backtest-engine.md)` for Nautilus spec shape, replay
152
+ assumptions, and diagnostics.
153
+
154
+ Extra replay columns declared in `backtest.yaml` are preserved and can be read
155
+ through strategy feature-frame injection. Use the feature-frame helpers above to
156
+ align arbitrary `getagent.data` endpoints onto your base bar series before
157
+ calling `backtest.run(...)`; see the backtest docs above.
158
+
159
+ ### `getagent.runtime`
160
+
161
+ Managed runtime protocol for Playbooks.
162
+
163
+ Read `[sdk/runtime/catalog.md](sdk/runtime/catalog.md)` for the concrete context
164
+ surface, signal output contract, and examples.
165
+
166
+ - context:
167
+ - `runtime.manifest`
168
+ - `runtime.backtest_spec`
169
+ - `runtime.run_id`
170
+ - output:
171
+ - `runtime.emit_signal(...)`
172
+ - `runtime.get_emitted_signals()`
173
+
174
+ Use `runtime` for runner-injected context and signal output. Do not expect a
175
+ built-in planner, memory loop, or general agent runtime from this module.
176
+
177
+ ### `getagent.llm`
178
+
179
+ Managed bounded model access for live-only Playbooks.
180
+
181
+ Read `[sdk/llm/catalog.md](sdk/llm/catalog.md)` for the concrete call surface,
182
+ runtime limits, typed errors, and examples.
183
+
184
+ - Available only when `manifest.yaml` sets `runtime_profile: llm_bounded`
185
+ - `llm.is_available()` reflects whether the runner injected bounded LLM access
186
+ - `llm.complete(...)` and `llm.chat(...)` run against one runner-managed model
187
+ - Call count, prompt size, output tokens, and timeout are all capped by the
188
+ deployment runtime
189
+ - Tool calls, free model switching, and arbitrary HTTP clients are not exposed
190
+
191
+ Use `getagent.llm` only for unreplayable/live-only logic. Historical backtest
192
+ still requires `runtime_profile: deterministic`.
193
+
194
+ ## See also
195
+
196
+ - `[sandbox-runtime.md](sandbox-runtime.md)` — runtime contract
197
+ - `[package-schema.md](package-schema.md)` — package structure and manifest
198
+ - `[api/index.md](api/index.md)` — HTTP control plane, not Python imports