Download and stream historical price data for variety of financial instruments (Forex, Commodities and Indices) from Dukascopy Bank SA.
Maintained. Last release 13 days ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install dukascopy-pythondukascopy-python
Download historical financial market data from Dukascopy Bank SA, including tick-level prices and OHLCV candles for Forex, commodities, indices, and other financial instruments.
Supports multiple data feed versions, configurable HTTP sessions, optional logging, and Pandas integration.
Installation
pip install dukascopy-python
Backward Compatibility
The previous API remains available through dukascopy_python.compat, which uses data feed version 1 internally.
Existing applications can continue using fetch(), live_fetch(), and legacy constants by updating their imports.
from datetime import datetime, timezone
import dukascopy_python.compat as duka
from dukascopy_python.compat.instruments import (
INSTRUMENT_FX_MAJORS_EUR_USD,
)
df = duka.fetch(
INSTRUMENT_FX_MAJORS_EUR_USD,
duka.INTERVAL_MIN_1,
duka.OFFER_SIDE_BID,
datetime(2025, 1, 1, tzinfo=timezone.utc),
datetime(2025, 1, 2, tzinfo=timezone.utc),
)
df.to_csv("output.csv")
New API
The new API provides two functions:
fetch_candles()— Retrieve historical OHLCV candles.fetch_ticks()— Retrieve historical bid/ask tick data.
Fetch Candles
from datetime import datetime, timezone
import dukascopy_python as duka
from dukascopy_python.instruments import I_EUR_USD
candles = duka.fetch_candles(
instrument=I_EUR_USD,
interval=1,
time_unit=duka.TimeUnit.HOUR,
offer_side=duka.OfferSide.BID,
start=datetime(2025, 1, 1, tzinfo=timezone.utc),
end=datetime(2025, 2, 1, tzinfo=timezone.utc),
version=2,
)
for candle in candles:
print(candle)
Fetch Ticks
ticks = duka.fetch_ticks(
instrument=I_EUR_USD,
start=datetime(2025, 1, 1, tzinfo=timezone.utc),
end=datetime(2025, 1, 2, tzinfo=timezone.utc),
version=2,
)
for tick in ticks:
print(tick)
Both functions return iterable model objects.
Parameters
| Parameter | Description |
|---|---|
instrument |