@@ -971,21 +971,31 @@ def from_pb(cls, order: electricity_trading_pb2.Order) -> Self:
971971 side = MarketSide .from_pb (order .side ),
972972 price = Price .from_pb (order .price ),
973973 quantity = Energy .from_pb (order .quantity ),
974- stop_price = Price .from_pb (order .stop_price )
975- if order .HasField ("stop_price" )
976- else None ,
977- peak_price_delta = Price .from_pb (order .peak_price_delta )
978- if order .HasField ("peak_price_delta" )
979- else None ,
980- display_quantity = Energy .from_pb (order .display_quantity )
981- if order .HasField ("display_quantity" )
982- else None ,
983- execution_option = OrderExecutionOption .from_pb (order .execution_option )
984- if order .HasField ("execution_option" )
985- else None ,
986- valid_until = order .valid_until .ToDatetime (tzinfo = timezone .utc )
987- if order .HasField ("valid_until" )
988- else None ,
974+ stop_price = (
975+ Price .from_pb (order .stop_price )
976+ if order .HasField ("stop_price" )
977+ else None
978+ ),
979+ peak_price_delta = (
980+ Price .from_pb (order .peak_price_delta )
981+ if order .HasField ("peak_price_delta" )
982+ else None
983+ ),
984+ display_quantity = (
985+ Energy .from_pb (order .display_quantity )
986+ if order .HasField ("display_quantity" )
987+ else None
988+ ),
989+ execution_option = (
990+ OrderExecutionOption .from_pb (order .execution_option )
991+ if order .HasField ("execution_option" )
992+ else None
993+ ),
994+ valid_until = (
995+ order .valid_until .ToDatetime (tzinfo = timezone .utc )
996+ if order .HasField ("valid_until" )
997+ else None
998+ ),
989999 payload = json_format .MessageToDict (order .payload ) if order .payload else None ,
9901000 tag = order .tag if order .tag else None ,
9911001 )
@@ -1010,12 +1020,12 @@ def to_pb(self) -> electricity_trading_pb2.Order:
10101020 price = self .price .to_pb (),
10111021 quantity = self .quantity .to_pb (),
10121022 stop_price = self .stop_price .to_pb () if self .stop_price else None ,
1013- peak_price_delta = self . peak_price_delta . to_pb ()
1014- if self .peak_price_delta
1015- else None ,
1016- display_quantity = self . display_quantity . to_pb ()
1017- if self .display_quantity
1018- else None ,
1023+ peak_price_delta = (
1024+ self . peak_price_delta . to_pb () if self .peak_price_delta else None
1025+ ) ,
1026+ display_quantity = (
1027+ self . display_quantity . to_pb () if self .display_quantity else None
1028+ ) ,
10191029 execution_option = (
10201030 electricity_trading_pb2 .OrderExecutionOption .ValueType (
10211031 self .execution_option .value
@@ -1415,18 +1425,22 @@ def to_pb(self) -> electricity_trading_pb2.GridpoolOrderFilter:
14151425 Protobuf GridpoolOrderFilter corresponding to the object.
14161426 """
14171427 return electricity_trading_pb2 .GridpoolOrderFilter (
1418- states = [
1419- electricity_trading_pb2 .OrderState .ValueType (state .value )
1420- for state in self .order_states
1421- ]
1422- if self .order_states
1423- else None ,
1424- side = electricity_trading_pb2 .MarketSide .ValueType (self .side .value )
1425- if self .side
1426- else None ,
1427- delivery_period = self .delivery_period .to_pb ()
1428- if self .delivery_period
1429- else None ,
1428+ states = (
1429+ [
1430+ electricity_trading_pb2 .OrderState .ValueType (state .value )
1431+ for state in self .order_states
1432+ ]
1433+ if self .order_states
1434+ else None
1435+ ),
1436+ side = (
1437+ electricity_trading_pb2 .MarketSide .ValueType (self .side .value )
1438+ if self .side
1439+ else None
1440+ ),
1441+ delivery_period = (
1442+ self .delivery_period .to_pb () if self .delivery_period else None
1443+ ),
14301444 delivery_area = self .delivery_area .to_pb () if self .delivery_area else None ,
14311445 tag = self .tag if self .tag else None ,
14321446 )
@@ -1520,14 +1534,16 @@ def to_pb(self) -> electricity_trading_pb2.GridpoolTradeFilter:
15201534 Protobuf GridpoolTradeFilter corresponding to the object.
15211535 """
15221536 return electricity_trading_pb2 .GridpoolTradeFilter (
1523- states = [TradeState .to_pb (state ) for state in self .trade_states ]
1524- if self .trade_states
1525- else None ,
1537+ states = (
1538+ [TradeState .to_pb (state ) for state in self .trade_states ]
1539+ if self .trade_states
1540+ else None
1541+ ),
15261542 trade_ids = self .trade_ids if self .trade_ids else None ,
15271543 side = MarketSide .to_pb (self .side ) if self .side else None ,
1528- delivery_period = self . delivery_period . to_pb ()
1529- if self .delivery_period
1530- else None ,
1544+ delivery_period = (
1545+ self . delivery_period . to_pb () if self .delivery_period else None
1546+ ) ,
15311547 delivery_area = self .delivery_area .to_pb () if self .delivery_area else None ,
15321548 )
15331549
@@ -1613,21 +1629,23 @@ def to_pb(self) -> electricity_trading_pb2.PublicTradeFilter:
16131629 Protobuf PublicTradeFilter corresponding to the object.
16141630 """
16151631 return electricity_trading_pb2 .PublicTradeFilter (
1616- states = [
1617- electricity_trading_pb2 .TradeState .ValueType (state .value )
1618- for state in self .states
1619- ]
1620- if self .states
1621- else None ,
1622- delivery_period = self .delivery_period .to_pb ()
1623- if self .delivery_period
1624- else None ,
1625- buy_delivery_area = self .buy_delivery_area .to_pb ()
1626- if self .buy_delivery_area
1627- else None ,
1628- sell_delivery_area = self .sell_delivery_area .to_pb ()
1629- if self .sell_delivery_area
1630- else None ,
1632+ states = (
1633+ [
1634+ electricity_trading_pb2 .TradeState .ValueType (state .value )
1635+ for state in self .states
1636+ ]
1637+ if self .states
1638+ else None
1639+ ),
1640+ delivery_period = (
1641+ self .delivery_period .to_pb () if self .delivery_period else None
1642+ ),
1643+ buy_delivery_area = (
1644+ self .buy_delivery_area .to_pb () if self .buy_delivery_area else None
1645+ ),
1646+ sell_delivery_area = (
1647+ self .sell_delivery_area .to_pb () if self .sell_delivery_area else None
1648+ ),
16311649 )
16321650
16331651
@@ -1695,30 +1713,46 @@ def from_pb(
16951713 UpdateOrder object corresponding to the protobuf message.
16961714 """
16971715 return cls (
1698- price = Price .from_pb (update_order .price )
1699- if update_order .HasField ("price" )
1700- else None ,
1701- quantity = Energy .from_pb (update_order .quantity )
1702- if update_order .HasField ("quantity" )
1703- else None ,
1704- stop_price = Price .from_pb (update_order .stop_price )
1705- if update_order .HasField ("stop_price" )
1706- else None ,
1707- peak_price_delta = Price .from_pb (update_order .peak_price_delta )
1708- if update_order .HasField ("peak_price_delta" )
1709- else None ,
1710- display_quantity = Energy .from_pb (update_order .display_quantity )
1711- if update_order .HasField ("display_quantity" )
1712- else None ,
1713- execution_option = OrderExecutionOption .from_pb (update_order .execution_option )
1714- if update_order .HasField ("execution_option" )
1715- else None ,
1716- valid_until = update_order .valid_until .ToDatetime (tzinfo = timezone .utc )
1717- if update_order .HasField ("valid_until" )
1718- else None ,
1719- payload = json_format .MessageToDict (update_order .payload )
1720- if update_order .payload
1721- else None ,
1716+ price = (
1717+ Price .from_pb (update_order .price )
1718+ if update_order .HasField ("price" )
1719+ else None
1720+ ),
1721+ quantity = (
1722+ Energy .from_pb (update_order .quantity )
1723+ if update_order .HasField ("quantity" )
1724+ else None
1725+ ),
1726+ stop_price = (
1727+ Price .from_pb (update_order .stop_price )
1728+ if update_order .HasField ("stop_price" )
1729+ else None
1730+ ),
1731+ peak_price_delta = (
1732+ Price .from_pb (update_order .peak_price_delta )
1733+ if update_order .HasField ("peak_price_delta" )
1734+ else None
1735+ ),
1736+ display_quantity = (
1737+ Energy .from_pb (update_order .display_quantity )
1738+ if update_order .HasField ("display_quantity" )
1739+ else None
1740+ ),
1741+ execution_option = (
1742+ OrderExecutionOption .from_pb (update_order .execution_option )
1743+ if update_order .HasField ("execution_option" )
1744+ else None
1745+ ),
1746+ valid_until = (
1747+ update_order .valid_until .ToDatetime (tzinfo = timezone .utc )
1748+ if update_order .HasField ("valid_until" )
1749+ else None
1750+ ),
1751+ payload = (
1752+ json_format .MessageToDict (update_order .payload )
1753+ if update_order .payload
1754+ else None
1755+ ),
17221756 tag = update_order .tag if update_order .HasField ("tag" ) else None ,
17231757 )
17241758
@@ -1737,12 +1771,12 @@ def to_pb(self) -> electricity_trading_pb2.UpdateGridpoolOrderRequest.UpdateOrde
17371771 price = self .price .to_pb () if self .price else None ,
17381772 quantity = self .quantity .to_pb () if self .quantity else None ,
17391773 stop_price = self .stop_price .to_pb () if self .stop_price else None ,
1740- peak_price_delta = self . peak_price_delta . to_pb ()
1741- if self .peak_price_delta
1742- else None ,
1743- display_quantity = self . display_quantity . to_pb ()
1744- if self .display_quantity
1745- else None ,
1774+ peak_price_delta = (
1775+ self . peak_price_delta . to_pb () if self .peak_price_delta else None
1776+ ) ,
1777+ display_quantity = (
1778+ self . display_quantity . to_pb () if self .display_quantity else None
1779+ ) ,
17461780 execution_option = (
17471781 electricity_trading_pb2 .OrderExecutionOption .ValueType (
17481782 self .execution_option .value
0 commit comments