battery_optimizer.utils#

Functions

clean_filename(filename)

datetime_to_trading_block(settlement_period)

Calculates the corresponding trading block number for the given time and number of blocks per day.

get_market_type_for_frequency_product(product)

get_true_locations(df)

Get locations of True values in a boolean DataFrame.

Classes

Country(*values)

FrequencyProductDirection(*values)

FrequencyProductType(*values)

FrequencyProductVariable(*values)

HUVariablesEnum(*values)

IntradayDeliveryLength(*values)

IntradayResultAggregationName(*values)

IntradayStrategyName(*values)

MarketType(*values)

Canonical market identifiers used by optimization requests and results.

MelMilSide(*values)

MelMilVersion(*values)

ObjectiveName(*values)

PowerUnits(*values)

ProblemType(*values)

RampingLogicName(*values)

SoEAnchor(*values)

Settlement-period instant a knee point's power/energy values are evaluated against.

UseCase(*values)

class battery_optimizer.utils.Country(*values)#

Bases: StrEnum

DE = 'de'#
HU = 'hu'#
NL = 'nl'#
UK = 'uk'#
classmethod from_str(value)#
Parameters:

value (str)

get_tz()#
class battery_optimizer.utils.FrequencyProductDirection(*values)#

Bases: StrEnum

NEG = 'neg'#
POS = 'pos'#
class battery_optimizer.utils.FrequencyProductType(*values)#

Bases: StrEnum

AFRR_CAPACITY_NEG = 'afrr_capacity_neg'#
AFRR_CAPACITY_POS = 'afrr_capacity_pos'#
AFRR_ENERGY_NEG = 'afrr_energy_neg'#
AFRR_ENERGY_POS = 'afrr_energy_pos'#
DCH = 'dch'#
DCL = 'dcl'#
DMH = 'dmh'#
DML = 'dml'#
DRH = 'drh'#
DRL = 'drl'#
FCR = 'fcr'#
class battery_optimizer.utils.FrequencyProductVariable(*values)#

Bases: StrEnum

AFRR_CAPACITY_NEG_VOL = 'afrr_capacity_neg_vol'#
AFRR_CAPACITY_POS_VOL = 'afrr_capacity_pos_vol'#
AFRR_ENERGY_NEG_VOL = 'afrr_energy_neg_vol'#
AFRR_ENERGY_POS_VOL = 'afrr_energy_pos_vol'#
DCH_VOL = 'dch_vol'#
DCL_VOL = 'dcl_vol'#
DMH_VOL = 'dmh_vol'#
DML_VOL = 'dml_vol'#
DRH_VOL = 'drh_vol'#
DRL_VOL = 'drl_vol'#
FCR_VOL = 'fcr_vol'#
class battery_optimizer.utils.HUVariablesEnum(*values)#

Bases: StrEnum

IS_PV_TO_BATTERY = 'is_PV_to_battery'#
PV_TO_BATTERY_KW = 'PV_to_battery_kw'#
PV_TO_GRID_INTRADAY_SELL_KW = 'pv_to_grid_intraday_sell_kw'#
PV_TO_GRID_KW = 'PV_to_grid_kw'#
class battery_optimizer.utils.IntradayDeliveryLength(*values)#

Bases: StrEnum

half_hour = 'HalfHour'#
quarter_hour = 'QuarterHour'#
class battery_optimizer.utils.IntradayResultAggregationName(*values)#

Bases: StrEnum

minmax = 'minmax'#
raw = 'raw'#
class battery_optimizer.utils.IntradayStrategyName(*values)#

Bases: StrEnum

bucket = 'bucket'#
vwap = 'vwap'#
class battery_optimizer.utils.MarketType(*values)#

Bases: StrEnum

Canonical market identifiers used by optimization requests and results.

This enum defines the normalized market taxonomy used throughout the optimizer, including spot, intraday, balancing, and ancillary-service markets.

Notes

  • Members defined with auto() use enum.StrEnum default behavior, i.e. their serialized value is the lower-cased member name.

  • EPEX_IDA1 and EPEX_DA keep explicit values for backward compatibility with external payloads and historical datasets.

IMBALANCE#

Imbalance settlement market used to settle real-time deviations versus nominated schedules.

INTRADAY#

Intraday continuous wholesale market.

EPEX_IDA1#

EPEX Spot Intraday Auction 1 product identifier.

EPEX_DA#

EPEX Spot day-ahead auction market identifier.

FCR#

Frequency Containment Reserve market (primary frequency response).

AFRR_CAPACITY#

aFRR capacity reservation market (availability payment for reserved upward and/or downward balancing capacity).

AFRR_ENERGY_POS#

Positive aFRR activation energy market (upward regulation / discharge-side activation).

AFRR_ENERGY_NEG#

Negative aFRR activation energy market (downward regulation / charge-side activation).

DC#

UK Dynamic Containment service market.

DR#

UK Dynamic Regulation service market.

DM#

UK Dynamic Moderation service market.

N2EX1h#

N2EX hourly day-ahead auction product.

EPEX30MIN#

EPEX half-hour day-ahead product.

VIRTUAL_WHOLESALE#

Additional synthetic market that is used only for internal purposes, such as the day-ahead extension of the intraday continuous market. Note that this market is not meant to be used in external payloads and should not be exposed outside of the optimizer’s internal logic. Further note that for this market we do not allow the caller to provide already marketed volumes.

AFRR_CAPACITY = 'afrr_capacity'#
AFRR_ENERGY_NEG = 'afrr_energy_neg'#
AFRR_ENERGY_POS = 'afrr_energy_pos'#
DC = 'dc'#
DM = 'dm'#
DR = 'dr'#
EPEX30MIN = 'epex30min'#
EPEX_DA = 'epexDA'#
EPEX_IDA1 = 'epexIDA1'#
FCR = 'fcr'#
HUPXDA = 'hupxda'#
IMBALANCE = 'imbalance'#
INTRADAY = 'intraday'#
N2EX1h = 'n2ex1h'#
VIRTUAL_WHOLESALE = 'virtual_wholesale'#
class battery_optimizer.utils.MelMilSide(*values)#

Bases: StrEnum

mel = 'mel'#
mil = 'mil'#
class battery_optimizer.utils.MelMilVersion(*values)#

Bases: StrEnum

v1 = 'v1'#
v2 = 'v2'#
class battery_optimizer.utils.ObjectiveName(*values)#

Bases: StrEnum

mel = 'mel'#
mil = 'mil'#
pnl = 'pnl'#
class battery_optimizer.utils.PowerUnits(*values)#

Bases: StrEnum

KW = 'kW'#
MW = 'MW'#
ONEHUNDREDKW = '100kW'#
TENKW = '10kW'#
class battery_optimizer.utils.ProblemType(*values)#

Bases: StrEnum

AFRR_ENERGY = 'afrr_energy'#
BOD = 'bod'#
MDO_MDB = 'mdo_mdb'#
MELMIL = 'melmil'#
MELMILBOA = 'melmilboa'#
MELMILNOW = 'melmilnow'#
PNL = 'pnl'#
class battery_optimizer.utils.RampingLogicName(*values)#

Bases: StrEnum

dc_only = 'dc_only'#
class battery_optimizer.utils.SoEAnchor(*values)#

Bases: StrEnum

Settlement-period instant a knee point’s power/energy values are evaluated against.

end = 'end'#
start = 'start'#
class battery_optimizer.utils.UseCase(*values)#

Bases: StrEnum

BESS = 'bess'#
EV = 'ev'#
battery_optimizer.utils.clean_filename(filename)#
Parameters:

filename (str)

Return type:

str

battery_optimizer.utils.datetime_to_trading_block(settlement_period, blocks_per_day=48)#

Calculates the corresponding trading block number for the given time and number of blocks per day.

Block numbers start from 1 up to the number of blocks per day.

Example 1: in a 30 minutes per block market, i.e. 48 blocks/day, 00:00 -> 1 06:30 -> 14 23:30 -> 48

Example 2: in a 15 minutes per block market, i.e. 96 blocks/day, 00:00 -> 1 12:15 -> 50 12:30 -> 51 12:45 -> 52 23:30 -> 96

Args:

settlement_period (datetime): start time of a trading block blocks_per_day (int, optional): number of trading blocks in one day for this particular market. Defaults to 48.

Raises:

ValueError: Raised if wrong number of trading blocks provided

Returns:

int: corresponding trading block for given time

Parameters:
Return type:

int

battery_optimizer.utils.get_market_type_for_frequency_product(product)#
Parameters:

product (FrequencyProductType)

Return type:

MarketType

battery_optimizer.utils.get_true_locations(df)#

Get locations of True values in a boolean DataFrame.

Parameters: df (pd.DataFrame): DataFrame with boolean values

Returns: list: List of tuples containing (index, column) for True values