trading-cli 0.3.0__py3-none-any.whl

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.
@@ -0,0 +1,309 @@
1
+ Metadata-Version: 2.4
2
+ Name: trading-cli
3
+ Version: 0.3.0
4
+ Summary: Trade any exchange from the command line — agent-native trading CLI
5
+ Author: FastBooks
6
+ License: MIT
7
+ Keywords: trading,cli,crypto,exchange,agent,fastbooks
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Financial and Insurance Industry
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Topic :: Office/Business :: Financial :: Investment
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: click>=8.0
21
+ Requires-Dist: requests>=2.28
22
+ Provides-Extra: standalone
23
+ Requires-Dist: ccxt>=4.0; extra == "standalone"
24
+ Provides-Extra: mcp
25
+ Requires-Dist: mcp>=1.0; extra == "mcp"
26
+ Provides-Extra: agent
27
+ Requires-Dist: ccxt>=4.0; extra == "agent"
28
+ Requires-Dist: mcp>=1.0; extra == "agent"
29
+ Provides-Extra: strategies
30
+ Requires-Dist: fastbooks-clistrategies; extra == "strategies"
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0; extra == "dev"
33
+ Requires-Dist: ccxt>=4.0; extra == "dev"
34
+ Requires-Dist: mcp>=1.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ ```
38
+ ███████╗ █████╗ ███████╗████████╗██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗
39
+ ██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔═══██╗██╔═══██╗██║ ██╔╝██╔════╝
40
+ █████╗ ███████║███████╗ ██║ ██████╔╝██║ ██║██║ ██║█████╔╝ ███████╗
41
+ ██╔══╝ ██╔══██║╚════██║ ██║ ██╔══██╗██║ ██║██║ ██║██╔═██╗ ╚════██║
42
+ ██║ ██║ ██║███████║ ██║ ██████╔╝╚██████╔╝╚██████╔╝██║ ██╗███████║
43
+ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
44
+ trade the entire market — crypto · stocks · forex · perps · predictions
45
+ one CLI · every venue · human-readable or --json for agents
46
+ ```
47
+
48
+ <h1 align="center">FastBooks CLI</h1>
49
+
50
+ <p align="center">
51
+ <b>Every market on Earth, one command line.</b><br/>
52
+ Live data and execution across crypto, equities, forex, perps, commodities,
53
+ on-chain DEXes, tokenized assets, and prediction markets — built for humans <i>and</i> agents.
54
+ </p>
55
+
56
+ ---
57
+
58
+ Trade any market from the command line — and from agents. One interface over
59
+ crypto exchanges, brokers, forex, and prediction markets, with **dual output**:
60
+ human-readable tables by default, machine-readable JSON with `--json`.
61
+
62
+ > **For agents / LLMs:** see [SKILL.md](SKILL.md) for the structured skill
63
+ > definition (command grammar, JSON schemas, env vars). This file is the
64
+ > human guide.
65
+
66
+ ---
67
+
68
+ ## Install
69
+
70
+ Once published, it's a one-liner:
71
+
72
+ ```bash
73
+ pipx install fastbooks-cli # recommended (isolated); or: pip install fastbooks-cli
74
+ fastbooks --help
75
+ ```
76
+
77
+ From a checkout (development):
78
+
79
+ ```bash
80
+ cd cli && pip install -e . # installs the `fastbooks` command
81
+ ```
82
+
83
+ Requires Python ≥ 3.10. Runtime deps are just `click` and `requests`.
84
+
85
+ ## Talking to the backend
86
+
87
+ The CLI is a thin client over two HTTP services:
88
+
89
+ | Service | Default | Env var |
90
+ |---------|---------|---------|
91
+ | Routing API (markets, execution, keys) | `http://localhost:3002` | `FASTBOOKS_ROUTING_URL` |
92
+ | Bots service (deploy, forward-test) | `http://localhost:8003` | `FASTBOOKS_BOTS_URL` |
93
+
94
+ ```bash
95
+ fastbooks config show # show resolved URLs
96
+ fastbooks config doctor # ping both services
97
+ ```
98
+
99
+ Auth: FastBooks platform keys (`apikey`) are **fully self-service — no admin
100
+ token**. The only token you may need is `FASTBOOKS_API_TOKEN` (a JWT), and only
101
+ for storing exchange keys & saved backtests.
102
+
103
+ ---
104
+
105
+ ## Quickstart — the four core flows
106
+
107
+ ```bash
108
+ # 1. Create a FastBooks API key (self-service, no admin token; free, read-only, 5 req/sec)
109
+ fastbooks apikey create --label my-bot
110
+ fastbooks apikey limits # see the default limits
111
+ fastbooks apikey info fb_live_xxx # inspect your key (present the key itself)
112
+ fastbooks apikey revoke fb_live_xxx # revoke your key (present the key itself)
113
+
114
+ # 2. Get market data
115
+ fastbooks markets tickers --category crypto
116
+ fastbooks markets orderbook binance BTC/USDT
117
+ fastbooks markets ohlcv binance BTC/USDT -t 1h -n 100
118
+ fastbooks apikey verify fb_live_xxx # market data via the public API key
119
+
120
+ # 3. Deploy a bot on FastBooks paper
121
+ fastbooks bots deploy -n "Paper Momentum" -v alpaca -s momentum -c 50000 --paper
122
+ fastbooks bots list
123
+ fastbooks bots stop <bot_id>
124
+
125
+ # 4. Connect an exchange, then forward-test (paper) or go live
126
+ export FASTBOOKS_API_TOKEN=<your jwt>
127
+ fastbooks wallet add binance -k <KEY> -s <SECRET>
128
+ fastbooks backtest forward-test --venue alpaca --capital 50000 --paper
129
+ # ...same command with --live once you're confident
130
+ ```
131
+
132
+ Add `--json` to any command for agent-friendly output.
133
+
134
+ ---
135
+
136
+ ## Command groups
137
+
138
+ | Group | Status | Purpose |
139
+ |-------|--------|---------|
140
+ | `markets` | ✅ live | Orderbooks, tickers, OHLCV, symbols, options |
141
+ | `execute` | ✅ live | Place/cancel/list orders, balance, positions, leverage, quote |
142
+ | `bots` | ✅ live | Create/deploy, start/stop/pause, monitor, emergency-stop |
143
+ | `backtest` | ✅ live | Historical sims + single-cycle forward tests |
144
+ | `apikey` | ✅ live | Self-service FastBooks platform keys (create/limits/verify) |
145
+ | `wallet` | ✅ live | Exchange API-key management (`add`/`list`/`test`/`remove`) |
146
+ | `config` | ✅ live | Show config, health-check services |
147
+ | `repl` | ✅ live | Interactive session |
148
+ | `strategy` | ✅ live | Run a bundled local strategy directly (e.g. Hyperliquid momentum) |
149
+ | `swap` | 🧪 experimental | On-chain swaps — requires a swap router not enabled on all deployments |
150
+ | `dex` | 🧪 experimental | DEX perps (GMX/dYdX/Aevo) — requires a dex router not enabled on all deployments |
151
+ | `polymarket` | 🧪 experimental | Prediction-market trading — requires the Polymarket router |
152
+
153
+ `fastbooks <group> --help` lists every subcommand and flag.
154
+
155
+ See [EXCHANGES.md](EXCHANGES.md) for per-venue setup, auth, and symbol formats.
156
+
157
+ ---
158
+
159
+ ## Capabilities at a glance
160
+
161
+ - **Unified market data** across crypto, equities, ETFs, forex, indices, commodities, on-chain (DEX), tokenized assets, and prediction markets — one ticker model, one set of commands.
162
+ - **Order execution** on CEXes, Hyperliquid perps, brokers (Alpaca, IBKR), forex (OANDA/Saxo), and paper — venue-agnostic place/cancel/list/balance/positions/leverage/quote.
163
+ - **Bots**: deploy on FastBooks paper or live, start/stop/pause, monitor (events/logs/report), emergency-stop.
164
+ - **Backtesting**: historical sims + single-cycle forward tests across any supported venue.
165
+ - **Self-service API keys** for the public read API (free, 5 req/sec).
166
+ - **Agent-native**: `--json` on everything; one result object or `{"error",...}` per call.
167
+
168
+ ## Market data coverage
169
+
170
+ | Asset class | Category filter | Example venues / source |
171
+ |-------------|-----------------|--------------------------|
172
+ | Crypto spot | `crypto` / `spot` | Binance, Bybit, OKX, Kraken, Coinbase, KuCoin |
173
+ | Crypto perps | `perpetuals` | Hyperliquid (+ experimental GMX/dYdX/Aevo) |
174
+ | Stocks & ETFs | `stocks` | US + global equities (region universes below) |
175
+ | Forex | `forex` | major/minor FX pairs |
176
+ | Indices | `index` | global indices |
177
+ | Commodities | `commodity` | metals, energy, ags |
178
+ | On-chain (DEX) | `dex` | Solana/EVM pools |
179
+ | Tokenized assets | `tokenized` | tokenized equities/RWAs |
180
+ | Prediction | `prediction` | Polymarket, Limitless |
181
+ | Options | — | `markets options <underlying>` (e.g. Deribit) |
182
+
183
+ **Data endpoints (via `fastbooks markets`):**
184
+
185
+ | Command | What you get |
186
+ |---------|--------------|
187
+ | `tickers [--category] [--exchange] [--search] [--page] [--limit]` | Unified live tickers (price, 24h change/volume), paginated & searchable |
188
+ | `orderbook <exchange> <symbol>` | L2 order book |
189
+ | `orderbooks [--category all\|spot\|perpetuals]` | Aggregated multi-venue books |
190
+ | `ohlcv <exchange> <symbol> [-t TF] [-n N]` | OHLCV candles — timeframes `1m,5m,15m,30m,1h,4h,1d,1w` |
191
+ | `symbols [-r REGION] [-s SECTOR] [-n N]` | Regional equity universe — regions `us,ca,uk,au,eu,jp,asia` |
192
+ | `options <underlying>` | Options chain |
193
+
194
+ ### Getting full ticker lists (handy for agents)
195
+
196
+ `--all` auto-paginates the entire universe in one command; `--export` writes it
197
+ to `.json` or `.csv` (inferred from the extension):
198
+
199
+ ```bash
200
+ # The whole universe, no manual paging
201
+ fastbooks --json markets tickers --all > universe.json
202
+ fastbooks markets tickers --all --export universe.csv
203
+
204
+ # Per asset class (export each)
205
+ fastbooks markets tickers --all --category crypto --export crypto.csv
206
+ fastbooks markets tickers --all --category stocks --export stocks.csv
207
+ fastbooks markets tickers --all --category forex --export forex.csv
208
+ fastbooks markets tickers --all --category index --export indices.csv
209
+
210
+ # Per exchange, or search by symbol/name
211
+ fastbooks --json markets tickers --all --exchange binance > binance.json
212
+ fastbooks markets tickers --search AAPL
213
+
214
+ # Full regional equity universes
215
+ for r in us ca uk eu jp asia au; do
216
+ fastbooks --json markets symbols -r "$r" -n 5000 > "symbols_$r.json"
217
+ done
218
+
219
+ # 5-minute candles + history (served from the server-side OHLCV cache)
220
+ fastbooks --json markets ohlcv binance BTC/USDT -t 5m -n 1000
221
+ ```
222
+
223
+ **Server-side OHLCV cache.** Candle responses are cached in the routing API
224
+ per `(exchange, symbol, timeframe, limit)` with a timeframe-derived TTL (e.g.
225
+ 5m ≈ 60s), so repeated chart/bot/agent reads are served from memory and don't
226
+ re-hit upstream providers. A cache hit is marked `"cached": true` in the JSON.
227
+ Tune with `OHLCV_CACHE_MAX` / `OHLCV_CACHE_DISABLED`.
228
+
229
+ > **Roadmap:** durable cross-restart deep-history warehousing (immutable bars in
230
+ > Postgres/object storage with scheduled backfill) — today deep history is the
231
+ > file-based `history_cache/` populated by `gather_history.py`, and the in-memory
232
+ > cache above accelerates live reads.
233
+
234
+ ---
235
+
236
+ ## JSON mode (agents)
237
+
238
+ ```bash
239
+ fastbooks --json execute balance binance
240
+ # {"balances": [{"asset": "BTC", "free": "0.5", "total": "0.5"}, ...]}
241
+ ```
242
+
243
+ Every command emits either a result object or `{"error": "...", "details": ...}`
244
+ on failure, with a non-zero exit code. See [SKILL.md](SKILL.md) for schemas.
245
+
246
+ ---
247
+
248
+ ## Tests
249
+
250
+ ```bash
251
+ python3 -m pytest -q # offline; no backend needed
252
+ FASTBOOKS_E2E=1 python3 -m pytest -q # live smoke against running services
253
+ ```
254
+
255
+ See [tests/README.md](tests/README.md). The capability suite asserts the CLI
256
+ hits the correct backend endpoints (method + path + auth) for the four flows.
257
+
258
+ ---
259
+
260
+ ## Publishing to PyPI
261
+
262
+ The package builds from `pyproject.toml` (PEP 621, setuptools backend) — no
263
+ Poetry needed. One-time tooling:
264
+
265
+ ```bash
266
+ pip install --upgrade build twine
267
+ ```
268
+
269
+ Release steps (run from `cli/`):
270
+
271
+ ```bash
272
+ # 1. Bump the version in pyproject.toml (e.g. 0.2.0 -> 0.2.1)
273
+ # 2. Build sdist + wheel into dist/
274
+ python3 -m build
275
+
276
+ # 3. Sanity-check the metadata
277
+ twine check dist/*
278
+
279
+ # 4. Upload to TestPyPI first (recommended), then verify the install
280
+ twine upload --repository testpypi dist/*
281
+ pipx install --index-url https://test.pypi.org/simple/ fastbooks-cli
282
+
283
+ # 5. Upload to real PyPI
284
+ twine upload dist/*
285
+ ```
286
+
287
+ Auth uses an API token (create at https://pypi.org/manage/account/token/). Put it in
288
+ `~/.pypirc` or pass it as the password with username `__token__`:
289
+
290
+ ```ini
291
+ # ~/.pypirc
292
+ [pypi]
293
+ username = __token__
294
+ password = pypi-AgEN...your-token...
295
+ [testpypi]
296
+ username = __token__
297
+ password = pypi-AgEN...your-testpypi-token...
298
+ ```
299
+
300
+ Notes:
301
+ - The project name `fastbooks-cli` must be free on PyPI (check
302
+ https://pypi.org/project/fastbooks-cli/); the `fastbooks` command name is unaffected by that.
303
+ - `MANIFEST.in` ships `README.md`, `SKILL.md`, `EXCHANGES.md`, `LICENSE`, and `examples/`
304
+ in the sdist. Only the `fastbooks_cli` package is included — **no strategy logic**.
305
+ - Each upload version is immutable; bump the version for every release.
306
+ - For automated releases, use the PyPI **Trusted Publisher** (OIDC) GitHub Action
307
+ instead of a long-lived token.
308
+ - The proprietary `fastbooks-clistrategies` package is built the same way but
309
+ published privately (or installed from a Git URL), never to public PyPI.
@@ -0,0 +1,32 @@
1
+ fastbooks_cli/__init__.py,sha256=fnCiPNlJI3PFKCtQGkw3ZKX18AShyvyMCvAE3W42EYc,79
2
+ fastbooks_cli/__main__.py,sha256=JnhTyQ6zmocnFP2mk2_9TvFKY1ieBu8yieeS7O3qLrI,107
3
+ fastbooks_cli/client.py,sha256=RxnNWgzhIYMGYUOqvkgmYcc7dJAUtexH5H0WZ70ZxmU,50918
4
+ fastbooks_cli/config_store.py,sha256=sc8MLWxWiHfrUgq7YuWxevBZV_MGeuZqUca5gLDS9us,3264
5
+ fastbooks_cli/direct.py,sha256=wXZt5bFQoExh-bx1o3eU2ISDZjzVnpWHhnm523h3O9s,6953
6
+ fastbooks_cli/main.py,sha256=tFpemuYfF1a2W5ujedaAsBW3IHsI5fXABxvjA9vR19Y,3233
7
+ fastbooks_cli/mcp_server.py,sha256=YwmocyNqzv7LjeAKIe10J9WcE2OgDrOhwxo0pzVr77Q,8077
8
+ fastbooks_cli/output.py,sha256=injg5mnfUWYoBVCFDIlmSiK4gwNXBj2OmohEYB_cJYs,3028
9
+ fastbooks_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ fastbooks_cli/commands/apikey.py,sha256=EAa_izz_Wv2WPS5_pbCXGhamYJOKYWvsPseJLb8ujaY,4637
11
+ fastbooks_cli/commands/backtest.py,sha256=IsBRBQDxd-l0px9T9A6ua5NAhN2cd0y8JseoTQWGp_0,20641
12
+ fastbooks_cli/commands/bots.py,sha256=oU3LervRQdj22ulObnkxUsVUfJSXGWfk7ALIxGnoM2U,17031
13
+ fastbooks_cli/commands/config.py,sha256=YhMpf6gB9zBBGSVcwoVZgXq49HSGHuS9BbESQX7yUWo,11257
14
+ fastbooks_cli/commands/dex.py,sha256=ME30uksPTmXc8oqgiPzzc2Fy_YzcMQ9dWut5z6FROC4,18511
15
+ fastbooks_cli/commands/direct.py,sha256=smciQq2FrKbKH_ihWt4I1w-NlP03ihM2030JzaZCBfU,5357
16
+ fastbooks_cli/commands/execution.py,sha256=Oz-RX2rTE7r5GxMPIEIlO2BfMOJGYHqoGMG6vu4yJTs,10991
17
+ fastbooks_cli/commands/init_cmd.py,sha256=ZE5X1P9ufczg78F465KsFYM-SZ8oNeQo_v6-qeN3IW0,6771
18
+ fastbooks_cli/commands/markets.py,sha256=6Mc2f-VeIVRJMOIm4SzqNawbdLT9BqqRzOLdin43TvU,10339
19
+ fastbooks_cli/commands/mcp_cmd.py,sha256=-zqlH5AYo56qz1jVadcBlR6jpXDaE0Xb6yjLY_q4tQU,875
20
+ fastbooks_cli/commands/onchain.py,sha256=iwE8LyEIP1BkwvnthmAYInCHEe07u4WRWM4YXkqWlC8,4271
21
+ fastbooks_cli/commands/polymarket.py,sha256=OBLy9atNgYyS2y7Gm81fT1d99WcktzCk_WfSs-bsLV4,74642
22
+ fastbooks_cli/commands/repl.py,sha256=XYwA_Y28U2g5DnsSN71r1LwK5gM3cju-j20uwMCrMmQ,13711
23
+ fastbooks_cli/commands/strategy.py,sha256=drUAPi_iZ_LbjMNbARzGrNh-DJi9r7iXk7XUseuQ0rg,8212
24
+ fastbooks_cli/commands/swap.py,sha256=vluY9E2iNTy3xo29W-L0c915fDL2KUl9o9x70jbY8UY,13508
25
+ fastbooks_cli/commands/wallet.py,sha256=e_pIPUD3PEiYPUP4Op_w4Gl8I17sCqf3ctm3y4uungU,17045
26
+ fastbooks_cli/strategies/__init__.py,sha256=m0nS7f80Eq9AKy_XdMeD4V0dWAlgvu7EAHP2Rgx8pEk,2651
27
+ trading_cli-0.3.0.dist-info/licenses/LICENSE,sha256=RjKhaoTVOKAg-bZ5i6Ncqz5ALsxKljjAYl2SrbbXXgA,1066
28
+ trading_cli-0.3.0.dist-info/METADATA,sha256=abmHXYa-Up077U5X9P9bWwSPjoH-_S5bIE5NRnoQQvg,13019
29
+ trading_cli-0.3.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
30
+ trading_cli-0.3.0.dist-info/entry_points.txt,sha256=NKXYUcBrpGX0yD4Q__RpIWROfBRqEEstcM6wgu4vnwc,134
31
+ trading_cli-0.3.0.dist-info/top_level.txt,sha256=JIFant7JlVPAv0s0Tp7JlUnJYq6egCcLmxG6aAWKGXM,14
32
+ trading_cli-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ fastbooks = fastbooks_cli.main:main
3
+ fastbooks-mcp = fastbooks_cli.mcp_server:main
4
+ trading = fastbooks_cli.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FastBooks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ fastbooks_cli