From 1c576d72d1d5de82bf335c639eeac2644b2296cf Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 22 Mar 2023 13:22:24 -0400 Subject: [PATCH] Dump `Position`s as pformatted dicts for now.. --- piker/accounting/_pos.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/piker/accounting/_pos.py b/piker/accounting/_pos.py index 724b357f..e7f83d98 100644 --- a/piker/accounting/_pos.py +++ b/piker/accounting/_pos.py @@ -26,6 +26,7 @@ from __future__ import annotations from contextlib import contextmanager as cm from decimal import Decimal from math import copysign +from pprint import pformat import re from typing import ( Any, @@ -88,6 +89,9 @@ class Position(Struct): expiry: Optional[datetime] = None + def __repr__(self) -> str: + return pformat(self.to_dict()) + def to_dict(self) -> dict: return { f: getattr(self, f) @@ -657,7 +661,7 @@ class PpTable(Struct): if pp_entries: log.info( f'Updating ``pps.toml``:\n' - f'Current positions:\n{pp_entries}' + f'Current positions:\n{pformat(pp_entries)}' ) self.conf[self.brokername][self.acctid] = pp_entries