20 lines
682 B
Python
20 lines
682 B
Python
from __future__ import annotations
|
|
import time
|
|
from typing import List
|
|
from ..dsl import OrderEvent, FillEvent
|
|
|
|
class ExchangeGatewaySimulator:
|
|
"""
|
|
Simple exchange gateway simulator that converts PlanDelta hits into FillEvent outputs deterministically.
|
|
"""
|
|
def __init__(self, latency_ms: int = 5):
|
|
self.latency_ms = latency_ms
|
|
|
|
def simulate_fills(self, orders: List[OrderEvent]) -> List[FillEvent]:
|
|
t = time.time()
|
|
fills: List[FillEvent] = []
|
|
for o in orders:
|
|
f = FillEvent(fill_id=f"fill-{o.order_id}", timestamp=t, order_id=o.order_id, quantity=o.quantity, price=o.price, venue="SIM_EX", delta_id=o.delta_id)
|
|
fills.append(f)
|
|
return fills
|