Add Binance Testnet exchange gateway
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
from llm_trade_bot.database import Database
|
||||
@@ -35,3 +36,44 @@ async def test_run_lifecycle(tmp_path: Path):
|
||||
assert last["summary"] == "idle"
|
||||
finally:
|
||||
await database.close()
|
||||
|
||||
|
||||
async def test_managed_orders_migrate_legacy_rows_to_bybit(tmp_path: Path):
|
||||
path = tmp_path / "legacy.db"
|
||||
connection = sqlite3.connect(path)
|
||||
connection.execute(
|
||||
"""
|
||||
CREATE TABLE managed_orders (
|
||||
order_link_id TEXT PRIMARY KEY, order_id TEXT, category TEXT NOT NULL,
|
||||
symbol TEXT NOT NULL, side TEXT NOT NULL, status TEXT NOT NULL,
|
||||
expires_at TEXT, trailing_distance TEXT, raw_json TEXT NOT NULL, updated_at TEXT NOT NULL
|
||||
)
|
||||
"""
|
||||
)
|
||||
connection.execute(
|
||||
"""
|
||||
INSERT INTO managed_orders VALUES (
|
||||
'ltb-old', 'old-1', 'linear', 'BTCUSDT', 'Buy', 'Created',
|
||||
'2000-01-01T00:00:00+00:00', NULL, '{}', '2000-01-01T00:00:00+00:00'
|
||||
)
|
||||
"""
|
||||
)
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
database = Database(path)
|
||||
await database.open()
|
||||
try:
|
||||
rows = await database.expired_managed_orders(provider="bybit")
|
||||
assert rows == [
|
||||
{
|
||||
"order_link_id": "ltb-old",
|
||||
"order_id": "old-1",
|
||||
"provider": "bybit",
|
||||
"category": "linear",
|
||||
"symbol": "BTCUSDT",
|
||||
}
|
||||
]
|
||||
assert await database.expired_managed_orders(provider="binance") == []
|
||||
finally:
|
||||
await database.close()
|
||||
|
||||
Reference in New Issue
Block a user