Skip to content

Commit 2dd303d

Browse files
committed
Init commit
0 parents  commit 2dd303d

51 files changed

Lines changed: 5150 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
quality:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ['3.11', '3.12', '3.13']
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
cache: pip
30+
31+
- name: Install project and dev tools
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install -e ".[dev]"
35+
36+
- name: Lint with Ruff
37+
run: ruff check .
38+
39+
- name: Run pytest
40+
run: pytest
41+
42+
- name: Execute example notebooks
43+
if: matrix.python-version == '3.13'
44+
env:
45+
MPLBACKEND: Agg
46+
run: |
47+
mkdir -p /tmp/quanteval-notebooks
48+
jupyter nbconvert --to notebook --execute --output-dir /tmp/quanteval-notebooks examples/01_quickstart.ipynb
49+
jupyter nbconvert --to notebook --execute --output-dir /tmp/quanteval-notebooks examples/02_parameter_optimization.ipynb
50+
jupyter nbconvert --to notebook --execute --output-dir /tmp/quanteval-notebooks examples/03_strategy_comparison.ipynb
51+
52+
- name: Build distribution
53+
if: matrix.python-version == '3.13'
54+
run: python -m build
55+
56+
- name: Validate package metadata
57+
if: matrix.python-version == '3.13'
58+
run: twine check dist/*
59+
60+
pre-commit:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: actions/setup-python@v5
65+
with:
66+
python-version: '3.13'
67+
cache: pip
68+
- name: Install pre-commit
69+
run: pip install pre-commit
70+
- name: Run pre-commit hooks
71+
run: pre-commit run --all-files

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.13'
20+
cache: pip
21+
22+
- name: Install build dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
python -m pip install -e ".[dev]"
26+
27+
- name: Build release artifacts
28+
run: python -m build
29+
30+
- name: Validate artifacts
31+
run: twine check dist/*
32+
33+
- name: Create GitHub release
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
generate_release_notes: true
37+
files: |
38+
dist/*

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# artifacts
2+
__pycache__/
3+
*.py[cod]
4+
*.so
5+
.Python
6+
.coverage
7+
.coverage.*
8+
.mypy_cache/
9+
.pytest_cache/
10+
.ruff_cache/
11+
.ipynb_checkpoints/
12+
.venv/
13+
venv/
14+
build/
15+
dist/
16+
site/
17+
htmlcov/
18+
*.egg-info/
19+
pip-wheel-metadata/
20+
data_cache/
21+
.sisyphus/
22+
.vscode/
23+
.idea/
24+
25+
# agents
26+
AGENTS.md
27+
CLAUDE.md

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
repos:
2+
- repo: https://github.com/kynan/nbstripout
3+
rev: 0.9.1
4+
hooks:
5+
- id: nbstripout
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-yaml
13+
- id: check-added-large-files
14+
args: ['--maxkb=500']
15+
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.9.10
18+
hooks:
19+
- id: ruff
20+
args: [--fix]
21+
- id: ruff-format
22+
23+
- repo: https://github.com/nbQA-dev/nbQA
24+
rev: 1.9.1
25+
hooks:
26+
- id: nbqa-ruff
27+
args: [--fix]
28+
files: ^examples/

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5+
6+
## [0.1.0] - 2026-03-14
7+
8+
### Added
9+
- Backtesting engine with delayed signal execution to reduce look-ahead bias
10+
- Built-in strategies: dual moving average cross, Bollinger band mean reversion, buy-and-hold benchmark
11+
- Technical factor library: SMA, EMA, RSI, MACD, Bollinger Bands, ATR, Momentum, VolumeMA, ROC, Stochastic Oscillator
12+
- Grid search and walk-forward parameter optimisation
13+
- Multi-strategy comparison framework with correlation analysis and equal-weight portfolio construction
14+
- Static (matplotlib) and interactive (Plotly) visualisation for equity curves and drawdowns
15+
- AkShare data loader with local Parquet caching for Chinese A-share, ETF, and index data
16+
- GitHub Actions CI: lint, pytest (Python 3.11–3.13), notebook smoke tests, build validation
17+
- GitHub Actions release workflow: tag-triggered artifact build and GitHub Release creation
18+
- Bilingual documentation: English README and Chinese README, contributing guide, and tutorial
19+
- Example Jupyter notebooks: quickstart, parameter optimisation, strategy comparison
20+
21+
### Notes
22+
- Requires Python >= 3.11
23+
24+
[0.1.0]: https://github.com/KarhouTam/quanteval/releases/tag/v0.1.0

CODE_OF_CONDUCT.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and unwelcome sexual attention
31+
or advances
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail
56+
address, posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
karhou.tam@example.com.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series of
86+
actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or permanent
93+
ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No online or
102+
offline interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within the
113+
community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.1, available at
119+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120+
121+
Community Impact Guidelines were inspired by
122+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123+
124+
For answers to common questions about this code of conduct, see the FAQ at
125+
[https://www.contributor-covenant.org/faq][faq]. Translations are available at
126+
[https://www.contributor-covenant.org/translations][translations].
127+
128+
[homepage]: https://www.contributor-covenant.org
129+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130+
[Mozilla CoC]: https://github.com/mozilla/diversity
131+
[faq]: https://www.contributor-covenant.org/faq
132+
[translations]: https://www.contributor-covenant.org/translations

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to QuantEval
2+
3+
Thank you for helping improve QuantEval.
4+
5+
## Development setup
6+
7+
```bash
8+
git clone https://github.com/KarhouTam/quanteval.git
9+
cd quanteval
10+
python -m pip install -e ".[dev]"
11+
```
12+
13+
## Local checks
14+
15+
Please run these before opening a pull request:
16+
17+
```bash
18+
ruff check .
19+
pytest
20+
python -m build
21+
twine check dist/*
22+
```
23+
24+
## Pull request expectations
25+
26+
- keep changes focused
27+
- add or update tests for behavior changes
28+
- update English and Chinese documentation when public behavior changes
29+
- prefer small, reusable Python utilities over notebook-only logic
30+
31+
## Reporting issues
32+
33+
Include the following when possible:
34+
35+
- reproduction steps
36+
- expected behavior
37+
- actual behavior
38+
- Python version and dependency context
39+
- a minimal code sample or notebook cell sequence
40+
41+
## Notebook guidance
42+
43+
- avoid hard-coded local absolute paths
44+
- keep outputs useful but not misleading
45+
- prefer package imports over `sys.path` hacks whenever possible
46+
47+
## License
48+
49+
By contributing, you agree that your contributions will be released under the MIT License.

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2026 Karhou Tam
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)