Repository navigation
Rebalancer order-safety fixes, deflated Sharpe, ITCH and IBKR fixes, verification docs #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ricardofrantz
wants to merge
67
commits into
main
Choose a base branch
from
feat/execution-records-rebased
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
9c3ca9e
docs: add VERIFICATION.md and a headline box in the README
jac-made[bot] 9ec1d33
docs(changelog): structure the 0.20.0 notes around the verification
jac-made[bot] 37e616f
docs: security policy and a supply-chain section in the README
jac-made[bot] 0f97e1a
ci(release): SHA256SUMS and build-provenance attestation for release …
jac-made[bot] 741c43b
fix(itch): read the Stock Directory symbol from its real offset
jac-made[bot] 6b53377
fix(broker): report an IBKR connection loss during an order
jac-made[bot] d7484f4
fix(stats): deflated_sharpe follows Bailey and Lopez de Prado (2014)
jac-made[bot] 3fa3ef4
style: rustfmt and clippy fixes for the IBKR guard and the DSR tests
jac-made[bot] 3722970
refactor: forbid unsafe code in the four Rust crates
jac-made[bot] eb0ecf9
docs: make six ignored doctests compile and run; document equity_curv…
jac-made[bot] 90904ea
test: pin the exact answers of the book queries and setters
jac-made[bot] 122d450
docs(changelog): security, ITCH, IBKR and deflated Sharpe entries for…
jac-made[bot] f3c3d68
fix(rebalancer): six order-safety bugs, and tests for every mutation gap
jac-made[bot] 83b69fb
docs(changelog): rebalancer fixes and known issues for 0.20.0
jac-made[bot] 9ab3ee8
docs: a five-scene tour of nanobook, run in CI
jac-made[bot] 74e7533
docs(readme): 'See it work' section with the tour's real output and c…
jac-made[bot] 16dbbd0
docs: a 'check every claim yourself' table with the real 0.20.0 outputs
jac-made[bot] 3627568
test(rebalancer): kill or explain every remaining mutation survivor
jac-made[bot] 453f6e7
test(python): run the deflated Sharpe tests in CI
jac-made[bot] 1eff14b
build: ship only sources, tests, examples and user docs in the crate
jac-made[bot] 852645d
docs(changelog): note the new BacktestBridgeOptions field for struct …
jac-made[bot] a7f4125
rebalancer: test order pacing, retry backoff, EPERM message, zero-qua…
jac-made[bot] 44f51b4
ci(release): write SHA256SUMS with the release file names
jac-made[bot] 419a7a0
build: ship the replay fixture that corpus-replay reads
jac-made[bot] 2211be7
docs: say which events advance the timestamp and when Lean CI runs
jac-made[bot] 6c87ae7
test(kill): probe pid 1 with signal 0 before sending SIGTERM
jac-made[bot] e127e52
fix(pid_file): hold an exclusive lock on the PID file
jac-made[bot] d6f9ee7
fix(recovery): match open orders by filled plus remaining shares
jac-made[bot] 7275461
fix(rebalancer): PID lock and log-dir checks behave the same on Windows
jac-made[bot] 223f0b4
fix(pid_file): lock a separate .lock file so --kill can read the PID …
jac-made[bot] 43f6dd2
test(rebalancer): write the log dir as a TOML literal string
jac-made[bot] 9cca4fa
test(risk): pin limit boundaries, short logic and config checks
jac-made[bot] a352d05
test(portfolio): pin rebalance, stop and bridge values exactly
jac-made[bot] 4b3eaea
test(broker): build the binance tests only with the binance feature
jac-made[bot] ccadf8f
test(metrics): pin exact values in portfolio metrics
jac-made[bot] fd99b7d
test(broker): pin Binance, mock and directly reachable IBKR behaviour
jac-made[bot] a5c64f9
fix(broker): IBKR reconcile uses the order's side; Binance websocket …
jac-made[bot] b8bf8d0
refactor(broker): pull pure helpers out of the IBKR client methods
jac-made[bot] 2ab684c
refactor(broker): pull pure helpers out of IBKR order and reconcile code
jac-made[bot] 73de01d
test(broker): pin IBKR account, quote, order-event, cancel and reconc…
jac-made[bot] c1057d5
test(risk): pin worst-weight tie, weight allocation split and Display…
jac-made[bot] 895d13c
test(portfolio): pin sizing guards, median shortcut, lower-tail limit…
jac-made[bot] 2b872ea
test(broker): pin mock open-order rows and websocket flag, buffer, co…
jac-made[bot] 98e17e7
refactor(rebalancer): pull the lock-error classification out of PidFi…
jac-made[bot] 44ca3ab
test(rebalancer): pin PID lock errors, guard-drop warning and reconci…
jac-made[bot] dfdde48
fix(broker): Binance websocket reconnect stops after its attempt limit
jac-made[bot] dce499b
test(stp): an STP-cancelled incoming order's record holds nothing
jac-made[bot] 56f8f78
docs: 0.20.0 mutation-testing results and two known issues
jac-made[bot] dcb23e5
docs(changelog): BacktestBridgeResult also gains three fields
jac-made[bot] 6201236
Merge main into feat/execution-records-rebased
jac-made[bot] 4751a26
fix(broker): MockBroker::cancel_order also removes configured open-or…
jac-made[bot] 2a590f4
fix(broker): clamp the Binance websocket backoff exponent before pow
jac-made[bot] a4de469
fix(rebalancer): write the PID file atomically; stop the holder child…
jac-made[bot] 43fb11e
fix(rebalancer): take the PID guard before the cron completed-window …
jac-made[bot] 05b1de5
fix(rebalancer): name the cause when the logging directory check fails
jac-made[bot] 3643edd
test(rebalancer): escape the logging dir as TOML; reverse the broker …
jac-made[bot] de9dc4e
docs(portfolio): fix the mean return in the Sortino test comment
jac-made[bot] 5f28b16
docs: correct the Timestamp table, the IBKR connection-loss and recov…
jac-made[bot] 9368404
docs: IBKR connection-loss fix is partial; Timestamp is an event counter
jac-made[bot] 62dfc82
fix(broker): reconcile_partial_fill counts only the change since the …
jac-made[bot] 144a4e1
fix(broker): read Binance open orders from GET /api/v3/openOrders
jac-made[bot] ac0f321
fix(rebalancer): recovery matches open orders on symbol and quantity
jac-made[bot] 98407dd
fix(broker): reconcile_partial_fill reads a symbol missing from the p…
jac-made[bot] 7ed72c0
fix(broker): execute_limit_order reads IBKR connection notices from t…
jac-made[bot] a2986ab
docs: BrokerOrderStatus has a symbol
jac-made[bot] 6b38bd5
docs(changelog): broker and rebalancer go to 0.11.0, risk to 0.8.2
jac-made[bot] a90931f
test(rebalancer): a log path through a file is reported as unreadable
jac-made[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Security policy | ||
|
|
||
| ## Reporting a vulnerability | ||
|
|
||
| Please report security problems privately, through GitHub: | ||
| **Security → Report a vulnerability** on this repository | ||
| ([direct link](https://github.com/BoringQuantSystems/nanobook/security/advisories/new)). | ||
| Do not open a public issue for a security problem. | ||
|
|
||
| Include what you found, how to reproduce it, and which version and features you | ||
| used. We aim to acknowledge a report within 7 days and to publish a fix and a | ||
| GitHub security advisory once it is ready, crediting you unless you ask otherwise. | ||
|
|
||
| ## Supported versions | ||
|
|
||
| | Version | Security fixes | | ||
| |---------|----------------| | ||
| | 0.20.x | yes | | ||
| | < 0.20 | no; please upgrade | | ||
|
|
||
| nanobook is pre-1.0; see [SEMVER.md](SEMVER.md) for what that means for upgrades. | ||
|
|
||
| ## Check every claim yourself | ||
|
|
||
| Each row is a claim, the command that checks it from a clone of this repository, and the | ||
| output we got when preparing 0.20.0. | ||
|
|
||
| | Claim | Command | Output for 0.20.0 | | ||
| |---|---|---| | ||
| | No `unsafe` code in the Rust crates | `grep -rn 'unsafe' src broker/src risk/src rebalancer/src` | the five `#![forbid(unsafe_code)]` lines, one comment and one error message that contain the word; no `unsafe` block | | ||
| | One runtime dependency | `cargo tree -p nanobook -e normal --depth 1` | `nanobook` → `rustc-hash` | | ||
| | Dependencies pass the policy | `cargo deny check` | `advisories ok, bans ok, licenses ok, sources ok` | | ||
| | No known vulnerable dependency | `cargo audit` | no findings (348 crates scanned) | | ||
| | The matching laws are proved | `verification/lean/check.sh 0` | 11 laws on `propext`, `Classical.choice`, `Quot.sound` only; `leanchecker accepted Nanobook`; `corpus matches (25 cases)` | | ||
| | The Rust engine matches the model | `verification/lean/differential.sh 1000` | `zero mismatches in 1000 seeds` | | ||
| | The tour's numbers are real | `python python/examples/tour.py` | the output shown in the README | | ||
| | A release binary was built here | `gh attestation verify <file> --repo BoringQuantSystems/nanobook` | `Verification succeeded` (from 0.20.0 on) | | ||
| | The tests catch planted bugs | `cargo mutants` (see VERIFICATION.md for the exact setup) | see "Mutation testing" in VERIFICATION.md | | ||
|
|
||
| ## What we check, and where you can verify it | ||
|
|
||
| Every claim below can be checked in this repository or on a public service. | ||
|
|
||
| **The code** | ||
|
|
||
| - No `unsafe` code in `nanobook`, `nanobook-broker`, `nanobook-risk` or | ||
| `nanobook-rebalancer`: each crate root has `#![forbid(unsafe_code)]`. The Python | ||
| bindings (`nanobook-python`) call into Python through PyO3, which needs `unsafe` | ||
| by nature; that crate has no hand-written `unsafe` blocks. | ||
| - The order-matching rules are proved in Lean 4 on a model of the engine, and CI | ||
| runs the Rust engine against that model on every push | ||
| ([VERIFICATION.md](VERIFICATION.md)). | ||
| - Property tests, regression tests, fuzz targets (`fuzz/`) and mutation testing | ||
| (`fuzz/mutants-baseline.md`). | ||
|
|
||
| **What you install** | ||
|
|
||
| - The `nanobook` crate with default features has one runtime dependency, | ||
| `rustc-hash`. Every other dependency is behind an opt-in feature. | ||
| - The Python package declares no Python runtime dependencies. Its only build script | ||
| sets linker flags for the extension module; nothing is downloaded at install time. | ||
| - The network-facing code (IBKR and Binance adapters) lives in `nanobook-broker`, | ||
| behind the `ibkr` and `binance` features, and is not in the PyPI wheels. | ||
|
|
||
| **Dependencies** | ||
|
|
||
| - `cargo deny` (licences, bans, sources, advisories; `deny.toml`) and `cargo audit` | ||
| run on every change to a manifest or lock file and every Monday | ||
| (`.github/workflows/audit.yml`). | ||
| - Dependabot opens update pull requests for Cargo, pip and GitHub Actions. | ||
| - [Socket](https://socket.dev) scans every pull request for supply-chain risks. | ||
|
|
||
| **Build and release** | ||
|
|
||
| - Every GitHub Action is pinned to a full commit hash, and every workflow runs with | ||
| read-only permissions unless a job needs more. | ||
| - PyPI releases use trusted publishing (no stored token) and carry PEP 740 | ||
| attestations, so you can check that a wheel was built by this repository's | ||
| workflow. | ||
| - GitHub Releases carry a `SHA256SUMS` file and a signed build-provenance attestation | ||
| for every `lob` binary. Check a download with `sha256sum -c SHA256SUMS` and its origin | ||
| with `gh attestation verify <file> --repo BoringQuantSystems/nanobook`. | ||
| - The [OpenSSF Scorecard](https://scorecard.dev/viewer/?uri=github.com/BoringQuantSystems/nanobook) | ||
| rates the repository's security practices weekly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.