| Crates.io | dukascopy_rust |
| lib.rs | dukascopy_rust |
| version | 0.2.0 |
| created_at | 2025-05-08 12:56:25.270895+00 |
| updated_at | 2025-05-08 12:56:25.270895+00 |
| description | Rust wrapper for Dukascopy’s free charting API |
| homepage | https://github.com/Erhabor-Fona/dukascopy_rust |
| repository | https://github.com/Erhabor-Fona/dukascopy_rust |
| max_upload_size | |
| id | 1665307 |
| size | 64,380 |
Rust wrapper for Dukascopy’s free charting API. Provides:
fetch_instrument_groups()fetch(...) → raw rows or typed Candlestream(...) → async Stream of ticksCandle model via TryFrom<Vec<Value>>[dependencies]
dukascopy_rust = "0.2"
cargo build
use dukascopy_rust::{
instrument_generator::fetch_instrument_groups,
dukascopy_base::{fetch, stream},
models::Candle,
};
use chrono::{Utc, TimeZone};
use futures::{StreamExt, pin_mut};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1) Instrument groups
let groups = fetch_instrument_groups(None).await?;
println!("Groups: {:?}", groups.keys());
// 2) Historical OHLCV
let start = Utc.with_ymd_and_hms(2025, 1, 1, 0, 0, 0).unwrap()
.timestamp_millis();
let raw: Vec<Vec<serde_json::Value>> =
fetch("EUR/USD", "1DAY", "B", start, Some(5), None).await?;
let candles: Vec<Candle> = raw
.into_iter()
.map(Candle::try_from)
.collect::<Result<_, _>>()?;
println!("Candles: {:#?}", candles);
// 3) Live tick stream (10s)
let now = Utc::now().timestamp_millis() - 2_000;
let mut ticks = stream("EUR/USD".into(), "TICK".into(), "B".into(),
now, Some(now + 10_000), None);
pin_mut!(ticks);
while let Some(t) = ticks.next().await {
println!("Tick: {:?}", t);
}
Ok(())
}
Dual-licensed under MIT. See LICENSE-MIT for details.