feat: collect Bybit orderbook observations for training
This commit is contained in:
@@ -62,6 +62,57 @@ def test_prune_deletes_only_one_bounded_batch_per_table(tmp_path) -> None:
|
||||
assert len(storage.recent_signals(PRUNE_BATCH_SIZE + 10)) == 5
|
||||
|
||||
|
||||
def test_market_observation_export_is_symbol_scoped_and_paginated(tmp_path) -> None:
|
||||
storage = Storage(tmp_path / "tradebot.sqlite3")
|
||||
first_id = storage.insert_market_observation(
|
||||
symbol="BTCUSDT",
|
||||
bid_price=100.0,
|
||||
bid_size=2.0,
|
||||
ask_price=101.0,
|
||||
ask_size=1.0,
|
||||
mid_price=100.5,
|
||||
microprice=100.6666666667,
|
||||
spread_bps=99.50248756,
|
||||
imbalance=1 / 3,
|
||||
last_price=100.4,
|
||||
source_timestamp_ms=1_789_000_000_000,
|
||||
)
|
||||
second_id = storage.insert_market_observation(
|
||||
symbol="BTCUSDT",
|
||||
bid_price=101.0,
|
||||
bid_size=1.0,
|
||||
ask_price=102.0,
|
||||
ask_size=1.0,
|
||||
mid_price=101.5,
|
||||
microprice=101.5,
|
||||
spread_bps=98.52216749,
|
||||
imbalance=0.0,
|
||||
last_price=101.4,
|
||||
source_timestamp_ms=1_789_000_030_000,
|
||||
)
|
||||
storage.insert_market_observation(
|
||||
symbol="ETHUSDT",
|
||||
bid_price=10.0,
|
||||
bid_size=1.0,
|
||||
ask_price=11.0,
|
||||
ask_size=1.0,
|
||||
mid_price=10.5,
|
||||
microprice=10.5,
|
||||
spread_bps=952.38095238,
|
||||
imbalance=0.0,
|
||||
last_price=10.4,
|
||||
)
|
||||
|
||||
rows = storage.market_observations_after(
|
||||
symbol="BTCUSDT",
|
||||
after_id=first_id,
|
||||
limit=1,
|
||||
)
|
||||
|
||||
assert [row["id"] for row in rows] == [second_id]
|
||||
assert rows[0]["source_timestamp_ms"] == 1_789_000_030_000
|
||||
|
||||
|
||||
def test_runtime_compaction_preserves_durable_state_and_bounds_telemetry(tmp_path) -> None:
|
||||
database = tmp_path / "tradebot.sqlite3"
|
||||
storage = Storage(database)
|
||||
|
||||
Reference in New Issue
Block a user