32 lines
863 B
Python
32 lines
863 B
Python
from __future__ import annotations
|
|
|
|
"""Toy price-feed adapter.
|
|
This adapter simulates receiving quotes from an exchange and exposes a simple
|
|
interface that the ArbSphere coordinator can consume.
|
|
"""
|
|
|
|
from typing import Dict, Any, List
|
|
import time
|
|
|
|
|
|
class PriceFeedAdapter:
|
|
def __init__(self, source: str = "mock-exchange") -> None:
|
|
self.source = source
|
|
self._tick = 0
|
|
|
|
def poll(self) -> Dict[str, Any]:
|
|
# deterministic synthetic data
|
|
self._tick += 1
|
|
now = time.time()
|
|
price = 100.0 + (self._tick % 5) # simple wobble
|
|
return {
|
|
"source": self.source,
|
|
"ts": now,
|
|
"price": price,
|
|
"bid": price - 0.05,
|
|
"ask": price + 0.05,
|
|
}
|
|
|
|
def as_series(self, n: int = 10) -> List[Dict[str, Any]]:
|
|
return [self.poll() for _ in range(n)]
|