-
Notifications
You must be signed in to change notification settings - Fork 5
463 lines (398 loc) · 15.3 KB
/
Copy pathtest.yml
File metadata and controls
463 lines (398 loc) · 15.3 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
name: Auto Test
on:
push:
branches: [main, develop, "feature/**", "claude/**"]
pull_request:
branches: [main, develop]
env:
GIT_LFS_SKIP_SMUDGE: "1"
TALIB_VERSION: "0.6.4"
TALIB_CACHE_VERSION: "1"
PYTHON_VERSION: "3.11"
jobs:
# ---------------------------------------------------------------------------
# Job 1: Lint & import checks (fast, no data needed)
# ---------------------------------------------------------------------------
lint:
name: Lint & Syntax Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install minimal dependencies
run: |
pip install --upgrade pip
pip install pyflakes
- name: Check Python syntax (all project modules)
run: pyflakes alpha/ strategy/ portfolio/ user_data/strategies/ dataset/
# ---------------------------------------------------------------------------
# Job 2: Unit tests
# ---------------------------------------------------------------------------
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions/setup-talib
with:
talib-version: ${{ env.TALIB_VERSION }}
cache-version: ${{ env.TALIB_CACHE_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
restore-keys: pip-${{ env.PYTHON_VERSION }}-
- name: Install dependencies
run: |
pip install --upgrade pip "setuptools<75" wheel
pip install -r requirements.txt
pip install -r requirements-ml.txt
pip install scipy pytest
pip install -e .
- name: Generate synthetic test data
run: portbench generate-data
- name: Run unit tests
run: pytest tests/ -v --tb=short
# ---------------------------------------------------------------------------
# Job 3: Strategy import validation
# ---------------------------------------------------------------------------
strategy-import:
name: Strategy Import Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions/setup-talib
with:
talib-version: ${{ env.TALIB_VERSION }}
cache-version: ${{ env.TALIB_CACHE_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
restore-keys: pip-${{ env.PYTHON_VERSION }}-
- name: Install Python dependencies
run: |
pip install --upgrade pip "setuptools<75" wheel
pip install -r requirements.txt
pip install -r requirements-ml.txt
pip install scipy
pip install -e .
- name: Validate all strategy imports
run: |
python -c "
import sys
errors = []
# Alpha modules
try:
from alpha.interface import IAlpha
print('OK: alpha.interface.IAlpha')
except Exception as e:
errors.append(f'alpha.interface: {e}')
try:
from alpha.SimpleEmaFactors import EmaAlpha
print('OK: alpha.SimpleEmaFactors.EmaAlpha')
except Exception as e:
errors.append(f'alpha.SimpleEmaFactors: {e}')
# Trading strategies
try:
from strategy.EmaCrossStrategy import EmaCrossStrategy
print('OK: strategy.EmaCrossStrategy')
except Exception as e:
errors.append(f'strategy.EmaCrossStrategy: {e}')
try:
from strategy.MacdAdxStrategy import MacdAdxStrategy
print('OK: strategy.MacdAdxStrategy')
except Exception as e:
errors.append(f'strategy.MacdAdxStrategy: {e}')
# Portfolio strategies
try:
from user_data.strategies.ONS import ONS_Portfolio
print('OK: user_data.strategies.ONS.ONS_Portfolio')
except Exception as e:
errors.append(f'user_data.strategies.ONS: {e}')
try:
from user_data.strategies.inv_vol import InverseVolatilityPortfolio
print('OK: user_data.strategies.inv_vol.InverseVolatilityPortfolio')
except Exception as e:
errors.append(f'user_data.strategies.inv_vol: {e}')
try:
from user_data.strategies.min_var import MinimumVariancePortfolio
print('OK: user_data.strategies.min_var.MinimumVariancePortfolio')
except Exception as e:
errors.append(f'user_data.strategies.min_var: {e}')
try:
from user_data.strategies.best_single_asset import BestSingleAssetPortfolio
print('OK: user_data.strategies.best_single_asset.BestSingleAssetPortfolio')
except Exception as e:
errors.append(f'user_data.strategies.best_single_asset: {e}')
# Portfolio pipeline
try:
from portfolio.PortfolioManagement import run_portfolio
print('OK: portfolio.PortfolioManagement.run_portfolio')
except Exception as e:
errors.append(f'portfolio.PortfolioManagement: {e}')
if errors:
print(f'\nFAILED: {len(errors)} import error(s):')
for err in errors:
print(f' - {err}')
sys.exit(1)
else:
print(f'\nAll imports passed.')
"
# ---------------------------------------------------------------------------
# Job 4: Portfolio pipeline smoke test
# ---------------------------------------------------------------------------
portfolio-pipeline:
name: Portfolio Pipeline Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions/setup-talib
with:
talib-version: ${{ env.TALIB_VERSION }}
cache-version: ${{ env.TALIB_CACHE_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
restore-keys: pip-${{ env.PYTHON_VERSION }}-
- name: Install Python dependencies
run: |
pip install --upgrade pip "setuptools<75" wheel
pip install -r requirements.txt
pip install scipy
pip install -e .
- name: Generate synthetic test data
run: portbench generate-data
- name: Run standalone portfolio pipeline
run: portbench portfolio
# ---------------------------------------------------------------------------
# Job 5: Backtest smoke tests
# ---------------------------------------------------------------------------
backtest-smoke:
name: Backtest Smoke Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions/setup-talib
with:
talib-version: ${{ env.TALIB_VERSION }}
cache-version: ${{ env.TALIB_CACHE_VERSION }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
restore-keys: pip-${{ env.PYTHON_VERSION }}-
- name: Install Python dependencies
run: |
pip install --upgrade pip "setuptools<75" wheel
pip install -r requirements.txt
pip install scipy
pip install -e .
- name: Generate synthetic test data
run: portbench generate-data
# ── Trading strategies ──
- name: Backtest EmaCrossStrategy (crypto, 1d)
run: |
portbench backtesting \
--strategy EmaCrossStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs BTC/USDT ETH/USDT
- name: Backtest EmaCrossStrategy (crypto, 4h)
run: |
portbench backtesting \
--strategy EmaCrossStrategy \
--strategy-path ./strategy \
--timeframe 4h \
--timerange 20250501-20250601 \
--pairs BTC/USDT ETH/USDT SOL/USDT XRP/USDT
- name: Backtest MacdAdxStrategy (stocks, 1d)
run: |
portbench backtesting \
--strategy MacdAdxStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs AAPL/USD MSFT/USD
- name: Backtest RsiBollingerStrategy (stocks, 4h)
run: |
portbench backtesting \
--strategy RsiBollingerStrategy \
--strategy-path ./strategy \
--timeframe 4h \
--timerange 20250501-20250601 \
--pairs AAPL/USD MSFT/USD NVDA/USD GOOG/USD
- name: Backtest IchimokuCloudStrategy (crypto, 1d)
run: |
portbench backtesting \
--strategy IchimokuCloudStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs BTC/USDT ETH/USDT
- name: Backtest StochasticCciStrategy (stocks, 1d)
run: |
portbench backtesting \
--strategy StochasticCciStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs AAPL/USD MSFT/USD
- name: Backtest EmaCrossStrategy (indices, 1d)
run: |
portbench backtesting \
--strategy EmaCrossStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs DJI/USD FTSE/USD GSPC/USD
- name: Backtest MacdAdxStrategy (mixed assets, 1d)
run: |
portbench backtesting \
--strategy MacdAdxStrategy \
--strategy-path ./strategy \
--timeframe 1d \
--timerange 20250501-20250601 \
--pairs BTC/USDT ETH/USDT AAPL/USD MSFT/USD DJI/USD
# ── Portfolio strategies ──
- name: Backtest ONS_Portfolio (mixed, 5m, short range)
run: |
portbench backtesting \
--strategy ONS_Portfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs BTC/USDT ETH/USDT AAPL/USD \
--dry-run-wallet 1000000
- name: Backtest ONS_Portfolio (crypto, 4h)
run: |
portbench backtesting \
--strategy ONS_Portfolio \
--strategy-path ./user_data/strategies \
--timeframe 4h \
--timerange 20260101-20260131 \
--pairs BTC/USDT ETH/USDT SOL/USDT XRP/USDT \
--dry-run-wallet 1000000
- name: Backtest InverseVolatilityPortfolio (stocks, 5m)
run: |
portbench backtesting \
--strategy InverseVolatilityPortfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs AAPL/USD MSFT/USD NVDA/USD GOOG/USD \
--dry-run-wallet 1000000
- name: Backtest MinimumVariancePortfolio (crypto, 5m)
run: |
portbench backtesting \
--strategy MinimumVariancePortfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs BTC/USDT ETH/USDT SOL/USDT \
--dry-run-wallet 1000000
- name: Backtest BestSingleAssetPortfolio (stocks, 1d)
run: |
portbench backtesting \
--strategy BestSingleAssetPortfolio \
--strategy-path ./user_data/strategies \
--timeframe 1d \
--timerange 20240101-20260131 \
--pairs AAPL/USD MSFT/USD NVDA/USD GOOG/USD \
--dry-run-wallet 1000000
- name: Backtest ExponentialGradientPortfolio (mixed, 5m)
run: |
portbench backtesting \
--strategy ExponentialGradientPortfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs BTC/USDT ETH/USDT AAPL/USD DJI/USD \
--dry-run-wallet 1000000
- name: Backtest MaxSharpePortfolio (crypto, 5m)
run: |
portbench backtesting \
--strategy MaxSharpePortfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs BTC/USDT ETH/USDT SOL/USDT XRP/USDT \
--dry-run-wallet 1000000
- name: Backtest RiskParityPortfolio (indices, 1d)
run: |
portbench backtesting \
--strategy RiskParityPortfolio \
--strategy-path ./user_data/strategies \
--timeframe 1d \
--timerange 20240101-20260131 \
--pairs DJI/USD FTSE/USD GSPC/USD \
--dry-run-wallet 1000000
- name: Backtest ONS_Portfolio (indices, 4h)
run: |
portbench backtesting \
--strategy ONS_Portfolio \
--strategy-path ./user_data/strategies \
--timeframe 4h \
--timerange 20260101-20260131 \
--pairs DJI/USD FTSE/USD GSPC/USD \
--dry-run-wallet 1000000
# ── Polymarket strategies ──
- name: Backtest PolymarketMomentumStrategy (5m)
run: |
portbench backtesting \
--strategy PolymarketMomentumStrategy \
--strategy-path ./strategy \
--timeframe 5m \
--timerange 20240901-20241001 \
--pairs TRUMP-WIN-YES/USDT BTC-100K-YES/USDT ETH-10K-NO/USDT
- name: Backtest PolymarketMeanReversionStrategy (4h)
run: |
portbench backtesting \
--strategy PolymarketMeanReversionStrategy \
--strategy-path ./strategy \
--timeframe 4h \
--timerange 20240901-20250101 \
--pairs TRUMP-WIN-YES/USDT FED-RATE-CUT-YES/USDT SPX-6000-YES/USDT
- name: Backtest PolymarketPortfolio (5m)
run: |
portbench backtesting \
--strategy PolymarketPortfolio \
--strategy-path ./user_data/strategies \
--timeframe 5m \
--timerange 20260101-20260103 \
--pairs TRUMP-WIN-YES/USDT BTC-100K-YES/USDT ETH-10K-YES/USDT \
--dry-run-wallet 1000000