Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (111 loc) · 5.88 KB
/
Copy pathMakefile
File metadata and controls
138 lines (111 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ==========================================================
# Crypto Quant Platform
# ==========================================================
# make setup — install deps, generate secrets, seed data
# make demo — run the end-to-end walkthrough
# make serve — start the API locally
# make test — run the test suite
# ==========================================================
# Python 3.10 specifically — vectorbt 0.26.2 pins numba 0.56.4, which does
# not build on 3.11+. Prefer a real python3.10 over whatever `python3` points
# at, because on a machine with pyenv `python3` is frequently 3.9 and the
# failure it produces is useless: pip reports "no matching distribution for
# scipy==1.14.1" rather than "wrong Python". Override with `make PYTHON=...`.
PYTHON ?= $(shell command -v python3.10 2>/dev/null || command -v python3)
HOST_PORT ?= 5000
VENV ?= venv
BIN = $(VENV)/bin
.DEFAULT_GOAL := help
.PHONY: help setup venv check-python verify-venv deps env seed serve demo report mcp test test-fast lint audit lock fmt clean docker-demo check
help: ## Show this help
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
# ── Setup ────────────────────────────────────────────────
setup: venv deps env seed ## One-command setup: deps, secrets, market data
@echo ""
@echo " Setup complete. Next:"
@echo " make serve # start the API on :5000"
@echo " make demo # run the guided walkthrough"
@echo ""
venv: check-python
@test -d $(VENV) || $(PYTHON) -m venv $(VENV)
check-python: ## Verify the interpreter can actually build this project
@$(PYTHON) -c 'import sys; sys.exit(0 if sys.version_info[:2] == (3, 10) else 1)' 2>/dev/null || { \
echo ""; \
echo " This project needs Python 3.10."; \
echo " Found: $$($(PYTHON) -V 2>&1) at $(PYTHON)"; \
echo ""; \
echo " vectorbt 0.26.2 requires numba 0.56.4, which does not build on"; \
echo " 3.11+. See docs/ROADMAP.md for why this is pinned."; \
echo ""; \
echo " macOS: brew install python@3.10 && make setup"; \
echo " pyenv: pyenv install 3.10 && make PYTHON=\$$(pyenv root)/versions/3.10*/bin/python setup"; \
echo " Linux: sudo apt install python3.10 python3.10-venv && make setup"; \
echo ""; \
echo " Or skip all of it: make docker-demo"; \
echo ""; \
exit 1; \
}
@echo " using $$($(PYTHON) -V 2>&1)"
verify-venv: ## Catch a venv built by the wrong interpreter
@test -d $(VENV) || { echo " no venv yet — run: make setup"; exit 1; }
@$(BIN)/python -c 'import sys; sys.exit(0 if sys.version_info[:2] == (3, 10) else 1)' 2>/dev/null || { \
echo ""; \
echo " The existing venv is $$($(BIN)/python -V 2>&1), not 3.10."; \
echo " It was probably created before python3.10 was installed."; \
echo ""; \
echo " rm -rf $(VENV) && make setup"; \
echo ""; \
exit 1; \
}
deps: venv ## Install runtime + dev dependencies
@$(BIN)/pip install --quiet --upgrade pip
@$(BIN)/pip install --quiet -r requirements.txt -r requirements-dev.txt
@echo " dependencies installed"
env: ## Create .env with freshly generated secrets (never overwrites)
@$(PYTHON) scripts/init_env.py
seed: ## Download market data (falls back to committed fixtures offline)
@$(BIN)/python -m scripts.seed_data || $(BIN)/python -m scripts.seed_data --offline
seed-offline: ## Seed from committed fixtures only — no network
@$(BIN)/python -m scripts.seed_data --offline
# ── Run ──────────────────────────────────────────────────
serve: ## Start the API on :5000
@$(BIN)/python -m core.webapp.app
demo: ## Run the end-to-end walkthrough against a local server
@./scripts/demo.sh
docker-demo: ## Same walkthrough, fully containerised (HOST_PORT=5077 to move it)
@HOST_PORT=$(HOST_PORT) docker compose up --build -d demo
@HOST_PORT=$(HOST_PORT) ./scripts/demo.sh --no-build
report: ## Walk-forward HTML report (STRATEGY=RSI SYMBOL=BTC-USD)
@$(BIN)/python -m scripts.walkforward --strategy $(or $(STRATEGY),RSI) \
--symbol $(or $(SYMBOL),BTC-USD) --param rsi_window=10,14,20,30 --open
mcp: ## Run the MCP server on stdio (for Claude Desktop / Cursor)
@$(BIN)/python -m core.mcp.server
# ── Quality ──────────────────────────────────────────────
test: ## Run the full test suite with coverage
@$(BIN)/pytest tests/ --cov=core --cov-report=term-missing
test-fast: ## Run the test suite without coverage
@$(BIN)/pytest tests/ -q
audit: ## Check dependencies for known vulnerabilities
@$(BIN)/pip install --quiet pip-audit
@$(BIN)/pip-audit -r requirements.lock --no-deps --progress-spinner off
lock: ## Regenerate requirements.lock after editing requirements.txt
@# Generated inside the deployment image, not on your laptop. Resolution
@# is platform-specific: a lock built on macOS picks different wheels
@# than the linux/amd64 image that actually runs, and --require-hashes
@# then fails the build.
@docker run --rm --platform linux/amd64 -v "$(PWD)":/w -w /w \
python:3.10-slim-bookworm bash -c '\
pip install -q uv && \
uv pip compile --generate-hashes --no-header --python-version 3.10 \
-o requirements.lock requirements.txt --quiet'
@echo "requirements.lock regenerated — commit it with the requirements.txt change."
lint: ## Check for errors and unused imports
@$(BIN)/ruff check core/ tests/ scripts/
fmt: ## Auto-fix lint issues and sort imports
@$(BIN)/ruff check --fix core/ tests/ scripts/
check: lint audit test ## Everything CI runs
clean: ## Remove caches and build artefacts
@find . -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true
@rm -rf .pytest_cache .coverage htmlcov .ruff_cache
@echo " cleaned"