eb_nordpool

Crates.ioeb_nordpool
lib.rseb_nordpool
version0.4.1
created_at2024-08-05 17:02:09.443373+00
updated_at2025-05-14 15:56:34.762541+00
descriptionExtract elspot prices from nordpool
homepage
repositoryhttps://github.com/emilbratt/eb_nordpool
max_upload_size
id1326235
size1,232,102
Emil Bratt (emilbratt)

documentation

README

EB NordPool - An elspot fetching Library 🦀

  • Fetch elspot prices from NordPool with Rust

Getting Started

use eb_nordpool::{
    elspot::from_nordpool,
    elspot::dataportal_dayaheadprices::{regions, currencies},
    units,
};

// Select date in "YYYY-MM-DD" format (NOTE: only last two months).
let date = "2025-05-14";
// Select currency.
let currency = "EUR";
// Select regions.
let _regions = vec!["NO1", "SE3", "FI"]; // Must have at least one.
// or select all regions..
let regions = regions::SUPPORTED_REGIONS.iter().map(|r| r.as_ref()).collect::<Vec<&str>>();

// NOTE: you can easily print out all supported currencies and regions..
currencies::list_supported();
regions::list_supported();

// Now we can download data.
let data = from_nordpool(currency, date, &regions).unwrap();

// And now we can extract the prices and do stuff.
let mut regions = data.extract_prices_all_regions();
for prices in regions.iter_mut() {
    for p in prices.into_iter() {
        let (from, to) = p.from_to();
        println!("{} | From: {from} - To: {to}", p.region);

        println!("{}", p.price_label());

        // Convert to more sane units.
        units::convert_to_kwh(p);
        units::convert_to_currency_fraction(p);

        println!("{}\n", p.price_label());

        // Get price as float.
        let _p = p.as_f64();
    }
}

println!("date: {}", data.date());
println!("currency: {}", data.currency());
println!("is final: {}", data.is_final());

Refer to crate docs for more details on how to fetch prices.

Testing

For all but the "ignored" ones found in download.rs.

cargo test

For ignored ones in download.rs (uses no capture because we need to read output data).

cargo test -- --ignored --nocapture
Commit count: 76

cargo fmt