Skip to main content

An easy way to nagivate EFA blocks and settlement periods in GB electricity trading.

Project description

efaciency

Tests PyPi Coverage

A package to simplify working with EFA blocks and settlement periods in the GB electricity trading system.

Installation

This package can be installed via pip:

$ pip install efaciency

Examples

Settlement periods

Get the starting timestamp for a settlement period.

>>> from datetime import date, datetime
>>> import efaciency

>>> efaciency.sp.to_ts(settlement_period=4)  # defaults to today as settlement date
datetime.datetime(2025, 2, 18, 1, 30, tzinfo=zoneinfo.ZoneInfo(key='Europe/London'))

>>> efaciency.sp.to_ts(settlement_period=13, settlement_date=date(2025, 5, 23))
datetime.datetime(2025, 5, 23, 6, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/London'))

You can also get the settlement for a given timestamp:

>>> efaciency.sp.from_ts(ts=datetime(2025, 1, 12, 17, 30))
36

EFA blocks

Get the starting and ending timestamp for an EFA block.

>>> from datetime import date, datetime
>>> import efaciency

>>> efaciency.block.to_start_ts(efa_block=3)  # defaults to today as EFA date
datetime.datetime(2025, 2, 18, 7, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/London'))

>>> efaciency.block.to_start_ts(efa_block=1, efa_date=date(2025, 5, 23))
datetime.datetime(2025, 5, 22, 23, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/London'))

You can also get the EFA block for a given timestamp:

>>> efaciency.block.from_ts(ts=datetime(2025, 1, 12, 17, 30))
5

What about clock change?

If a datetime with no timezone is provided, efaciency always assumes Europe/London timezone.

On clock change days, a tz-aware datetime must be passed or the fold parameter must be used.

>>> efaciency.sp.from_ts(datetime(2025, 10, 26, 1))
3

>>> efaciency.sp.from_ts(datetime(2025, 10, 26, 1).replace(fold=1))
5

Usage with Pandas or Polars

Examples of efaciency usage with Pandas or Polars dataframes:

# pandas
df["sp"] = df["ts"].apply(efaciency.sp.from_ts)
# polars
df.with_columns(pl.col("ts").map_elements(efaciency.sp.from_ts, return_dtype=pl.Int64).alias("sp"))

CLI

You can also use the efaciency CLI:

efaciency --help

Contribution

Please make a pull request or log an issue on GitHub.

License

Code is released as free software under the MIT License (see LICENSE file).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

efaciency-0.4.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

efaciency-0.4.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file efaciency-0.4.1.tar.gz.

File metadata

  • Download URL: efaciency-0.4.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for efaciency-0.4.1.tar.gz
Algorithm Hash digest
SHA256 c5ef4fa64bb8d9edc9213b218562abe627d89cc7b1f205676cceea849460fe2d
MD5 57decb1874f0b9f588983b31eb5375ad
BLAKE2b-256 a28aa48c88a3ec0da34cb6603c52a4a11c47ff087911500a5ed86f94356967e6

See more details on using hashes here.

File details

Details for the file efaciency-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: efaciency-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for efaciency-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1257b42cc3a602b2e6ec1fd47a1a0b27b63b6667f85e22e3e127fec28fd05317
MD5 b6cc0a16ba3d09417ff1e04febf55adf
BLAKE2b-256 4f3d50714fa7245651bd7fe61be21174bff31fd070353d069c6e409ce648dfb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page