Skip to content

day_ahead

frequenz.client.electricity_trading.cli.day_ahead ¤

Functions for CLI tool to interact with the trading API.

Functions¤

frequenz.client.electricity_trading.cli.day_ahead.list_day_ahead_prices ¤

list_day_ahead_prices(
    entsoe_key: str,
    start: datetime,
    end: datetime,
    country_code: str,
) -> None

List day-ahead prices for a given country code.

PARAMETER DESCRIPTION
entsoe_key

The API key for the Entsoe API

TYPE: str

start

The start date of the query

TYPE: datetime

end

The end date of the query

TYPE: datetime

country_code

The country code for which to query the prices

TYPE: str

Source code in frequenz/client/electricity_trading/cli/day_ahead.py
def list_day_ahead_prices(
    entsoe_key: str,
    start: datetime,
    end: datetime,
    country_code: str,
) -> None:
    """
    List day-ahead prices for a given country code.

    Args:
        entsoe_key: The API key for the Entsoe API
        start: The start date of the query
        end: The end date of the query
        country_code: The country code for which to query the prices
    """
    start_ts = pd.Timestamp(start)
    end_ts = pd.Timestamp(end)

    client = EntsoePandasClient(api_key=entsoe_key)
    da_prices = client.query_day_ahead_prices(country_code, start=start_ts, end=end_ts)

    da_prices.name = "price"
    da_prices.index.name = "timestamp"

    print(da_prices.to_csv())