fxmacrodata 1.1.0__tar.gz → 1.2.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.
- {fxmacrodata-1.1.0/fxmacrodata.egg-info → fxmacrodata-1.2.0}/PKG-INFO +143 -17
- fxmacrodata-1.1.0/PKG-INFO → fxmacrodata-1.2.0/README.md +116 -44
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata/async_client.py +5 -2
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata/client.py +5 -2
- fxmacrodata-1.2.0/fxmacrodata/openbb/__init__.py +94 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/constants.py +120 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/launcher.py +58 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/metadata.py +352 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/__init__.py +0 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/commodities.py +105 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/cot.py +145 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/data_catalogue.py +143 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/forex.py +99 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/macro_indicators.py +112 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/models/release_calendar.py +94 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/router.py +109 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/utils/__init__.py +0 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/utils/catalogue.py +43 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/utils/helpers.py +135 -0
- fxmacrodata-1.2.0/fxmacrodata/openbb/workspace_backend.py +243 -0
- fxmacrodata-1.2.0/fxmacrodata.egg-info/PKG-INFO +363 -0
- fxmacrodata-1.2.0/fxmacrodata.egg-info/SOURCES.txt +37 -0
- fxmacrodata-1.2.0/fxmacrodata.egg-info/entry_points.txt +10 -0
- fxmacrodata-1.2.0/fxmacrodata.egg-info/requires.txt +44 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/pyproject.toml +47 -3
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/tests/test_client.py +14 -7
- fxmacrodata-1.2.0/tests/test_client_auth.py +103 -0
- fxmacrodata-1.2.0/tests/test_openbb_helpers.py +99 -0
- fxmacrodata-1.2.0/tests/test_openbb_launchers.py +81 -0
- fxmacrodata-1.2.0/tests/test_openbb_metadata.py +58 -0
- fxmacrodata-1.2.0/tests/test_openbb_provider_fetchers.py +144 -0
- fxmacrodata-1.2.0/tests/test_openbb_workspace_backend.py +177 -0
- fxmacrodata-1.1.0/README.md +0 -208
- fxmacrodata-1.1.0/fxmacrodata.egg-info/SOURCES.txt +0 -14
- fxmacrodata-1.1.0/fxmacrodata.egg-info/requires.txt +0 -14
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/LICENSE +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata/__init__.py +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata/exceptions.py +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata/utils.py +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata.egg-info/dependency_links.txt +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/fxmacrodata.egg-info/top_level.txt +0 -0
- {fxmacrodata-1.1.0 → fxmacrodata-1.2.0}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fxmacrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Python client for the FXMacroData API, providing forex macroeconomic data for traders, quants, and analysts.
|
|
5
5
|
Author-email: FXMacroData <info@fxmacrodata.com>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://fxmacrodata.com/?utm_source=pypi&utm_medium=package&utm_campaign=python_sdk
|
|
8
8
|
Project-URL: Documentation, https://fxmacrodata.com/api/docs?utm_source=pypi&utm_medium=package&utm_campaign=python_sdk
|
|
9
9
|
Project-URL: Source, https://github.com/fxmacrodata/fxmacrodata
|
|
@@ -14,8 +14,32 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: requests>=2.28
|
|
16
16
|
Requires-Dist: aiohttp>=3.8
|
|
17
|
+
Provides-Extra: openbb
|
|
18
|
+
Requires-Dist: openbb>=4.7.2; extra == "openbb"
|
|
19
|
+
Requires-Dist: openbb-core>=1.6.10; extra == "openbb"
|
|
20
|
+
Provides-Extra: openbb-api
|
|
21
|
+
Requires-Dist: openbb>=4.7.2; extra == "openbb-api"
|
|
22
|
+
Requires-Dist: openbb-core>=1.6.10; extra == "openbb-api"
|
|
23
|
+
Requires-Dist: openbb-platform-api>=1.3.6; extra == "openbb-api"
|
|
24
|
+
Provides-Extra: openbb-cli
|
|
25
|
+
Requires-Dist: openbb>=4.7.2; extra == "openbb-cli"
|
|
26
|
+
Requires-Dist: openbb-core>=1.6.10; extra == "openbb-cli"
|
|
27
|
+
Requires-Dist: openbb-cli>=1.0; extra == "openbb-cli"
|
|
28
|
+
Provides-Extra: mcp
|
|
29
|
+
Requires-Dist: openbb>=4.7.2; extra == "mcp"
|
|
30
|
+
Requires-Dist: openbb-core>=1.6.10; extra == "mcp"
|
|
31
|
+
Requires-Dist: openbb-mcp-server>=1.4.1; extra == "mcp"
|
|
32
|
+
Provides-Extra: workspace
|
|
33
|
+
Requires-Dist: fastapi>=0.100; extra == "workspace"
|
|
34
|
+
Requires-Dist: uvicorn>=0.23; extra == "workspace"
|
|
17
35
|
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: fastapi>=0.100; extra == "dev"
|
|
37
|
+
Requires-Dist: httpx>=0.24; extra == "dev"
|
|
38
|
+
Requires-Dist: httpx2>=2.0; extra == "dev"
|
|
39
|
+
Requires-Dist: openbb-core>=1.6.10; extra == "dev"
|
|
40
|
+
Requires-Dist: openbb-platform-api>=1.3.6; extra == "dev"
|
|
18
41
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
19
43
|
Requires-Dist: pytest-mock>=3.10; extra == "dev"
|
|
20
44
|
Requires-Dist: python-dotenv>=1.1; extra == "dev"
|
|
21
45
|
Requires-Dist: python-semantic-release>=7.23; extra == "dev"
|
|
@@ -25,6 +49,7 @@ Requires-Dist: ruff>=0.0; extra == "dev"
|
|
|
25
49
|
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
26
50
|
Requires-Dist: black>=24.0; extra == "dev"
|
|
27
51
|
Requires-Dist: types-requests>=2.28; extra == "dev"
|
|
52
|
+
Requires-Dist: uvicorn>=0.23; extra == "dev"
|
|
28
53
|
Dynamic: license-file
|
|
29
54
|
|
|
30
55
|
# FXMacroData Python SDK 🐍📊
|
|
@@ -36,7 +61,7 @@ Dynamic: license-file
|
|
|
36
61
|
|
|
37
62
|
The **FXMacroData Python SDK** provides a simple and efficient interface for fetching **macroeconomic indicators**, **forex prices**, **release calendars**, **COT positioning**, and **commodity prices** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
63
|
|
|
39
|
-
It includes both synchronous and asynchronous clients
|
|
64
|
+
It includes both synchronous and asynchronous clients and supports free USD macro endpoints.
|
|
40
65
|
|
|
41
66
|
---
|
|
42
67
|
|
|
@@ -50,8 +75,8 @@ It includes both synchronous and asynchronous clients, supports free USD endpoin
|
|
|
50
75
|
- **COT data** — CFTC Commitment of Traders positioning
|
|
51
76
|
- **Commodity prices** — gold, silver, platinum
|
|
52
77
|
- Free access to **USD** macro data.
|
|
53
|
-
-
|
|
54
|
-
- API key required
|
|
78
|
+
- FX spot-rate history through `get_fx_price`.
|
|
79
|
+
- API key required for protected datasets, including non-USD indicators, FX spot-rate history, COT, and commodities.
|
|
55
80
|
- Full support for:
|
|
56
81
|
- **Synchronous client**
|
|
57
82
|
- **Asynchronous client**
|
|
@@ -92,7 +117,7 @@ data = client.get_indicator(
|
|
|
92
117
|
)
|
|
93
118
|
print(data)
|
|
94
119
|
|
|
95
|
-
#
|
|
120
|
+
# Forex price endpoint
|
|
96
121
|
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
97
122
|
print(fx)
|
|
98
123
|
|
|
@@ -131,7 +156,7 @@ async def main():
|
|
|
131
156
|
data = await client.get_indicator("eur", "inflation")
|
|
132
157
|
print(data)
|
|
133
158
|
|
|
134
|
-
#
|
|
159
|
+
# Forex price endpoint
|
|
135
160
|
fx = await client.get_fx_price("usd", "jpy")
|
|
136
161
|
print(fx)
|
|
137
162
|
|
|
@@ -156,6 +181,101 @@ asyncio.run(main())
|
|
|
156
181
|
|
|
157
182
|
---
|
|
158
183
|
|
|
184
|
+
## OpenBB Integration
|
|
185
|
+
|
|
186
|
+
FXMacroData supports all practical OpenBB integration paths from this package:
|
|
187
|
+
|
|
188
|
+
- OpenBB Python: installable provider/router extension for `obb.fxmacrodata.*`.
|
|
189
|
+
- OpenBB REST API: `/api/v1/fxmacrodata/*` routes through `openbb-api`.
|
|
190
|
+
- OpenBB Workspace, generated: widgets generated by `openbb-api` from inline metadata.
|
|
191
|
+
- OpenBB Workspace, custom: standalone backend serving `widgets.json`, `apps.json`, and data endpoints.
|
|
192
|
+
- OpenBB MCP: tools exposed through `openbb-mcp`.
|
|
193
|
+
- OpenBB CLI: commands available after `openbb-build`.
|
|
194
|
+
|
|
195
|
+
OpenBB packages require Python 3.10+. Install the OpenBB Python extra:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
pip install "fxmacrodata[openbb]"
|
|
199
|
+
openbb-build
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Then use FXMacroData from the OpenBB Python interface:
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from openbb import obb
|
|
206
|
+
|
|
207
|
+
obb.user.credentials.fxmacrodata_api_key = "YOUR_API_KEY"
|
|
208
|
+
|
|
209
|
+
catalogue = obb.fxmacrodata.data_catalogue(
|
|
210
|
+
currency="USD",
|
|
211
|
+
provider="fxmacrodata",
|
|
212
|
+
).to_df()
|
|
213
|
+
|
|
214
|
+
inflation = obb.fxmacrodata.macro_indicators(
|
|
215
|
+
currency="USD",
|
|
216
|
+
indicator="inflation",
|
|
217
|
+
start_date="2020-01-01",
|
|
218
|
+
provider="fxmacrodata",
|
|
219
|
+
).to_df()
|
|
220
|
+
|
|
221
|
+
eurusd = obb.fxmacrodata.fx_historical(
|
|
222
|
+
base="EUR",
|
|
223
|
+
quote="USD",
|
|
224
|
+
start_date="2024-01-01",
|
|
225
|
+
provider="fxmacrodata",
|
|
226
|
+
).to_df()
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Run the OpenBB REST API and generated Workspace backend:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
pip install "fxmacrodata[openbb-api]"
|
|
233
|
+
openbb-build
|
|
234
|
+
fxmacrodata-openbb-api --host 127.0.0.1 --port 6900
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Workspace can be connected to `http://127.0.0.1:6900`. The generated
|
|
238
|
+
`/widgets.json` uses FXMacroData's inline OpenBB widget metadata.
|
|
239
|
+
|
|
240
|
+
Run the OpenBB Workspace custom backend:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
pip install "fxmacrodata[workspace]"
|
|
244
|
+
fxmacrodata-openbb-backend
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Default backend URL:
|
|
248
|
+
|
|
249
|
+
```text
|
|
250
|
+
http://127.0.0.1:7779
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Workspace exposes `/widgets.json`, `/apps.json`, `/catalogue`,
|
|
254
|
+
`/release_calendar`, `/macro_indicator`, `/forex`, `/cot`, and `/commodity`.
|
|
255
|
+
Swagger/OpenAPI docs are disabled by default for this backend. For local
|
|
256
|
+
debugging only, set `FXMACRODATA_OPENBB_ENABLE_DOCS=1` before starting it.
|
|
257
|
+
|
|
258
|
+
Run OpenBB MCP:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
pip install "fxmacrodata[mcp]"
|
|
262
|
+
openbb-build
|
|
263
|
+
fxmacrodata-openbb-mcp --default-categories fxmacrodata --host 127.0.0.1 --port 8001
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Run OpenBB CLI:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
pip install "fxmacrodata[openbb-cli]"
|
|
270
|
+
openbb-build
|
|
271
|
+
openbb
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
See `docs/openbb-integration.md` for the full integration matrix and the
|
|
275
|
+
separate upstream OpenBB repository contribution path.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
159
279
|
## 📘 API Overview
|
|
160
280
|
|
|
161
281
|
### `get_indicator(currency, indicator, start_date=None, end_date=None)`
|
|
@@ -166,10 +286,10 @@ Fetches macroeconomic indicator time series data.
|
|
|
166
286
|
- **API key required for non-USD.**
|
|
167
287
|
|
|
168
288
|
### `get_fx_price(base, quote, start_date=None, end_date=None, indicators=None)`
|
|
169
|
-
Fetches daily FX spot rates
|
|
289
|
+
Fetches daily FX spot rates between two currencies.
|
|
170
290
|
|
|
171
291
|
- `indicators`: Optional comma-separated technical indicators — `"sma_20"`, `"sma_50"`, `"sma_200"`, `"rsi_14"`, `"macd"`, `"ema_12"`, `"ema_26"`, `"bollinger_bands"`, or `"all"`.
|
|
172
|
-
- **
|
|
292
|
+
- **API key required.**
|
|
173
293
|
|
|
174
294
|
### `get_calendar(currency, indicator=None)`
|
|
175
295
|
Fetches upcoming economic data release dates for a currency.
|
|
@@ -199,25 +319,31 @@ Fetches commodity price time series.
|
|
|
199
319
|
|
|
200
320
|
## 💹 Supported Currencies & Indicators
|
|
201
321
|
|
|
322
|
+
**18 currencies supported:** USD, EUR, GBP, JPY, AUD, CAD, CHF, NZD, HKD, SGD, NOK, PLN, SEK, DKK, BRL, CNY, KRW, MXN.
|
|
323
|
+
|
|
324
|
+
The table below shows a sample of indicator coverage across four major currencies. Use `get_data_catalogue()` to discover the full list for any currency.
|
|
325
|
+
|
|
202
326
|
| Category | Metric | USD | EUR | AUD | GBP |
|
|
203
327
|
|---------|--------|-----|-----|-----|-----|
|
|
204
328
|
| **Economy** | GDP Growth | ✓ | ✓ | ✓ | ✓ |
|
|
205
329
|
| | Inflation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
206
330
|
| | Trade Balance | ✓ | ✓ | ✓ | ✓ |
|
|
207
331
|
| | Current Account Balance | ✓ | ✓ | ✓ | ✓ |
|
|
332
|
+
| | Retail Sales | ✓ | ✓ | ✓ | ✓ |
|
|
333
|
+
| | Industrial Production | ✓ | — | — | — |
|
|
208
334
|
| **Labor Market** | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
|
|
209
|
-
| | Employment Level | ✓ |
|
|
210
|
-
| | Full-Time Employment | ✓ |
|
|
211
|
-
| | Part-Time Employment | ✓ |
|
|
212
|
-
| | Participation Rate | ✓ |
|
|
335
|
+
| | Employment Level | ✓ | ✓ | ✓ | ✓ |
|
|
336
|
+
| | Full-Time Employment | ✓ | ✓ | ✓ | — |
|
|
337
|
+
| | Part-Time Employment | ✓ | ✓ | ✓ | ✓ |
|
|
338
|
+
| | Participation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
213
339
|
| | Non-Farm Payrolls | ✓ | — | — | — |
|
|
214
340
|
| **Monetary Policy** | Policy Rate | ✓ | ✓ | ✓ | ✓ |
|
|
215
|
-
| |
|
|
216
|
-
|
|
|
217
|
-
|
|
|
341
|
+
| | Risk-Free Rate | ✓ | ✓ | ✓ | ✓ |
|
|
342
|
+
| | Central Bank Assets | ✓ | — | ✓ | — |
|
|
343
|
+
| **Government Bond Yields** | 2-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
218
344
|
| | 5-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
219
345
|
| | 10-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
220
|
-
| | Inflation-Linked Bond | ✓ |
|
|
346
|
+
| | Inflation-Linked Bond | ✓ | ✓ | ✓ | ✓ |
|
|
221
347
|
|
|
222
348
|
---
|
|
223
349
|
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fxmacrodata
|
|
3
|
-
Version: 1.1.0
|
|
4
|
-
Summary: Python client for the FXMacroData API, providing forex macroeconomic data for traders, quants, and analysts.
|
|
5
|
-
Author-email: FXMacroData <info@fxmacrodata.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://fxmacrodata.com/?utm_source=pypi&utm_medium=package&utm_campaign=python_sdk
|
|
8
|
-
Project-URL: Documentation, https://fxmacrodata.com/api/docs?utm_source=pypi&utm_medium=package&utm_campaign=python_sdk
|
|
9
|
-
Project-URL: Source, https://github.com/fxmacrodata/fxmacrodata
|
|
10
|
-
Project-URL: Issues, https://github.com/fxmacrodata/fxmacrodata
|
|
11
|
-
Keywords: forex,macro data,macroeconomics,trading,quant,economic indicators,fxmacrodata,rapidapi
|
|
12
|
-
Requires-Python: >=3.9
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: requests>=2.28
|
|
16
|
-
Requires-Dist: aiohttp>=3.8
|
|
17
|
-
Provides-Extra: dev
|
|
18
|
-
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
19
|
-
Requires-Dist: pytest-mock>=3.10; extra == "dev"
|
|
20
|
-
Requires-Dist: python-dotenv>=1.1; extra == "dev"
|
|
21
|
-
Requires-Dist: python-semantic-release>=7.23; extra == "dev"
|
|
22
|
-
Requires-Dist: twine>=4.0; extra == "dev"
|
|
23
|
-
Requires-Dist: build>=1.0; extra == "dev"
|
|
24
|
-
Requires-Dist: ruff>=0.0; extra == "dev"
|
|
25
|
-
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
26
|
-
Requires-Dist: black>=24.0; extra == "dev"
|
|
27
|
-
Requires-Dist: types-requests>=2.28; extra == "dev"
|
|
28
|
-
Dynamic: license-file
|
|
29
|
-
|
|
30
1
|
# FXMacroData Python SDK 🐍📊
|
|
31
2
|
|
|
32
3
|

|
|
@@ -36,7 +7,7 @@ Dynamic: license-file
|
|
|
36
7
|
|
|
37
8
|
The **FXMacroData Python SDK** provides a simple and efficient interface for fetching **macroeconomic indicators**, **forex prices**, **release calendars**, **COT positioning**, and **commodity prices** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
9
|
|
|
39
|
-
It includes both synchronous and asynchronous clients
|
|
10
|
+
It includes both synchronous and asynchronous clients and supports free USD macro endpoints.
|
|
40
11
|
|
|
41
12
|
---
|
|
42
13
|
|
|
@@ -50,8 +21,8 @@ It includes both synchronous and asynchronous clients, supports free USD endpoin
|
|
|
50
21
|
- **COT data** — CFTC Commitment of Traders positioning
|
|
51
22
|
- **Commodity prices** — gold, silver, platinum
|
|
52
23
|
- Free access to **USD** macro data.
|
|
53
|
-
-
|
|
54
|
-
- API key required
|
|
24
|
+
- FX spot-rate history through `get_fx_price`.
|
|
25
|
+
- API key required for protected datasets, including non-USD indicators, FX spot-rate history, COT, and commodities.
|
|
55
26
|
- Full support for:
|
|
56
27
|
- **Synchronous client**
|
|
57
28
|
- **Asynchronous client**
|
|
@@ -92,7 +63,7 @@ data = client.get_indicator(
|
|
|
92
63
|
)
|
|
93
64
|
print(data)
|
|
94
65
|
|
|
95
|
-
#
|
|
66
|
+
# Forex price endpoint
|
|
96
67
|
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
97
68
|
print(fx)
|
|
98
69
|
|
|
@@ -131,7 +102,7 @@ async def main():
|
|
|
131
102
|
data = await client.get_indicator("eur", "inflation")
|
|
132
103
|
print(data)
|
|
133
104
|
|
|
134
|
-
#
|
|
105
|
+
# Forex price endpoint
|
|
135
106
|
fx = await client.get_fx_price("usd", "jpy")
|
|
136
107
|
print(fx)
|
|
137
108
|
|
|
@@ -156,6 +127,101 @@ asyncio.run(main())
|
|
|
156
127
|
|
|
157
128
|
---
|
|
158
129
|
|
|
130
|
+
## OpenBB Integration
|
|
131
|
+
|
|
132
|
+
FXMacroData supports all practical OpenBB integration paths from this package:
|
|
133
|
+
|
|
134
|
+
- OpenBB Python: installable provider/router extension for `obb.fxmacrodata.*`.
|
|
135
|
+
- OpenBB REST API: `/api/v1/fxmacrodata/*` routes through `openbb-api`.
|
|
136
|
+
- OpenBB Workspace, generated: widgets generated by `openbb-api` from inline metadata.
|
|
137
|
+
- OpenBB Workspace, custom: standalone backend serving `widgets.json`, `apps.json`, and data endpoints.
|
|
138
|
+
- OpenBB MCP: tools exposed through `openbb-mcp`.
|
|
139
|
+
- OpenBB CLI: commands available after `openbb-build`.
|
|
140
|
+
|
|
141
|
+
OpenBB packages require Python 3.10+. Install the OpenBB Python extra:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install "fxmacrodata[openbb]"
|
|
145
|
+
openbb-build
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Then use FXMacroData from the OpenBB Python interface:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from openbb import obb
|
|
152
|
+
|
|
153
|
+
obb.user.credentials.fxmacrodata_api_key = "YOUR_API_KEY"
|
|
154
|
+
|
|
155
|
+
catalogue = obb.fxmacrodata.data_catalogue(
|
|
156
|
+
currency="USD",
|
|
157
|
+
provider="fxmacrodata",
|
|
158
|
+
).to_df()
|
|
159
|
+
|
|
160
|
+
inflation = obb.fxmacrodata.macro_indicators(
|
|
161
|
+
currency="USD",
|
|
162
|
+
indicator="inflation",
|
|
163
|
+
start_date="2020-01-01",
|
|
164
|
+
provider="fxmacrodata",
|
|
165
|
+
).to_df()
|
|
166
|
+
|
|
167
|
+
eurusd = obb.fxmacrodata.fx_historical(
|
|
168
|
+
base="EUR",
|
|
169
|
+
quote="USD",
|
|
170
|
+
start_date="2024-01-01",
|
|
171
|
+
provider="fxmacrodata",
|
|
172
|
+
).to_df()
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Run the OpenBB REST API and generated Workspace backend:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install "fxmacrodata[openbb-api]"
|
|
179
|
+
openbb-build
|
|
180
|
+
fxmacrodata-openbb-api --host 127.0.0.1 --port 6900
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Workspace can be connected to `http://127.0.0.1:6900`. The generated
|
|
184
|
+
`/widgets.json` uses FXMacroData's inline OpenBB widget metadata.
|
|
185
|
+
|
|
186
|
+
Run the OpenBB Workspace custom backend:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pip install "fxmacrodata[workspace]"
|
|
190
|
+
fxmacrodata-openbb-backend
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Default backend URL:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
http://127.0.0.1:7779
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Workspace exposes `/widgets.json`, `/apps.json`, `/catalogue`,
|
|
200
|
+
`/release_calendar`, `/macro_indicator`, `/forex`, `/cot`, and `/commodity`.
|
|
201
|
+
Swagger/OpenAPI docs are disabled by default for this backend. For local
|
|
202
|
+
debugging only, set `FXMACRODATA_OPENBB_ENABLE_DOCS=1` before starting it.
|
|
203
|
+
|
|
204
|
+
Run OpenBB MCP:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pip install "fxmacrodata[mcp]"
|
|
208
|
+
openbb-build
|
|
209
|
+
fxmacrodata-openbb-mcp --default-categories fxmacrodata --host 127.0.0.1 --port 8001
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Run OpenBB CLI:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install "fxmacrodata[openbb-cli]"
|
|
216
|
+
openbb-build
|
|
217
|
+
openbb
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
See `docs/openbb-integration.md` for the full integration matrix and the
|
|
221
|
+
separate upstream OpenBB repository contribution path.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
159
225
|
## 📘 API Overview
|
|
160
226
|
|
|
161
227
|
### `get_indicator(currency, indicator, start_date=None, end_date=None)`
|
|
@@ -166,10 +232,10 @@ Fetches macroeconomic indicator time series data.
|
|
|
166
232
|
- **API key required for non-USD.**
|
|
167
233
|
|
|
168
234
|
### `get_fx_price(base, quote, start_date=None, end_date=None, indicators=None)`
|
|
169
|
-
Fetches daily FX spot rates
|
|
235
|
+
Fetches daily FX spot rates between two currencies.
|
|
170
236
|
|
|
171
237
|
- `indicators`: Optional comma-separated technical indicators — `"sma_20"`, `"sma_50"`, `"sma_200"`, `"rsi_14"`, `"macd"`, `"ema_12"`, `"ema_26"`, `"bollinger_bands"`, or `"all"`.
|
|
172
|
-
- **
|
|
238
|
+
- **API key required.**
|
|
173
239
|
|
|
174
240
|
### `get_calendar(currency, indicator=None)`
|
|
175
241
|
Fetches upcoming economic data release dates for a currency.
|
|
@@ -199,25 +265,31 @@ Fetches commodity price time series.
|
|
|
199
265
|
|
|
200
266
|
## 💹 Supported Currencies & Indicators
|
|
201
267
|
|
|
268
|
+
**18 currencies supported:** USD, EUR, GBP, JPY, AUD, CAD, CHF, NZD, HKD, SGD, NOK, PLN, SEK, DKK, BRL, CNY, KRW, MXN.
|
|
269
|
+
|
|
270
|
+
The table below shows a sample of indicator coverage across four major currencies. Use `get_data_catalogue()` to discover the full list for any currency.
|
|
271
|
+
|
|
202
272
|
| Category | Metric | USD | EUR | AUD | GBP |
|
|
203
273
|
|---------|--------|-----|-----|-----|-----|
|
|
204
274
|
| **Economy** | GDP Growth | ✓ | ✓ | ✓ | ✓ |
|
|
205
275
|
| | Inflation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
206
276
|
| | Trade Balance | ✓ | ✓ | ✓ | ✓ |
|
|
207
277
|
| | Current Account Balance | ✓ | ✓ | ✓ | ✓ |
|
|
278
|
+
| | Retail Sales | ✓ | ✓ | ✓ | ✓ |
|
|
279
|
+
| | Industrial Production | ✓ | — | — | — |
|
|
208
280
|
| **Labor Market** | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
|
|
209
|
-
| | Employment Level | ✓ |
|
|
210
|
-
| | Full-Time Employment | ✓ |
|
|
211
|
-
| | Part-Time Employment | ✓ |
|
|
212
|
-
| | Participation Rate | ✓ |
|
|
281
|
+
| | Employment Level | ✓ | ✓ | ✓ | ✓ |
|
|
282
|
+
| | Full-Time Employment | ✓ | ✓ | ✓ | — |
|
|
283
|
+
| | Part-Time Employment | ✓ | ✓ | ✓ | ✓ |
|
|
284
|
+
| | Participation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
213
285
|
| | Non-Farm Payrolls | ✓ | — | — | — |
|
|
214
286
|
| **Monetary Policy** | Policy Rate | ✓ | ✓ | ✓ | ✓ |
|
|
215
|
-
| |
|
|
216
|
-
|
|
|
217
|
-
|
|
|
287
|
+
| | Risk-Free Rate | ✓ | ✓ | ✓ | ✓ |
|
|
288
|
+
| | Central Bank Assets | ✓ | — | ✓ | — |
|
|
289
|
+
| **Government Bond Yields** | 2-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
218
290
|
| | 5-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
219
291
|
| | 10-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
220
|
-
| | Inflation-Linked Bond | ✓ |
|
|
292
|
+
| | Inflation-Linked Bond | ✓ | ✓ | ✓ | ✓ |
|
|
221
293
|
|
|
222
294
|
---
|
|
223
295
|
|
|
@@ -60,7 +60,7 @@ class AsyncClient:
|
|
|
60
60
|
return await self._request(url, params, headers)
|
|
61
61
|
|
|
62
62
|
# ------------------------------------------------------------------
|
|
63
|
-
# FX spot rates
|
|
63
|
+
# FX spot rates
|
|
64
64
|
# ------------------------------------------------------------------
|
|
65
65
|
async def get_fx_price(
|
|
66
66
|
self,
|
|
@@ -80,7 +80,10 @@ class AsyncClient:
|
|
|
80
80
|
params["end_date"] = end_date
|
|
81
81
|
if indicators:
|
|
82
82
|
params["indicators"] = indicators
|
|
83
|
-
|
|
83
|
+
if not self.api_key:
|
|
84
|
+
raise FXMacroDataError("API key required for forex endpoints.")
|
|
85
|
+
headers = {"X-API-Key": self.api_key}
|
|
86
|
+
return await self._request(url, params, headers)
|
|
84
87
|
|
|
85
88
|
# ------------------------------------------------------------------
|
|
86
89
|
# Release calendar
|
|
@@ -50,7 +50,7 @@ class Client:
|
|
|
50
50
|
return self._request(url, params, headers)
|
|
51
51
|
|
|
52
52
|
# ------------------------------------------------------------------
|
|
53
|
-
# FX spot rates
|
|
53
|
+
# FX spot rates
|
|
54
54
|
# ------------------------------------------------------------------
|
|
55
55
|
def get_fx_price(
|
|
56
56
|
self,
|
|
@@ -70,7 +70,10 @@ class Client:
|
|
|
70
70
|
params["end_date"] = end_date
|
|
71
71
|
if indicators:
|
|
72
72
|
params["indicators"] = indicators
|
|
73
|
-
|
|
73
|
+
if not self.api_key:
|
|
74
|
+
raise FXMacroDataError("API key required for forex endpoints.")
|
|
75
|
+
headers = {"X-API-Key": self.api_key}
|
|
76
|
+
return self._request(url, params, headers)
|
|
74
77
|
|
|
75
78
|
# ------------------------------------------------------------------
|
|
76
79
|
# Release calendar
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""OpenBB integration for the FXMacroData Python package.
|
|
2
|
+
|
|
3
|
+
This module registers FXMacroData as an OpenBB provider extension. The
|
|
4
|
+
user-facing commands live in :mod:`fxmacrodata.openbb.router`.
|
|
5
|
+
|
|
6
|
+
Install the main package with the OpenBB extra and run ``openbb-build`` so
|
|
7
|
+
OpenBB discovers the router and provider entry points::
|
|
8
|
+
|
|
9
|
+
pip install "fxmacrodata[openbb]"
|
|
10
|
+
openbb-build
|
|
11
|
+
|
|
12
|
+
Then use the OpenBB Python interface::
|
|
13
|
+
|
|
14
|
+
from openbb import obb
|
|
15
|
+
|
|
16
|
+
obb.user.credentials.fxmacrodata_api_key = "YOUR_KEY"
|
|
17
|
+
df = obb.fxmacrodata.fx_historical(
|
|
18
|
+
base="EUR",
|
|
19
|
+
quote="USD",
|
|
20
|
+
provider="fxmacrodata",
|
|
21
|
+
).to_df()
|
|
22
|
+
|
|
23
|
+
Fetcher classes can also be imported directly from
|
|
24
|
+
``fxmacrodata.openbb.models`` for lower-level tests and integrations::
|
|
25
|
+
|
|
26
|
+
from fxmacrodata.openbb.models.macro_indicators import (
|
|
27
|
+
FXMacroDataMacroIndicatorsFetcher,
|
|
28
|
+
)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from typing import Any
|
|
32
|
+
|
|
33
|
+
__version__ = "0.1.0"
|
|
34
|
+
|
|
35
|
+
_OpenBBProvider: Any = None
|
|
36
|
+
try:
|
|
37
|
+
from openbb_core.provider.abstract.provider import Provider as _ImportedProvider
|
|
38
|
+
except ModuleNotFoundError as exc:
|
|
39
|
+
if exc.name != "openbb_core":
|
|
40
|
+
raise
|
|
41
|
+
else:
|
|
42
|
+
_OpenBBProvider = _ImportedProvider
|
|
43
|
+
|
|
44
|
+
if _OpenBBProvider is None:
|
|
45
|
+
fxmacrodata_provider = None
|
|
46
|
+
__all__ = ["fxmacrodata_provider"]
|
|
47
|
+
else:
|
|
48
|
+
from fxmacrodata.openbb.models.commodities import FXMacroDataCommodityFetcher
|
|
49
|
+
from fxmacrodata.openbb.models.cot import FXMacroDataCotFetcher
|
|
50
|
+
from fxmacrodata.openbb.models.data_catalogue import FXMacroDataDataCatalogueFetcher
|
|
51
|
+
from fxmacrodata.openbb.models.forex import FXMacroDataFxHistoricalFetcher
|
|
52
|
+
from fxmacrodata.openbb.models.macro_indicators import (
|
|
53
|
+
FXMacroDataMacroIndicatorsFetcher,
|
|
54
|
+
)
|
|
55
|
+
from fxmacrodata.openbb.models.release_calendar import (
|
|
56
|
+
FXMacroDataReleaseCalendarFetcher,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
__all__ = [
|
|
60
|
+
"fxmacrodata_provider",
|
|
61
|
+
"FXMacroDataCotFetcher",
|
|
62
|
+
"FXMacroDataCommodityFetcher",
|
|
63
|
+
"FXMacroDataDataCatalogueFetcher",
|
|
64
|
+
"FXMacroDataFxHistoricalFetcher",
|
|
65
|
+
"FXMacroDataMacroIndicatorsFetcher",
|
|
66
|
+
"FXMacroDataReleaseCalendarFetcher",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
fxmacrodata_provider = _OpenBBProvider(
|
|
70
|
+
name="fxmacrodata",
|
|
71
|
+
website="https://fxmacrodata.com",
|
|
72
|
+
description=(
|
|
73
|
+
"FXMacroData provides macroeconomic indicator time series, FX spot "
|
|
74
|
+
"rates, CFTC Commitment of Traders positioning, commodity prices, "
|
|
75
|
+
"and economic release calendars from official government and "
|
|
76
|
+
"central-bank publications for FX market analysis."
|
|
77
|
+
),
|
|
78
|
+
# OpenBB stores this as ``fxmacrodata_api_key`` in user credentials.
|
|
79
|
+
credentials=["api_key"],
|
|
80
|
+
fetcher_dict={
|
|
81
|
+
# Usage: obb.fxmacrodata.data_catalogue(currency="USD")
|
|
82
|
+
"FXMacroDataDataCatalogue": FXMacroDataDataCatalogueFetcher,
|
|
83
|
+
# Usage: obb.fxmacrodata.macro_indicators(currency="USD", indicator="inflation")
|
|
84
|
+
"FXMacroDataMacroIndicators": FXMacroDataMacroIndicatorsFetcher,
|
|
85
|
+
# Usage: obb.fxmacrodata.fx_historical(base="AUD", quote="USD")
|
|
86
|
+
"FXMacroDataFxHistorical": FXMacroDataFxHistoricalFetcher,
|
|
87
|
+
# Usage: obb.fxmacrodata.cot(currency="EUR")
|
|
88
|
+
"FXMacroDataCot": FXMacroDataCotFetcher,
|
|
89
|
+
# Usage: obb.fxmacrodata.commodity(indicator="gold")
|
|
90
|
+
"FXMacroDataCommodity": FXMacroDataCommodityFetcher,
|
|
91
|
+
# Usage: obb.fxmacrodata.release_calendar(currency="USD")
|
|
92
|
+
"FXMacroDataReleaseCalendar": FXMacroDataReleaseCalendarFetcher,
|
|
93
|
+
},
|
|
94
|
+
)
|