21 unstable releases (3 breaking)
Uses new Rust 2024
| 0.4.1 | May 14, 2025 |
|---|---|
| 0.3.1 | Apr 1, 2025 |
| 0.2.5 | Mar 12, 2025 |
| 0.2.2 | Dec 22, 2024 |
| 0.2.0 | Nov 8, 2024 |
#62 in Finance
1,600 downloads per month
76KB
1K
SLoC
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, ®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.
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
Dependencies
~13–28MB
~293K SLoC