|
39 | 39 | from loguru import logger |
40 | 40 | from pydantic import BaseModel, Field |
41 | 41 |
|
42 | | -from quant_pod.execution.portfolio_state import Position, get_portfolio_state |
| 42 | +from quant_pod.execution.portfolio_state import PortfolioState, Position, get_portfolio_state |
43 | 43 |
|
44 | 44 | # ============================================================================= |
45 | 45 | # DATA MODELS |
@@ -107,7 +107,7 @@ class PaperBroker: |
107 | 107 | def __init__( |
108 | 108 | self, |
109 | 109 | conn: duckdb.DuckDBPyConnection | None = None, |
110 | | - portfolio: PortfolioState | None = None, # noqa: F821 |
| 110 | + portfolio: PortfolioState | None = None, |
111 | 111 | # Legacy parameter — ignored when conn is provided |
112 | 112 | db_path: str | None = None, |
113 | 113 | ): |
@@ -336,7 +336,7 @@ def _update_portfolio(self, fill: Fill, req: OrderRequest) -> None: |
336 | 336 | def get_fills(self, symbol: str | None = None, limit: int = 100) -> list[Fill]: |
337 | 337 | """Return recent fills, optionally filtered by symbol.""" |
338 | 338 | query = "SELECT * FROM fills" |
339 | | - params = [] |
| 339 | + params: list[str | int] = [] |
340 | 340 | if symbol: |
341 | 341 | query += " WHERE symbol = ?" |
342 | 342 | params.append(symbol) |
@@ -367,15 +367,15 @@ def get_total_commission(self) -> float: |
367 | 367 | row = self.conn.execute( |
368 | 368 | "SELECT COALESCE(SUM(commission), 0) FROM fills WHERE rejected = FALSE" |
369 | 369 | ).fetchone() |
370 | | - return float(row[0]) |
| 370 | + return float(row[0]) if row is not None else 0.0 |
371 | 371 |
|
372 | 372 | def get_avg_slippage_bps(self) -> float: |
373 | 373 | """Average slippage in basis points across all fills.""" |
374 | 374 | row = self.conn.execute( |
375 | 375 | "SELECT COALESCE(AVG(slippage_bps), 0) FROM fills " |
376 | 376 | "WHERE rejected = FALSE AND filled_quantity > 0" |
377 | 377 | ).fetchone() |
378 | | - return float(row[0]) |
| 378 | + return float(row[0]) if row is not None else 0.0 |
379 | 379 |
|
380 | 380 |
|
381 | 381 | # Singleton — prefer injecting via TradingContext in new code. |
|
0 commit comments