Skip to content

Commit 481d99d

Browse files
committed
Support listing orders without price or quantity
Cancelled orders don't have a price or quantity, which leads to failures when converting from protobuf. This allows missing price and quantities. Signed-off-by: cwasicki <[email protected]>
1 parent cfcfb51 commit 481d99d

File tree

1 file changed

+10
-2
lines changed
  • src/frequenz/client/electricity_trading

1 file changed

+10
-2
lines changed

src/frequenz/client/electricity_trading/_types.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,16 @@ def from_pb(cls, order: electricity_trading_pb2.Order) -> Self:
10101010
delivery_period=DeliveryPeriod.from_pb(order.delivery_period),
10111011
type=OrderType.from_pb(order.type),
10121012
side=MarketSide.from_pb(order.side),
1013-
price=Price.from_pb(order.price),
1014-
quantity=Power.from_pb(order.quantity),
1013+
price=(
1014+
Price.from_pb(order.price)
1015+
if order.HasField("price")
1016+
else Price(Decimal("NaN"), Currency.UNSPECIFIED)
1017+
),
1018+
quantity=(
1019+
Power.from_pb(order.quantity)
1020+
if order.HasField("quantity")
1021+
else Power(Decimal("NaN"))
1022+
),
10151023
stop_price=(
10161024
Price.from_pb(order.stop_price)
10171025
if order.HasField("stop_price")

0 commit comments

Comments
 (0)