Skip to content

Commit 30e2682

Browse files
committed
docs(readme): sharpen honest positioning
1 parent 4f68c7f commit 30e2682

1 file changed

Lines changed: 71 additions & 35 deletions

File tree

README.md

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88

99
**Rust execution layer for Python trading strategies.**
1010

11-
nanobook is for traders and researchers who already generate signals or target
12-
weights in Python, but want execution mechanics handled by compiled,
13-
deterministic Rust code: portfolio accounting, transaction costs, stops,
11+
nanobook is a small execution kernel for the part of a trading system that is
12+
easy to underestimate: state. Your Python code can keep doing research,
13+
signals, sizing, and scheduling. nanobook handles the execution mechanics around
14+
that strategy: portfolio accounting, transaction costs, stops, deterministic
1415
limit-order-book simulation, pre-trade risk checks, and optional IBKR
1516
rebalancing.
1617

17-
Keep factor research, sizing, and scheduling in Python. Use nanobook for the
18-
stateful execution layer around it.
18+
Use it when you want to ask: "if my strategy emits these target weights, what
19+
exactly happens to cash, holdings, risk checks, order-book events, and audit
20+
logs?"
1921

2022
## Architecture
2123

@@ -34,16 +36,45 @@ stateful execution layer around it.
3436
└─────────────────────────────────────────────────┘
3537
```
3638

37-
## Use Cases
39+
## What You Can Do
3840

39-
- Backtest target-weight strategies from Python with Rust portfolio accounting.
40-
- Simulate rebalances, transaction costs, fixed/trailing stops, and portfolio metrics.
41-
- Test limit-order-book behavior with deterministic matching and event logs.
41+
- Turn a Python target-weight schedule into holdings, returns, equity curve,
42+
stop events, and portfolio metrics.
43+
- Simulate transaction costs, fixed/trailing stops, and deterministic
44+
limit-order-book execution.
45+
- Test order-book behavior with replayable events instead of ad hoc mocks.
4246
- Run pre-trade risk checks for concentration, leverage, and short exposure.
43-
- Rebalance an IBKR account from a target-weight file with dry-run and audit logs.
47+
- Rebalance an IBKR account from a target-weight file with dry-run, confirmation,
48+
reconciliation, and audit logs.
49+
50+
## Why It Is Worth a Look
51+
52+
- The boundary is sharp: Python decides **what** to trade; Rust accounts for
53+
**what happened**.
54+
- The core is deterministic: same inputs, same order matching, same portfolio
55+
path, same replay.
56+
- The Python package is a native PyO3 extension, so heavy loops run outside the
57+
GIL instead of turning into another slow Python backtester.
58+
- The test suite is aimed at the failure modes trading code usually hides:
59+
edge cases, property tests, reference-parity fixtures, fuzz harnesses, and
60+
mutation-testing notes.
61+
- The scope is intentionally narrow: execution mechanics, not a UI, not a
62+
connector zoo, not a full research stack.
63+
64+
## v0.10 Hardening
65+
66+
- Checked arithmetic for trade notional and VWAP; NaN/overflow-safe broker conversions.
67+
- Fallible risk-engine construction instead of config-time panics.
68+
- `rustls` default TLS backend, zeroize-on-drop for Binance credentials, and scrubbed broker logs.
69+
- Audit logs constrained to the working directory, with `0o600` permissions on Unix.
70+
- cargo-fuzz harnesses for matching and ITCH, plus an 89.76 % mutation-testing
71+
baseline for the matcher.
4472

4573
## What nanobook is NOT
4674

75+
The narrow scope is intentional: nanobook should be easy to audit, embed, and
76+
replace if your system grows beyond it.
77+
4778
- **Not a full trading platform.** For venue breadth, calendars, and
4879
operator UIs, see [NautilusTrader](https://github.com/nautechsystems/nautilus_trader)
4980
or [LEAN](https://github.com/QuantConnect/Lean).
@@ -88,7 +119,7 @@ pip install nanobook
88119

89120
```toml
90121
[dependencies]
91-
nanobook = "0.9.3"
122+
nanobook = "0.10.0"
92123
```
93124

94125
**From source:**
@@ -138,9 +169,9 @@ Your optimizer produces weights. `backtest_weights()` handles rebalancing,
138169
cost modeling, position tracking, and return computation at compiled speed
139170
with the GIL released.
140171

141-
**v0.9 additions:** fixed-parameter EWMA-style GARCH forecasting, portfolio optimizers
142-
(min-variance, max-Sharpe, risk-parity, inverse CVaR, inverse CDaR), and
143-
trailing/fixed stop-loss simulation — all accessible from Python.
172+
Portfolio tools include fixed-parameter EWMA-style GARCH forecasting,
173+
optimizers (min-variance, max-Sharpe, risk-parity, inverse CVaR, inverse
174+
CDaR), and trailing/fixed stop-loss simulation — all accessible from Python.
144175

145176
### Optimizer Example
146177

@@ -256,25 +287,19 @@ Engineering decisions that keep the system simple and fast:
256287

257288
- **Single-threaded** — deterministic by design; same inputs always produce same outputs
258289
- **In-process** — no networking overhead; wrap externally if needed
259-
- **No compliance layer**no self-trade prevention or circuit breakers (out of scope)
290+
- **Execution scope, not compliance**deterministic STP policies are included; regulatory workflows and circuit breakers are out of scope
260291
- **No complex order types** — no iceberg or pegged orders
261292

262293
## Documentation
263294

264-
- Full developer reference is merged below in this README (`## Full Reference (Merged from DOC.md)`).
295+
- Full developer reference is included below in this README (`## Full Reference`).
265296
- **[docs.rs](https://docs.rs/nanobook)** — Rust API docs
266297

267298
## License
268299

269300
MIT
270301

271-
## Full Reference (Merged from DOC.md)
272-
273-
274-
[![CI](https://github.com/ricardofrantz/nanobook/actions/workflows/ci.yml/badge.svg)](https://github.com/ricardofrantz/nanobook/actions/workflows/ci.yml)
275-
[![crates.io](https://img.shields.io/crates/v/nanobook.svg)](https://crates.io/crates/nanobook)
276-
[![docs.rs](https://docs.rs/nanobook/badge.svg)](https://docs.rs/nanobook)
277-
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
302+
## Full Reference
278303

279304
**Developer Reference** — Full API documentation for the nanobook workspace.
280305

@@ -301,7 +326,7 @@ MIT
301326
- [Persistence & Serde](#persistence--serde)
302327
- [CLI Reference](#cli-reference)
303328
- [Performance](#performance)
304-
- [Comparison with Other Rust LOBs](#comparison-with-other-rust-lobs)
329+
- [Where nanobook Fits](#where-nanobook-fits)
305330
- [Design Constraints](#design-constraints)
306331

307332
---
@@ -310,7 +335,7 @@ MIT
310335

311336
```toml
312337
[dependencies]
313-
nanobook = "0.9"
338+
nanobook = "0.10.0"
314339
```
315340

316341
```rust
@@ -546,7 +571,7 @@ Event types: `SubmitLimit`, `SubmitMarket`, `Cancel`, `Modify`.
546571
Disable for max performance:
547572

548573
```toml
549-
nanobook = { version = "0.9", default-features = false }
574+
nanobook = { version = "0.10.0", default-features = false }
550575
```
551576

552577
---
@@ -864,7 +889,7 @@ Notes:
864889
### Single Order Check
865890

866891
```rust
867-
let engine = RiskEngine::new(RiskConfig::default());
892+
let engine = RiskEngine::new(RiskConfig::default()).expect("valid risk config");
868893
let report = engine.check_order(
869894
&Symbol::new("AAPL"),
870895
BrokerSide::Buy,
@@ -1150,14 +1175,25 @@ Single-threaded throughput is roughly equivalent (both compile to LLVM IR). Wher
11501175

11511176
---
11521177

1153-
## Comparison with Other Rust LOBs
1178+
## Where nanobook Fits
1179+
1180+
nanobook is not trying to replace a full trading platform. It is the execution
1181+
kernel you can put under a Python strategy when you want deterministic accounting,
1182+
matching, risk checks, and a cautious path to broker execution.
1183+
1184+
| If you need... | Use... |
1185+
|----------------|--------|
1186+
| Python signal research with vectorized factor tooling | pandas, Polars, scipy, vectorbt, Riskfolio-Lib |
1187+
| A broad venue/connector layer | CCXT, Hummingbot, or a dedicated broker stack |
1188+
| A full platform with calendars, operator workflows, and many venues | NautilusTrader or LEAN |
1189+
| A compact Rust execution layer around target weights | **nanobook** |
1190+
| A standalone order-book crate only | A narrower LOB library may be enough |
11541191

1155-
| Library | Throughput | Order Types | Deterministic | Use Case |
1156-
|---------|------------|-------------|:---:|----------|
1157-
| **nanobook** | **~6M ops/sec** | Limit, Market, Stops, GTC/IOC/FOK | **Yes** | Strategy backtesting |
1158-
| [limitbook](https://lib.rs/crates/limitbook) | 3-5M ops/sec | Limit, Market | No | General purpose |
1159-
| [lobster](https://lib.rs/crates/lobster) | ~300K ops/sec | Limit, Market | No | Simple matching |
1160-
| [OrderBook-rs](https://github.com/joaquinbejar/OrderBook-rs) | 200K ops/sec | Many (iceberg, peg, etc.) | No | Production HFT |
1192+
nanobook's measured LOB hot path is still fast (~155 ns submit/no-match on the
1193+
v0.10 benchmark run), but the reason to use the project is the combination: LOB,
1194+
portfolio accounting, metrics, risk, Python bindings, broker adapters, and a
1195+
rebalancer in one small workspace. Benchmark on your own hardware before making
1196+
latency-sensitive decisions.
11611197

11621198
---
11631199

@@ -1169,7 +1205,7 @@ Engineering decisions that keep the system simple and fast:
11691205
|------------|-----------|
11701206
| **Single-threaded** | Deterministic by design — same inputs always produce same outputs |
11711207
| **In-process** | No networking overhead; wrap externally if needed |
1172-
| **No compliance** | No self-trade prevention or circuit breakers (out of scope) |
1208+
| **Execution scope, not compliance** | STP policies are supported; regulatory workflows and circuit breakers are out of scope |
11731209
| **No complex orders** | No iceberg or pegged orders |
11741210
| **Integer prices** | Fixed-point arithmetic avoids floating-point rounding |
11751211
| **Statistics in Python** | Spearman/IC/t-stat belong in scipy/Polars — proven, mature |

0 commit comments

Comments
 (0)