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
7 changes: 4 additions & 3 deletions application/signal_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def build_signal_snapshot(
source.get("signal_description"),
source.get("signal_message"),
)
price_as_of = _first_value(source.get("price_as_of"), source.get("snapshot_manifest_price_as_of"))
indicators = {
field: _json_safe(source[field])
for field in _INDICATOR_FIELDS
Expand All @@ -149,6 +150,7 @@ def build_signal_snapshot(
source.get("snapshot_as_of"),
source.get("trade_date"),
parsed_snapshot_date,
price_as_of,
)
),
"market_date": _json_safe(
Expand All @@ -158,6 +160,7 @@ def build_signal_snapshot(
source.get("snapshot_as_of"),
source.get("trade_date"),
parsed_snapshot_date,
price_as_of,
)
),
"effective_date": _json_safe(source.get("effective_date")),
Expand All @@ -168,9 +171,7 @@ def build_signal_snapshot(
source.get("signal_source"),
),
"quote_overlay_used": source.get("quote_overlay_used"),
"price_as_of": _json_safe(
_first_value(source.get("price_as_of"), source.get("snapshot_manifest_price_as_of"))
),
"price_as_of": _json_safe(price_as_of),
"universe_as_of": _json_safe(
_first_value(source.get("universe_as_of"), source.get("snapshot_manifest_universe_as_of"))
),
Expand Down
20 changes: 20 additions & 0 deletions tests/test_signal_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ def test_includes_snapshot_manifest_input_diagnostics(self):
self.assertEqual(snapshot["source_input_fallback_streak"], 1)
self.assertEqual(snapshot["source_refresh_run_id"], "12345")

def test_uses_price_as_of_as_snapshot_date_fallback(self):
snapshot = build_signal_snapshot(
platform="longbridge",
execution={
"snapshot_manifest_price_as_of": "2026-06-01",
"snapshot_manifest_universe_as_of": "2026-05-14",
"snapshot_manifest_source_input_status": "partial_history_refresh",
"latest_price_source": "longbridge_candlesticks",
"signal_display": (
"regime=risk_on breadth=68.0% benchmark_trend=up "
"target_stock=100.0% realized_stock=100.0% selected=4"
),
},
)

self.assertEqual(snapshot["market_date"], "2026-06-01")
self.assertEqual(snapshot["signal_as_of"], "2026-06-01")
self.assertEqual(snapshot["price_as_of"], "2026-06-01")
self.assertEqual(snapshot["universe_as_of"], "2026-05-14")


if __name__ == "__main__":
unittest.main()