backtest360 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. backtest360-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
  2. backtest360-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  3. backtest360-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +17 -0
  4. backtest360-0.1.0/.github/workflows/docs.yml +27 -0
  5. backtest360-0.1.0/.github/workflows/release.yml +64 -0
  6. backtest360-0.1.0/.github/workflows/test.yml +60 -0
  7. backtest360-0.1.0/.gitignore +50 -0
  8. backtest360-0.1.0/CHANGELOG.md +46 -0
  9. backtest360-0.1.0/CODE_OF_CONDUCT.md +59 -0
  10. backtest360-0.1.0/CONTRIBUTING.md +61 -0
  11. backtest360-0.1.0/LICENSE +21 -0
  12. backtest360-0.1.0/PKG-INFO +278 -0
  13. backtest360-0.1.0/README.md +241 -0
  14. backtest360-0.1.0/SECURITY.md +29 -0
  15. backtest360-0.1.0/conftest.py +1 -0
  16. backtest360-0.1.0/docs/concepts/result-anatomy.md +81 -0
  17. backtest360-0.1.0/docs/concepts/signal-vs-execution.md +46 -0
  18. backtest360-0.1.0/docs/concepts/strategy-shape.md +73 -0
  19. backtest360-0.1.0/docs/concepts/versioning.md +15 -0
  20. backtest360-0.1.0/docs/getting-started/api-key.md +18 -0
  21. backtest360-0.1.0/docs/getting-started/first-backtest.md +29 -0
  22. backtest360-0.1.0/docs/getting-started/install.md +19 -0
  23. backtest360-0.1.0/docs/how-to/custom-slippage.md +34 -0
  24. backtest360-0.1.0/docs/how-to/handle-errors.md +43 -0
  25. backtest360-0.1.0/docs/how-to/set-stops.md +43 -0
  26. backtest360-0.1.0/docs/how-to/use-your-own-data.md +31 -0
  27. backtest360-0.1.0/docs/index.md +44 -0
  28. backtest360-0.1.0/docs/reference/client.md +3 -0
  29. backtest360-0.1.0/docs/reference/costs.md +3 -0
  30. backtest360-0.1.0/docs/reference/exceptions.md +3 -0
  31. backtest360-0.1.0/docs/reference/execution.md +3 -0
  32. backtest360-0.1.0/docs/reference/market-hours.md +3 -0
  33. backtest360-0.1.0/docs/reference/result.md +3 -0
  34. backtest360-0.1.0/docs/reference/risk.md +3 -0
  35. backtest360-0.1.0/docs/reference/settings.md +3 -0
  36. backtest360-0.1.0/docs/reference/sizing.md +3 -0
  37. backtest360-0.1.0/docs/reference/strategy.md +3 -0
  38. backtest360-0.1.0/docs/tutorials/compare-strategies.md +42 -0
  39. backtest360-0.1.0/docs/tutorials/mean-reversion.md +37 -0
  40. backtest360-0.1.0/docs/tutorials/with-benchmark.md +48 -0
  41. backtest360-0.1.0/examples/README.md +24 -0
  42. backtest360-0.1.0/examples/compare_strategies.py +44 -0
  43. backtest360-0.1.0/examples/custom_strategy.py +85 -0
  44. backtest360-0.1.0/examples/error_handling.py +53 -0
  45. backtest360-0.1.0/examples/quickstart_yahoo_btc.py +47 -0
  46. backtest360-0.1.0/examples/raw_api.py +83 -0
  47. backtest360-0.1.0/examples/with_benchmark.py +45 -0
  48. backtest360-0.1.0/mkdocs.yml +80 -0
  49. backtest360-0.1.0/pyproject.toml +84 -0
  50. backtest360-0.1.0/src/backtest360/__init__.py +25 -0
  51. backtest360-0.1.0/src/backtest360/client.py +798 -0
  52. backtest360-0.1.0/src/backtest360/py.typed +0 -0
  53. backtest360-0.1.0/src/backtest360/strategy.py +509 -0
  54. backtest360-0.1.0/tests/test_client.py +1694 -0
  55. backtest360-0.1.0/tests/test_integration.py +86 -0
  56. backtest360-0.1.0/tests/test_strategy.py +431 -0
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: Bug report
3
+ about: Report a problem with the SDK
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+ ---
8
+
9
+ **Describe the bug**
10
+ A clear and concise description of what went wrong.
11
+
12
+ **Reproduction**
13
+ A minimal code snippet that triggers the issue:
14
+
15
+ ```python
16
+ from backtest360 import Client, Strategy
17
+ # ...
18
+ ```
19
+
20
+ **Expected behavior**
21
+ What you expected to happen.
22
+
23
+ **Environment**
24
+ - `backtest360` version: <!-- python -c "import backtest360; print(backtest360.__version__)" -->
25
+ - Python version:
26
+ - OS:
27
+
28
+ **Additional context**
29
+ Any error output (a `Backtest360Error` `status`/`code`/`request_id` is especially
30
+ helpful), logs, or context.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an improvement or new capability
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+ ---
8
+
9
+ **What problem are you trying to solve?**
10
+ A clear description of the use case or limitation you've run into.
11
+
12
+ **Proposed solution**
13
+ What you'd like the SDK to do.
14
+
15
+ **Alternatives considered**
16
+ Any workarounds or alternative approaches you've thought about.
17
+
18
+ **Additional context**
19
+ Anything else that would help us understand the request.
@@ -0,0 +1,17 @@
1
+ ## Summary
2
+
3
+ <!-- What does this PR change, and why? -->
4
+
5
+ ## Type of change
6
+
7
+ - [ ] Bug fix
8
+ - [ ] New feature
9
+ - [ ] Documentation
10
+ - [ ] Breaking change
11
+
12
+ ## Checklist
13
+
14
+ - [ ] Tests added or updated, and `pytest -q` passes
15
+ - [ ] `ruff check src tests` passes
16
+ - [ ] Docs updated (docstrings / `docs/` / `README.md`) if public behaviour changed
17
+ - [ ] `CHANGELOG.md` entry added under `Unreleased`
@@ -0,0 +1,27 @@
1
+ name: Deploy docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ deploy:
12
+ name: Build and deploy MkDocs to GitHub Pages
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install docs dependencies
24
+ run: pip install -e ".[docs]"
25
+
26
+ - name: Build and deploy docs
27
+ run: mkdocs gh-deploy --force
@@ -0,0 +1,64 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ contents: write
10
+ id-token: write # required for OIDC trusted publishing
11
+
12
+ jobs:
13
+ test:
14
+ uses: ./.github/workflows/test.yml
15
+
16
+ publish:
17
+ name: publish to PyPI
18
+ needs: test
19
+ runs-on: ubuntu-latest
20
+ environment: pypi
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - uses: actions/setup-python@v5
28
+ with:
29
+ python-version: "3.11"
30
+
31
+ - name: Build
32
+ run: |
33
+ pip install build
34
+ python -m build
35
+
36
+ - name: Check dist
37
+ run: |
38
+ pip install twine
39
+ twine check dist/*
40
+
41
+ - name: Publish to PyPI
42
+ uses: pypa/gh-action-pypi-publish@release/v1
43
+ # OIDC trusted publishing — no token stored
44
+
45
+ release-notes:
46
+ name: GitHub release
47
+ needs: publish
48
+ runs-on: ubuntu-latest
49
+ permissions:
50
+ contents: write
51
+
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+ with:
55
+ fetch-depth: 0
56
+
57
+ - name: Create GitHub release
58
+ uses: softprops/action-gh-release@v2
59
+ with:
60
+ # Release notes are driven by CHANGELOG.md, not auto-generated from
61
+ # PR/commit history (auto-gen may surface internal commit messages).
62
+ generate_release_notes: false
63
+ body: |
64
+ See [CHANGELOG.md](https://github.com/Backtest360/backtest360/blob/main/CHANGELOG.md) for full release notes.
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_call:
8
+
9
+ jobs:
10
+ test:
11
+ name: "py${{ matrix.python-version }}"
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install
26
+ run: pip install -e ".[dev]"
27
+
28
+ - name: Lint (ruff)
29
+ run: ruff check src tests
30
+
31
+ - name: Test
32
+ run: pytest -q
33
+
34
+ - name: Syntax-check examples
35
+ run: python -m compileall examples/
36
+
37
+ integration:
38
+ # Runs only on pull requests (not push-to-main) to avoid consuming API
39
+ # quota on every commit. The BACKTEST360_API_KEY secret must be set in
40
+ # repository Settings → Secrets and variables → Actions. Fork PRs skip
41
+ # the "Integration tests" step automatically because they cannot access
42
+ # repository secrets.
43
+ name: integration
44
+ runs-on: ubuntu-latest
45
+ if: github.event_name == 'pull_request'
46
+ env:
47
+ BACKTEST360_API_KEY: ${{ secrets.BACKTEST360_API_KEY }}
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+
51
+ - uses: actions/setup-python@v5
52
+ with:
53
+ python-version: "3.11"
54
+
55
+ - name: Install
56
+ run: pip install -e ".[dev]"
57
+
58
+ - name: Integration tests
59
+ if: env.BACKTEST360_API_KEY != ''
60
+ run: pytest -q -m integration
@@ -0,0 +1,50 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.so
7
+ *.egg
8
+ *.egg-info/
9
+ dist/
10
+ build/
11
+ .eggs/
12
+ *.whl
13
+
14
+ # Virtual envs
15
+ .venv/
16
+ venv/
17
+ env/
18
+
19
+ # Testing
20
+ .pytest_cache/
21
+ .coverage
22
+ htmlcov/
23
+ coverage.xml
24
+
25
+ # Type checking
26
+ .mypy_cache/
27
+
28
+ # Ruff
29
+ .ruff_cache/
30
+
31
+ # Hatch / build
32
+ .hatch/
33
+
34
+ # Docs
35
+ public/
36
+ site/
37
+
38
+ # IDE
39
+ .vscode/
40
+ .idea/
41
+ *.swp
42
+ *.swo
43
+
44
+ # OS
45
+ .DS_Store
46
+ Thumbs.db
47
+
48
+ # Local agent / assistant config — never commit to this public repo
49
+ CLAUDE.md
50
+ .claude/
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [0.1.0] — 2026-06-07
11
+
12
+ Initial public release.
13
+
14
+ ### Added
15
+
16
+ - `Client` — synchronous HTTP wrapper over the public Backtest360 API.
17
+ Methods: `backtest`, `backtest_signals`, `backtest_raw`, `latest_signal`,
18
+ `validate_strategy`, `list_strategies`, `list_indicators`, `version`, `health`.
19
+ - `Strategy` — strategy builder with boolean expression strings
20
+ (`long_entry`, `long_exit`, `short_entry`, `short_exit`) and indicator descriptors.
21
+ Pre-built templates: `rsi_threshold_long`, `rsi_mean_reversion`, `ma_crossover`,
22
+ `momentum_6m_long`.
23
+ - `Execution` — execution timing dataclass (`entry`, `exit`, `signal_frequency`,
24
+ `entry_window`, `exit_window`, `entry_fill`, `exit_fill`).
25
+ - `Costs` — transaction costs dataclass (`slippage_bps`, `fee_pct`,
26
+ `vol_scaled_slippage`, `vol_slippage_lookback`).
27
+ - `Risk` — stop-loss and drawdown protection dataclass (`stop`, `value`,
28
+ `atr_period`, `reentry`, `cooldown_bars`, `max_drawdown`).
29
+ - `Sizing` — position sizing dataclass (`weight`, `vol_target`,
30
+ `vol_target_lookback`, `leverage_limit`).
31
+ - `MarketHours` — daily anchor-hour config for sub-daily execution
32
+ (`open_hour`, `close_hour`, `strict_anchors`).
33
+ - `Settings` — engine-level run settings (`risk_free_rate`, `random_seed`,
34
+ `on_bad_data`).
35
+ - `Result` — response wrapper with `stats`, `trades`, `strategy_equity`,
36
+ `benchmark_equity`, `returns`, `signals`, `summary()`, and `raw`.
37
+ - `Backtest360Error` — single exception with `status`, `code`, `body`,
38
+ `request_id`. Machine-readable codes: `SDK_NO_API_KEY`, `SDK_PATH_FORBIDDEN`,
39
+ `SDK_INVALID_SIGNALS`, `SDK_MALFORMED_RESPONSE`.
40
+ - `BACKTEST360_API_KEY` and `BACKTEST360_ENGINE_URL` environment variables.
41
+ - `py.typed` marker — first-class mypy / pyright support.
42
+ - MIT license.
43
+
44
+ <!-- Link references -->
45
+
46
+ [0.1.0]: https://github.com/Backtest360/backtest360/releases/tag/v0.1.0
@@ -0,0 +1,59 @@
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, religion, or sexual identity and
10
+ 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:
18
+
19
+ - Demonstrating empathy and kindness toward other people
20
+ - Being respectful of differing opinions, viewpoints, and experiences
21
+ - Giving and gracefully accepting constructive feedback
22
+ - Accepting responsibility and apologizing to those affected by our mistakes
23
+ - Focusing on what is best for the overall community
24
+
25
+ Examples of unacceptable behavior:
26
+
27
+ - The use of sexualized language or imagery, and sexual attention or advances
28
+ - Trolling, insulting or derogatory comments, and personal or political attacks
29
+ - Public or private harassment
30
+ - Publishing others' private information without their explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Enforcement Responsibilities
35
+
36
+ Community leaders are responsible for clarifying and enforcing our standards and
37
+ will take appropriate and fair corrective action in response to any behavior
38
+ that they deem inappropriate, threatening, offensive, or harmful.
39
+
40
+ ## Scope
41
+
42
+ This Code of Conduct applies within all community spaces, and also applies when
43
+ an individual is officially representing the community in public spaces.
44
+
45
+ ## Enforcement
46
+
47
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
48
+ reported to the community leaders responsible for enforcement at
49
+ **hello@backtest360.com**. All complaints will be reviewed and investigated
50
+ promptly and fairly. Community leaders are obligated to respect the privacy and
51
+ security of the reporter of any incident.
52
+
53
+ ## Attribution
54
+
55
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
56
+ version 2.1, available at
57
+ https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
58
+
59
+ [homepage]: https://www.contributor-covenant.org
@@ -0,0 +1,61 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in improving `backtest360`. This document covers
4
+ the development setup and the conventions the project follows.
5
+
6
+ ## Development setup
7
+
8
+ ```bash
9
+ git clone https://github.com/Backtest360/backtest360.git
10
+ cd backtest360
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ This installs the SDK in editable mode along with the development tools
15
+ (`pytest`, `pytest-cov`, `ruff`).
16
+
17
+ ## Running the checks
18
+
19
+ ```bash
20
+ pytest -q # unit tests
21
+ ruff check src tests # lint
22
+ ```
23
+
24
+ Both must pass before a pull request can be merged. The unit suite is fully
25
+ mocked — it never makes network calls and does not require an API key.
26
+
27
+ Live integration tests are excluded from the default run. To exercise them
28
+ against a real engine, set `BACKTEST360_API_KEY` and select the marker:
29
+
30
+ ```bash
31
+ export BACKTEST360_API_KEY=b360_...
32
+ pytest -q -m integration
33
+ ```
34
+
35
+ ## Pull requests
36
+
37
+ - **One topic per branch.** Keep unrelated changes in separate pull requests.
38
+ - **Add tests** for any new behaviour or bug fix.
39
+ - **Update the docs** (`docs/`, docstrings, `README.md`) when you change public
40
+ behaviour.
41
+ - **Add a `CHANGELOG.md` entry** under the `Unreleased` heading describing the
42
+ change (`Added` / `Changed` / `Fixed` / `Breaking` / `Removed`).
43
+ - Keep the public surface minimal — this SDK talks to the engine over the
44
+ versioned HTTP API only.
45
+
46
+ ## Versioning
47
+
48
+ The project follows [semantic versioning](https://semver.org/): `MAJOR.MINOR.PATCH`.
49
+ Pre-1.0, breaking changes bump the `MINOR` version. Pre-release suffixes are
50
+ `aN` (alpha), `bN` (beta), and `rcN` (release candidate).
51
+
52
+ ## Reporting bugs
53
+
54
+ Open an issue at
55
+ [github.com/Backtest360/backtest360/issues](https://github.com/Backtest360/backtest360/issues)
56
+ with a minimal reproduction. For security issues, see [SECURITY.md](SECURITY.md)
57
+ — please do not file them publicly.
58
+
59
+ ## Questions
60
+
61
+ Reach us at hello@backtest360.com.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Backtest360
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.