Implement Kraken integration with REST and WebSocket clients, add market data handling, and enhance settings configuration
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import orjson
|
||||
|
||||
from arbitrade.storage.db import DuckDBStore
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class MarketSnapshotRecord:
|
||||
snapshot_at: datetime
|
||||
symbol: str
|
||||
source: str
|
||||
payload: dict[str, Any]
|
||||
latency_ms: float | None
|
||||
|
||||
|
||||
class MarketSnapshotRepository:
|
||||
def __init__(self, store: DuckDBStore) -> None:
|
||||
self._store = store
|
||||
|
||||
def insert(self, record: MarketSnapshotRecord) -> None:
|
||||
with self._store.connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO market_snapshots (snapshot_at, symbol, source, payload, latency_ms)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""",
|
||||
[
|
||||
record.snapshot_at,
|
||||
record.symbol,
|
||||
record.source,
|
||||
orjson.dumps(record.payload).decode("utf-8"),
|
||||
record.latency_ms,
|
||||
],
|
||||
)
|
||||
Reference in New Issue
Block a user