Skip to content

Commit 5c56938

Browse files
fix: add order type field to PublicOrder class
Signed-off-by: Matthias Wende <[email protected]>
1 parent 98534a2 commit 5c56938

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
@@ -1959,6 +1959,9 @@ class PublicOrder: # pylint: disable=too-many-instance-attributes
19591959
delivery_period: DeliveryPeriod
19601960
"""The delivery period for the contract."""
19611961

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

@@ -2007,11 +2010,17 @@ def from_pb(
20072010
if public_order.HasField("execution_option")
20082011
else None
20092012
)
2013+
order_type = (
2014+
OrderType.from_pb(public_order.type)
2015+
if public_order.HasField("type")
2016+
else None
2017+
)
20102018

20112019
return cls(
20122020
public_order_id=public_order.id,
20132021
delivery_area=DeliveryArea.from_pb(public_order.delivery_area),
20142022
delivery_period=DeliveryPeriod.from_pb(public_order.delivery_period),
2023+
type=order_type,
20152024
side=MarketSide.from_pb(public_order.side),
20162025
price=Price.from_pb(public_order.price),
20172026
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)