Skip to content

Commit d8082b6

Browse files
fix: add order type field to PublicOrder class
Signed-off-by: Matthias Wende <[email protected]>
1 parent 70a68db commit d8082b6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/frequenz/client/electricity_trading/_types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,9 @@ class PublicOrder: # pylint: disable=too-many-instance-attributes
19611961
delivery_period: DeliveryPeriod
19621962
"""The delivery period for the contract."""
19631963

1964+
type: OrderType | None
1965+
"""The type of order (e.g., LIMIT, STOP_LIMIT, ICEBERG)."""
1966+
19641967
side: MarketSide
19651968
"""Indicates if the order is on the Buy or Sell side of the market."""
19661969

@@ -2009,11 +2012,17 @@ def from_pb(
20092012
if public_order.HasField("execution_option")
20102013
else None
20112014
)
2015+
order_type = (
2016+
OrderType.from_pb(public_order.type)
2017+
if public_order.HasField("type")
2018+
else None
2019+
)
20122020

20132021
return cls(
20142022
public_order_id=public_order.id,
20152023
delivery_area=DeliveryArea.from_pb(public_order.delivery_area),
20162024
delivery_period=DeliveryPeriod.from_pb(public_order.delivery_period),
2025+
type=order_type,
20172026
side=MarketSide.from_pb(public_order.side),
20182027
price=Price.from_pb(public_order.price),
20192028
quantity=Power.from_pb(public_order.quantity),

tests/test_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
public_order_id=42,
180180
delivery_area=DeliveryArea(code="XYZ", code_type=EnergyMarketCodeType.EUROPE_EIC),
181181
delivery_period=DeliveryPeriod(start=START_TIME, duration=timedelta(minutes=15)),
182+
type=OrderType.LIMIT,
182183
side=MarketSide.BUY,
183184
price=Price(amount=Decimal("100.00"), currency=Currency.EUR),
184185
quantity=Power(mw=Decimal("5.00")),
@@ -196,6 +197,7 @@
196197
start=START_TIME_PB,
197198
duration=delivery_duration_pb2.DeliveryDuration.DELIVERY_DURATION_15,
198199
),
200+
type=electricity_trading_pb2.OrderType.ORDER_TYPE_LIMIT,
199201
side=electricity_trading_pb2.MarketSide.MARKET_SIDE_BUY,
200202
price=price_pb2.Price(
201203
amount=decimal_pb2.Decimal(value="100.00"),

0 commit comments

Comments
 (0)