Metadata-Version: 2.4
Name: nanobook
Version: 0.17.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Office/Business :: Financial :: Investment
Summary: Rust-backed Python package for target-weight backtests, portfolio metrics, deterministic order-book simulation, and pre-trade risk checks
Keywords: orderbook,trading,matching-engine,backtesting,finance
Author: Ricardo Frantz
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://docs.rs/nanobook
Project-URL: Homepage, https://github.com/BoringQuantSystems/nanobook
Project-URL: Issues, https://github.com/BoringQuantSystems/nanobook/issues
Project-URL: Repository, https://github.com/BoringQuantSystems/nanobook

# nanobook Python bindings

Rust extension plus pure-Python research helpers. Build with `uv sync --group dev` from this directory.

## Monte Carlo scenarios (Rust-backed, parity-safe)

`nanobook.scenarios` provides terminal price distributions for stress testing and
forecasting. When the extension is built with the `scenarios` feature (default in
wheels), `int`/`None` seeds delegate to Rust: NumPy PCG64 draws feed Rust math so
results match the `nanotrade/calc` reference at tight tolerance. A pure-Python
fallback remains for `random.Random` seeds and environments without numpy.

```python
import nanobook

res = nanobook.monte_carlo_stock_valuation(
    "XYZ",
    74.0,
    version="advanced",
    n_paths=200,
    seed=42,
    gp_growth_mean=0.16,
    multiple_mean=22.0,
    macro_shock_mean=-0.03,
)
print(res)  # MonteCarloResult(..., median_price=86.36)
print(res.median_price, res.implied_median_annual_return)

paths = res.to_price_paths(4, method="linear")
# See examples/scenario_backtest.py for feeding paths into backtest_weights.
```

Regenerate frozen parity fixtures:

```bash
cd ../../nanotrade && uv run python ../nanobook/python/scripts/generate_scenarios_parity.py
```

Run scenario tests:

```bash
uv run pytest tests/test_scenarios*.py tests/property/test_prop_scenarios.py tests/reference/test_ref_scenarios.py -q
```
