Skip to main content

tam

Config-driven event backtesting for stocks/indices: YAML in, an interactive HTML dashboard out. Strategies (moving-average, MA crossover, trend rotation, online-learning ML, local-LLM) are all pluggable — examples/backtest.py doesn't import any strategy directly, it builds whatever's listed in the config's strategies: section by name.

Published on PyPI as tam-quant (pip install tam-quant; import tam either way). Running in Google Colab or Jupyter instead of this repo's own CLI? See NOTEBOOK.md. Want to use individual pieces (data fetching, rendering, live updates) outside the config-driven runner, or see every component's API at a glance? See LIB.md.

Setup

Requires uv and Python 3.11 (pinned in .python-version — uv will fetch it automatically if you don't have it).

uv sync --extra dev

This creates .venv/ and installs everything, including dev dependencies (pytest). Run any command below with uv run ... so it uses that environment — no need to activate the venv manually.

If you want to use the FMP data provider instead of the (no-key-needed) yfinance default, copy .env.example to .env and fill in FMP_API_KEY.

Running the examples

Each example is a YAML config passed to the same runner:

uv run python -m examples.backtest examples/moving_average_config.yaml
uv run python -m examples.backtest examples/ma_crossover_config.yaml
uv run python -m examples.backtest examples/trend_rotation_config.yaml

These three work out of the box — no extra setup, no external services. Each run prints a summary table (returns, Sharpe, drawdown, etc. per strategy) with a live progress bar, and writes an interactive HTML dashboard to examples/output/<name>_report.html — open that in a browser to see the equity curves, drawdown, and per-trade markers (toggle with the "Show Trades" button).

examples/llm_trading_config.yaml is different: it drives a strategy that queries a local language model each simulated day, and by default also periodically LoRA fine-tunes it (both via mlx-lm, M-series Mac only). The first run downloads the base model from Hugging Face (needs network once). Because it calls the model every simulated day, this one is much slower than the others — try a short date range first (edit start/end in the config) before running the full period. See the comments in that file for how to point it at Ollama or another server instead, or turn LoRA fine-tuning off.

Want to try your own mix of strategies? Copy one of the configs and edit its strategies: list — see tam/strategy/*.py for what's registered and what params each one takes.

Running the tests

uv run pytest

No network access or external services required — everything is tested against fakes/mocks (fake data providers, a stubbed LLM client, etc.).

Metadata

Release files for tam-quant 0.1.65

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tam-quant 0.1.65
File Size Uploaded
tam_quant-0.1.65.tar.gz 272.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tam-quant 0.1.65
File Interpreter ABI Platform
tam_quant-0.1.65-py3-none-any.whl Python 3 none any Details

Total release size: 500.5 kB

Release files / tam_quant-0.1.65.tar.gz

Download URL tam_quant-0.1.65.tar.gz
Size 272.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3b689f25fcfcc59dec2435a1aca6a48b7afc35f3333d2ffd212f1c412d1f323a
BLAKE2b-256 checksum
How to use checksums
0a4d8829acb587d7308f748d1f46db8f8ba697c118568794c6c972692d9d34c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tam_quant-0.1.65-py3-none-any.whl

Download URL tam_quant-0.1.65-py3-none-any.whl
Size 227.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b29dfdd34407a30e19299ce27bb11a61a1fa7079d6d523808946ecbe9e53aec
BLAKE2b-256 checksum
How to use checksums
9c6d8368aea9b8cae6d137547fe05dcdb70f48c2e64e52485579ab5b64f775ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.75

2 release files

0.1.74

2 release files

0.1.73

2 release files

0.1.72

2 release files

0.1.71

2 release files

0.1.70

2 release files

0.1.69

2 release files

0.1.68

2 release files

0.1.67

2 release files

0.1.66

2 release files

This release

0.1.65 This release

2 release files

0.1.64

2 release files

0.1.63

2 release files

0.1.62

2 release files

0.1.61

2 release files

0.1.60

2 release files

0.1.59

2 release files

0.1.58

2 release files

0.1.57

2 release files

0.1.56

2 release files

0.1.55

2 release files

0.1.54

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.51

2 release files

0.1.50

2 release files

0.1.49

2 release files

0.1.48

2 release files

0.1.47

2 release files

0.1.46

2 release files

0.1.45

2 release files

0.1.44

2 release files

0.1.43

2 release files

0.1.42

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.39

2 release files

0.1.38

2 release files

0.1.37

2 release files

0.1.36

2 release files

0.1.35

2 release files

0.1.34

2 release files

0.1.33

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page