| Crates.io | eb_nordpool |
| lib.rs | eb_nordpool |
| version | 0.4.1 |
| created_at | 2024-08-05 17:02:09.443373+00 |
| updated_at | 2025-05-14 15:56:34.762541+00 |
| description | Extract elspot prices from nordpool |
| homepage | |
| repository | https://github.com/emilbratt/eb_nordpool |
| max_upload_size | |
| id | 1326235 |
| size | 1,232,102 |
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, ®ions).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.
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