Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ flask
gunicorn
firstrade==0.0.39
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@b846c9d777a450e95d23c264853997d671f47dd9
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@361338f60900182e3be535cd5fd2be2b9a07b422
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@0cd90a37f3ea5e4b6fe27c9a435834df7df3a25f
google-cloud-storage
requests
pytest
6 changes: 6 additions & 0 deletions strategy_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def load_runtime_parameters(self) -> dict[str, Any]:

def _build_runtime_overrides(profile: str, runtime_settings: PlatformRuntimeSettings) -> dict[str, Any]:
overrides: dict[str, Any] = {}
reserved_cash_floor_usd = getattr(runtime_settings, "reserved_cash_floor_usd", 0.0)
reserved_cash_ratio = getattr(runtime_settings, "reserved_cash_ratio", None)
if float(reserved_cash_floor_usd or 0.0) > 0.0:
overrides["reserved_cash_floor_usd"] = float(reserved_cash_floor_usd)
if reserved_cash_ratio is not None and float(reserved_cash_ratio or 0.0) > 0.0:
overrides["reserved_cash_ratio"] = float(reserved_cash_ratio)
income_layer_enabled = getattr(runtime_settings, "income_layer_enabled", None)
income_layer_start_usd = getattr(runtime_settings, "income_layer_start_usd", None)
income_layer_max_ratio = getattr(runtime_settings, "income_layer_max_ratio", None)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_strategy_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ def test_dca_overrides_apply_to_runtime_config():
}


def test_reserved_cash_policy_overrides_apply_to_runtime_config():
settings = _runtime_settings(
strategy_profile="soxl_soxx_trend_income",
reserved_cash_floor_usd=150.0,
reserved_cash_ratio=0.03,
)

assert _build_runtime_overrides("soxl_soxx_trend_income", settings) == {
"reserved_cash_floor_usd": 150.0,
"reserved_cash_ratio": 0.03,
}


def test_dca_overrides_ignore_non_dca_profiles():
settings = _runtime_settings(dca_mode="smart", dca_base_investment_usd=500.0)

Expand Down