Skip to content

Commit 4c10890

Browse files
committed
Fix init file example errors
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 1d53c1e commit 4c10890

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

src/frequenz/client/electricity_trading/__init__.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
with the specific version you wish to install.
2525
2626
# Choose the version you want to install
27-
```python
27+
```bash
2828
VERSION=0.2.3
2929
pip install frequenz-client-electricity-trading==$VERSION
3030
```
@@ -40,7 +40,8 @@
4040
4141
# Change server address if needed
4242
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
43-
API_KEY = open('/path/to/api_key.txt').read().strip()
43+
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
44+
API_KEY = f.read().strip()
4445
client = Client(
4546
server_url=SERVICE_URL,
4647
auth_key=API_KEY
@@ -58,6 +59,7 @@
5859
5960
```python
6061
from frequenz.client.electricity_trading import (
62+
Client,
6163
Currency,
6264
DeliveryArea,
6365
DeliveryPeriod,
@@ -70,8 +72,17 @@
7072
from datetime import datetime, timedelta
7173
from decimal import Decimal
7274
75+
# Change server address if needed
76+
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
77+
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
78+
API_KEY = f.read().strip()
79+
client = Client(
80+
server_url=SERVICE_URL,
81+
auth_key=API_KEY
82+
)
83+
7384
# Define order parameters
74-
gridpool_id = 1
85+
GRIDPOOL_ID = 1
7586
delivery_area = DeliveryArea(
7687
code="10YDE-EON------1", # TenneT
7788
code_type=EnergyMarketCodeType.EUROPE_EIC
@@ -83,7 +94,7 @@
8394
price = Price(amount=Decimal("50.0"), currency=Currency.EUR)
8495
quantity = Energy(mwh=Decimal("0.1"))
8596
order = await client.create_gridpool_order(
86-
gridpool_id=gridpool_id,
97+
gridpool_id=GRIDPOOL_ID,
8798
delivery_area=delivery_area,
8899
delivery_period=delivery_period,
89100
order_type=OrderType.LIMIT,
@@ -99,7 +110,18 @@
99110
???+ example "List orders for a gridpool"
100111
101112
```python
102-
from frequenz.client.electricity_trading import MarketSide
113+
from frequenz.client.electricity_trading import ( Client, MarketSide )
114+
115+
# Change server address if needed
116+
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
117+
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
118+
API_KEY = f.read().strip()
119+
client = Client(
120+
server_url=SERVICE_URL,
121+
auth_key=API_KEY
122+
)
123+
124+
gridpool_id: int = 1
103125
104126
# List all orders for a given gridpool
105127
orders = await client.list_gridpool_orders(
@@ -120,6 +142,16 @@
120142
121143
???+ example "Stream public trades"
122144
```python
145+
from frequenz.client.electricity_trading import Client
146+
147+
# Change server address if needed
148+
SERVICE_URL = "grpc://electricity-trading.api.frequenz.com:443?ssl=true"
149+
with open('/path/to/api_key.txt', 'r', encoding='utf-8') as f:
150+
API_KEY = f.read().strip()
151+
client = Client(
152+
server_url=SERVICE_URL,
153+
auth_key=API_KEY
154+
)
123155
stream_public_trades = await client.stream_public_trades()
124156
async for public_trade in stream_public_trades:
125157
print(f"Received public trade: {public_trade}")

0 commit comments

Comments
 (0)