prop-mc 1.0.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.
- prop_mc-1.0.0/.github/workflows/ci.yml +46 -0
- prop_mc-1.0.0/.github/workflows/release.yml +52 -0
- prop_mc-1.0.0/.gitignore +11 -0
- prop_mc-1.0.0/CHANGELOG.md +20 -0
- prop_mc-1.0.0/CITATION.cff +25 -0
- prop_mc-1.0.0/LICENSE +21 -0
- prop_mc-1.0.0/PKG-INFO +129 -0
- prop_mc-1.0.0/README.md +101 -0
- prop_mc-1.0.0/docs/equity_fan.png +0 -0
- prop_mc-1.0.0/docs/paper.md +57 -0
- prop_mc-1.0.0/docs/sizing_frontier.png +0 -0
- prop_mc-1.0.0/examples/make_figures.py +203 -0
- prop_mc-1.0.0/examples/quickstart.py +35 -0
- prop_mc-1.0.0/pyproject.toml +78 -0
- prop_mc-1.0.0/src/prop_mc/__init__.py +25 -0
- prop_mc-1.0.0/src/prop_mc/cli.py +121 -0
- prop_mc-1.0.0/src/prop_mc/py.typed +0 -0
- prop_mc-1.0.0/src/prop_mc/rules.py +122 -0
- prop_mc-1.0.0/src/prop_mc/simulate.py +392 -0
- prop_mc-1.0.0/tests/test_cli.py +72 -0
- prop_mc-1.0.0/tests/test_rules.py +40 -0
- prop_mc-1.0.0/tests/test_simulate.py +155 -0
- prop_mc-1.0.0/uv.lock +1298 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
os: [ubuntu-latest, windows-latest]
|
|
20
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v7
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
27
|
+
with:
|
|
28
|
+
enable-cache: true
|
|
29
|
+
|
|
30
|
+
- name: Install Python
|
|
31
|
+
run: uv python install ${{ matrix.python-version }}
|
|
32
|
+
|
|
33
|
+
- name: Sync environment
|
|
34
|
+
run: uv sync --all-extras --python ${{ matrix.python-version }}
|
|
35
|
+
|
|
36
|
+
- name: Lint
|
|
37
|
+
run: uv run ruff check .
|
|
38
|
+
|
|
39
|
+
- name: Type check
|
|
40
|
+
run: uv run mypy src
|
|
41
|
+
|
|
42
|
+
- name: Test
|
|
43
|
+
run: uv run pytest -q --cov=prop_mc
|
|
44
|
+
|
|
45
|
+
- name: Example
|
|
46
|
+
run: uv run python examples/quickstart.py
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions: {}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v10.4.0
|
|
20
|
+
with:
|
|
21
|
+
enable-cache: true
|
|
22
|
+
|
|
23
|
+
- name: Sync environment
|
|
24
|
+
run: uv sync --all-extras
|
|
25
|
+
|
|
26
|
+
- name: Lint
|
|
27
|
+
run: uv run ruff check .
|
|
28
|
+
|
|
29
|
+
- name: Type check
|
|
30
|
+
run: uv run mypy src
|
|
31
|
+
|
|
32
|
+
- name: Test
|
|
33
|
+
run: uv run pytest -q --cov=prop_mc
|
|
34
|
+
|
|
35
|
+
- name: Build
|
|
36
|
+
run: uv build
|
|
37
|
+
|
|
38
|
+
- name: Check whether the version is already on PyPI
|
|
39
|
+
id: pypi
|
|
40
|
+
run: |
|
|
41
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
42
|
+
if curl -fsS "https://pypi.org/pypi/prop-mc/${VERSION}/json" > /dev/null 2>&1; then
|
|
43
|
+
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
44
|
+
else
|
|
45
|
+
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
- name: Publish to PyPI
|
|
49
|
+
if: steps.pypi.outputs.exists == 'false'
|
|
50
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
51
|
+
with:
|
|
52
|
+
attestations: true
|
prop_mc-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to prop-mc are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
|
|
5
|
+
[SemVer](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-12-03
|
|
8
|
+
|
|
9
|
+
Initial public release.
|
|
10
|
+
|
|
11
|
+
- `PropRules` and `preset_50k_eod()` modeling EOD-trailing and static
|
|
12
|
+
drawdown floors, daily loss limits (flatten or hard breach), consistency
|
|
13
|
+
caps, minimum trading days, evaluation and activation fees, and multi-cycle
|
|
14
|
+
funded payouts.
|
|
15
|
+
- Vectorized `sample_paths` (i.i.d. and circular block bootstrap),
|
|
16
|
+
`simulate_eval`, `optimize_scale`, and `stress_cost_sensitivity`.
|
|
17
|
+
- Markdown, JSON, and dark-theme HTML reports plus `prop-mc run` and
|
|
18
|
+
`prop-mc sweep` CLI subcommands.
|
|
19
|
+
|
|
20
|
+
[1.0.0]: https://github.com/hontie/prop-mc/releases/tag/v1.0.0
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use prop-mc in your research, please cite it."
|
|
3
|
+
type: software
|
|
4
|
+
title: prop-mc
|
|
5
|
+
authors:
|
|
6
|
+
- alias: hontie
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
date-released: "2026-12-03"
|
|
9
|
+
license: MIT
|
|
10
|
+
repository-code: "https://github.com/hontie/prop-mc"
|
|
11
|
+
abstract: >-
|
|
12
|
+
Vectorized Monte Carlo simulator for futures prop-firm evaluation pass
|
|
13
|
+
rates, EOD and static trailing-drawdown ruin, daily loss limits, consistency
|
|
14
|
+
caps, funded payout survival, and net expected value after fees.
|
|
15
|
+
keywords:
|
|
16
|
+
- quantitative-finance
|
|
17
|
+
- prop-trading
|
|
18
|
+
- monte-carlo
|
|
19
|
+
- drawdown
|
|
20
|
+
- risk-management
|
|
21
|
+
- futures
|
|
22
|
+
related-identifiers:
|
|
23
|
+
- type: url
|
|
24
|
+
value: "https://github.com/hontie/prop-mc/blob/main/docs/paper.md"
|
|
25
|
+
description: Accompanying paper
|
prop_mc-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hontie
|
|
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.
|
prop_mc-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: prop-mc
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Monte Carlo evaluation survival, trailing-drawdown ruin, and net-EV simulator for futures prop-firm rules.
|
|
5
|
+
Project-URL: Homepage, https://github.com/hontie/prop-mc
|
|
6
|
+
Project-URL: Repository, https://github.com/hontie/prop-mc
|
|
7
|
+
Project-URL: Issues, https://github.com/hontie/prop-mc/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/hontie/prop-mc/blob/main/CHANGELOG.md
|
|
9
|
+
Author: hontie
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: drawdown,futures,monte-carlo,polars,prop-trading,quantitative-finance,risk-management
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: numpy>=1.26
|
|
26
|
+
Requires-Dist: polars>=1.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# prop-mc
|
|
30
|
+
|
|
31
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
32
|
+
[](https://pypi.org/project/prop-mc/)
|
|
33
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
34
|
+
[](https://pypi.org/project/prop-mc/)
|
|
35
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
36
|
+
[](LICENSE)
|
|
37
|
+
|
|
38
|
+
A positive-Sharpe trading strategy can still have negative expected value inside a futures prop-firm account. An end-of-day trailing drawdown, a daily loss limit, a 50 percent consistency cap, and reset fees turn position sizing into a boundary-crossing problem rather than a Sharpe maximization problem.
|
|
39
|
+
|
|
40
|
+
`prop-mc` simulates thousands of evaluation and funded-payout paths directly from your daily USD PnL series in vectorized NumPy and Polars. It reports pass rate at 30 days, 60 days, and full horizon, drawdown ruin rate, daily-loss-limit hits, consistency-cap delays, median days to pass, joint funded payout probability, and net expected value after fees.
|
|
41
|
+
|
|
42
|
+
The modeling details and sizing math are in [docs/paper.md](docs/paper.md).
|
|
43
|
+
|
|
44
|
+
## Why Sharpe does not pick contract size
|
|
45
|
+
|
|
46
|
+
On a seeded positive-expectancy stream (`mean +$65/day`, `std $320/day`, 5,000 paths with 5-day block bootstrap) inside a standard `$50K` EOD-trailing account (`$3K` target, `$2K` trailing DD, `$1.2K` DLL, `50%` consistency cap, `$150` eval fee):
|
|
47
|
+
|
|
48
|
+
| Scale | Pass rate | Ruin rate | Median days | Joint payout | Net EV |
|
|
49
|
+
| ---: | ---: | ---: | ---: | ---: | ---: |
|
|
50
|
+
| `0.25x` | 13.0% | 1.2% | 213d | 1.7% | `-$98.70` |
|
|
51
|
+
| `0.50x` | 60.8% | 21.1% | 141d | 36.4% | `$1,761.06` |
|
|
52
|
+
| `0.75x` | 62.2% | 36.8% | 84d | 38.1% | `$1,898.76` |
|
|
53
|
+
| `1.00x` | 55.8% | 44.1% | 53d | 30.7% | `$1,371.72` |
|
|
54
|
+
| `1.50x` | 48.6% | 51.4% | 26d | 24.4% | `$967.80` |
|
|
55
|
+
| `2.00x` | 46.5% | 53.5% | 16d | 22.2% | `$848.46` |
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
Doubling size from `1.0x` to `2.0x` cuts median days to pass from 53 to 16 while cutting net EV by 38 percent. Cutting size too far (`0.25x`) eliminates ruin (`1.2%`) but stalls out below the profit target (`-$98.70` net EV).
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
Both figures are regenerated from the same seed by `uv run python examples/make_figures.py`.
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install prop-mc
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For development:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://github.com/hontie/prop-mc.git
|
|
75
|
+
cd prop-mc
|
|
76
|
+
uv sync --all-extras
|
|
77
|
+
uv run pytest -q --cov=prop_mc
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Quickstart
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import numpy as np
|
|
84
|
+
from prop_mc import optimize_scale, preset_50k_eod, simulate_eval
|
|
85
|
+
|
|
86
|
+
rng = np.random.default_rng(7)
|
|
87
|
+
daily_pnl = rng.normal(65.0, 320.0, size=500) # daily USD PnL from your backtest
|
|
88
|
+
|
|
89
|
+
rules = preset_50k_eod() # $50K account, $3K target, $2K EOD trailing DD, $1.2K DLL, 50% cap
|
|
90
|
+
res = simulate_eval(daily_pnl, rules, n_trials=5_000, block_size=5, seed=7)
|
|
91
|
+
print(res.to_markdown())
|
|
92
|
+
|
|
93
|
+
# Find the contract-size multiplier that maximizes net EV after reset fees
|
|
94
|
+
frontier = optimize_scale(daily_pnl, rules, scales=(0.5, 0.75, 1.0, 1.5, 2.0), n_trials=5_000)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Command line
|
|
98
|
+
|
|
99
|
+
Simulate any daily USD PnL `.csv` or `.parquet` export:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
prop-mc run daily_pnl.csv --pnl-col pnl --trials 5000 --block-size 5 --html report.html
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Sweep risk multipliers to see where oversizing breaks net EV:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
prop-mc sweep daily_pnl.csv --pnl-col pnl --scales 0.25,0.5,0.75,1.0,1.25,1.5,2.0
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
All account parameters can be overridden from the command line (`--account`, `--target`, `--max-dd`, `--trailing eod|static`, `--dll`, `--dll-mode flatten|breach`, `--consistency`, `--eval-fee`, `--activation-fee`, `--payout-target`, `--split`, `--max-payouts`).
|
|
112
|
+
|
|
113
|
+
## What it models
|
|
114
|
+
|
|
115
|
+
- **EOD trailing vs. static drawdown:** in `eod` mode, the floor tracks `min(account_size, peak_equity - max_drawdown)`, locking at starting balance once you clear `max_drawdown` in profit.
|
|
116
|
+
- **Daily loss limits:** `flatten` caps any losing session at `-daily_loss_limit` (matching an intraday auto-liquidation lock); `breach` terminates the account on contact.
|
|
117
|
+
- **Consistency caps:** when `max_single_day_win > consistency_cap * total_profit`, passing is delayed until cumulative profit grows enough to bring the best day inside the cap.
|
|
118
|
+
- **Two-stage survival:** passing an evaluation earns zero dollars by itself. Stage 2 simulates up to `max_payouts` sequential funded payout cycles on independent resampled paths, reporting both conditional funded payout probability and joint `P(pass eval AND collect payout)`.
|
|
119
|
+
- **Block bootstrap:** `block_size > 1` resamples contiguous multi-day blocks so volatility clustering and losing streaks survive into the simulation instead of washing out under i.i.d. draws.
|
|
120
|
+
|
|
121
|
+
## Related projects
|
|
122
|
+
|
|
123
|
+
- **[clockbars](https://github.com/hontie/clockbars)**: nine activity and flow bar kinds in Polars, verified identical across batch, live, and chunked execution.
|
|
124
|
+
- **[tradesigns](https://github.com/hontie/tradesigns)**: trade classification rules scored against CME aggressor flags on 34.4 million prints.
|
|
125
|
+
- **[auditbacktest](https://github.com/hontie/backtest-audit)**: ten-check leakage, overfitting, decay, and cost-stress auditor for trading backtests.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT. See [LICENSE](LICENSE).
|
prop_mc-1.0.0/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# prop-mc
|
|
2
|
+
|
|
3
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/prop-mc/)
|
|
5
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
6
|
+
[](https://pypi.org/project/prop-mc/)
|
|
7
|
+
[](https://github.com/hontie/prop-mc/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
A positive-Sharpe trading strategy can still have negative expected value inside a futures prop-firm account. An end-of-day trailing drawdown, a daily loss limit, a 50 percent consistency cap, and reset fees turn position sizing into a boundary-crossing problem rather than a Sharpe maximization problem.
|
|
11
|
+
|
|
12
|
+
`prop-mc` simulates thousands of evaluation and funded-payout paths directly from your daily USD PnL series in vectorized NumPy and Polars. It reports pass rate at 30 days, 60 days, and full horizon, drawdown ruin rate, daily-loss-limit hits, consistency-cap delays, median days to pass, joint funded payout probability, and net expected value after fees.
|
|
13
|
+
|
|
14
|
+
The modeling details and sizing math are in [docs/paper.md](docs/paper.md).
|
|
15
|
+
|
|
16
|
+
## Why Sharpe does not pick contract size
|
|
17
|
+
|
|
18
|
+
On a seeded positive-expectancy stream (`mean +$65/day`, `std $320/day`, 5,000 paths with 5-day block bootstrap) inside a standard `$50K` EOD-trailing account (`$3K` target, `$2K` trailing DD, `$1.2K` DLL, `50%` consistency cap, `$150` eval fee):
|
|
19
|
+
|
|
20
|
+
| Scale | Pass rate | Ruin rate | Median days | Joint payout | Net EV |
|
|
21
|
+
| ---: | ---: | ---: | ---: | ---: | ---: |
|
|
22
|
+
| `0.25x` | 13.0% | 1.2% | 213d | 1.7% | `-$98.70` |
|
|
23
|
+
| `0.50x` | 60.8% | 21.1% | 141d | 36.4% | `$1,761.06` |
|
|
24
|
+
| `0.75x` | 62.2% | 36.8% | 84d | 38.1% | `$1,898.76` |
|
|
25
|
+
| `1.00x` | 55.8% | 44.1% | 53d | 30.7% | `$1,371.72` |
|
|
26
|
+
| `1.50x` | 48.6% | 51.4% | 26d | 24.4% | `$967.80` |
|
|
27
|
+
| `2.00x` | 46.5% | 53.5% | 16d | 22.2% | `$848.46` |
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
Doubling size from `1.0x` to `2.0x` cuts median days to pass from 53 to 16 while cutting net EV by 38 percent. Cutting size too far (`0.25x`) eliminates ruin (`1.2%`) but stalls out below the profit target (`-$98.70` net EV).
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
Both figures are regenerated from the same seed by `uv run python examples/make_figures.py`.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install prop-mc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For development:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/hontie/prop-mc.git
|
|
47
|
+
cd prop-mc
|
|
48
|
+
uv sync --all-extras
|
|
49
|
+
uv run pytest -q --cov=prop_mc
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quickstart
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import numpy as np
|
|
56
|
+
from prop_mc import optimize_scale, preset_50k_eod, simulate_eval
|
|
57
|
+
|
|
58
|
+
rng = np.random.default_rng(7)
|
|
59
|
+
daily_pnl = rng.normal(65.0, 320.0, size=500) # daily USD PnL from your backtest
|
|
60
|
+
|
|
61
|
+
rules = preset_50k_eod() # $50K account, $3K target, $2K EOD trailing DD, $1.2K DLL, 50% cap
|
|
62
|
+
res = simulate_eval(daily_pnl, rules, n_trials=5_000, block_size=5, seed=7)
|
|
63
|
+
print(res.to_markdown())
|
|
64
|
+
|
|
65
|
+
# Find the contract-size multiplier that maximizes net EV after reset fees
|
|
66
|
+
frontier = optimize_scale(daily_pnl, rules, scales=(0.5, 0.75, 1.0, 1.5, 2.0), n_trials=5_000)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Command line
|
|
70
|
+
|
|
71
|
+
Simulate any daily USD PnL `.csv` or `.parquet` export:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
prop-mc run daily_pnl.csv --pnl-col pnl --trials 5000 --block-size 5 --html report.html
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Sweep risk multipliers to see where oversizing breaks net EV:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
prop-mc sweep daily_pnl.csv --pnl-col pnl --scales 0.25,0.5,0.75,1.0,1.25,1.5,2.0
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
All account parameters can be overridden from the command line (`--account`, `--target`, `--max-dd`, `--trailing eod|static`, `--dll`, `--dll-mode flatten|breach`, `--consistency`, `--eval-fee`, `--activation-fee`, `--payout-target`, `--split`, `--max-payouts`).
|
|
84
|
+
|
|
85
|
+
## What it models
|
|
86
|
+
|
|
87
|
+
- **EOD trailing vs. static drawdown:** in `eod` mode, the floor tracks `min(account_size, peak_equity - max_drawdown)`, locking at starting balance once you clear `max_drawdown` in profit.
|
|
88
|
+
- **Daily loss limits:** `flatten` caps any losing session at `-daily_loss_limit` (matching an intraday auto-liquidation lock); `breach` terminates the account on contact.
|
|
89
|
+
- **Consistency caps:** when `max_single_day_win > consistency_cap * total_profit`, passing is delayed until cumulative profit grows enough to bring the best day inside the cap.
|
|
90
|
+
- **Two-stage survival:** passing an evaluation earns zero dollars by itself. Stage 2 simulates up to `max_payouts` sequential funded payout cycles on independent resampled paths, reporting both conditional funded payout probability and joint `P(pass eval AND collect payout)`.
|
|
91
|
+
- **Block bootstrap:** `block_size > 1` resamples contiguous multi-day blocks so volatility clustering and losing streaks survive into the simulation instead of washing out under i.i.d. draws.
|
|
92
|
+
|
|
93
|
+
## Related projects
|
|
94
|
+
|
|
95
|
+
- **[clockbars](https://github.com/hontie/clockbars)**: nine activity and flow bar kinds in Polars, verified identical across batch, live, and chunked execution.
|
|
96
|
+
- **[tradesigns](https://github.com/hontie/tradesigns)**: trade classification rules scored against CME aggressor flags on 34.4 million prints.
|
|
97
|
+
- **[auditbacktest](https://github.com/hontie/backtest-audit)**: ten-check leakage, overfitting, decay, and cost-stress auditor for trading backtests.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT. See [LICENSE](LICENSE).
|
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Trailing Drawdowns as a Boundary-Crossing Problem
|
|
2
|
+
|
|
3
|
+
**Two-stage survival, consistency drag, and net-EV sizing for futures prop accounts**
|
|
4
|
+
|
|
5
|
+
hontie, Modeus Lab
|
|
6
|
+
December 2026
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Abstract
|
|
11
|
+
|
|
12
|
+
Evaluating a systematic strategy on Sharpe ratio alone misses the binding constraints of funded futures accounts. A trailing drawdown floor, a daily loss limit, a single-day consistency cap, and reset fees turn expected value into a nonlinear function of position scale. `prop-mc` simulates two-stage evaluation and funded payout survival directly from daily USD PnL via i.i.d. or circular block bootstrap in vectorized NumPy, measuring pass probability, ruin rate, consistency delay, joint payout probability, and net expected value across contract scales and cost stress multipliers.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Why Sharpe does not choose contract size
|
|
17
|
+
|
|
18
|
+
In an unconstrained account, doubling contract size doubles both expected return and standard deviation, leaving Sharpe unchanged. Inside a prop evaluation with profit target $G$, trailing drawdown limit $D$, and evaluation fee $F$, doubling contract size changes the barrier ratio $G / \sigma$ and $D / \sigma$.
|
|
19
|
+
|
|
20
|
+
When contract size is too small, daily noise barely moves toward $G$, and the account stalls or times out while paying monthly or reset fees. When contract size is too large, two or three routine losing sessions hit $-D$ before drift accumulates, pushing ruin probability sharply higher. Between those two regimes sits a finite net-EV peak that depends on the full distribution of daily PnL (skewness, fat left tails, and multi-day losing streaks), not only its first two moments.
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
## 2. Two-stage accounting
|
|
25
|
+
|
|
26
|
+
Passing an evaluation pays nothing; in many programs it triggers an activation fee $A$. Real cash flows arrive only after surviving Stage 1 (evaluation) and completing one or more Stage 2 funded payout cycles of target $P$ at trader split $s \in (0, 1]$.
|
|
27
|
+
|
|
28
|
+
For $M$ simulated paths with $K_i \in \{0, 1, \dots, K_{\max}\}$ funded payouts earned on path $i$:
|
|
29
|
+
|
|
30
|
+
$$\text{Net EV} = \left(\frac{1}{M}\sum_{i=1}^M K_i\right) P \cdot s - F - \hat{p}_{\text{pass}} \cdot A$$
|
|
31
|
+
|
|
32
|
+
Separating Stage 1 pass rate $\hat{p}_{\text{pass}}$ from conditional funded payout probability $\hat{p}_{\text{funded} \mid \text{pass}}$ prevents a common accounting mistake: strategies that gamble their way past Stage 1 at high variance often blow up before their first funded payout, producing high pass rates alongside negative net EV.
|
|
33
|
+
|
|
34
|
+
## 3. EOD trailing floor, DLL, and consistency drag
|
|
35
|
+
|
|
36
|
+
On day $t$ with realized PnL $x_t$:
|
|
37
|
+
|
|
38
|
+
1. **Daily loss limit ($L$):** if $x_t \le -L$, `dll_mode="flatten"` clamps realized PnL to $-L$; `dll_mode="breach"` terminates the path immediately.
|
|
39
|
+
2. **Drawdown check:** equity updates $E_t = E_{t-1} + x_t^{\text{eff}}$; if $E_t \le B_{t-1}$, the account fails.
|
|
40
|
+
3. **EOD trailing floor:** peak equity updates $H_t = \max(H_{t-1}, E_t)$ and the floor advances $B_t = \min(E_0, H_t - D)$, locking at initial balance $E_0$ once $H_t \ge E_0 + D$. In `static` mode, $B_t \equiv E_0 - D$.
|
|
41
|
+
4. **Consistency cap ($c$):** an active path passes on day $t \ge t_{\min}$ only when $E_t - E_0 \ge G$ and $\max_{1 \le j \le t} x_j^{\text{eff}} \le c (E_t - E_0)$. Any path that hits $G$ earlier with an oversized winning day stays exposed to drawdown until total profit reaches $\max_j x_j^{\text{eff}} / c$.
|
|
42
|
+
|
|
43
|
+
## 4. Block bootstrap and cost stress
|
|
44
|
+
|
|
45
|
+
Daily trading PnL is rarely i.i.d.: volatility regimes cluster, and multi-day drawdowns persist across sessions. Setting `block_size=5` resamples contiguous 5-day circular blocks (Politis and Romano, 1994), preserving short-horizon serial correlation and tail clustering.
|
|
46
|
+
|
|
47
|
+
`stress_cost_sensitivity` runs the same seed across `1x`, `1.5x`, and `2x` per-day cost drag so traders can see how sensitive their pass rate and net EV are to realistic live slippage.
|
|
48
|
+
|
|
49
|
+
## 5. Limitations
|
|
50
|
+
|
|
51
|
+
- Daily-bar simulation models end-of-day trailing floors and daily loss limits, not intrabar unrealized peak-to-valley breaches (live intraday-trailing programs are stricter than EOD-trailing ones).
|
|
52
|
+
- Funded payout cycles assume independent daily PnL draws from the historical distribution; regime decay or live execution drift should be audited separately with `auditbacktest`.
|
|
53
|
+
|
|
54
|
+
## References
|
|
55
|
+
|
|
56
|
+
- Politis, D. N., and J. P. Romano. 1994. "The Stationary Bootstrap." *Journal of the American Statistical Association* 89 (428): 1303–1313.
|
|
57
|
+
- Vince, R. 1992. *The Mathematics of Money Management: Risk Analysis Techniques for Traders*. New York: Wiley.
|
|
Binary file
|