dukascopy-fx
Library-first Rust fetcher for Dukascopy historical market data.
This crate is built mainly as a library for quant/research pipelines and apps.
CLI tooling exists, but is secondary.
Why this crate
- Simple yfinance-like API (
Ticker,history,rate_at) - Works for FX pairs and single symbols (equities/indices/metals)
- Automatic instrument scaling (standard FX, JPY, metals, index-like)
- Built-in retry/backoff, request limiting, LRU cache
- Incremental update support with checkpoints
- Universe catalog with aliases (e.g.
AAPL -> AAPLUS)
Installation
[]
= "0.4"
= { = "1", = ["full"] }
Quick Start (recommended)
use ;
async
API Guide
1) Single symbol or pair with one input
Use unified parsing when user input may be mixed (AAPL or EUR/USD).
use ;
use now;
let fx = get_rate_for_input.await?;
let stock = get_rate_for_input.await?;
let req = symbol?;
let msft = get_rate_for_request.await?;
Parsing rules:
- input containing
/-> explicit pair - other input -> single symbol
2) Ticker API
use ;
use Duration;
let t1 = new;
let t2: Ticker = "GBP/JPY".parse?;
let t3 = ticker!;
let month = t1.history.await?;
let day_30m = t1.interval.history.await?;
3) Function API
use ;
use Duration;
let eurusd = get_rate.await?;
let aapl_pln = get_rate_in_quote.await?;
let series = get_rates_range.await?;
4) Batch download
use ;
let tickers = vec!;
let batch = download.await?;
5) Incremental updates (checkpoint)
use ;
use Duration;
let store = open?;
let ticker = new.interval;
let rows = ticker.fetch_incremental.await?;
println!;
Advanced Client (power users)
Use advanced API when you need explicit control over resolution, aliases, quote defaults, and custom instrument configs.
use ;
let client = new
.cache_size
.timeout_secs
.default_quote_currency
.pair_resolution_mode
.code_alias
.with_instrument_config
.build;
let _ = client;
Instrument Coverage
Typical instrument families:
| Type | Typical Divisor | Typical Decimals | Examples |
|---|---|---|---|
| Standard FX | 100,000 | 5 | EUR/USD, GBP/USD |
| JPY pairs | 1,000 | 3 | USD/JPY, EUR/JPY |
| Metals | 1,000 | 3 | XAU/USD, XAG/USD |
| Index/equity-like | 1,000 (common) | 2 | USA500IDX/USD, AAPLUS/USD |
Universe file (config/universe.json) supports:
- instrument definitions (
symbol,base,quote,asset_class, etc.) - alias mapping (
code_aliases) - alias chains (
SP500 -> US500 -> USA500IDX)
Optional CLI (fetcher workflows)
Binary: fx_fetcher
Typical flow:
# 1) sync/refresh universe
# 2) initial backfill
# 3) incremental update
Core commands:
list-instrumentsbackfillupdatesync-universeexport
Data Notes
- Historical depth depends on instrument (major FX often available since 2003)
- Data is fetched from hourly files; latest complete data is usually delayed by ~1 hour
- Weekend handling adjusts requests to last available trading timestamp
Troubleshooting
Invalid currency code
- use alphanumeric codes, length
2..12 - for market symbols, use canonical code or alias map
DataNotFound
- requested timestamp may be outside available history
- market may be closed
- instrument may not have data for that timeframe
No conversion route
- set conversion mode to synthetic and configure bridge currencies in advanced client
License
MIT