dukascopy-python 4.0.1__tar.gz → 6.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. dukascopy_python-6.0.0/PKG-INFO +302 -0
  2. dukascopy_python-6.0.0/README.md +262 -0
  3. dukascopy_python-6.0.0/dukascopy_python/__init__.py +182 -0
  4. {dukascopy_python-4.0.1/dukascopy_python → dukascopy_python-6.0.0/dukascopy_python/compat}/__init__.py +17 -1
  5. {dukascopy_python-4.0.1/dukascopy_python → dukascopy_python-6.0.0/dukascopy_python/compat}/instruments.py +1510 -0
  6. dukascopy_python-6.0.0/dukascopy_python/core/__init__.py +22 -0
  7. dukascopy_python-6.0.0/dukascopy_python/core/http.py +34 -0
  8. dukascopy_python-6.0.0/dukascopy_python/core/interfaces.py +72 -0
  9. dukascopy_python-6.0.0/dukascopy_python/core/logger.py +54 -0
  10. dukascopy_python-6.0.0/dukascopy_python/core/utils.py +175 -0
  11. dukascopy_python-6.0.0/dukascopy_python/impl/v1/__init__.py +332 -0
  12. dukascopy_python-6.0.0/dukascopy_python/impl/v2/__init__.py +545 -0
  13. dukascopy_python-6.0.0/dukascopy_python/instruments/__init__.py +6 -0
  14. dukascopy_python-6.0.0/dukascopy_python/instruments/generator.py +98 -0
  15. dukascopy_python-6.0.0/dukascopy_python/instruments/instruments.py +21074 -0
  16. dukascopy_python-6.0.0/dukascopy_python.egg-info/PKG-INFO +302 -0
  17. dukascopy_python-6.0.0/dukascopy_python.egg-info/SOURCES.txt +21 -0
  18. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/dukascopy_python.egg-info/requires.txt +0 -1
  19. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/pyproject.toml +1 -2
  20. dukascopy_python-4.0.1/PKG-INFO +0 -238
  21. dukascopy_python-4.0.1/README.md +0 -197
  22. dukascopy_python-4.0.1/dukascopy_python.egg-info/PKG-INFO +0 -238
  23. dukascopy_python-4.0.1/dukascopy_python.egg-info/SOURCES.txt +0 -10
  24. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/LICENSE +0 -0
  25. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/dukascopy_python.egg-info/dependency_links.txt +0 -0
  26. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/dukascopy_python.egg-info/top_level.txt +0 -0
  27. {dukascopy_python-4.0.1 → dukascopy_python-6.0.0}/setup.cfg +0 -0
@@ -0,0 +1,302 @@
1
+ Metadata-Version: 2.4
2
+ Name: dukascopy-python
3
+ Version: 6.0.0
4
+ Summary: Download and stream historical price data for variety of financial instruments (Forex, Commodities and Indices) from Dukascopy Bank SA.
5
+ Author-email: Eghosa Osayande <osayandeeghosam@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 drui9
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/Eghosa-Osayande/dukascopy
28
+ Keywords: tick-data,forex-data,tick-api,ticks,dukascopy
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Programming Language :: Python
31
+ Classifier: Programming Language :: Python :: 3
32
+ Requires-Python: >=3.10
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: requests
36
+ Provides-Extra: dev
37
+ Requires-Dist: build; extra == "dev"
38
+ Requires-Dist: twine; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # dukascopy-python
42
+ [![PyPI Downloads](https://static.pepy.tech/badge/dukascopy-python)](https://pepy.tech/projects/dukascopy-python)
43
+
44
+ Download historical financial market data from [Dukascopy Bank SA](https://www.dukascopy.com), including tick-level prices and OHLCV candles for Forex, commodities, indices, and other financial instruments.
45
+
46
+ Supports multiple data feed versions, configurable HTTP sessions, optional logging, and Pandas integration.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install dukascopy-python
52
+ ```
53
+
54
+ ## Backward Compatibility
55
+
56
+ The previous API remains available through `dukascopy_python.compat`, which uses data feed version 1 internally.
57
+
58
+ Existing applications can continue using `fetch()`, `live_fetch()`, and legacy constants by updating their imports.
59
+
60
+ ```python
61
+ from datetime import datetime, timezone
62
+
63
+ import dukascopy_python.compat as duka
64
+ from dukascopy_python.compat.instruments import (
65
+ INSTRUMENT_FX_MAJORS_EUR_USD,
66
+ )
67
+
68
+ df = duka.fetch(
69
+ INSTRUMENT_FX_MAJORS_EUR_USD,
70
+ duka.INTERVAL_MIN_1,
71
+ duka.OFFER_SIDE_BID,
72
+ datetime(2025, 1, 1, tzinfo=timezone.utc),
73
+ datetime(2025, 1, 2, tzinfo=timezone.utc),
74
+ )
75
+
76
+ df.to_csv("output.csv")
77
+ ```
78
+
79
+ ## New API
80
+
81
+ The new API provides two functions:
82
+
83
+ - `fetch_candles()` — Retrieve historical OHLCV candles.
84
+ - `fetch_ticks()` — Retrieve historical bid/ask tick data.
85
+
86
+ ### Fetch Candles
87
+
88
+ ```python
89
+ from datetime import datetime, timezone
90
+
91
+ import dukascopy_python as duka
92
+ from dukascopy_python.instruments import I_EUR_USD
93
+
94
+ candles = duka.fetch_candles(
95
+ instrument=I_EUR_USD,
96
+ interval=1,
97
+ time_unit=duka.TimeUnit.HOUR,
98
+ offer_side=duka.OfferSide.BID,
99
+ start=datetime(2025, 1, 1, tzinfo=timezone.utc),
100
+ end=datetime(2025, 2, 1, tzinfo=timezone.utc),
101
+ version=2,
102
+ )
103
+
104
+ for candle in candles:
105
+ print(candle)
106
+ ```
107
+
108
+ ### Fetch Ticks
109
+
110
+ ```python
111
+ ticks = duka.fetch_ticks(
112
+ instrument=I_EUR_USD,
113
+ start=datetime(2025, 1, 1, tzinfo=timezone.utc),
114
+ end=datetime(2025, 1, 2, tzinfo=timezone.utc),
115
+ version=2,
116
+ )
117
+
118
+ for tick in ticks:
119
+ print(tick)
120
+ ```
121
+
122
+ Both functions return iterable model objects.
123
+
124
+ ### Parameters
125
+
126
+ | Parameter | Description |
127
+ |---|---|
128
+ | `instrument` | Instrument code, e.g. `I_EUR_USD` |
129
+ | `start` | Start datetime (inclusive range boundary, subject to feed behaviour) |
130
+ | `end` | End datetime; must be later than `start` |
131
+ | `version` | `1` or `2`; defaults to the globally configured version |
132
+ | `validate_instrument_name` | Validate and convert the instrument identifier; default `True` |
133
+ | `create_session` | Optional callable returning an HTTP session |
134
+ | `logger` | Optional `logging.Logger` instance |
135
+
136
+ Additional parameters for `fetch_candles()`:
137
+
138
+ | Parameter | Description |
139
+ |---|---|
140
+ | `interval` | Positive integer specifying the candle interval |
141
+ | `time_unit` | `TimeUnit` enum, e.g. `TimeUnit.MINUTE` |
142
+ | `offer_side` | `OfferSide.BID` or `OfferSide.ASK` |
143
+
144
+ `start` and `end` must both be timezone-aware or both timezone-naive. UTC-aware datetimes are recommended.
145
+
146
+ ## Data Feed Versions
147
+
148
+ Two data feed implementations are available.
149
+
150
+ | Version | Implementation |
151
+ |---|---|
152
+ | `1` | `DataFeedV1` (default) |
153
+ | `2` | `DataFeedV2` |
154
+
155
+ ### Set the Default Version
156
+
157
+ ```python
158
+ duka.set_default_version(2)
159
+ ```
160
+
161
+ All subsequent fetch operations use version 2 unless explicitly overridden.
162
+
163
+ ### Override Version Per Request
164
+
165
+ ```python
166
+ candles = duka.fetch_candles(
167
+ instrument=I_EUR_USD,
168
+ interval=5,
169
+ time_unit=duka.TimeUnit.MINUTE,
170
+ offer_side=duka.OfferSide.BID,
171
+ start=start,
172
+ end=end,
173
+ version=1,
174
+ )
175
+ ```
176
+
177
+ The `version` argument overrides the default for that request without changing the global setting.
178
+
179
+ ## Data Models
180
+
181
+ ### Candle
182
+
183
+ | Field | Description |
184
+ |---|---|
185
+ | `timestamp` | Candle timestamp |
186
+ | `open`, `high`, `low`, `close` | OHLC prices |
187
+ | `volume` | Trading volume |
188
+ | `time_unit` | Candle time unit |
189
+ | `interval` | Candle interval |
190
+
191
+ ### Tick
192
+
193
+ | Field | Description |
194
+ |---|---|
195
+ | `timestamp` | Tick timestamp |
196
+ | `bid`, `ask` | Bid and ask prices |
197
+ | `bid_volume`, `ask_volume` | Bid and ask volumes |
198
+ | `volume` | Tick volume |
199
+
200
+ ## Pandas Integration
201
+
202
+ Convert retrieved candles or ticks into a Pandas DataFrame.
203
+
204
+ ```python
205
+ candles = list(duka.fetch_candles(
206
+ instrument=I_EUR_USD,
207
+ interval=1,
208
+ time_unit=duka.TimeUnit.HOUR,
209
+ offer_side=duka.OfferSide.BID,
210
+ start=start,
211
+ end=end,
212
+ ))
213
+
214
+ df = duka.to_dataframe(candles)
215
+
216
+ df.to_csv("candles.csv")
217
+ df.to_json("candles.json")
218
+ ```
219
+
220
+ Pandas is an optional dependency. Install it with:
221
+
222
+ ```bash
223
+ pip install pandas
224
+ ```
225
+
226
+ ## Advanced Configuration
227
+
228
+ ### Custom HTTP Session
229
+
230
+ Use the `create_session` argument to provide a session factory.
231
+
232
+ ```python
233
+ candles = duka.fetch_candles(
234
+ instrument=I_EUR_USD,
235
+ interval=1,
236
+ time_unit=duka.TimeUnit.HOUR,
237
+ offer_side=duka.OfferSide.BID,
238
+ start=start,
239
+ end=end,
240
+ create_session=lambda: duka.create_session(retries=7),
241
+ )
242
+ ```
243
+
244
+ The library manages the returned session using a context manager.
245
+
246
+ ### Custom Logging
247
+
248
+ Provide a configured Python logger:
249
+
250
+ ```python
251
+ import logging
252
+
253
+ logger = duka.create_logger(
254
+ name="dukascopy",
255
+ level=logging.DEBUG,
256
+ )
257
+
258
+ ticks = duka.fetch_ticks(
259
+ instrument=I_EUR_USD,
260
+ start=start,
261
+ end=end,
262
+ logger=logger,
263
+ )
264
+ ```
265
+
266
+ ### Instrument Validation
267
+
268
+ Instrument validation and identifier conversion are enabled by default.
269
+
270
+ To bypass them:
271
+
272
+ ```python
273
+ ticks = duka.fetch_ticks(
274
+ instrument="EUR/USD",
275
+ start=start,
276
+ end=end,
277
+ version=2,
278
+ validate_instrument_name=False,
279
+ )
280
+ ```
281
+
282
+ When validation is disabled, the instrument identifier is passed directly to the selected data feed.
283
+
284
+ ## Migration Reference
285
+
286
+ | Previous API | New API |
287
+ |---|---|
288
+ | `dukascopy_python.compat` | `dukascopy_python` |
289
+ | `fetch()` | `fetch_candles()` / `fetch_ticks()` |
290
+ | `live_fetch()` | Available through `compat` |
291
+ | `INTERVAL_MIN_1` | `interval=1, time_unit=TimeUnit.MINUTE` |
292
+ | `OFFER_SIDE_BID` | `OfferSide.BID` |
293
+ | `INSTRUMENT_FX_MAJORS_EUR_USD` | `I_EUR_USD` |
294
+ | Pandas DataFrame | Iterable `Candle` / `Tick` objects |
295
+
296
+ ## License
297
+
298
+ MIT
299
+
300
+ ## Contributing
301
+
302
+ Contributions, bug reports, and pull requests are welcome.
@@ -0,0 +1,262 @@
1
+ # dukascopy-python
2
+ [![PyPI Downloads](https://static.pepy.tech/badge/dukascopy-python)](https://pepy.tech/projects/dukascopy-python)
3
+
4
+ Download historical financial market data from [Dukascopy Bank SA](https://www.dukascopy.com), including tick-level prices and OHLCV candles for Forex, commodities, indices, and other financial instruments.
5
+
6
+ Supports multiple data feed versions, configurable HTTP sessions, optional logging, and Pandas integration.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install dukascopy-python
12
+ ```
13
+
14
+ ## Backward Compatibility
15
+
16
+ The previous API remains available through `dukascopy_python.compat`, which uses data feed version 1 internally.
17
+
18
+ Existing applications can continue using `fetch()`, `live_fetch()`, and legacy constants by updating their imports.
19
+
20
+ ```python
21
+ from datetime import datetime, timezone
22
+
23
+ import dukascopy_python.compat as duka
24
+ from dukascopy_python.compat.instruments import (
25
+ INSTRUMENT_FX_MAJORS_EUR_USD,
26
+ )
27
+
28
+ df = duka.fetch(
29
+ INSTRUMENT_FX_MAJORS_EUR_USD,
30
+ duka.INTERVAL_MIN_1,
31
+ duka.OFFER_SIDE_BID,
32
+ datetime(2025, 1, 1, tzinfo=timezone.utc),
33
+ datetime(2025, 1, 2, tzinfo=timezone.utc),
34
+ )
35
+
36
+ df.to_csv("output.csv")
37
+ ```
38
+
39
+ ## New API
40
+
41
+ The new API provides two functions:
42
+
43
+ - `fetch_candles()` — Retrieve historical OHLCV candles.
44
+ - `fetch_ticks()` — Retrieve historical bid/ask tick data.
45
+
46
+ ### Fetch Candles
47
+
48
+ ```python
49
+ from datetime import datetime, timezone
50
+
51
+ import dukascopy_python as duka
52
+ from dukascopy_python.instruments import I_EUR_USD
53
+
54
+ candles = duka.fetch_candles(
55
+ instrument=I_EUR_USD,
56
+ interval=1,
57
+ time_unit=duka.TimeUnit.HOUR,
58
+ offer_side=duka.OfferSide.BID,
59
+ start=datetime(2025, 1, 1, tzinfo=timezone.utc),
60
+ end=datetime(2025, 2, 1, tzinfo=timezone.utc),
61
+ version=2,
62
+ )
63
+
64
+ for candle in candles:
65
+ print(candle)
66
+ ```
67
+
68
+ ### Fetch Ticks
69
+
70
+ ```python
71
+ ticks = duka.fetch_ticks(
72
+ instrument=I_EUR_USD,
73
+ start=datetime(2025, 1, 1, tzinfo=timezone.utc),
74
+ end=datetime(2025, 1, 2, tzinfo=timezone.utc),
75
+ version=2,
76
+ )
77
+
78
+ for tick in ticks:
79
+ print(tick)
80
+ ```
81
+
82
+ Both functions return iterable model objects.
83
+
84
+ ### Parameters
85
+
86
+ | Parameter | Description |
87
+ |---|---|
88
+ | `instrument` | Instrument code, e.g. `I_EUR_USD` |
89
+ | `start` | Start datetime (inclusive range boundary, subject to feed behaviour) |
90
+ | `end` | End datetime; must be later than `start` |
91
+ | `version` | `1` or `2`; defaults to the globally configured version |
92
+ | `validate_instrument_name` | Validate and convert the instrument identifier; default `True` |
93
+ | `create_session` | Optional callable returning an HTTP session |
94
+ | `logger` | Optional `logging.Logger` instance |
95
+
96
+ Additional parameters for `fetch_candles()`:
97
+
98
+ | Parameter | Description |
99
+ |---|---|
100
+ | `interval` | Positive integer specifying the candle interval |
101
+ | `time_unit` | `TimeUnit` enum, e.g. `TimeUnit.MINUTE` |
102
+ | `offer_side` | `OfferSide.BID` or `OfferSide.ASK` |
103
+
104
+ `start` and `end` must both be timezone-aware or both timezone-naive. UTC-aware datetimes are recommended.
105
+
106
+ ## Data Feed Versions
107
+
108
+ Two data feed implementations are available.
109
+
110
+ | Version | Implementation |
111
+ |---|---|
112
+ | `1` | `DataFeedV1` (default) |
113
+ | `2` | `DataFeedV2` |
114
+
115
+ ### Set the Default Version
116
+
117
+ ```python
118
+ duka.set_default_version(2)
119
+ ```
120
+
121
+ All subsequent fetch operations use version 2 unless explicitly overridden.
122
+
123
+ ### Override Version Per Request
124
+
125
+ ```python
126
+ candles = duka.fetch_candles(
127
+ instrument=I_EUR_USD,
128
+ interval=5,
129
+ time_unit=duka.TimeUnit.MINUTE,
130
+ offer_side=duka.OfferSide.BID,
131
+ start=start,
132
+ end=end,
133
+ version=1,
134
+ )
135
+ ```
136
+
137
+ The `version` argument overrides the default for that request without changing the global setting.
138
+
139
+ ## Data Models
140
+
141
+ ### Candle
142
+
143
+ | Field | Description |
144
+ |---|---|
145
+ | `timestamp` | Candle timestamp |
146
+ | `open`, `high`, `low`, `close` | OHLC prices |
147
+ | `volume` | Trading volume |
148
+ | `time_unit` | Candle time unit |
149
+ | `interval` | Candle interval |
150
+
151
+ ### Tick
152
+
153
+ | Field | Description |
154
+ |---|---|
155
+ | `timestamp` | Tick timestamp |
156
+ | `bid`, `ask` | Bid and ask prices |
157
+ | `bid_volume`, `ask_volume` | Bid and ask volumes |
158
+ | `volume` | Tick volume |
159
+
160
+ ## Pandas Integration
161
+
162
+ Convert retrieved candles or ticks into a Pandas DataFrame.
163
+
164
+ ```python
165
+ candles = list(duka.fetch_candles(
166
+ instrument=I_EUR_USD,
167
+ interval=1,
168
+ time_unit=duka.TimeUnit.HOUR,
169
+ offer_side=duka.OfferSide.BID,
170
+ start=start,
171
+ end=end,
172
+ ))
173
+
174
+ df = duka.to_dataframe(candles)
175
+
176
+ df.to_csv("candles.csv")
177
+ df.to_json("candles.json")
178
+ ```
179
+
180
+ Pandas is an optional dependency. Install it with:
181
+
182
+ ```bash
183
+ pip install pandas
184
+ ```
185
+
186
+ ## Advanced Configuration
187
+
188
+ ### Custom HTTP Session
189
+
190
+ Use the `create_session` argument to provide a session factory.
191
+
192
+ ```python
193
+ candles = duka.fetch_candles(
194
+ instrument=I_EUR_USD,
195
+ interval=1,
196
+ time_unit=duka.TimeUnit.HOUR,
197
+ offer_side=duka.OfferSide.BID,
198
+ start=start,
199
+ end=end,
200
+ create_session=lambda: duka.create_session(retries=7),
201
+ )
202
+ ```
203
+
204
+ The library manages the returned session using a context manager.
205
+
206
+ ### Custom Logging
207
+
208
+ Provide a configured Python logger:
209
+
210
+ ```python
211
+ import logging
212
+
213
+ logger = duka.create_logger(
214
+ name="dukascopy",
215
+ level=logging.DEBUG,
216
+ )
217
+
218
+ ticks = duka.fetch_ticks(
219
+ instrument=I_EUR_USD,
220
+ start=start,
221
+ end=end,
222
+ logger=logger,
223
+ )
224
+ ```
225
+
226
+ ### Instrument Validation
227
+
228
+ Instrument validation and identifier conversion are enabled by default.
229
+
230
+ To bypass them:
231
+
232
+ ```python
233
+ ticks = duka.fetch_ticks(
234
+ instrument="EUR/USD",
235
+ start=start,
236
+ end=end,
237
+ version=2,
238
+ validate_instrument_name=False,
239
+ )
240
+ ```
241
+
242
+ When validation is disabled, the instrument identifier is passed directly to the selected data feed.
243
+
244
+ ## Migration Reference
245
+
246
+ | Previous API | New API |
247
+ |---|---|
248
+ | `dukascopy_python.compat` | `dukascopy_python` |
249
+ | `fetch()` | `fetch_candles()` / `fetch_ticks()` |
250
+ | `live_fetch()` | Available through `compat` |
251
+ | `INTERVAL_MIN_1` | `interval=1, time_unit=TimeUnit.MINUTE` |
252
+ | `OFFER_SIDE_BID` | `OfferSide.BID` |
253
+ | `INSTRUMENT_FX_MAJORS_EUR_USD` | `I_EUR_USD` |
254
+ | Pandas DataFrame | Iterable `Candle` / `Tick` objects |
255
+
256
+ ## License
257
+
258
+ MIT
259
+
260
+ ## Contributing
261
+
262
+ Contributions, bug reports, and pull requests are welcome.