doribt 0.2.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.
- doribt-0.2.0/.gitattributes +5 -0
- doribt-0.2.0/.github/workflows/ci.yml +76 -0
- doribt-0.2.0/.github/workflows/publish.yml +83 -0
- doribt-0.2.0/.gitignore +23 -0
- doribt-0.2.0/AGENTS.md +20 -0
- doribt-0.2.0/CHANGELOG.md +10 -0
- doribt-0.2.0/CONTRIBUTING.md +18 -0
- doribt-0.2.0/LICENSE +202 -0
- doribt-0.2.0/PKG-INFO +107 -0
- doribt-0.2.0/README.md +86 -0
- doribt-0.2.0/benchmarks/minute/README.md +22 -0
- doribt-0.2.0/benchmarks/minute/run.py +122 -0
- doribt-0.2.0/benchmarks/minute/vectorbt_adapter.py +140 -0
- doribt-0.2.0/benchmarks/minute/worker.py +195 -0
- doribt-0.2.0/docs/api-design.md +41 -0
- doribt-0.2.0/docs/china-market.md +61 -0
- doribt-0.2.0/docs/corporate-actions.md +37 -0
- doribt-0.2.0/docs/data-contract.md +67 -0
- doribt-0.2.0/docs/execution-model.md +54 -0
- doribt-0.2.0/docs/market-validation.md +67 -0
- doribt-0.2.0/docs/minute-execution.md +59 -0
- doribt-0.2.0/docs/minute-performance-2026-10-06.json +138 -0
- doribt-0.2.0/docs/minute-performance-optimized-2026-10-06.json +250 -0
- doribt-0.2.0/docs/minute-performance-optimized.md +53 -0
- doribt-0.2.0/docs/minute-performance.md +41 -0
- doribt-0.2.0/docs/minute-validation.md +40 -0
- doribt-0.2.0/docs/model.md +51 -0
- doribt-0.2.0/docs/performance.md +49 -0
- doribt-0.2.0/docs/pypi-publishing.md +43 -0
- doribt-0.2.0/docs/quality.md +67 -0
- doribt-0.2.0/docs/release-0.1.0.md +45 -0
- doribt-0.2.0/docs/release-preparation.md +72 -0
- doribt-0.2.0/docs/release-progress.md +84 -0
- doribt-0.2.0/docs/research-contract.md +106 -0
- doribt-0.2.0/docs/results.md +115 -0
- doribt-0.2.0/docs/roadmap.md +53 -0
- doribt-0.2.0/docs/scheduled-execution.md +43 -0
- doribt-0.2.0/examples/dividends.py +111 -0
- doribt-0.2.0/examples/historical_rules.py +113 -0
- doribt-0.2.0/examples/market_data.py +73 -0
- doribt-0.2.0/examples/minute.py +82 -0
- doribt-0.2.0/examples/quickstart.py +37 -0
- doribt-0.2.0/examples/research.py +122 -0
- doribt-0.2.0/examples/sma.py +68 -0
- doribt-0.2.0/examples/strategies.py +105 -0
- doribt-0.2.0/pyproject.toml +78 -0
- doribt-0.2.0/scripts/audit.py +46 -0
- doribt-0.2.0/scripts/benchmark.py +197 -0
- doribt-0.2.0/scripts/benchmark_workloads.py +182 -0
- doribt-0.2.0/scripts/check.py +61 -0
- doribt-0.2.0/scripts/check_size.py +31 -0
- doribt-0.2.0/scripts/check_wheel.py +198 -0
- doribt-0.2.0/scripts/etf_reference.py +101 -0
- doribt-0.2.0/scripts/market_case.py +225 -0
- doribt-0.2.0/scripts/minute_case.py +111 -0
- doribt-0.2.0/scripts/minute_reference.py +119 -0
- doribt-0.2.0/src/doribt/__init__.py +69 -0
- doribt-0.2.0/src/doribt/accounting/__init__.py +1 -0
- doribt-0.2.0/src/doribt/accounting/account.py +91 -0
- doribt-0.2.0/src/doribt/accounting/costs.py +32 -0
- doribt-0.2.0/src/doribt/accounting/orders.py +162 -0
- doribt-0.2.0/src/doribt/accounting/rights.py +239 -0
- doribt-0.2.0/src/doribt/accounting/taxes.py +170 -0
- doribt-0.2.0/src/doribt/kernels/__init__.py +1 -0
- doribt-0.2.0/src/doribt/kernels/compiled.py +93 -0
- doribt-0.2.0/src/doribt/kernels/execution.py +193 -0
- doribt-0.2.0/src/doribt/kernels/segments.py +79 -0
- doribt-0.2.0/src/doribt/market/__init__.py +1 -0
- doribt-0.2.0/src/doribt/market/actions.py +77 -0
- doribt-0.2.0/src/doribt/market/adjustments.py +88 -0
- doribt-0.2.0/src/doribt/market/bars.py +133 -0
- doribt-0.2.0/src/doribt/market/china.py +128 -0
- doribt-0.2.0/src/doribt/market/clock.py +56 -0
- doribt-0.2.0/src/doribt/market/data.py +269 -0
- doribt-0.2.0/src/doribt/market/instruments.py +24 -0
- doribt-0.2.0/src/doribt/market/rules.py +102 -0
- doribt-0.2.0/src/doribt/provenance.py +198 -0
- doribt-0.2.0/src/doribt/py.typed +0 -0
- doribt-0.2.0/src/doribt/reporting/__init__.py +1 -0
- doribt-0.2.0/src/doribt/reporting/analysis.py +159 -0
- doribt-0.2.0/src/doribt/reporting/benchmark.py +55 -0
- doribt-0.2.0/src/doribt/reporting/daily.py +94 -0
- doribt-0.2.0/src/doribt/reporting/export.py +224 -0
- doribt-0.2.0/src/doribt/reporting/plotting.py +97 -0
- doribt-0.2.0/src/doribt/reporting/publish.py +28 -0
- doribt-0.2.0/src/doribt/reporting/report.py +131 -0
- doribt-0.2.0/src/doribt/reporting/result.py +194 -0
- doribt-0.2.0/src/doribt/reporting/trades.py +186 -0
- doribt-0.2.0/src/doribt/research/__init__.py +1 -0
- doribt-0.2.0/src/doribt/research/config.py +128 -0
- doribt-0.2.0/src/doribt/research/outputs.py +176 -0
- doribt-0.2.0/src/doribt/research/parameters.py +122 -0
- doribt-0.2.0/src/doribt/runtime/__init__.py +1 -0
- doribt-0.2.0/src/doribt/runtime/bar_runtime.py +118 -0
- doribt-0.2.0/src/doribt/runtime/bar_targets.py +72 -0
- doribt-0.2.0/src/doribt/runtime/broker.py +297 -0
- doribt-0.2.0/src/doribt/runtime/context.py +213 -0
- doribt-0.2.0/src/doribt/runtime/engine.py +353 -0
- doribt-0.2.0/src/doribt/runtime/intents.py +75 -0
- doribt-0.2.0/src/doribt/runtime/matching.py +167 -0
- doribt-0.2.0/src/doribt/runtime/scheduled.py +131 -0
- doribt-0.2.0/src/doribt/runtime/slippage.py +53 -0
- doribt-0.2.0/src/doribt/runtime/targets.py +107 -0
- doribt-0.2.0/src/doribt/serialization.py +44 -0
- doribt-0.2.0/src/doribt/validation.py +50 -0
- doribt-0.2.0/tests/conftest.py +6 -0
- doribt-0.2.0/tests/corporate_fixtures.py +69 -0
- doribt-0.2.0/tests/engine_fixtures.py +51 -0
- doribt-0.2.0/tests/market_fixtures.py +72 -0
- doribt-0.2.0/tests/minute_fixtures.py +74 -0
- doribt-0.2.0/tests/test_analysis.py +117 -0
- doribt-0.2.0/tests/test_benchmark.py +75 -0
- doribt-0.2.0/tests/test_bonus_shares.py +162 -0
- doribt-0.2.0/tests/test_china_rules.py +130 -0
- doribt-0.2.0/tests/test_corporate_reference.py +86 -0
- doribt-0.2.0/tests/test_dividend_tax.py +72 -0
- doribt-0.2.0/tests/test_dividends.py +100 -0
- doribt-0.2.0/tests/test_engine.py +185 -0
- doribt-0.2.0/tests/test_engine_reference.py +98 -0
- doribt-0.2.0/tests/test_example.py +32 -0
- doribt-0.2.0/tests/test_execution_edges.py +109 -0
- doribt-0.2.0/tests/test_export.py +252 -0
- doribt-0.2.0/tests/test_fee_regressions.py +35 -0
- doribt-0.2.0/tests/test_market_case.py +154 -0
- doribt-0.2.0/tests/test_market_data.py +158 -0
- doribt-0.2.0/tests/test_minute_execution.py +223 -0
- doribt-0.2.0/tests/test_minute_lifecycle.py +257 -0
- doribt-0.2.0/tests/test_minute_reference.py +36 -0
- doribt-0.2.0/tests/test_order_quantities.py +93 -0
- doribt-0.2.0/tests/test_price_adjustments.py +183 -0
- doribt-0.2.0/tests/test_provenance.py +116 -0
- doribt-0.2.0/tests/test_published_action.py +30 -0
- doribt-0.2.0/tests/test_quality_gates.py +56 -0
- doribt-0.2.0/tests/test_repeated_runs.py +72 -0
- doribt-0.2.0/tests/test_research_outputs.py +125 -0
- doribt-0.2.0/tests/test_research_parameters.py +124 -0
- doribt-0.2.0/tests/test_research_report.py +163 -0
- doribt-0.2.0/tests/test_rules_actions.py +111 -0
- doribt-0.2.0/tests/test_scheduled.py +179 -0
- doribt-0.2.0/uv.lock +870 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
name: Milestone CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'milestone/**'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
workflow_call:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
env:
|
|
14
|
+
PYTHONUTF8: '1'
|
|
15
|
+
PYTHONIOENCODING: utf-8
|
|
16
|
+
|
|
17
|
+
concurrency:
|
|
18
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
test:
|
|
23
|
+
name: check (${{ matrix.os }}, ${{ matrix.backend }})
|
|
24
|
+
timeout-minutes: 15
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
os: [ubuntu-latest, windows-latest]
|
|
29
|
+
backend: [python, numba]
|
|
30
|
+
runs-on: ${{ matrix.os }}
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
33
|
+
with:
|
|
34
|
+
persist-credentials: false
|
|
35
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: '3.13'
|
|
38
|
+
- run: python -m pip install uv==0.10.11
|
|
39
|
+
- if: matrix.backend == 'python'
|
|
40
|
+
run: uv sync --locked
|
|
41
|
+
- if: matrix.backend == 'numba'
|
|
42
|
+
run: uv sync --locked --extra numba
|
|
43
|
+
- run: uv run --no-sync python scripts/check.py --backend ${{ matrix.backend }}
|
|
44
|
+
|
|
45
|
+
dependencies:
|
|
46
|
+
name: locked dependency audit
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
timeout-minutes: 10
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
51
|
+
with:
|
|
52
|
+
persist-credentials: false
|
|
53
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
|
54
|
+
with:
|
|
55
|
+
python-version: '3.13'
|
|
56
|
+
- run: python -m pip install uv==0.10.11
|
|
57
|
+
- run: uv sync --locked
|
|
58
|
+
- run: uv run --no-sync python scripts/audit.py
|
|
59
|
+
|
|
60
|
+
secrets:
|
|
61
|
+
name: secret scan
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
timeout-minutes: 5
|
|
64
|
+
steps:
|
|
65
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
66
|
+
with:
|
|
67
|
+
persist-credentials: false
|
|
68
|
+
fetch-depth: 0
|
|
69
|
+
- name: Install verified Gitleaks and scan history
|
|
70
|
+
shell: bash
|
|
71
|
+
run: |
|
|
72
|
+
curl --fail --location --retry 3 --output "$RUNNER_TEMP/gitleaks.tar.gz" \
|
|
73
|
+
https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
|
|
74
|
+
echo "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb $RUNNER_TEMP/gitleaks.tar.gz" | sha256sum --check
|
|
75
|
+
tar -xzf "$RUNNER_TEMP/gitleaks.tar.gz" -C "$RUNNER_TEMP" gitleaks
|
|
76
|
+
"$RUNNER_TEMP/gitleaks" git --redact --no-banner .
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
PYTHONUTF8: '1'
|
|
12
|
+
PYTHONIOENCODING: utf-8
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: pypi-${{ github.ref }}
|
|
16
|
+
cancel-in-progress: false
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
quality:
|
|
20
|
+
uses: ./.github/workflows/ci.yml
|
|
21
|
+
|
|
22
|
+
build:
|
|
23
|
+
needs: quality
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
timeout-minutes: 10
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
28
|
+
with:
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
- name: 核对发行来源与版本
|
|
32
|
+
env:
|
|
33
|
+
RELEASE_TAG: ${{ github.ref_name }}
|
|
34
|
+
run: |
|
|
35
|
+
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
|
|
36
|
+
python - <<'PY'
|
|
37
|
+
import os, re, tomllib
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
version = tomllib.loads(Path('pyproject.toml').read_text())['project']['version']
|
|
40
|
+
if not re.fullmatch(r'\d+\.\d+\.\d+', version) or os.environ['RELEASE_TAG'] != 'v' + version:
|
|
41
|
+
raise SystemExit('发行标签与正式版本不一致')
|
|
42
|
+
PY
|
|
43
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
|
|
44
|
+
with:
|
|
45
|
+
python-version: '3.13'
|
|
46
|
+
- run: python -m pip install uv==0.10.11
|
|
47
|
+
- run: uv sync --locked --extra numba
|
|
48
|
+
- name: 构建并验证实际发行包
|
|
49
|
+
run: |
|
|
50
|
+
uv build
|
|
51
|
+
uv run --no-sync python scripts/check_wheel.py dist/*.whl
|
|
52
|
+
uv run --no-sync python scripts/check_wheel.py dist/*.whl --backend numba
|
|
53
|
+
(cd dist && sha256sum *.whl *.tar.gz > SHA256SUMS)
|
|
54
|
+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
55
|
+
with:
|
|
56
|
+
name: release-dist
|
|
57
|
+
path: dist/
|
|
58
|
+
if-no-files-found: error
|
|
59
|
+
|
|
60
|
+
publish:
|
|
61
|
+
needs: build
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
timeout-minutes: 10
|
|
64
|
+
environment:
|
|
65
|
+
name: pypi
|
|
66
|
+
url: https://pypi.org/project/doribt/
|
|
67
|
+
permissions:
|
|
68
|
+
id-token: write
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
|
71
|
+
with:
|
|
72
|
+
name: release-dist
|
|
73
|
+
path: dist/
|
|
74
|
+
- name: 核对构建产物
|
|
75
|
+
run: |
|
|
76
|
+
cd dist
|
|
77
|
+
sha256sum --check SHA256SUMS
|
|
78
|
+
mkdir ../packages
|
|
79
|
+
cp *.whl *.tar.gz ../packages/
|
|
80
|
+
- name: 发布到 PyPI
|
|
81
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
|
|
82
|
+
with:
|
|
83
|
+
packages-dir: packages/
|
doribt-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.nbc
|
|
5
|
+
*.nbi
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.hypothesis/
|
|
10
|
+
.quality/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
.coverage
|
|
15
|
+
coverage.xml
|
|
16
|
+
htmlcov/
|
|
17
|
+
.env
|
|
18
|
+
.env.*
|
|
19
|
+
!.env.example
|
|
20
|
+
data/
|
|
21
|
+
results/
|
|
22
|
+
.DS_Store
|
|
23
|
+
Thumbs.db
|
doribt-0.2.0/AGENTS.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# DoriBT development
|
|
2
|
+
|
|
3
|
+
Read README.md, docs/roadmap.md, docs/api-design.md and docs/quality.md before changes.
|
|
4
|
+
Keep implementation status distinct from release targets. The first release requires
|
|
5
|
+
the complete baseline engine in the roadmap, not only the experimental simulator.
|
|
6
|
+
|
|
7
|
+
- Implement one coherent objective at a time; review public API usage with a runnable example.
|
|
8
|
+
- 图表文案、项目自有日志及新增或修改的代码注释优先使用中文;保留 API 名称、
|
|
9
|
+
标识符和常用指标缩写。不翻译第三方工具输出或改写用户自定义标签。
|
|
10
|
+
- Python files in src, tests, examples and scripts must be at most 400 physical lines.
|
|
11
|
+
- Every function must satisfy Ruff C901 complexity <= 10. Split by responsibility;
|
|
12
|
+
do not hide branches in clever expressions or add blanket exclusions.
|
|
13
|
+
- Before committing, run the local quality entry for affected backends. Run targeted
|
|
14
|
+
checks during iteration and the full local gate on the final change.
|
|
15
|
+
- Commit completed main objectives with a concise Chinese Conventional Commit.
|
|
16
|
+
- Only milestone or release tags trigger CI; ordinary pushes and PR updates do not.
|
|
17
|
+
- Use codex/ branches and PRs. Preserve dedicated repository author identity DorisLab;
|
|
18
|
+
check author, committer and SSH destination before any push.
|
|
19
|
+
- Do not publish private consumer code, credentials or unlicensed datasets.
|
|
20
|
+
- Update docs/release-progress.md with evidence, unresolved requirements and the next objective.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 参与 DoriBT
|
|
2
|
+
|
|
3
|
+
欢迎提交错误报告、带来源的交易规则说明、可复现测试和小范围改进。维护者优先处理实际研究需求,不承诺问题响应或合并时间。
|
|
4
|
+
|
|
5
|
+
提交问题时,请提供 Python/依赖版本、执行后端、最小输入、预期与实际结果。请使用合成数据或确认可公开的数据;不要上传账号、令牌、私人策略和无权再分发的行情。
|
|
6
|
+
|
|
7
|
+
修改前阅读 [README](README.md)、[执行模型](docs/execution-model.md)、[API 设计](docs/api-design.md)和[开发目标](docs/roadmap.md)。行为改动同时更新对应契约与有独立预期的测试;不能只以两个相似实现结果相同证明规则正确。新增规则请附交易所等一手来源及适用日期。
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
uv sync --locked --extra numba
|
|
11
|
+
uv run --no-sync python scripts/check.py --backend numba --audit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
基础安装、定向检查与凭据扫描见[质量检查](docs/quality.md)。不得用跳过失败检查、删除断言、扩大忽略范围或放宽账本容差获取绿灯。依赖漏洞若无法立即修复,应提交有依据和期限的处理提案;当前没有忽略清单。
|
|
15
|
+
|
|
16
|
+
通过分支和 Pull Request 提交变更。提交信息使用 Conventional Commits;说明行为、验证与已知限制。`experimental` 可以演进,但实际变更须写入版本记录。推送前核对仓库本地的作者邮箱、署名和远程;SSH 认证身份不等于提交作者身份。
|
|
17
|
+
|
|
18
|
+
提交的贡献遵循本仓库 Apache-2.0 许可。
|
doribt-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
doribt-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: doribt
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Daily and minute cash-account backtesting for A-share research
|
|
5
|
+
Project-URL: Documentation, https://dorislab.github.io/DoriBT/
|
|
6
|
+
Project-URL: Repository, https://github.com/DorisLab/DoriBT
|
|
7
|
+
Project-URL: Issues, https://github.com/DorisLab/DoriBT/issues
|
|
8
|
+
Author: DoriBT contributors
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
14
|
+
Requires-Python: <3.14,>=3.13
|
|
15
|
+
Requires-Dist: numpy<3,>=2.0
|
|
16
|
+
Provides-Extra: numba
|
|
17
|
+
Requires-Dist: numba<0.69,>=0.61; extra == 'numba'
|
|
18
|
+
Provides-Extra: plot
|
|
19
|
+
Requires-Dist: matplotlib<4,>=3.10; extra == 'plot'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# DoriBT
|
|
23
|
+
|
|
24
|
+
面向 A 股研究的 Python 回测引擎,支持日线与 1/5 分钟现金账户回测。
|
|
25
|
+
|
|
26
|
+
- 多标的共享资金、T+1、历史交易规则和分红送转。
|
|
27
|
+
- 部分成交、可配置佣金与最低佣金、成交量参与率和滑点。
|
|
28
|
+
- 函数策略与预计算目标,参数声明、自定义指标和研究输出。
|
|
29
|
+
- 日频报告、基准与超额收益、图表和可对账的 CSV/JSON 导出。
|
|
30
|
+
- NumPy 基础引擎,可选 Numba 加速和 Matplotlib 绘图。
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
支持 Python 3.13,Windows 和 Linux。
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
python -m pip install doribt
|
|
38
|
+
# 可选加速与图表:
|
|
39
|
+
python -m pip install "doribt[numba,plot]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 第一次回测
|
|
43
|
+
|
|
44
|
+
下例使用人工行情,无需账号或行情服务。收盘提交目标,下一根 bar 开盘尝试成交;价格、日历与状态由调用者提供。
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
"""安装 doribt 后即可运行;仅使用合成行情与公开 API。"""
|
|
48
|
+
|
|
49
|
+
from doribt import Backtest, Context, Costs, Instrument, MarketData, RunConfig, china_rules
|
|
50
|
+
|
|
51
|
+
days = ["2025-01-02", "2025-01-03", "2025-01-06"]
|
|
52
|
+
prices = [10, 10, 11]
|
|
53
|
+
data = MarketData.from_records(
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
"session": day,
|
|
57
|
+
"symbol": "DEMO",
|
|
58
|
+
"status": "trading",
|
|
59
|
+
"open": price,
|
|
60
|
+
"high": price,
|
|
61
|
+
"low": price,
|
|
62
|
+
"close": price,
|
|
63
|
+
"volume": 500_000,
|
|
64
|
+
"upper_limit": 12,
|
|
65
|
+
"lower_limit": 8,
|
|
66
|
+
}
|
|
67
|
+
for day, price in zip(days, prices, strict=True)
|
|
68
|
+
],
|
|
69
|
+
calendar=days,
|
|
70
|
+
instruments=[Instrument(symbol="DEMO", kind="etf")],
|
|
71
|
+
rules=china_rules({"DEMO": "szse_equity_etf"}, start=days[0], end=days[-1]),
|
|
72
|
+
source="人工三日行情,仅用于演示",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def buy_and_hold(ctx: Context) -> None:
|
|
77
|
+
ctx.target_weights({"DEMO": 0.9})
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
config = RunConfig(initial_cash=10_000, costs=Costs(commission=0.0003, minimum_commission=5))
|
|
81
|
+
result = Backtest(data, config=config).run(buy_and_hold)
|
|
82
|
+
print("期末权益:", result.equity[-1]) # 10895 元:剩余现金 995 + 持仓 900 × 11。
|
|
83
|
+
print("总收益率:", result.report().stats["total_return"])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
保存为 `quickstart.py`,运行 `python quickstart.py`,期末权益应为 **10895 元**。
|
|
87
|
+
|
|
88
|
+
## 示例与参考
|
|
89
|
+
|
|
90
|
+
完整示例位于 [examples](https://github.com/DorisLab/DoriBT/tree/main/examples):买入持有、均线、组合轮动、分钟订单、权益处理、参数化研究与报告。
|
|
91
|
+
|
|
92
|
+
[数据输入](https://github.com/DorisLab/DoriBT/blob/main/docs/data-contract.md) · [策略与执行](https://github.com/DorisLab/DoriBT/blob/main/docs/execution-model.md) · [分钟回测](https://github.com/DorisLab/DoriBT/blob/main/docs/minute-execution.md) · [结果与导出](https://github.com/DorisLab/DoriBT/blob/main/docs/results.md)
|
|
93
|
+
|
|
94
|
+
原始价用于成交与账户记账,按决策时点复权的价格用于研究。规则预设覆盖 2020–2025 沪深普通股票与境内股票 ETF;自定义规则须提供适用区间和来源。不提供行情下载或实盘接口,不覆盖盘口排队、融资融券、期货期权与 ETF 申赎。
|
|
95
|
+
|
|
96
|
+
## 参与开发
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
git clone https://github.com/DorisLab/DoriBT.git
|
|
100
|
+
cd DoriBT
|
|
101
|
+
uv sync --locked --extra numba
|
|
102
|
+
uv run --no-sync python scripts/check.py --backend numba --audit
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
开发检查见 [贡献说明](https://github.com/DorisLab/DoriBT/blob/main/CONTRIBUTING.md)与[质量门禁](https://github.com/DorisLab/DoriBT/blob/main/docs/quality.md)。CI 仅在 milestone/release 运行,普通提交和 PR 不触发。欢迎提供最小复现、规则依据及聚焦的改进;维护者按实际需要推进,不承诺支持时限或 API 稳定性。
|
|
106
|
+
|
|
107
|
+
采用 [Apache-2.0](https://github.com/DorisLab/DoriBT/blob/main/LICENSE) 许可证。
|
doribt-0.2.0/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# DoriBT
|
|
2
|
+
|
|
3
|
+
面向 A 股研究的 Python 回测引擎,支持日线与 1/5 分钟现金账户回测。
|
|
4
|
+
|
|
5
|
+
- 多标的共享资金、T+1、历史交易规则和分红送转。
|
|
6
|
+
- 部分成交、可配置佣金与最低佣金、成交量参与率和滑点。
|
|
7
|
+
- 函数策略与预计算目标,参数声明、自定义指标和研究输出。
|
|
8
|
+
- 日频报告、基准与超额收益、图表和可对账的 CSV/JSON 导出。
|
|
9
|
+
- NumPy 基础引擎,可选 Numba 加速和 Matplotlib 绘图。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
支持 Python 3.13,Windows 和 Linux。
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
python -m pip install doribt
|
|
17
|
+
# 可选加速与图表:
|
|
18
|
+
python -m pip install "doribt[numba,plot]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 第一次回测
|
|
22
|
+
|
|
23
|
+
下例使用人工行情,无需账号或行情服务。收盘提交目标,下一根 bar 开盘尝试成交;价格、日历与状态由调用者提供。
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
"""安装 doribt 后即可运行;仅使用合成行情与公开 API。"""
|
|
27
|
+
|
|
28
|
+
from doribt import Backtest, Context, Costs, Instrument, MarketData, RunConfig, china_rules
|
|
29
|
+
|
|
30
|
+
days = ["2025-01-02", "2025-01-03", "2025-01-06"]
|
|
31
|
+
prices = [10, 10, 11]
|
|
32
|
+
data = MarketData.from_records(
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
"session": day,
|
|
36
|
+
"symbol": "DEMO",
|
|
37
|
+
"status": "trading",
|
|
38
|
+
"open": price,
|
|
39
|
+
"high": price,
|
|
40
|
+
"low": price,
|
|
41
|
+
"close": price,
|
|
42
|
+
"volume": 500_000,
|
|
43
|
+
"upper_limit": 12,
|
|
44
|
+
"lower_limit": 8,
|
|
45
|
+
}
|
|
46
|
+
for day, price in zip(days, prices, strict=True)
|
|
47
|
+
],
|
|
48
|
+
calendar=days,
|
|
49
|
+
instruments=[Instrument(symbol="DEMO", kind="etf")],
|
|
50
|
+
rules=china_rules({"DEMO": "szse_equity_etf"}, start=days[0], end=days[-1]),
|
|
51
|
+
source="人工三日行情,仅用于演示",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def buy_and_hold(ctx: Context) -> None:
|
|
56
|
+
ctx.target_weights({"DEMO": 0.9})
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
config = RunConfig(initial_cash=10_000, costs=Costs(commission=0.0003, minimum_commission=5))
|
|
60
|
+
result = Backtest(data, config=config).run(buy_and_hold)
|
|
61
|
+
print("期末权益:", result.equity[-1]) # 10895 元:剩余现金 995 + 持仓 900 × 11。
|
|
62
|
+
print("总收益率:", result.report().stats["total_return"])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
保存为 `quickstart.py`,运行 `python quickstart.py`,期末权益应为 **10895 元**。
|
|
66
|
+
|
|
67
|
+
## 示例与参考
|
|
68
|
+
|
|
69
|
+
完整示例位于 [examples](https://github.com/DorisLab/DoriBT/tree/main/examples):买入持有、均线、组合轮动、分钟订单、权益处理、参数化研究与报告。
|
|
70
|
+
|
|
71
|
+
[数据输入](https://github.com/DorisLab/DoriBT/blob/main/docs/data-contract.md) · [策略与执行](https://github.com/DorisLab/DoriBT/blob/main/docs/execution-model.md) · [分钟回测](https://github.com/DorisLab/DoriBT/blob/main/docs/minute-execution.md) · [结果与导出](https://github.com/DorisLab/DoriBT/blob/main/docs/results.md)
|
|
72
|
+
|
|
73
|
+
原始价用于成交与账户记账,按决策时点复权的价格用于研究。规则预设覆盖 2020–2025 沪深普通股票与境内股票 ETF;自定义规则须提供适用区间和来源。不提供行情下载或实盘接口,不覆盖盘口排队、融资融券、期货期权与 ETF 申赎。
|
|
74
|
+
|
|
75
|
+
## 参与开发
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
git clone https://github.com/DorisLab/DoriBT.git
|
|
79
|
+
cd DoriBT
|
|
80
|
+
uv sync --locked --extra numba
|
|
81
|
+
uv run --no-sync python scripts/check.py --backend numba --audit
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
开发检查见 [贡献说明](https://github.com/DorisLab/DoriBT/blob/main/CONTRIBUTING.md)与[质量门禁](https://github.com/DorisLab/DoriBT/blob/main/docs/quality.md)。CI 仅在 milestone/release 运行,普通提交和 PR 不触发。欢迎提供最小复现、规则依据及聚焦的改进;维护者按实际需要推进,不承诺支持时限或 API 稳定性。
|
|
85
|
+
|
|
86
|
+
采用 [Apache-2.0](https://github.com/DorisLab/DoriBT/blob/main/LICENSE) 许可证。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 分钟执行性能协议
|
|
2
|
+
|
|
3
|
+
这是开发验证工具,不是 DoriBT 运行依赖。vectorbt 适配器只调用 vectorbt 的订单、共享状态和估值 API;不调用 DoriBT 的 broker、金额计算或撮合内核。
|
|
4
|
+
|
|
5
|
+
准备 Python 3.13 的单独环境,安装当前 DoriBT 源码与 vectorbt==0.28.5、NumPy==2.5.3、Numba==0.68.0。环境指向当前源码便于核对内容,不能指向较旧发布 wheel。驱动器使用本仓库 dev 环境的 psutil:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
uv run --no-sync python -m benchmarks.minute.run PRIVATE_SNAPSHOT \
|
|
9
|
+
--python COMPARISON_ENV_PYTHON --output NEW_RESULT_DIRECTORY --batch 10 --repeats 3
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
PRIVATE_SNAPSHOT 含标准 market.csv 和 calendar.csv,字段见 scripts/minute_case.py。必须先通过该脚本与独立 Decimal 对账。工具不读取或下载供应商数据;不可把未授权原始行情提交进仓库。
|
|
13
|
+
|
|
14
|
+
每个参数账户独立:人民币十万元、单只深市境内股票 ETF、T+1、佣金万三且每个 DAY 订单最低五元、零印花税/过户费、固定一个 tick 不利滑点、成交量参与率 0.1%。只模拟连续竞价,收盘竞价行保留估值。每天 09:45 以截至该时点的分钟均线决定持有 10,000 份或空仓;快线 30、40、…,慢线 240,未满窗口不交易。目标变更撤旧子单,未满足目标跨日生成合法数量的新子单。
|
|
15
|
+
|
|
16
|
+
统一核对逐 bar 现金、持仓、权益,以及逐笔时间、数量、价格和佣金。DoriBT 整数账本须与 Decimal 精确相等;vectorbt 的浮点现金/权益允许 0.0001 记账单位(即 1e-8 元)计算误差,成交金额/佣金规范化后逐项一致。不是只比较最终收益。
|
|
17
|
+
|
|
18
|
+
时间区分数据准备、第一次执行(含新缓存 JIT)、预热后重复运行、参数批量。DoriBT 复用同一 Backtest 的已编译行情并串行调用;vectorbt 一次传入 N 列独立资金账户。都包含生成完整现金/持仓/权益曲线与成交表;不包含文件导出、信号计算、Decimal 对账。DoriBT 同时构建订单/意图/来源等更丰富结果,vectorbt 仅保留适配器运行状态和成交表,此额外工作未剥离。
|
|
19
|
+
|
|
20
|
+
当前驱动器依次比较 `python`/`numba` 原逐 bar 回调、`python-scheduled`/`numba-scheduled` 的 PositionTargets 路径,以及 `vectorbt`。目标对象构造与输入验证属于准备阶段,来源记录和返回结果仍计入执行耗时。回调与预计算路径使用完全相同的目标数组,均只在目标变化时重新声明;不能用每 bar 重下目标的回调作为故意放慢的对照。五条路径共用当前版本的行情与来源缓存。
|
|
21
|
+
|
|
22
|
+
每种引擎新起进程并使用独立空 Numba 缓存。RSS 每 5ms 采样进程树,范围包含共同数据载入、依赖导入、预热、保留的参数组输出和账本核对,不能称为撮合内核自身内存。worker_wall 包含全部验证及导入,不能当成单次冷启动;first_run 不含 import 和输入解析。原始 JSON 保存所有样本、输入/适配器哈希、版本及账本摘要。速度排名仅适用于这个有限协议,不代表 vectorbt 原生提供了完整 A 股生命周期。
|