2b3d3e3ff8
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21 lines
960 B
Python
21 lines
960 B
Python
from src.portfolio.runner import build_worker_for
|
|
from src.portfolio.base import SleeveSpec
|
|
from src.live.strategy_worker import StrategyWorker
|
|
from src.live.pairs_worker import PairsWorker
|
|
|
|
|
|
def test_build_single_worker_capital_from_alloc(tmp_path):
|
|
spec = SleeveSpec(kind="single", name="MR01", sid="MR01_BTC", asset="BTC",
|
|
params={"bb_window": 50, "k": 2.5, "sl_atr": 2.0, "max_bars": 24})
|
|
w = build_worker_for(spec, alloc_capital=300.0, leverage=2.0, data_dir=tmp_path)
|
|
assert isinstance(w, StrategyWorker)
|
|
assert w.capital == 300.0 and w.leverage == 2.0
|
|
|
|
|
|
def test_build_pairs_worker(tmp_path):
|
|
spec = SleeveSpec(kind="pairs", name="PR01", sid="PR_ETHBTC", a="ETH", b="BTC",
|
|
params={"n": 50, "z_in": 2.0, "z_exit": 0.75, "max_bars": 72})
|
|
w = build_worker_for(spec, alloc_capital=200.0, leverage=2.0, data_dir=tmp_path)
|
|
assert isinstance(w, PairsWorker)
|
|
assert w.capital == 200.0
|