electricity_trading
frequenz.client.electricity_trading ¤
Electricity Trading API client for Python.
Frequenz Electricity Trading API Client¤
This module provides an easy-to-use Python interface to interact with the Frequenz Electricity Trading API. It allows you to create orders, manage market data, and interact with the electricity trading ecosystem.
Features¤
- Create and manage gridpool orders: Place new orders, update existing ones, and cancel orders when necessary.
- Stream live data: Get real-time updates on market data, including order books, trades, and market prices.
- Retrieve historical data: Access historical data on market trades.
Installation¤
You can install the Frequenz Electricity Trading API client via pip. Replace VERSION
with the specific version you wish to install.
Choose the version you want to install¤
Initialization¤
First, initialize the client with the appropriate server URL and API key.
Initialize the client
import asyncio
from frequenz.client.electricity_trading import Client
# Change server address if needed
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
API_KEY = f.read().strip()
async def initialize():
client = Client(
server_url=SERVICE_URL,
auth_key=API_KEY
)
asyncio.run(initialize())
Example Usage¤
Create an Order¤
Here's an example of how to create a limit order to buy energy.
Create a limit order
import asyncio
from frequenz.client.electricity_trading import (
Client,
Currency,
DeliveryArea,
DeliveryPeriod,
EnergyMarketCodeType,
MarketSide,
OrderType,
Power,
Price,
)
from datetime import datetime, timedelta
from decimal import Decimal
# Change server address if needed
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
API_KEY = f.read().strip()
async def create_order():
client = Client(
server_url=SERVICE_URL,
auth_key=API_KEY
)
# Define order parameters
gridpool_id = 1
delivery_area = DeliveryArea(
code="10YDE-EON------1", # TenneT
code_type=EnergyMarketCodeType.EUROPE_EIC
)
delivery_period = DeliveryPeriod(
start=datetime.fromisoformat("2024-05-01T00:00:00+00:00"),
duration=timedelta(minutes=15)
)
price = Price(amount=Decimal("50.0"), currency=Currency.EUR)
quantity = Power(mw=Decimal("0.1"))
order = await client.create_gridpool_order(
gridpool_id=gridpool_id,
delivery_area=delivery_area,
delivery_period=delivery_period,
order_type=OrderType.LIMIT,
side=MarketSide.BUY,
price=price,
quantity=quantity,
)
asyncio.run(create_order())
List Orders for a Gridpool¤
Orders for a given gridpool can be listed using various filters.
List orders for a gridpool
import asyncio
from frequenz.client.electricity_trading import ( Client, MarketSide )
# Change server address if needed
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
API_KEY = f.read().strip()
async def list_orders():
client = Client(
server_url=SERVICE_URL,
auth_key=API_KEY
)
gridpool_id: int = 1
# List all orders for a given gridpool
orders = await client.list_gridpool_orders(
gridpool_id=gridpool_id,
)
# List only the buy orders for a given gridpool
buy_orders = await client.list_gridpool_orders(
gridpool_id=gridpool_id,
side=MarketSide.BUY,
)
asyncio.run(list_orders())
Streaming Public Trades¤
To get real-time updates on market trades, use the following code:
Stream public trades
import asyncio
from frequenz.client.electricity_trading import Client
# Change server address if needed
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
API_KEY = f.read().strip()
async def stream_trades():
client = Client(
server_url=SERVICE_URL,
auth_key=API_KEY
)
stream_public_trades = await client.stream_public_trades()
async for public_trade in stream_public_trades:
print(f"Received public trade: {public_trade}")
asyncio.run(stream_trades())
Classes¤
frequenz.client.electricity_trading.Client ¤
Bases: BaseApiClient[ElectricityTradingServiceStub]
Electricity trading client.
Source code in frequenz/client/electricity_trading/_client.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
|
Attributes¤
channel
property
¤
channel: Channel
The underlying gRPC channel used to communicate with the server.
Warning
This channel is provided as a last resort for advanced users. It is not recommended to use this property directly unless you know what you are doing and you don't care about being tied to a specific gRPC library.
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
channel_defaults
property
¤
The default options for the gRPC channel.
stub
property
¤
Get the gRPC stub for the Electricity Trading service.
RETURNS | DESCRIPTION |
---|---|
ElectricityTradingServiceAsyncStub
|
The gRPC stub. |
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
Functions¤
__aexit__
async
¤
__aexit__(
_exc_type: type[BaseException] | None,
_exc_val: BaseException | None,
_exc_tb: Any | None,
) -> bool | None
Exit a context manager.
Source code in frequenz/client/base/client.py
__init__ ¤
Initialize the client.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the Electricity Trading service.
TYPE:
|
connect
|
Whether to connect to the server immediately.
TYPE:
|
auth_key
|
The API key for the authorization.
TYPE:
|
Source code in frequenz/client/electricity_trading/_client.py
__new__ ¤
Create a new instance of the client or return an existing one if it already exists.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the Electricity Trading service.
TYPE:
|
connect
|
Whether to connect to the server immediately.
TYPE:
|
auth_key
|
The API key for the authorization.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'Client'
|
The client instance. |
Source code in frequenz/client/electricity_trading/_client.py
cancel_all_gridpool_orders
async
¤
Cancel all orders for a specific Gridpool.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The Gridpool to cancel the orders for.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
The ID of the Gridpool for which the orders were cancelled. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while cancelling all gridpool orders. |
Source code in frequenz/client/electricity_trading/_client.py
cancel_gridpool_order
async
¤
cancel_gridpool_order(
gridpool_id: int,
order_id: int,
timeout: timedelta | None = None,
) -> OrderDetail
Cancel a single order for a given Gridpool.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The Gridpool to cancel the order for.
TYPE:
|
order_id
|
The order to cancel.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OrderDetail
|
The cancelled order. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while cancelling the gridpool order. |
Source code in frequenz/client/electricity_trading/_client.py
connect ¤
connect(server_url: str | None = None) -> None
Connect to the server, possibly using a new URL.
If the client is already connected and the URL is the same as the previous URL, this method does nothing. If you want to force a reconnection, you can call disconnect() first.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the server to connect to. If not provided, the previously used URL is used.
TYPE:
|
Source code in frequenz/client/base/client.py
create_gridpool_order
async
¤
create_gridpool_order(
gridpool_id: int,
delivery_area: DeliveryArea,
delivery_period: DeliveryPeriod,
order_type: OrderType,
side: MarketSide,
price: Price,
quantity: Power,
stop_price: Price | None = None,
peak_price_delta: Price | None = None,
display_quantity: Power | None = None,
execution_option: OrderExecutionOption | None = None,
valid_until: datetime | None = None,
payload: dict[str, Value] | None = None,
tag: str | None = None,
timeout: timedelta | None = None,
) -> OrderDetail
Create a gridpool order.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
ID of the gridpool to create the order for.
TYPE:
|
delivery_area
|
Delivery area of the order.
TYPE:
|
delivery_period
|
Delivery period of the order.
TYPE:
|
order_type
|
Type of the order.
TYPE:
|
side
|
Side of the order.
TYPE:
|
price
|
Price of the order.
TYPE:
|
quantity
|
Quantity of the order.
TYPE:
|
stop_price
|
Stop price of the order.
TYPE:
|
peak_price_delta
|
Peak price delta of the order.
TYPE:
|
display_quantity
|
Display quantity of the order.
TYPE:
|
execution_option
|
Execution option of the order.
TYPE:
|
valid_until
|
Valid until of the order.
TYPE:
|
payload
|
Payload of the order. |
tag
|
Tag of the order.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OrderDetail
|
The created order. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
An error occurred while creating the order. |
Source code in frequenz/client/electricity_trading/_client.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
disconnect
async
¤
Disconnect from the server.
If the client is not connected, this method does nothing.
get_gridpool_order
async
¤
get_gridpool_order(
gridpool_id: int,
order_id: int,
timeout: timedelta | None = None,
) -> OrderDetail
Get a single order from a given gridpool.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The Gridpool to retrieve the order for.
TYPE:
|
order_id
|
The order to retrieve.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OrderDetail
|
The order. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while getting the order. |
Source code in frequenz/client/electricity_trading/_client.py
list_gridpool_orders
async
¤
list_gridpool_orders(
gridpool_id: int,
order_states: list[OrderState] | None = None,
side: MarketSide | None = None,
delivery_period: DeliveryPeriod | None = None,
delivery_area: DeliveryArea | None = None,
tag: str | None = None,
page_size: int | None = None,
timeout: timedelta | None = None,
) -> AsyncIterator[OrderDetail]
List orders for a specific Gridpool with optional filters.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The Gridpool to retrieve the orders for.
TYPE:
|
order_states
|
List of order states to filter by.
TYPE:
|
side
|
The side of the market to filter by.
TYPE:
|
delivery_period
|
The delivery period to filter by.
TYPE:
|
delivery_area
|
The delivery area to filter by.
TYPE:
|
tag
|
The tag to filter by.
TYPE:
|
page_size
|
The number of orders to return per page.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
YIELDS | DESCRIPTION |
---|---|
AsyncIterator[OrderDetail]
|
The list of orders for the given gridpool. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while listing the orders. |
Source code in frequenz/client/electricity_trading/_client.py
list_gridpool_trades
async
¤
list_gridpool_trades(
gridpool_id: int,
trade_states: list[TradeState] | None = None,
trade_ids: list[int] | None = None,
market_side: MarketSide | None = None,
delivery_period: DeliveryPeriod | None = None,
delivery_area: DeliveryArea | None = None,
page_size: int | None = None,
timeout: timedelta | None = None,
) -> AsyncIterator[Trade]
List trades for a specific Gridpool with optional filters.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The Gridpool to retrieve the trades for.
TYPE:
|
trade_states
|
List of trade states to filter by.
TYPE:
|
trade_ids
|
List of trade IDs to filter by. |
market_side
|
The side of the market to filter by.
TYPE:
|
delivery_period
|
The delivery period to filter by.
TYPE:
|
delivery_area
|
The delivery area to filter by.
TYPE:
|
page_size
|
The number of trades to return per page.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
YIELDS | DESCRIPTION |
---|---|
AsyncIterator[Trade]
|
The list of trades for the given gridpool. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while listing gridpool trades. |
Source code in frequenz/client/electricity_trading/_client.py
list_public_trades
async
¤
list_public_trades(
states: list[TradeState] | None = None,
delivery_period: DeliveryPeriod | None = None,
buy_delivery_area: DeliveryArea | None = None,
sell_delivery_area: DeliveryArea | None = None,
page_size: int | None = None,
timeout: timedelta | None = None,
) -> AsyncIterator[PublicTrade]
List all executed public orders with optional filters and pagination.
PARAMETER | DESCRIPTION |
---|---|
states
|
List of order states to filter by.
TYPE:
|
delivery_period
|
The delivery period to filter by.
TYPE:
|
buy_delivery_area
|
The buy delivery area to filter by.
TYPE:
|
sell_delivery_area
|
The sell delivery area to filter by.
TYPE:
|
page_size
|
The number of public trades to return per page.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
YIELDS | DESCRIPTION |
---|---|
AsyncIterator[PublicTrade]
|
The list of public trades for each page. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while listing public trades. |
Source code in frequenz/client/electricity_trading/_client.py
stream_gridpool_orders
async
¤
stream_gridpool_orders(
gridpool_id: int,
order_states: list[OrderState] | None = None,
market_side: MarketSide | None = None,
delivery_area: DeliveryArea | None = None,
delivery_period: DeliveryPeriod | None = None,
tag: str | None = None,
) -> Receiver[OrderDetail]
Stream gridpool orders.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
ID of the gridpool to stream orders for.
TYPE:
|
order_states
|
List of order states to filter for.
TYPE:
|
market_side
|
Market side to filter for.
TYPE:
|
delivery_area
|
Delivery area to filter for.
TYPE:
|
delivery_period
|
Delivery period to filter for.
TYPE:
|
tag
|
Tag to filter for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[OrderDetail]
|
Async generator of orders. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while streaming the orders. |
Source code in frequenz/client/electricity_trading/_client.py
stream_gridpool_trades
async
¤
stream_gridpool_trades(
gridpool_id: int,
trade_states: list[TradeState] | None = None,
trade_ids: list[int] | None = None,
market_side: MarketSide | None = None,
delivery_period: DeliveryPeriod | None = None,
delivery_area: DeliveryArea | None = None,
) -> Receiver[Trade]
Stream gridpool trades.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
The ID of the gridpool to stream trades for.
TYPE:
|
trade_states
|
List of trade states to filter for.
TYPE:
|
trade_ids
|
List of trade IDs to filter for. |
market_side
|
The market side to filter for.
TYPE:
|
delivery_period
|
The delivery period to filter for.
TYPE:
|
delivery_area
|
The delivery area to filter for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[Trade]
|
The gridpool trades streamer. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while streaming gridpool trades. |
Source code in frequenz/client/electricity_trading/_client.py
stream_public_trades
async
¤
stream_public_trades(
states: list[TradeState] | None = None,
delivery_period: DeliveryPeriod | None = None,
buy_delivery_area: DeliveryArea | None = None,
sell_delivery_area: DeliveryArea | None = None,
) -> Receiver[PublicTrade]
Stream public trades.
PARAMETER | DESCRIPTION |
---|---|
states
|
List of order states to filter for.
TYPE:
|
delivery_period
|
Delivery period to filter for.
TYPE:
|
buy_delivery_area
|
Buy delivery area to filter for.
TYPE:
|
sell_delivery_area
|
Sell delivery area to filter for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[PublicTrade]
|
Async generator of orders. |
RAISES | DESCRIPTION |
---|---|
RpcError
|
If an error occurs while streaming public trades. |
Source code in frequenz/client/electricity_trading/_client.py
update_gridpool_order
async
¤
update_gridpool_order(
gridpool_id: int,
order_id: int,
price: Price | None | _Sentinel = NO_VALUE,
quantity: Power | None | _Sentinel = NO_VALUE,
stop_price: Price | None | _Sentinel = NO_VALUE,
peak_price_delta: Price | None | _Sentinel = NO_VALUE,
display_quantity: Power | None | _Sentinel = NO_VALUE,
execution_option: (
OrderExecutionOption | None | _Sentinel
) = NO_VALUE,
valid_until: datetime | None | _Sentinel = NO_VALUE,
payload: dict[str, Value] | None | _Sentinel = NO_VALUE,
tag: str | None | _Sentinel = NO_VALUE,
timeout: timedelta | None = None,
) -> OrderDetail
Update an existing order for a given Gridpool.
PARAMETER | DESCRIPTION |
---|---|
gridpool_id
|
ID of the Gridpool the order belongs to.
TYPE:
|
order_id
|
Order ID.
TYPE:
|
price
|
The updated limit price at which the contract is to be traded. This is the maximum price for a BUY order or the minimum price for a SELL order.
TYPE:
|
quantity
|
The updated quantity of the contract being traded, specified in MW.
TYPE:
|
stop_price
|
Applicable for STOP_LIMIT orders. This is the updated stop price that triggers the limit order.
TYPE:
|
peak_price_delta
|
Applicable for ICEBERG orders. This is the updated price difference between the peak price and the limit price.
TYPE:
|
display_quantity
|
Applicable for ICEBERG orders. This is the updated quantity of the order to be displayed in the order book.
TYPE:
|
execution_option
|
Updated execution options such as All or None, Fill or Kill, etc.
TYPE:
|
valid_until
|
This is an updated timestamp defining the time after which the order should be cancelled if not filled. The timestamp is in UTC.
TYPE:
|
payload
|
Updated user-defined payload individual to a specific order. This can be any data that the user wants to associate with the order. |
tag
|
Updated user-defined tag to group related orders.
TYPE:
|
timeout
|
Timeout duration, defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OrderDetail
|
The updated order. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If no fields to update are provided. |
RpcError
|
An error occurred while updating the order. |
Source code in frequenz/client/electricity_trading/_client.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 |
|
validate_params ¤
validate_params(
price: Price | None | _Sentinel = NO_VALUE,
quantity: Power | None | _Sentinel = NO_VALUE,
stop_price: Price | None | _Sentinel = NO_VALUE,
peak_price_delta: Price | None | _Sentinel = NO_VALUE,
display_quantity: Power | None | _Sentinel = NO_VALUE,
delivery_period: DeliveryPeriod | None = None,
valid_until: datetime | None | _Sentinel = NO_VALUE,
execution_option: (
OrderExecutionOption | None | _Sentinel
) = NO_VALUE,
order_type: OrderType | None = None,
) -> None
Validate the parameters of an order.
This method ensures the following: - Price and quantity values have the correct number of decimal places and are positive. - The delivery_start and valid_until values are in the future.
PARAMETER | DESCRIPTION |
---|---|
price
|
The price of the order.
TYPE:
|
quantity
|
The quantity of the order.
TYPE:
|
stop_price
|
The stop price of the order.
TYPE:
|
peak_price_delta
|
The peak price delta of the order.
TYPE:
|
display_quantity
|
The display quantity of the order.
TYPE:
|
delivery_period
|
The delivery period of the order.
TYPE:
|
valid_until
|
The valid until of the order.
TYPE:
|
execution_option
|
The execution option of the order.
TYPE:
|
order_type
|
The order type.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the parameters are invalid. |
NotImplementedError
|
If the order type is not supported. |
Source code in frequenz/client/electricity_trading/_client.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
frequenz.client.electricity_trading.Currency ¤
Bases: Enum
List of supported currencies.
New currencies can be added to this enum to support additional markets.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
UNSPECIFIED
class-attribute
instance-attribute
¤
Currency is not specified.
Functions¤
from_pb
classmethod
¤
Convert a protobuf Currency value to Currency enum.
PARAMETER | DESCRIPTION |
---|---|
currency
|
Currency to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'Currency'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a Currency object to protobuf Currency.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the Currency object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.DeliveryArea
dataclass
¤
Geographical or administrative region.
These are, usually defined and maintained by a Transmission System Operator (TSO), where electricity deliveries for a contract occur.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
code_type
instance-attribute
¤
code_type: EnergyMarketCodeType
Type of code used for identifying the delivery area itself.
Functions¤
from_pb
classmethod
¤
from_pb(delivery_area: DeliveryArea) -> Self
Convert a protobuf DeliveryArea to DeliveryArea object.
PARAMETER | DESCRIPTION |
---|---|
delivery_area
|
DeliveryArea to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
DeliveryArea object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a DeliveryArea object to protobuf DeliveryArea.
RETURNS | DESCRIPTION |
---|---|
DeliveryArea
|
Protobuf message corresponding to the DeliveryArea object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.DeliveryDuration ¤
Bases: Enum
Specifies the time increment, in minutes, used for electricity deliveries and trading.
These durations serve as the basis for defining the delivery period in contracts, and they dictate how energy is scheduled and delivered to meet contractual obligations.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
MINUTES_15
class-attribute
instance-attribute
¤
15-minute contract duration.
MINUTES_30
class-attribute
instance-attribute
¤
30-minute contract duration.
MINUTES_60
class-attribute
instance-attribute
¤
1-hour contract duration.
UNSPECIFIED
class-attribute
instance-attribute
¤
Default value, indicates that the duration is unspecified.
Functions¤
from_pb
classmethod
¤
Convert a protobuf DeliveryDuration value to DeliveryDuration enum.
PARAMETER | DESCRIPTION |
---|---|
delivery_duration
|
Delivery duration to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'DeliveryDuration'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a DeliveryDuration object to protobuf DeliveryDuration.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the DeliveryDuration object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.DeliveryPeriod ¤
Time period during which the contract is delivered.
It is defined by a start timestamp and a duration.
Source code in frequenz/client/electricity_trading/_types.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
Attributes¤
duration
instance-attribute
¤
duration: DeliveryDuration = MINUTES_60
The length of the delivery period.
start
instance-attribute
¤
Start UTC timestamp represents the beginning of the delivery period. This timestamp is inclusive, meaning that the delivery period starts from this point in time.
Functions¤
__eq__ ¤
Check if two DeliveryPeriod objects are equal.
Source code in frequenz/client/electricity_trading/_types.py
__hash__ ¤
__hash__() -> int
Create hash of the DeliveryPeriod object.
RETURNS | DESCRIPTION |
---|---|
int
|
Hash of the DeliveryPeriod object. |
__init__ ¤
Initialize the DeliveryPeriod object.
PARAMETER | DESCRIPTION |
---|---|
start
|
Start UTC timestamp represents the beginning of the delivery period.
TYPE:
|
duration
|
The length of the delivery period.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the start timestamp does not have a timezone. or if the duration is not 5, 15, 30, or 60 minutes. |
Source code in frequenz/client/electricity_trading/_types.py
__repr__ ¤
__repr__() -> str
Developer-friendly representation of the DeliveryPeriod object.
RETURNS | DESCRIPTION |
---|---|
str
|
Developer-friendly representation of the DeliveryPeriod object. |
__str__ ¤
__str__() -> str
Return string representation of the DeliveryPeriod object.
RETURNS | DESCRIPTION |
---|---|
str
|
String representation of the DeliveryPeriod object. |
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(delivery_period: DeliveryPeriod) -> Self
Convert a protobuf DeliveryPeriod to DeliveryPeriod object.
PARAMETER | DESCRIPTION |
---|---|
delivery_period
|
DeliveryPeriod to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
DeliveryPeriod object corresponding to the protobuf message. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the duration is not 5, 15, 30, or 60 minutes. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a DeliveryPeriod object to protobuf DeliveryPeriod.
RETURNS | DESCRIPTION |
---|---|
DeliveryPeriod
|
Protobuf message corresponding to the DeliveryPeriod object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.EnergyMarketCodeType ¤
Bases: Enum
Specifies the type of identification code used in the energy market.
This is used for uniquely identifying various entities such as delivery areas, market participants, and grid components. This enumeration aims to offer compatibility across different jurisdictional standards.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
EUROPE_EIC
class-attribute
instance-attribute
¤
European Energy Identification Code Standard.
UNSPECIFIED
class-attribute
instance-attribute
¤
Unspecified type. This value is a placeholder and should not be used.
US_NERC
class-attribute
instance-attribute
¤
North American Electric Reliability Corporation identifiers.
Functions¤
from_pb
classmethod
¤
Convert a protobuf EnergyMarketCodeType value to EnergyMarketCodeType enum.
PARAMETER | DESCRIPTION |
---|---|
energy_market_code_type
|
Energy market code type to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'EnergyMarketCodeType'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a EnergyMarketCodeType object to protobuf EnergyMarketCodeType.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the EnergyMarketCodeType object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.GridpoolOrderFilter
dataclass
¤
Parameters for filtering Gridpool orders.
Source code in frequenz/client/electricity_trading/_types.py
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 |
|
Attributes¤
delivery_area
class-attribute
instance-attribute
¤
delivery_area: DeliveryArea | None = None
Delivery area to filter for.
delivery_period
class-attribute
instance-attribute
¤
delivery_period: DeliveryPeriod | None = None
Delivery period to filter for.
order_states
class-attribute
instance-attribute
¤
order_states: list[OrderState] | None = None
List of order states to filter for.
tag
class-attribute
instance-attribute
¤
tag: str | None = None
Tag associated with the orders to be filtered.
Functions¤
__eq__ ¤
Check if two GridpoolOrderFilter objects are equal.
PARAMETER | DESCRIPTION |
---|---|
other
|
GridpoolOrderFilter object to compare with.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the two GridpoolOrderFilter objects are equal, False otherwise. |
Source code in frequenz/client/electricity_trading/_types.py
__hash__ ¤
__hash__() -> int
Create hash of the GridpoolOrderFilter object.
RETURNS | DESCRIPTION |
---|---|
int
|
Hash of the GridpoolOrderFilter object. |
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(gridpool_order_filter: GridpoolOrderFilter) -> Self
Convert a protobuf GridpoolOrderFilter to GridpoolOrderFilter object.
PARAMETER | DESCRIPTION |
---|---|
gridpool_order_filter
|
GridpoolOrderFilter to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
GridpoolOrderFilter object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a GridpoolOrderFilter object to protobuf GridpoolOrderFilter.
RETURNS | DESCRIPTION |
---|---|
GridpoolOrderFilter
|
Protobuf GridpoolOrderFilter corresponding to the object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.GridpoolTradeFilter
dataclass
¤
Parameters for filtering Gridpool trades.
Source code in frequenz/client/electricity_trading/_types.py
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 |
|
Attributes¤
delivery_area
class-attribute
instance-attribute
¤
delivery_area: DeliveryArea | None = None
Delivery area to filter for.
delivery_period
class-attribute
instance-attribute
¤
delivery_period: DeliveryPeriod | None = None
Delivery period to filter for.
trade_ids
class-attribute
instance-attribute
¤
List of trade ids to filter for.
trade_states
class-attribute
instance-attribute
¤
trade_states: list[TradeState] | None = None
List of trade states to filter for.
Functions¤
__eq__ ¤
Check if two GridpoolTradeFilter objects are equal.
PARAMETER | DESCRIPTION |
---|---|
other
|
GridpoolTradeFilter object to compare with.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the two GridpoolTradeFilter objects are equal, False otherwise. |
Source code in frequenz/client/electricity_trading/_types.py
__hash__ ¤
__hash__() -> int
Create hash of the GridpoolTradeFilter object.
RETURNS | DESCRIPTION |
---|---|
int
|
Hash of the GridpoolTradeFilter object. |
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
Convert a protobuf GridpoolTradeFilter to GridpoolTradeFilter object.
PARAMETER | DESCRIPTION |
---|---|
gridpool_trade_filter
|
GridpoolTradeFilter to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'GridpoolTradeFilter'
|
GridpoolTradeFilter object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a GridpoolTradeFilter object to protobuf GridpoolTradeFilter.
RETURNS | DESCRIPTION |
---|---|
GridpoolTradeFilter
|
Protobuf GridpoolTradeFilter corresponding to the object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.MarketActor ¤
Bases: Enum
Actors responsible for an order state change.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
MARKET_OPERATOR
class-attribute
instance-attribute
¤
The market operator was the actor.
UNSPECIFIED
class-attribute
instance-attribute
¤
The actor responsible for the state change has not been specified.
Functions¤
from_pb
classmethod
¤
Convert a protobuf MarketActor value to MarketActor enum.
PARAMETER | DESCRIPTION |
---|---|
market_actor
|
Market actor to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'MarketActor'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a MarketActor enum to protobuf MarketActor value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the MarketActor enum. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.MarketSide ¤
Bases: Enum
Which side of the market the order is on, either buying or selling.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
BUY
class-attribute
instance-attribute
¤
Order to purchase electricity, referred to as a 'bid' in the order book.
SELL
class-attribute
instance-attribute
¤
Order to sell electricity, referred to as an 'ask' or 'offer' in the order book.
UNSPECIFIED
class-attribute
instance-attribute
¤
The side of the market has not been set.
Functions¤
from_pb
classmethod
¤
Convert a protobuf MarketSide value to MarketSide enum.
PARAMETER | DESCRIPTION |
---|---|
market_side
|
Market side to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'MarketSide'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a MarketSide enum to protobuf MarketSide value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the MarketSide enum. |
frequenz.client.electricity_trading.Order
dataclass
¤
Represents an order in the electricity market.
Source code in frequenz/client/electricity_trading/_types.py
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
|
Attributes¤
delivery_area
instance-attribute
¤
delivery_area: DeliveryArea
The delivery area where the contract is to be delivered.
delivery_period
instance-attribute
¤
delivery_period: DeliveryPeriod
The delivery period for the contract.
display_quantity
class-attribute
instance-attribute
¤
display_quantity: Power | None = None
Applicable for ICEBERG orders. The quantity of the order to be displayed in the order book.
execution_option
class-attribute
instance-attribute
¤
execution_option: OrderExecutionOption | None = None
Order execution options such as All or None, Fill or Kill, etc.
payload
class-attribute
instance-attribute
¤
User-defined payload individual to a specific order. This can be any data that needs to be associated with the order.
peak_price_delta
class-attribute
instance-attribute
¤
peak_price_delta: Price | None = None
Applicable for ICEBERG orders. The price difference between the peak price and the limit price.
side
instance-attribute
¤
side: MarketSide
Indicates if the order is on the Buy or Sell side of the market.
stop_price
class-attribute
instance-attribute
¤
stop_price: Price | None = None
Applicable for STOP_LIMIT orders. The stop price that triggers the limit order.
tag
class-attribute
instance-attribute
¤
tag: str | None = None
User-defined tag to group related orders.
valid_until
class-attribute
instance-attribute
¤
valid_until: datetime | None = None
UTC timestamp defining the time after which the order should be cancelled if not filled.
Functions¤
__eq__ ¤
Check if two orders are equal.
PARAMETER | DESCRIPTION |
---|---|
other
|
The other order to compare to.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the orders are equal, False otherwise. |
Source code in frequenz/client/electricity_trading/_types.py
__post_init__ ¤
Post initialization checks to ensure that all datetimes are UTC.
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(order: Order) -> Self
Convert a protobuf Order to Order object.
PARAMETER | DESCRIPTION |
---|---|
order
|
Order to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Order object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert an Order object to protobuf Order.
RETURNS | DESCRIPTION |
---|---|
Order
|
Protobuf message corresponding to the Order object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.OrderDetail
dataclass
¤
Represents an order with full details, including its ID, state, and associated UTC timestamps.
ATTRIBUTE | DESCRIPTION |
---|---|
order_id |
Unique identifier of the order.
TYPE:
|
order |
The details of the order.
TYPE:
|
state_detail |
Details of the order's current state.
TYPE:
|
open_quantity |
Remaining open quantity for this order.
TYPE:
|
filled_quantity |
Filled quantity for this order.
TYPE:
|
create_time |
UTC Timestamp when the order was created.
TYPE:
|
modification_time |
UTC Timestamp of the last update to the order.
TYPE:
|
Source code in frequenz/client/electricity_trading/_types.py
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
|
Functions¤
__post_init__ ¤
Post initialization checks to ensure that all datetimes are UTC.
RAISES | DESCRIPTION |
---|---|
ValueError
|
If create_time or modification_time do not have timezone information. |
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(order_detail: OrderDetail) -> Self
Convert a protobuf OrderDetail to OrderDetail object.
PARAMETER | DESCRIPTION |
---|---|
order_detail
|
OrderDetail to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
OrderDetail object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert an OrderDetail object to protobuf OrderDetail.
RETURNS | DESCRIPTION |
---|---|
OrderDetail
|
Protobuf message corresponding to the OrderDetail object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.OrderExecutionOption ¤
Bases: Enum
Specific behavior for the execution of an order.
These options provide control on how an order is handled in the market.
If no OrderExecutionOption is set, the order remains open until it's fully
fulfilled, cancelled by the client, valid_until
timestamp is reached, or
the end of the trading session.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
AON
class-attribute
instance-attribute
¤
All or None: Order must be executed in its entirety, or not executed at all.
FOK
class-attribute
instance-attribute
¤
Fill or Kill: Order must be executed immediately in its entirety, or not at all.
IOC
class-attribute
instance-attribute
¤
Immediate or Cancel: Any portion of an order that cannot be filled immediately will be cancelled.
UNSPECIFIED
class-attribute
instance-attribute
¤
The order execution option has not been set.
Functions¤
from_pb
classmethod
¤
Convert a protobuf OrderExecutionOption value to OrderExecutionOption enum.
PARAMETER | DESCRIPTION |
---|---|
order_execution_option
|
order execution option to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'OrderExecutionOption'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a OrderExecutionOption object to protobuf OrderExecutionOption.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the OrderExecutionOption object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.OrderState ¤
Bases: Enum
State of an order.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
ACTIVE
class-attribute
instance-attribute
¤
The order has been confirmed and is open in the market. It may be unfilled or partially filled.
CANCELED
class-attribute
instance-attribute
¤
The order has been canceled. This can occur due to a cancellation request by the market participant, system, or market operator.
EXPIRED
class-attribute
instance-attribute
¤
The order has not been filled within the defined duration and has expired.
FAILED
class-attribute
instance-attribute
¤
The order submission failed and was unable to be placed on the order book, usually due to a validation error or system issue.
FILLED
class-attribute
instance-attribute
¤
The order has been completely filled and there are no remaining quantities on the order.
HIBERNATE
class-attribute
instance-attribute
¤
The order has been entered into the system but is not currently exposed to the market. This could be due to certain conditions not yet being met.
PENDING
class-attribute
instance-attribute
¤
The order has been sent to the marketplace but has not yet been confirmed. This can be due to awaiting validation or system processing.
UNSPECIFIED
class-attribute
instance-attribute
¤
The order state is not known. Usually the default state of a newly created order object before any operations have been applied.
Functions¤
from_pb
classmethod
¤
Convert a protobuf OrderState value to OrderState enum.
PARAMETER | DESCRIPTION |
---|---|
order_state
|
Order state to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'OrderState'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert an OrderState enum to protobuf OrderState value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the OrderState enum. |
frequenz.client.electricity_trading.OrderType ¤
Bases: Enum
Type of the order (specifies how the order is to be executed in the market).
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
BALANCE
class-attribute
instance-attribute
¤
Balance order aims to balance supply and demand, usually at a specific location or within a system.(Not yet supported).
BLOCK
class-attribute
instance-attribute
¤
User defined block order, generally a large quantity order filled all at once. (Not yet supported).
ICEBERG
class-attribute
instance-attribute
¤
A large order divided into smaller lots to hide the actual order quantity. Only the visible part of the order is shown in the order book.
LIMIT
class-attribute
instance-attribute
¤
Order to buy or sell at a specific price or better. It remains active until it is filled, cancelled, or expired.
PREARRANGED
class-attribute
instance-attribute
¤
On exchange prearranged trade, a trade that has been privately negotiated and then submitted to the exchange. (Not yet supported).
PRIVATE
class-attribute
instance-attribute
¤
Private and confidential trade, not visible in the public order book and has no market impact. (Not yet supported).
STOP_LIMIT
class-attribute
instance-attribute
¤
An order that will be executed at a specified price, or better, after a given stop price has been reached.
UNSPECIFIED
class-attribute
instance-attribute
¤
The order type has not been set.
Functions¤
from_pb
classmethod
¤
Convert a protobuf OrderType value to OrderType enum.
PARAMETER | DESCRIPTION |
---|---|
order_type
|
Order type to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'OrderType'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert an OrderType enum to protobuf OrderType value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the OrderType enum. |
frequenz.client.electricity_trading.Power
dataclass
¤
Represents power unit in Megawatthours (MW).
Source code in frequenz/client/electricity_trading/_types.py
Functions¤
__str__ ¤
__str__() -> str
Return the string representation of the Power object.
RETURNS | DESCRIPTION |
---|---|
str
|
The string representation of the Power object. |
from_pb
classmethod
¤
from_pb(power: Power) -> Self
Convert a protobuf Power to Power object.
PARAMETER | DESCRIPTION |
---|---|
power
|
Power to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Power object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a Power object to protobuf Power.
RETURNS | DESCRIPTION |
---|---|
Power
|
Protobuf message corresponding to the Power object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.Price
dataclass
¤
Price of an order.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
Functions¤
__str__ ¤
__str__() -> str
Return string representation of the Price object.
RETURNS | DESCRIPTION |
---|---|
str
|
String representation of the Price object. |
from_pb
classmethod
¤
from_pb(price: Price) -> Self
Convert a protobuf Price to Price object.
PARAMETER | DESCRIPTION |
---|---|
price
|
Price to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Price object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a Price object to protobuf Price.
RETURNS | DESCRIPTION |
---|---|
Price
|
Protobuf message corresponding to the Price object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.PublicTrade
dataclass
¤
Represents a public order in the market.
Source code in frequenz/client/electricity_trading/_types.py
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
|
Attributes¤
buy_delivery_area
instance-attribute
¤
buy_delivery_area: DeliveryArea
Delivery area code of the buy side.
delivery_period
instance-attribute
¤
delivery_period: DeliveryPeriod
The delivery period for the contract.
execution_time
instance-attribute
¤
execution_time: datetime
UTC Timestamp of the trades execution time.
public_trade_id
instance-attribute
¤
public_trade_id: int
ID of the order from the public order book.
sell_delivery_area
instance-attribute
¤
sell_delivery_area: DeliveryArea
Delivery area code of the sell side.
Functions¤
__post_init__ ¤
Post initialization checks to ensure that all datetimes are UTC.
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(public_trade: PublicTrade) -> Self
Convert a protobuf PublicTrade to PublicTrade object.
PARAMETER | DESCRIPTION |
---|---|
public_trade
|
PublicTrade to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
PublicTrade object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a PublicTrade object to protobuf PublicTrade.
RETURNS | DESCRIPTION |
---|---|
PublicTrade
|
Protobuf message corresponding to the PublicTrade object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.PublicTradeFilter
dataclass
¤
Parameters for filtering the historic, publicly executed orders (trades).
Source code in frequenz/client/electricity_trading/_types.py
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 |
|
Attributes¤
buy_delivery_area
class-attribute
instance-attribute
¤
buy_delivery_area: DeliveryArea | None = None
Delivery area to filter for on the buy side.
delivery_period
class-attribute
instance-attribute
¤
delivery_period: DeliveryPeriod | None = None
Delivery period to filter for.
sell_delivery_area
class-attribute
instance-attribute
¤
sell_delivery_area: DeliveryArea | None = None
Delivery area to filter for on the sell side.
states
class-attribute
instance-attribute
¤
states: list[TradeState] | None = None
List of order states to filter for.
Functions¤
__eq__ ¤
Check if two PublicTradeFilter objects are equal.
PARAMETER | DESCRIPTION |
---|---|
other
|
PublicTradeFilter object to compare with.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the two PublicTradeFilter objects are equal, False otherwise. |
Source code in frequenz/client/electricity_trading/_types.py
__hash__ ¤
__hash__() -> int
Create hash of the PublicTradeFilter object.
RETURNS | DESCRIPTION |
---|---|
int
|
Hash of the PublicTradeFilter object. |
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(public_trade_filter: PublicTradeFilter) -> Self
Convert a protobuf PublicTradeFilter to PublicTradeFilter object.
PARAMETER | DESCRIPTION |
---|---|
public_trade_filter
|
PublicTradeFilter to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
PublicTradeFilter object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a PublicTradeFilter object to protobuf PublicTradeFilter.
RETURNS | DESCRIPTION |
---|---|
PublicTradeFilter
|
Protobuf PublicTradeFilter corresponding to the object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.StateDetail
dataclass
¤
Details about the current state of the order.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
market_actor
instance-attribute
¤
market_actor: MarketActor
Actor responsible for the current state.
Functions¤
from_pb
classmethod
¤
from_pb(state_detail: StateDetail) -> Self
Convert a protobuf StateDetail to StateDetail object.
PARAMETER | DESCRIPTION |
---|---|
state_detail
|
StateDetail to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
StateDetail object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a StateDetail object to protobuf StateDetail.
RETURNS | DESCRIPTION |
---|---|
StateDetail
|
Protobuf message corresponding to the StateDetail object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.StateReason ¤
Bases: Enum
Reason that led to a state change.
Source code in frequenz/client/electricity_trading/_types.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
|
Attributes¤
DEACTIVATE
class-attribute
instance-attribute
¤
The order was deactivated.
FULL_EXECUTION
class-attribute
instance-attribute
¤
The order was fully executed.
ICEBERG_SLICE_ADD
class-attribute
instance-attribute
¤
An iceberg slice was added.
PARTIAL_EXECUTION
class-attribute
instance-attribute
¤
The order was partially executed.
QUOTE_ADD
class-attribute
instance-attribute
¤
A quote was added.
QUOTE_FULL_EXECUTION
class-attribute
instance-attribute
¤
A quote was fully executed.
QUOTE_PARTIAL_EXECUTION
class-attribute
instance-attribute
¤
A quote was partially executed.
UNKNOWN_STATE
class-attribute
instance-attribute
¤
The state of the order is unknown.
UNSPECIFIED
class-attribute
instance-attribute
¤
The reason for the state change has not been specified.
VALIDATION_FAIL
class-attribute
instance-attribute
¤
The order failed validation.
Functions¤
from_pb
classmethod
¤
Convert a protobuf StateReason value to StateReason enum.
PARAMETER | DESCRIPTION |
---|---|
state_reason
|
State reason to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'StateReason'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a StateReason enum to protobuf StateReason value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the StateReason enum. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.Trade
dataclass
¤
Represents a private trade in the electricity market.
Source code in frequenz/client/electricity_trading/_types.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
Attributes¤
delivery_period
instance-attribute
¤
delivery_period: DeliveryPeriod
The delivery period for the contract.
execution_time
instance-attribute
¤
execution_time: datetime
UTC Timestamp of the trade's execution time.
side
instance-attribute
¤
side: MarketSide
Indicates if the trade's order was on the Buy or Sell side of the market.
Functions¤
__post_init__ ¤
Post initialization checks to ensure that all datetimes are UTC.
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(trade: Trade) -> Self
Convert a protobuf Trade to Trade object.
PARAMETER | DESCRIPTION |
---|---|
trade
|
Trade to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
Trade object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a Trade object to protobuf Trade.
RETURNS | DESCRIPTION |
---|---|
Trade
|
Protobuf message corresponding to the Trade object. |
Source code in frequenz/client/electricity_trading/_types.py
frequenz.client.electricity_trading.TradeState ¤
Bases: Enum
State of a trade.
Source code in frequenz/client/electricity_trading/_types.py
Attributes¤
ACTIVE
class-attribute
instance-attribute
¤
The trade has been executed in the market.
APPROVAL_REQUESTED
class-attribute
instance-attribute
¤
An approval has been requested.
CANCELED
class-attribute
instance-attribute
¤
The trade has been cancelled. This can occur due to a cancellation request by the market participant, system, or market operator.
CANCEL_REJECTED
class-attribute
instance-attribute
¤
The trade cancellation request was rejected.
CANCEL_REQUESTED
class-attribute
instance-attribute
¤
A cancellation request for the trade has been submitted.
RECALL
class-attribute
instance-attribute
¤
The trade has been recalled. This could be due to a system issue or a request from the market participant or market operator.
RECALL_REJECTED
class-attribute
instance-attribute
¤
The trade recall request was rejected.
RECALL_REQUESTED
class-attribute
instance-attribute
¤
A recall request for the trade has been submitted.
UNSPECIFIED
class-attribute
instance-attribute
¤
The state is not known.
Functions¤
from_pb
classmethod
¤
Convert a protobuf TradeState value to TradeState enum.
PARAMETER | DESCRIPTION |
---|---|
trade_state
|
The trade state to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
'TradeState'
|
Enum value corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a TradeState enum to protobuf TradeState value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
Protobuf message corresponding to the TradeState enum. |
frequenz.client.electricity_trading.UpdateOrder
dataclass
¤
Represents the order properties that can be updated after an order has been placed.
At least one of the optional fields must be set for an update to take place.
Source code in frequenz/client/electricity_trading/_types.py
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 |
|
Attributes¤
display_quantity
class-attribute
instance-attribute
¤
display_quantity: Power | None = None
Applicable for ICEBERG orders. This is the updated quantity of the order to be displayed in the order book.
execution_option
class-attribute
instance-attribute
¤
execution_option: OrderExecutionOption | None = None
Updated execution options such as All or None, Fill or Kill, etc.
payload
class-attribute
instance-attribute
¤
Updated user-defined payload individual to a specific order. This can be any data that the user wants to associate with the order.
peak_price_delta
class-attribute
instance-attribute
¤
peak_price_delta: Price | None = None
Applicable for ICEBERG orders. This is the updated price difference between the peak price and the limit price.
price
class-attribute
instance-attribute
¤
price: Price | None = None
The updated limit price at which the contract is to be traded. This is the maximum price for a BUY order or the minimum price for a SELL order.
quantity
class-attribute
instance-attribute
¤
quantity: Power | None = None
The updated quantity of the contract being traded, specified in MW.
stop_price
class-attribute
instance-attribute
¤
stop_price: Price | None = None
Applicable for STOP_LIMIT orders. This is the updated stop price that triggers the limit order.
tag
class-attribute
instance-attribute
¤
tag: str | None = None
Updated user-defined tag to group related orders.
valid_until
class-attribute
instance-attribute
¤
valid_until: datetime | None = None
This is an updated timestamp defining the time after which the order should be cancelled if not filled. The timestamp is in UTC.
Functions¤
__post_init__ ¤
Post initialization checks to ensure that all datetimes are UTC.
Source code in frequenz/client/electricity_trading/_types.py
from_pb
classmethod
¤
from_pb(update_order: UpdateOrder) -> Self
Convert a protobuf UpdateOrder to UpdateOrder object.
PARAMETER | DESCRIPTION |
---|---|
update_order
|
UpdateOrder to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
UpdateOrder object corresponding to the protobuf message. |
Source code in frequenz/client/electricity_trading/_types.py
to_pb ¤
Convert a UpdateOrder object to protobuf UpdateOrder.
RETURNS | DESCRIPTION |
---|---|
UpdateOrder
|
Protobuf UpdateOrder corresponding to the object. |