|
4 | 4 | from types import SimpleNamespace |
5 | 5 |
|
6 | 6 | from application.firstrade_client import FirstradeCredentials |
7 | | -from application.rebalance_service import run_strategy_cycle |
| 7 | +from application.rebalance_service import _runtime_metadata_with_execution_policy, run_strategy_cycle |
8 | 8 | from notifications.telegram import I18N, build_translator, render_cycle_summary |
9 | 9 | from quant_platform_kit.strategy_contracts import PositionTarget, StrategyDecision |
10 | 10 | from runtime_config_support import PlatformRuntimeSettings |
@@ -36,6 +36,32 @@ def _runtime_settings_with_persistence(**overrides) -> PlatformRuntimeSettings: |
36 | 36 | return PlatformRuntimeSettings(**values) |
37 | 37 |
|
38 | 38 |
|
| 39 | +def test_runtime_metadata_uses_platform_execution_policy_over_strategy_metadata(): |
| 40 | + metadata = { |
| 41 | + "signal": "ok", |
| 42 | + "firstrade_execution_policy": { |
| 43 | + "reserved_cash_floor_usd": 1.0, |
| 44 | + "reserved_cash_ratio": 0.0, |
| 45 | + }, |
| 46 | + } |
| 47 | + |
| 48 | + result = _runtime_metadata_with_execution_policy( |
| 49 | + metadata, |
| 50 | + settings=_runtime_settings_with_persistence( |
| 51 | + reserved_cash_floor_usd=250.0, |
| 52 | + reserved_cash_ratio=0.03, |
| 53 | + ), |
| 54 | + ) |
| 55 | + |
| 56 | + assert result == { |
| 57 | + "signal": "ok", |
| 58 | + "firstrade_execution_policy": { |
| 59 | + "reserved_cash_floor_usd": 250.0, |
| 60 | + "reserved_cash_ratio": 0.03, |
| 61 | + }, |
| 62 | + } |
| 63 | + |
| 64 | + |
39 | 65 | class FakeFirstradeClient: |
40 | 66 | def __init__(self, _credentials, *, live_trading_enabled=False): |
41 | 67 | self.live_trading_enabled = live_trading_enabled |
|
0 commit comments