optz
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
"""SQLite positions and deals, aligned with SDK models; one writer per database."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
import sqlite3
|
||||
from contextlib import closing
|
||||
from dataclasses import asdict, fields
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from itertools import chain
|
||||
|
||||
from sdk import DealItem, PositionItem
|
||||
|
||||
@@ -106,7 +105,7 @@ class OrderBook:
|
||||
raise ValueError('System order ID and positive volume are required')
|
||||
|
||||
row = asdict(deal)
|
||||
row['order_local_id'] = deal.get_local_order_id()
|
||||
row['order_local_id'] = deal.local_order_id
|
||||
if not row['order_local_id']:
|
||||
raise ValueError('Local order ID is required')
|
||||
|
||||
@@ -145,7 +144,7 @@ class OrderBook:
|
||||
raise ValueError('Execution history is append-only')
|
||||
new_deals = deals[len(self.deals):]
|
||||
positions = [{**POSITION_DEFAULTS, **item} for item in items.values()]
|
||||
for row in [*positions, *new_deals]:
|
||||
for row in chain(positions, new_deals):
|
||||
if any(isinstance(value, float) and not math.isfinite(value) for value in row.values()):
|
||||
raise ValueError('Numeric values must be finite')
|
||||
with closing(self._connect()) as db, db:
|
||||
|
||||
Reference in New Issue
Block a user