feat(config): expose paper broker tuning via env (REQ-010 AC-5, BAT-009)
Wire the existing PaperBroker scenario knobs (fill_after_polls / qty_per_poll / reject_symbols) to daemon env so REQ-011 AC-2 e2e scenarios (delayed / partial / reject) can be reproduced by a daemon restart. Unset == prior PaperBroker() behaviour, byte-for-byte (no regression). - config.py: PaperBrokerConfig + from_env parsing (TREX_PAPER_*) - daemon.py: _build_broker injects config.paper into PaperBroker - .env.example: document the 3 paper tuning keys (paper-only, e2e) - tests: paper broker defaults + env tuning parsing SDLC: REQ-010 CHG-20260606-01 (AC-5 added) / -02 (Implemented); BAT-009 batch-lite release-candidate; REL-001 feedback handoff records pre-deployment e2e observations incl. event-publisher idle-drop and paper correlation_id collision (GitHub #4, #5). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,11 @@ import pytest
|
||||
|
||||
from trex_core.runtime.config import DaemonConfig
|
||||
|
||||
_KEYS = ("TREX_POSTGRESQL_DSN", "TREX_TOTAL_SLOTS", "TREX_API_HOST", "TREX_API_PORT")
|
||||
_KEYS = (
|
||||
"TREX_POSTGRESQL_DSN", "TREX_TOTAL_SLOTS", "TREX_API_HOST", "TREX_API_PORT",
|
||||
"TREX_PAPER_FILL_AFTER_POLLS", "TREX_PAPER_QTY_PER_POLL",
|
||||
"TREX_PAPER_REJECT_SYMBOLS",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -48,3 +52,26 @@ def test_missing_dsn_raises(tmp_path, monkeypatch):
|
||||
monkeypatch.chdir(tmp_path)
|
||||
with pytest.raises(RuntimeError):
|
||||
DaemonConfig.from_env()
|
||||
|
||||
|
||||
def test_paper_broker_defaults(tmp_path, monkeypatch):
|
||||
"""Unset paper env == immediate full fills, no rejects (REQ-011)."""
|
||||
monkeypatch.chdir(tmp_path)
|
||||
monkeypatch.setenv("TREX_POSTGRESQL_DSN", "dbname=x")
|
||||
cfg = DaemonConfig.from_env()
|
||||
assert cfg.paper.fill_after_polls == 0
|
||||
assert cfg.paper.qty_per_poll is None
|
||||
assert cfg.paper.reject_symbols == frozenset()
|
||||
|
||||
|
||||
def test_paper_broker_env_tuning(tmp_path, monkeypatch):
|
||||
"""Paper broker scenario knobs are parsed from env (REQ-011)."""
|
||||
monkeypatch.chdir(tmp_path)
|
||||
monkeypatch.setenv("TREX_POSTGRESQL_DSN", "dbname=x")
|
||||
monkeypatch.setenv("TREX_PAPER_FILL_AFTER_POLLS", "2")
|
||||
monkeypatch.setenv("TREX_PAPER_QTY_PER_POLL", "4")
|
||||
monkeypatch.setenv("TREX_PAPER_REJECT_SYMBOLS", "005930, 000660 ,")
|
||||
cfg = DaemonConfig.from_env()
|
||||
assert cfg.paper.fill_after_polls == 2
|
||||
assert cfg.paper.qty_per_poll == 4
|
||||
assert cfg.paper.reject_symbols == frozenset({"005930", "000660"})
|
||||
|
||||
Reference in New Issue
Block a user