Skip to content

Commit 3609b9f

Browse files
feat: update to API v0.7.0
Signed-off-by: Matthias Wende <[email protected]>
1 parent 0600ef2 commit 3609b9f

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies = [
4545
"frequenz-channels >= 1.6.1, < 2",
4646
"frequenz-client-base >= 0.9.0, < 0.10.0",
4747
"frequenz-client-common >= 0.1.0, < 0.4.0",
48-
"frequenz-api-electricity-trading >= 0.6.1, < 0.7.0",
48+
"frequenz-api-electricity-trading >= 0.7.0, < 0.8.0",
4949
"protobuf >= 5.29.2, < 7",
5050
]
5151
dynamic = ["version"]

src/frequenz/client/electricity_trading/_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import logging
1212
from datetime import datetime, timedelta, timezone
1313
from decimal import Decimal, InvalidOperation
14-
from typing import Any, AsyncIterator, Awaitable, Callable, cast
14+
from typing import Any, AsyncIterator, Awaitable, Callable, List, cast
1515
from zoneinfo import ZoneInfo
1616

1717
import grpc
@@ -232,7 +232,7 @@ def __init__(
232232
PublicOrderBookFilter,
233233
GrpcStreamBroadcaster[
234234
electricity_trading_pb2.ReceivePublicOrderBookStreamResponse,
235-
PublicOrder,
235+
List[PublicOrder],
236236
],
237237
] = {}
238238

@@ -1012,7 +1012,7 @@ def receive_public_order_book(
10121012
start_time: datetime | None = None,
10131013
end_time: datetime | None = None,
10141014
) -> GrpcStreamBroadcaster[
1015-
electricity_trading_pb2.ReceivePublicOrderBookStreamResponse, PublicOrder
1015+
electricity_trading_pb2.ReceivePublicOrderBookStreamResponse, List[PublicOrder]
10161016
]:
10171017
"""
10181018
Stream public orders with optional filters and time range.
@@ -1055,9 +1055,10 @@ def receive_public_order_book(
10551055
),
10561056
metadata=self._metadata,
10571057
),
1058-
lambda response: PublicOrder.from_pb(
1059-
response.public_order_book_record
1060-
),
1058+
lambda response: [
1059+
PublicOrder.from_pb(public_order)
1060+
for public_order in response.public_order_book_records
1061+
],
10611062
)
10621063
)
10631064
except grpc.RpcError as e:

src/frequenz/client/electricity_trading/_types.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
def from_pb(
33-
func: Callable[Concatenate[type[T], P], T]
33+
func: Callable[Concatenate[type[T], P], T],
3434
) -> Callable[Concatenate[type[T], P], T]:
3535
"""Standardize from_pb methods like error handling with this decorator.
3636
@@ -1968,7 +1968,7 @@ class PublicOrder: # pylint: disable=too-many-instance-attributes
19681968
quantity: Power
19691969
"""The quantity of the contract being traded."""
19701970

1971-
execution_option: OrderExecutionOption
1971+
execution_option: OrderExecutionOption | None
19721972
"""Order execution options such as All or None, Fill or Kill, etc."""
19731973

19741974
create_time: datetime
@@ -2034,8 +2034,12 @@ def to_pb(self) -> electricity_trading_pb2.PublicOrderBookRecord:
20342034
side=electricity_trading_pb2.MarketSide.ValueType(self.side.value),
20352035
price=self.price.to_pb(),
20362036
quantity=self.quantity.to_pb(),
2037-
execution_option=electricity_trading_pb2.OrderExecutionOption.ValueType(
2038-
self.execution_option.value
2037+
execution_option=(
2038+
electricity_trading_pb2.OrderExecutionOption.ValueType(
2039+
self.execution_option.value
2040+
)
2041+
if self.execution_option
2042+
else None
20392043
),
20402044
create_time=create_time,
20412045
update_time=update_time,

0 commit comments

Comments
 (0)