Build 060.27: implement Persistent Market Data Storage

This commit is contained in:
2026-08-01 03:22:25 +03:00
parent cb8acfe5fe
commit 58e5a12a4d
54 changed files with 10243 additions and 101 deletions

View File

@@ -46,6 +46,7 @@ def make_settings() -> SimpleNamespace:
exchange_name="dzengi",
default_symbol="BTC/USD_LEVERAGE",
trade_stream=SimpleNamespace(enabled=True),
market_data_storage=SimpleNamespace(enabled=True),
)
@@ -56,6 +57,12 @@ def test_create_app_builds_one_application_composition(
bot = object()
dispatcher = object()
runtime = object()
storage_lifecycle = object()
storage_sink = object()
storage = SimpleNamespace(
lifecycle=storage_lifecycle,
trade_observation_sink=storage_sink,
)
journal = RecordingJournal()
observed_runtime_settings: list[object] = []
registered_bots: list[object] = []
@@ -82,8 +89,23 @@ def test_create_app_builds_one_application_composition(
lambda: journal,
)
def build_runtime(received_settings: object) -> object:
monkeypatch.setattr(
app_factory,
"build_market_data_storage",
lambda received_settings: (
storage
if received_settings is settings
else None
),
)
def build_runtime(
received_settings: object,
*,
trade_observation_sink: object,
) -> object:
observed_runtime_settings.append(received_settings)
assert trade_observation_sink is storage_sink
return runtime
monkeypatch.setattr(
@@ -118,10 +140,18 @@ def test_create_app_builds_one_application_composition(
assert application.bot is bot
assert application.dispatcher is dispatcher
assert application.trade_stream_runtime is runtime
assert (
application.market_data_storage_lifecycle
is storage_lifecycle
)
assert observed_runtime_settings == [settings]
assert registered_bots == [bot]
assert routed_dispatchers == [dispatcher]
assert journal.info_calls[0][2]["trade_stream_enabled"] is True
assert (
journal.info_calls[0][2]["market_data_storage_enabled"]
is True
)
def test_runtime_build_error_is_fatal(
@@ -149,9 +179,18 @@ def test_runtime_build_error_is_fatal(
"JournalService",
RecordingJournal,
)
monkeypatch.setattr(
app_factory,
"build_market_data_storage",
lambda settings: None,
)
def fail_runtime_build(settings: object) -> None:
del settings
def fail_runtime_build(
settings: object,
*,
trade_observation_sink: object,
) -> None:
del settings, trade_observation_sink
raise expected
monkeypatch.setattr(