feat: persist skipped ledger fills
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
df0258bc36
commit
76cde2edd0
@@ -8,9 +8,8 @@ execution code path that production (KIS) takes.
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from datetime import UTC, datetime
|
||||
from decimal import Decimal
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from trex_core.adapters.broker.seq_store import SeqStore
|
||||
from trex_core.application.broker_port import (
|
||||
@@ -52,9 +51,9 @@ class PaperBroker:
|
||||
self,
|
||||
*,
|
||||
fill_after_polls: int = 0,
|
||||
qty_per_poll: Optional[int] = None,
|
||||
reject_symbols: Optional[set[str]] = None,
|
||||
seq_store: Optional[SeqStore] = None,
|
||||
qty_per_poll: int | None = None,
|
||||
reject_symbols: set[str] | None = None,
|
||||
seq_store: SeqStore | None = None,
|
||||
) -> None:
|
||||
self._fill_after = fill_after_polls
|
||||
self._qty_per_poll = qty_per_poll
|
||||
@@ -90,8 +89,8 @@ class PaperBroker:
|
||||
*,
|
||||
side: str,
|
||||
symbol: str,
|
||||
order_date: Optional[str] = None,
|
||||
submitted_at: Optional[datetime] = None,
|
||||
order_date: str | None = None,
|
||||
submitted_at: datetime | None = None,
|
||||
) -> FillStatus:
|
||||
with self._lock:
|
||||
o = self._orders.get(broker_order_id)
|
||||
@@ -122,6 +121,7 @@ class PaperBroker:
|
||||
state="filled", filled_qty=o.filled, avg_price=o.price,
|
||||
execution_id=execution_id, fee=fee, tax=tax,
|
||||
execution_venue=o.execution_venue,
|
||||
executed_at=datetime.now(tz=UTC),
|
||||
)
|
||||
return FillStatus(
|
||||
state="partially_filled",
|
||||
@@ -172,7 +172,7 @@ class PaperBroker:
|
||||
with self._lock:
|
||||
self._prices[symbol] = Decimal(str(price))
|
||||
|
||||
def get_current_price(self, symbol: str, market: str = "J") -> Optional[Decimal]:
|
||||
def get_current_price(self, symbol: str, market: str = "J") -> Decimal | None:
|
||||
"""Return the programmed current price for symbol, or None if unset.
|
||||
|
||||
market accepted for BrokerPort protocol conformance (REQ-118) but
|
||||
|
||||
Reference in New Issue
Block a user