nanobook 0.8.0__tar.gz

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 (116) hide show
  1. nanobook-0.8.0/.github/workflows/ci.yml +175 -0
  2. nanobook-0.8.0/.github/workflows/release.yml +129 -0
  3. nanobook-0.8.0/.github/workflows/wheels.yml +113 -0
  4. nanobook-0.8.0/.gitignore +18 -0
  5. nanobook-0.8.0/CHANGELOG.md +295 -0
  6. nanobook-0.8.0/CONTRIBUTING.md +86 -0
  7. nanobook-0.8.0/Cargo.lock +2871 -0
  8. nanobook-0.8.0/Cargo.toml +56 -0
  9. nanobook-0.8.0/DOC.md +858 -0
  10. nanobook-0.8.0/LICENSE +21 -0
  11. nanobook-0.8.0/PKG-INFO +229 -0
  12. nanobook-0.8.0/README.md +206 -0
  13. nanobook-0.8.0/RELEASING.md +52 -0
  14. nanobook-0.8.0/benches/portfolio.rs +194 -0
  15. nanobook-0.8.0/benches/stops.rs +105 -0
  16. nanobook-0.8.0/benches/throughput.rs +343 -0
  17. nanobook-0.8.0/broker/Cargo.toml +34 -0
  18. nanobook-0.8.0/broker/src/binance/auth.rs +34 -0
  19. nanobook-0.8.0/broker/src/binance/client.rs +239 -0
  20. nanobook-0.8.0/broker/src/binance/mod.rs +203 -0
  21. nanobook-0.8.0/broker/src/binance/types.rs +43 -0
  22. nanobook-0.8.0/broker/src/error.rs +26 -0
  23. nanobook-0.8.0/broker/src/ibkr/client.rs +195 -0
  24. nanobook-0.8.0/broker/src/ibkr/mod.rs +91 -0
  25. nanobook-0.8.0/broker/src/ibkr/orders.rs +215 -0
  26. nanobook-0.8.0/broker/src/lib.rs +49 -0
  27. nanobook-0.8.0/broker/src/mock.rs +317 -0
  28. nanobook-0.8.0/broker/src/types.rs +81 -0
  29. nanobook-0.8.0/broker/tests/binance_parsing.rs +236 -0
  30. nanobook-0.8.0/broker/tests/ibkr_types.rs +242 -0
  31. nanobook-0.8.0/clippy.toml +2 -0
  32. nanobook-0.8.0/deny.toml +39 -0
  33. nanobook-0.8.0/examples/basic_usage.rs +61 -0
  34. nanobook-0.8.0/examples/demo_quick.rs +108 -0
  35. nanobook-0.8.0/examples/ioc_execution.rs +78 -0
  36. nanobook-0.8.0/examples/market_making.rs +156 -0
  37. nanobook-0.8.0/examples/multi_symbol_lob.rs +100 -0
  38. nanobook-0.8.0/examples/portfolio_backtest.rs +92 -0
  39. nanobook-0.8.0/nanobook.pyi +217 -0
  40. nanobook-0.8.0/pyproject.toml +35 -0
  41. nanobook-0.8.0/python/Cargo.toml +20 -0
  42. nanobook-0.8.0/python/README.md +206 -0
  43. nanobook-0.8.0/python/nanobook.pyi +217 -0
  44. nanobook-0.8.0/python/src/backtest_bridge.rs +94 -0
  45. nanobook-0.8.0/python/src/broker.rs +392 -0
  46. nanobook-0.8.0/python/src/cv.rs +25 -0
  47. nanobook-0.8.0/python/src/event.rs +43 -0
  48. nanobook-0.8.0/python/src/exchange.rs +417 -0
  49. nanobook-0.8.0/python/src/indicators.rs +102 -0
  50. nanobook-0.8.0/python/src/itch.rs +25 -0
  51. nanobook-0.8.0/python/src/lib.rs +84 -0
  52. nanobook-0.8.0/python/src/metrics.rs +144 -0
  53. nanobook-0.8.0/python/src/multi.rs +122 -0
  54. nanobook-0.8.0/python/src/order.rs +69 -0
  55. nanobook-0.8.0/python/src/portfolio.rs +253 -0
  56. nanobook-0.8.0/python/src/position.rs +50 -0
  57. nanobook-0.8.0/python/src/results.rs +288 -0
  58. nanobook-0.8.0/python/src/risk.rs +183 -0
  59. nanobook-0.8.0/python/src/stats.rs +46 -0
  60. nanobook-0.8.0/python/src/strategy.rs +82 -0
  61. nanobook-0.8.0/python/src/sweep.rs +73 -0
  62. nanobook-0.8.0/python/src/types.rs +48 -0
  63. nanobook-0.8.0/python/tests/profile_sweep.py +44 -0
  64. nanobook-0.8.0/python/tests/property/test_prop_indicators.py +104 -0
  65. nanobook-0.8.0/python/tests/property/test_prop_metrics.py +129 -0
  66. nanobook-0.8.0/python/tests/reference/conftest.py +38 -0
  67. nanobook-0.8.0/python/tests/reference/test_ref_cv.py +64 -0
  68. nanobook-0.8.0/python/tests/reference/test_ref_indicators.py +167 -0
  69. nanobook-0.8.0/python/tests/reference/test_ref_metrics.py +120 -0
  70. nanobook-0.8.0/python/tests/reference/test_ref_stats.py +88 -0
  71. nanobook-0.8.0/python/tests/test_exchange.py +194 -0
  72. nanobook-0.8.0/python/tests/test_itch.py +150 -0
  73. nanobook-0.8.0/python/tests/test_portfolio.py +104 -0
  74. nanobook-0.8.0/python/tests/test_sweep.py +51 -0
  75. nanobook-0.8.0/python/tests/test_v05_edge_cases.py +94 -0
  76. nanobook-0.8.0/python/tests/test_v05_features.py +342 -0
  77. nanobook-0.8.0/risk/Cargo.toml +18 -0
  78. nanobook-0.8.0/risk/src/checks.rs +278 -0
  79. nanobook-0.8.0/risk/src/config.rs +89 -0
  80. nanobook-0.8.0/risk/src/lib.rs +153 -0
  81. nanobook-0.8.0/risk/src/report.rs +57 -0
  82. nanobook-0.8.0/risk/tests/check_order_tests.rs +272 -0
  83. nanobook-0.8.0/src/backtest_bridge.rs +162 -0
  84. nanobook-0.8.0/src/bin/lob.rs +495 -0
  85. nanobook-0.8.0/src/book.rs +570 -0
  86. nanobook-0.8.0/src/cv.rs +150 -0
  87. nanobook-0.8.0/src/error.rs +47 -0
  88. nanobook-0.8.0/src/event.rs +555 -0
  89. nanobook-0.8.0/src/exchange.rs +1297 -0
  90. nanobook-0.8.0/src/indicators.rs +483 -0
  91. nanobook-0.8.0/src/itch.rs +291 -0
  92. nanobook-0.8.0/src/level.rs +354 -0
  93. nanobook-0.8.0/src/lib.rs +197 -0
  94. nanobook-0.8.0/src/matching.rs +477 -0
  95. nanobook-0.8.0/src/multi_exchange.rs +155 -0
  96. nanobook-0.8.0/src/order.rs +284 -0
  97. nanobook-0.8.0/src/persistence.rs +184 -0
  98. nanobook-0.8.0/src/portfolio/cost_model.rs +107 -0
  99. nanobook-0.8.0/src/portfolio/metrics.rs +597 -0
  100. nanobook-0.8.0/src/portfolio/mod.rs +617 -0
  101. nanobook-0.8.0/src/portfolio/position.rs +214 -0
  102. nanobook-0.8.0/src/portfolio/strategy.rs +249 -0
  103. nanobook-0.8.0/src/portfolio/sweep.rs +163 -0
  104. nanobook-0.8.0/src/price_levels.rs +498 -0
  105. nanobook-0.8.0/src/result.rs +152 -0
  106. nanobook-0.8.0/src/side.rs +54 -0
  107. nanobook-0.8.0/src/snapshot.rs +301 -0
  108. nanobook-0.8.0/src/stats.rs +409 -0
  109. nanobook-0.8.0/src/stop.rs +813 -0
  110. nanobook-0.8.0/src/tif.rs +77 -0
  111. nanobook-0.8.0/src/trade.rs +215 -0
  112. nanobook-0.8.0/src/types.rs +250 -0
  113. nanobook-0.8.0/tests/edge_cases.rs +227 -0
  114. nanobook-0.8.0/tests/portfolio_invariants.rs +297 -0
  115. nanobook-0.8.0/tests/proptest_invariants.rs +693 -0
  116. nanobook-0.8.0/tests/safety_tests.rs +161 -0
@@ -0,0 +1,175 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+ branches: [master, main]
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+
12
+ jobs:
13
+ test:
14
+ name: Test (${{ matrix.os }})
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os: [ubuntu-latest, macos-latest, windows-latest]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Install Rust
24
+ uses: dtolnay/rust-toolchain@stable
25
+
26
+ - uses: Swatinem/rust-cache@v2
27
+
28
+ - name: Run tests (all features)
29
+ run: cargo test --all-features
30
+
31
+ - name: Run tests (no default features)
32
+ run: cargo test --no-default-features
33
+
34
+ python-test:
35
+ name: Python (${{ matrix.os }}, ${{ matrix.python }})
36
+ runs-on: ${{ matrix.os }}
37
+ strategy:
38
+ fail-fast: false
39
+ matrix:
40
+ # All Python versions on Linux; latest only on Mac/Windows
41
+ include:
42
+ - { os: ubuntu-latest, python: "3.11" }
43
+ - { os: ubuntu-latest, python: "3.12" }
44
+ - { os: ubuntu-latest, python: "3.13" }
45
+ - { os: ubuntu-latest, python: "3.14" }
46
+ - { os: macos-latest, python: "3.13" }
47
+ - { os: windows-latest, python: "3.13" }
48
+ env:
49
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: ${{ matrix.python }}
56
+
57
+ - uses: dtolnay/rust-toolchain@stable
58
+
59
+ - uses: Swatinem/rust-cache@v2
60
+ with:
61
+ key: python-${{ matrix.python }}
62
+
63
+ - run: pip install pytest hypothesis
64
+
65
+ - name: Build and install Python extension
66
+ run: pip install ./python
67
+
68
+ - name: Run Python tests (property + unit)
69
+ run: pytest python/tests/ -v --ignore=python/tests/reference
70
+
71
+ lint:
72
+ name: Lint
73
+ runs-on: ubuntu-latest
74
+ steps:
75
+ - uses: actions/checkout@v4
76
+
77
+ - name: Install Rust
78
+ uses: dtolnay/rust-toolchain@stable
79
+ with:
80
+ components: clippy, rustfmt
81
+
82
+ - uses: Swatinem/rust-cache@v2
83
+
84
+ - name: Check formatting
85
+ run: cargo fmt --all -- --check
86
+
87
+ - name: Clippy
88
+ run: cargo clippy --all-targets --all-features -- -D warnings
89
+
90
+ security:
91
+ name: Security audit
92
+ runs-on: ubuntu-latest
93
+ steps:
94
+ - uses: actions/checkout@v4
95
+
96
+ - name: Install Rust
97
+ uses: dtolnay/rust-toolchain@stable
98
+
99
+ - uses: Swatinem/rust-cache@v2
100
+
101
+ - name: Install cargo-deny
102
+ run: cargo install cargo-deny --locked
103
+
104
+ - name: Run cargo-deny
105
+ run: cargo deny check
106
+
107
+ - name: Install cargo-audit
108
+ run: cargo install cargo-audit --locked
109
+
110
+ - name: Run cargo-audit
111
+ run: cargo audit
112
+
113
+ miri:
114
+ name: Miri (undefined behavior)
115
+ runs-on: ubuntu-latest
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+
119
+ - name: Install Rust nightly + Miri
120
+ uses: dtolnay/rust-toolchain@nightly
121
+ with:
122
+ components: miri
123
+
124
+ - uses: Swatinem/rust-cache@v2
125
+ with:
126
+ key: miri
127
+
128
+ - name: Run Miri
129
+ run: cargo +nightly miri test --lib --no-default-features
130
+ env:
131
+ MIRIFLAGS: "-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check"
132
+
133
+ - name: Run Miri (portfolio)
134
+ run: cargo +nightly miri test --lib --features portfolio
135
+ env:
136
+ MIRIFLAGS: "-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check"
137
+
138
+ coverage:
139
+ name: Code coverage
140
+ runs-on: ubuntu-latest
141
+ steps:
142
+ - uses: actions/checkout@v4
143
+
144
+ - name: Install Rust
145
+ uses: dtolnay/rust-toolchain@stable
146
+
147
+ - uses: Swatinem/rust-cache@v2
148
+ with:
149
+ key: coverage
150
+
151
+ - name: Install cargo-llvm-cov
152
+ run: cargo install cargo-llvm-cov --locked
153
+
154
+ - name: Generate coverage
155
+ run: cargo llvm-cov --all-features --lcov --output-path lcov.info
156
+
157
+ - name: Upload to Codecov
158
+ uses: codecov/codecov-action@v5
159
+ with:
160
+ files: lcov.info
161
+ fail_ci_if_error: false
162
+
163
+ bench:
164
+ name: Benchmark
165
+ runs-on: ubuntu-latest
166
+ steps:
167
+ - uses: actions/checkout@v4
168
+
169
+ - name: Install Rust
170
+ uses: dtolnay/rust-toolchain@stable
171
+
172
+ - uses: Swatinem/rust-cache@v2
173
+
174
+ - name: Run benchmarks
175
+ run: cargo bench --all-features
@@ -0,0 +1,129 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ env:
9
+ CARGO_TERM_COLOR: always
10
+
11
+ jobs:
12
+ build:
13
+ name: Build ${{ matrix.target }}
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ include:
19
+ - target: x86_64-unknown-linux-gnu
20
+ os: ubuntu-latest
21
+ archive: tar.gz
22
+ - target: x86_64-unknown-linux-musl
23
+ os: ubuntu-latest
24
+ archive: tar.gz
25
+ - target: aarch64-unknown-linux-gnu
26
+ os: ubuntu-latest
27
+ archive: tar.gz
28
+ - target: x86_64-apple-darwin
29
+ os: macos-latest
30
+ archive: tar.gz
31
+ - target: aarch64-apple-darwin
32
+ os: macos-latest
33
+ archive: tar.gz
34
+ - target: x86_64-pc-windows-msvc
35
+ os: windows-latest
36
+ archive: zip
37
+
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+
41
+ - name: Install Rust
42
+ uses: dtolnay/rust-toolchain@stable
43
+ with:
44
+ targets: ${{ matrix.target }}
45
+
46
+ - uses: Swatinem/rust-cache@v2
47
+ with:
48
+ key: release-${{ matrix.target }}
49
+
50
+ - name: Install cross-compilation tools
51
+ if: matrix.target == 'aarch64-unknown-linux-gnu'
52
+ run: |
53
+ sudo apt-get update
54
+ sudo apt-get install -y gcc-aarch64-linux-gnu
55
+
56
+ - name: Install musl tools
57
+ if: matrix.target == 'x86_64-unknown-linux-musl'
58
+ run: |
59
+ sudo apt-get update
60
+ sudo apt-get install -y musl-tools
61
+
62
+ - name: Build
63
+ run: cargo build --release --target ${{ matrix.target }} --bin lob
64
+ env:
65
+ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
66
+
67
+ - name: Package (Unix)
68
+ if: matrix.os != 'windows-latest'
69
+ run: |
70
+ cd target/${{ matrix.target }}/release
71
+ tar czf ../../../lob-${{ matrix.target }}.tar.gz lob
72
+ cd ../../..
73
+
74
+ - name: Package (Windows)
75
+ if: matrix.os == 'windows-latest'
76
+ run: |
77
+ cd target/${{ matrix.target }}/release
78
+ 7z a ../../../lob-${{ matrix.target }}.zip lob.exe
79
+ cd ../../..
80
+
81
+ - name: Upload artifact
82
+ uses: actions/upload-artifact@v4
83
+ with:
84
+ name: lob-${{ matrix.target }}
85
+ path: lob-${{ matrix.target }}.${{ matrix.archive }}
86
+
87
+ release:
88
+ name: Create Release
89
+ needs: build
90
+ runs-on: ubuntu-latest
91
+ permissions:
92
+ contents: write
93
+
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+
97
+ - name: Download all artifacts
98
+ uses: actions/download-artifact@v4
99
+ with:
100
+ path: artifacts
101
+
102
+ - name: Extract changelog for this version
103
+ run: |
104
+ VERSION=${GITHUB_REF_NAME#v}
105
+ awk "/^## \[${VERSION}\]/{found=1; next} /^## \[/{if(found) exit} found" CHANGELOG.md > RELEASE_NOTES.md
106
+ if [ ! -s RELEASE_NOTES.md ]; then
107
+ echo "No CHANGELOG entry for ${VERSION}, falling back to auto-generated notes." > RELEASE_NOTES.md
108
+ fi
109
+
110
+ - name: Create Release
111
+ uses: softprops/action-gh-release@v2
112
+ with:
113
+ files: artifacts/**/*
114
+ body_path: RELEASE_NOTES.md
115
+
116
+ publish-crate:
117
+ name: Publish to crates.io
118
+ needs: release
119
+ runs-on: ubuntu-latest
120
+ steps:
121
+ - uses: actions/checkout@v4
122
+
123
+ - name: Install Rust
124
+ uses: dtolnay/rust-toolchain@stable
125
+
126
+ - name: Publish
127
+ run: cargo publish
128
+ env:
129
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
@@ -0,0 +1,113 @@
1
+ name: Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ linux:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ target: [x86_64, aarch64]
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: '3.11'
23
+ - name: Build wheels
24
+ uses: PyO3/maturin-action@v1
25
+ with:
26
+ target: ${{ matrix.target }}
27
+ args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
28
+ sccache: 'true'
29
+ manylinux: auto
30
+ - name: Upload wheels
31
+ uses: actions/upload-artifact@v4
32
+ with:
33
+ name: wheels-linux-${{ matrix.target }}
34
+ path: dist
35
+
36
+ windows:
37
+ runs-on: windows-latest
38
+ strategy:
39
+ matrix:
40
+ target: [x64]
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ - uses: actions/setup-python@v5
44
+ with:
45
+ python-version: '3.11'
46
+ architecture: ${{ matrix.target }}
47
+ - name: Build wheels
48
+ uses: PyO3/maturin-action@v1
49
+ with:
50
+ target: ${{ matrix.target }}
51
+ args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
52
+ sccache: 'true'
53
+ - name: Upload wheels
54
+ uses: actions/upload-artifact@v4
55
+ with:
56
+ name: wheels-windows-${{ matrix.target }}
57
+ path: dist
58
+
59
+ macos:
60
+ runs-on: macos-latest
61
+ strategy:
62
+ matrix:
63
+ target: [universal2-apple-darwin]
64
+ steps:
65
+ - uses: actions/checkout@v4
66
+ - uses: actions/setup-python@v5
67
+ with:
68
+ python-version: '3.11'
69
+ - name: Build wheels
70
+ uses: PyO3/maturin-action@v1
71
+ with:
72
+ target: ${{ matrix.target }}
73
+ args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
74
+ sccache: 'true'
75
+ - name: Upload wheels
76
+ uses: actions/upload-artifact@v4
77
+ with:
78
+ name: wheels-macos-${{ matrix.target }}
79
+ path: dist
80
+
81
+ sdist:
82
+ runs-on: ubuntu-latest
83
+ steps:
84
+ - uses: actions/checkout@v4
85
+ - name: Build sdist
86
+ uses: PyO3/maturin-action@v1
87
+ with:
88
+ command: sdist
89
+ args: --out dist --manifest-path python/Cargo.toml
90
+ - name: Upload sdist
91
+ uses: actions/upload-artifact@v4
92
+ with:
93
+ name: wheels-sdist
94
+ path: dist
95
+
96
+ release:
97
+ name: Release
98
+ runs-on: ubuntu-latest
99
+ if: "startsWith(github.ref, 'refs/tags/')"
100
+ needs: [linux, windows, macos, sdist]
101
+ permissions:
102
+ # This permission is required for trusted publishing.
103
+ id-token: write
104
+ steps:
105
+ - uses: actions/download-artifact@v4
106
+ with:
107
+ pattern: wheels-*
108
+ merge-multiple: true
109
+ path: dist
110
+ - name: Publish to PyPI
111
+ uses: pypa/gh-action-pypi-publish@release/v1
112
+ with:
113
+ packages-dir: dist
@@ -0,0 +1,18 @@
1
+ # Rust
2
+ /target/
3
+ Cargo.lock
4
+
5
+ # IDE
6
+ .idea/
7
+ .vscode/
8
+ *.swp
9
+ *.swo
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.pyc
14
+ *.so
15
+
16
+ # OS
17
+ .DS_Store
18
+ Thumbs.db