fxmacrodata 0.1.0__tar.gz → 1.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.
- fxmacrodata-1.0.0/PKG-INFO +172 -0
- fxmacrodata-1.0.0/README.md +143 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata/async_client.py +31 -7
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata/client.py +32 -5
- fxmacrodata-1.0.0/fxmacrodata.egg-info/PKG-INFO +172 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/pyproject.toml +1 -1
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/tests/test_client.py +15 -6
- fxmacrodata-0.1.0/PKG-INFO +0 -64
- fxmacrodata-0.1.0/README.md +0 -35
- fxmacrodata-0.1.0/fxmacrodata.egg-info/PKG-INFO +0 -64
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/LICENSE +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata/__init__.py +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata/exceptions.py +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata/utils.py +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata.egg-info/SOURCES.txt +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata.egg-info/dependency_links.txt +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata.egg-info/requires.txt +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/fxmacrodata.egg-info/top_level.txt +0 -0
- {fxmacrodata-0.1.0 → fxmacrodata-1.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fxmacrodata
|
|
3
|
+
Version: 1.0.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
|
+
# FXMacroData Python SDK 🐍📊
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
The **FXMacroData Python SDK** provides a simple and efficient interface for fetching **macroeconomic indicators** and **forex price history** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
|
+
|
|
39
|
+
It includes both synchronous and asynchronous clients, supports free USD endpoints, and offers a free Forex Price API for exchange rate data.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🌟 Features
|
|
44
|
+
|
|
45
|
+
- Fetch:
|
|
46
|
+
- **Policy Rates**
|
|
47
|
+
- **Inflation & CPI**
|
|
48
|
+
- **GDP**
|
|
49
|
+
- **Unemployment**
|
|
50
|
+
- **Balance of Trade**
|
|
51
|
+
- **Government Bond Yields**
|
|
52
|
+
- Free access to **USD** macro data.
|
|
53
|
+
- Free **Forex Price API** (`get_fx_price`).
|
|
54
|
+
- API key required only for **non-USD** indicators.
|
|
55
|
+
- Full support for:
|
|
56
|
+
- **Synchronous client**
|
|
57
|
+
- **Asynchronous client**
|
|
58
|
+
- Lightweight: depends only on `requests` and `aiohttp`.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📦 Installation
|
|
63
|
+
|
|
64
|
+
Install from PyPI:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install fxmacrodata
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or install the latest version from GitHub:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install git+https://github.com/fxmacrodata/fxmacrodata.git
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🔧 Usage
|
|
79
|
+
|
|
80
|
+
### Synchronous
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from fxmacrodata import Client
|
|
84
|
+
|
|
85
|
+
client = Client(api_key="YOUR_API_KEY")
|
|
86
|
+
|
|
87
|
+
# Fetch macroeconomic indicators
|
|
88
|
+
data = client.get_indicator(
|
|
89
|
+
"aud", "policy_rate",
|
|
90
|
+
start_date="2023-01-01",
|
|
91
|
+
end_date="2023-11-01"
|
|
92
|
+
)
|
|
93
|
+
print(data)
|
|
94
|
+
|
|
95
|
+
# Free Forex Price Endpoint
|
|
96
|
+
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
97
|
+
print(fx)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Asynchronous
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
import asyncio
|
|
106
|
+
from fxmacrodata import AsyncClient
|
|
107
|
+
|
|
108
|
+
async def main():
|
|
109
|
+
async with AsyncClient(api_key="YOUR_API_KEY") as client:
|
|
110
|
+
# Fetch macroeconomic indicators
|
|
111
|
+
data = await client.get_indicator("eur", "cpi")
|
|
112
|
+
print(data)
|
|
113
|
+
|
|
114
|
+
# Free Forex Price Endpoint
|
|
115
|
+
fx = await client.get_fx_price("usd", "jpy")
|
|
116
|
+
print(fx)
|
|
117
|
+
|
|
118
|
+
asyncio.run(main())
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📘 API Overview
|
|
124
|
+
|
|
125
|
+
### `get_indicator(currency, indicator, start_date=None, end_date=None)`
|
|
126
|
+
Fetches macroeconomic indicator time series data.
|
|
127
|
+
|
|
128
|
+
- `currency`: `"usd"`, `"aud"`, `"eur"`, `"gbp"`, `"cad"`, `"nok"`, `"nzd"`, `"jpy"`, etc.
|
|
129
|
+
- `indicator`: `"policy_rate"`, `"cpi"`, `"inflation"`, `"gdp"`, `"unemployment"`, `"trade_balance"`, `"current_account"`, etc.
|
|
130
|
+
- **API key required for non-USD.**
|
|
131
|
+
|
|
132
|
+
### `get_fx_price(base, quote, start_date=None, end_date=None)`
|
|
133
|
+
Fetches historical FX prices between two currencies. **No API key needed for USD-based queries.**
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 💹 Supported Currencies & Indicators
|
|
138
|
+
|
|
139
|
+
| Category | Metric | USD | EUR | AUD | GBP |
|
|
140
|
+
|---------|--------|-----|-----|-----|-----|
|
|
141
|
+
| **Economy** | GDP Growth | ✓ | ✓ | ✓ | ✓ |
|
|
142
|
+
| | Inflation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
143
|
+
| | Trade Balance | ✓ | ✓ | ✓ | ✓ |
|
|
144
|
+
| | Current Account Balance | ✓ | ✓ | ✓ | ✓ |
|
|
145
|
+
| **Labor Market** | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
|
|
146
|
+
| | Employment Level | ✓ | — | ✓ | ✓ |
|
|
147
|
+
| | Full-Time Employment | ✓ | — | ✓ | — |
|
|
148
|
+
| | Part-Time Employment | ✓ | — | ✓ | — |
|
|
149
|
+
| | Participation Rate | ✓ | — | ✓ | ✓ |
|
|
150
|
+
| | Non-Farm Payrolls | ✓ | — | — | — |
|
|
151
|
+
| **Monetary Policy** | Policy Rate | ✓ | ✓ | ✓ | ✓ |
|
|
152
|
+
| | Interbank Rate | ✓ | ✓ | ✓ | ✓ |
|
|
153
|
+
| **Government Bond Yields** | 2-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
154
|
+
| | 3-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
155
|
+
| | 5-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
156
|
+
| | 10-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
157
|
+
| | Inflation-Linked Bond | ✓ | — | ✓ | ✓ |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 📄 License
|
|
162
|
+
|
|
163
|
+
MIT License © FXMacroData
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 🌐 Links
|
|
168
|
+
|
|
169
|
+
- Website: https://fxmacrodata.com
|
|
170
|
+
- API Docs: https://fxmacrodata.com/docs
|
|
171
|
+
- GitHub: https://github.com/fxmacrodata/fxmacrodata
|
|
172
|
+
- PyPI: https://pypi.org/project/fxmacrodata/
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# FXMacroData Python SDK 🐍📊
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
The **FXMacroData Python SDK** provides a simple and efficient interface for fetching **macroeconomic indicators** and **forex price history** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
9
|
+
|
|
10
|
+
It includes both synchronous and asynchronous clients, supports free USD endpoints, and offers a free Forex Price API for exchange rate data.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🌟 Features
|
|
15
|
+
|
|
16
|
+
- Fetch:
|
|
17
|
+
- **Policy Rates**
|
|
18
|
+
- **Inflation & CPI**
|
|
19
|
+
- **GDP**
|
|
20
|
+
- **Unemployment**
|
|
21
|
+
- **Balance of Trade**
|
|
22
|
+
- **Government Bond Yields**
|
|
23
|
+
- Free access to **USD** macro data.
|
|
24
|
+
- Free **Forex Price API** (`get_fx_price`).
|
|
25
|
+
- API key required only for **non-USD** indicators.
|
|
26
|
+
- Full support for:
|
|
27
|
+
- **Synchronous client**
|
|
28
|
+
- **Asynchronous client**
|
|
29
|
+
- Lightweight: depends only on `requests` and `aiohttp`.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 📦 Installation
|
|
34
|
+
|
|
35
|
+
Install from PyPI:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install fxmacrodata
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or install the latest version from GitHub:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install git+https://github.com/fxmacrodata/fxmacrodata.git
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🔧 Usage
|
|
50
|
+
|
|
51
|
+
### Synchronous
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from fxmacrodata import Client
|
|
55
|
+
|
|
56
|
+
client = Client(api_key="YOUR_API_KEY")
|
|
57
|
+
|
|
58
|
+
# Fetch macroeconomic indicators
|
|
59
|
+
data = client.get_indicator(
|
|
60
|
+
"aud", "policy_rate",
|
|
61
|
+
start_date="2023-01-01",
|
|
62
|
+
end_date="2023-11-01"
|
|
63
|
+
)
|
|
64
|
+
print(data)
|
|
65
|
+
|
|
66
|
+
# Free Forex Price Endpoint
|
|
67
|
+
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
68
|
+
print(fx)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### Asynchronous
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import asyncio
|
|
77
|
+
from fxmacrodata import AsyncClient
|
|
78
|
+
|
|
79
|
+
async def main():
|
|
80
|
+
async with AsyncClient(api_key="YOUR_API_KEY") as client:
|
|
81
|
+
# Fetch macroeconomic indicators
|
|
82
|
+
data = await client.get_indicator("eur", "cpi")
|
|
83
|
+
print(data)
|
|
84
|
+
|
|
85
|
+
# Free Forex Price Endpoint
|
|
86
|
+
fx = await client.get_fx_price("usd", "jpy")
|
|
87
|
+
print(fx)
|
|
88
|
+
|
|
89
|
+
asyncio.run(main())
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 📘 API Overview
|
|
95
|
+
|
|
96
|
+
### `get_indicator(currency, indicator, start_date=None, end_date=None)`
|
|
97
|
+
Fetches macroeconomic indicator time series data.
|
|
98
|
+
|
|
99
|
+
- `currency`: `"usd"`, `"aud"`, `"eur"`, `"gbp"`, `"cad"`, `"nok"`, `"nzd"`, `"jpy"`, etc.
|
|
100
|
+
- `indicator`: `"policy_rate"`, `"cpi"`, `"inflation"`, `"gdp"`, `"unemployment"`, `"trade_balance"`, `"current_account"`, etc.
|
|
101
|
+
- **API key required for non-USD.**
|
|
102
|
+
|
|
103
|
+
### `get_fx_price(base, quote, start_date=None, end_date=None)`
|
|
104
|
+
Fetches historical FX prices between two currencies. **No API key needed for USD-based queries.**
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 💹 Supported Currencies & Indicators
|
|
109
|
+
|
|
110
|
+
| Category | Metric | USD | EUR | AUD | GBP |
|
|
111
|
+
|---------|--------|-----|-----|-----|-----|
|
|
112
|
+
| **Economy** | GDP Growth | ✓ | ✓ | ✓ | ✓ |
|
|
113
|
+
| | Inflation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
114
|
+
| | Trade Balance | ✓ | ✓ | ✓ | ✓ |
|
|
115
|
+
| | Current Account Balance | ✓ | ✓ | ✓ | ✓ |
|
|
116
|
+
| **Labor Market** | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
|
|
117
|
+
| | Employment Level | ✓ | — | ✓ | ✓ |
|
|
118
|
+
| | Full-Time Employment | ✓ | — | ✓ | — |
|
|
119
|
+
| | Part-Time Employment | ✓ | — | ✓ | — |
|
|
120
|
+
| | Participation Rate | ✓ | — | ✓ | ✓ |
|
|
121
|
+
| | Non-Farm Payrolls | ✓ | — | — | — |
|
|
122
|
+
| **Monetary Policy** | Policy Rate | ✓ | ✓ | ✓ | ✓ |
|
|
123
|
+
| | Interbank Rate | ✓ | ✓ | ✓ | ✓ |
|
|
124
|
+
| **Government Bond Yields** | 2-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
125
|
+
| | 3-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
126
|
+
| | 5-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
127
|
+
| | 10-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
128
|
+
| | Inflation-Linked Bond | ✓ | — | ✓ | ✓ |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 📄 License
|
|
133
|
+
|
|
134
|
+
MIT License © FXMacroData
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🌐 Links
|
|
139
|
+
|
|
140
|
+
- Website: https://fxmacrodata.com
|
|
141
|
+
- API Docs: https://fxmacrodata.com/docs
|
|
142
|
+
- GitHub: https://github.com/fxmacrodata/fxmacrodata
|
|
143
|
+
- PyPI: https://pypi.org/project/fxmacrodata/
|
|
@@ -7,10 +7,6 @@ class AsyncClient:
|
|
|
7
7
|
BASE_URL = "https://fxmacrodata.com/api"
|
|
8
8
|
|
|
9
9
|
def __init__(self, api_key: Optional[str] = None):
|
|
10
|
-
"""
|
|
11
|
-
Asynchronous FXMacroData Client.
|
|
12
|
-
api_key: Required for non-USD currencies. USD is public.
|
|
13
|
-
"""
|
|
14
10
|
self.api_key: Optional[str] = api_key
|
|
15
11
|
self.session: Optional[aiohttp.ClientSession] = None
|
|
16
12
|
|
|
@@ -23,7 +19,7 @@ class AsyncClient:
|
|
|
23
19
|
await self.session.close()
|
|
24
20
|
self.session = None
|
|
25
21
|
|
|
26
|
-
async def
|
|
22
|
+
async def get_indicator(
|
|
27
23
|
self,
|
|
28
24
|
currency: str,
|
|
29
25
|
indicator: str,
|
|
@@ -50,10 +46,38 @@ class AsyncClient:
|
|
|
50
46
|
if not self.session:
|
|
51
47
|
self.session = aiohttp.ClientSession()
|
|
52
48
|
|
|
53
|
-
assert self.session is not None # mypy now knows session is initialized
|
|
54
|
-
|
|
55
49
|
async with self.session.get(url, headers=headers, params=params) as resp:
|
|
56
50
|
if resp.status != 200:
|
|
57
51
|
text = await resp.text()
|
|
58
52
|
raise FXMacroDataError(f"{resp.status} - {text}")
|
|
59
53
|
return await resp.json()
|
|
54
|
+
|
|
55
|
+
# --------------------------------------------
|
|
56
|
+
# NEW: Free Forex Endpoint (Async)
|
|
57
|
+
# --------------------------------------------
|
|
58
|
+
async def get_fx_price(
|
|
59
|
+
self,
|
|
60
|
+
base: str,
|
|
61
|
+
quote: str,
|
|
62
|
+
start_date: Optional[str] = None,
|
|
63
|
+
end_date: Optional[str] = None,
|
|
64
|
+
) -> dict:
|
|
65
|
+
base = base.lower()
|
|
66
|
+
quote = quote.lower()
|
|
67
|
+
|
|
68
|
+
url = f"{self.BASE_URL}/forex/{base}/{quote}"
|
|
69
|
+
|
|
70
|
+
params = {}
|
|
71
|
+
if start_date:
|
|
72
|
+
params["start_date"] = start_date
|
|
73
|
+
if end_date:
|
|
74
|
+
params["end_date"] = end_date
|
|
75
|
+
|
|
76
|
+
if not self.session:
|
|
77
|
+
self.session = aiohttp.ClientSession()
|
|
78
|
+
|
|
79
|
+
async with self.session.get(url, params=params) as resp:
|
|
80
|
+
if resp.status != 200:
|
|
81
|
+
text = await resp.text()
|
|
82
|
+
raise FXMacroDataError(f"{resp.status} - {text}")
|
|
83
|
+
return await resp.json()
|
|
@@ -7,13 +7,9 @@ class Client:
|
|
|
7
7
|
BASE_URL = "https://fxmacrodata.com/api"
|
|
8
8
|
|
|
9
9
|
def __init__(self, api_key: Optional[str] = None):
|
|
10
|
-
"""
|
|
11
|
-
Synchronous FXMacroData Client.
|
|
12
|
-
api_key: Required for non-USD currencies. USD is public.
|
|
13
|
-
"""
|
|
14
10
|
self.api_key = api_key
|
|
15
11
|
|
|
16
|
-
def
|
|
12
|
+
def get_indicator(
|
|
17
13
|
self,
|
|
18
14
|
currency: str,
|
|
19
15
|
indicator: str,
|
|
@@ -46,3 +42,34 @@ class Client:
|
|
|
46
42
|
raise FXMacroDataError(f"{response.status_code} - {response.text}")
|
|
47
43
|
|
|
48
44
|
return response.json()
|
|
45
|
+
|
|
46
|
+
# --------------------------------------------
|
|
47
|
+
# NEW: Free Forex Endpoint
|
|
48
|
+
# --------------------------------------------
|
|
49
|
+
def get_fx_price(
|
|
50
|
+
self,
|
|
51
|
+
base: str,
|
|
52
|
+
quote: str,
|
|
53
|
+
start_date: Optional[str] = None,
|
|
54
|
+
end_date: Optional[str] = None,
|
|
55
|
+
) -> dict:
|
|
56
|
+
base = base.lower()
|
|
57
|
+
quote = quote.lower()
|
|
58
|
+
|
|
59
|
+
url = f"{self.BASE_URL}/forex/{base}/{quote}"
|
|
60
|
+
|
|
61
|
+
params = {}
|
|
62
|
+
if start_date:
|
|
63
|
+
params["start_date"] = start_date
|
|
64
|
+
if end_date:
|
|
65
|
+
params["end_date"] = end_date
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
response = requests.get(url, params=params)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
raise FXMacroDataError(f"Request failed: {e}")
|
|
71
|
+
|
|
72
|
+
if response.status_code != 200:
|
|
73
|
+
raise FXMacroDataError(f"{response.status_code} - {response.text}")
|
|
74
|
+
|
|
75
|
+
return response.json()
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fxmacrodata
|
|
3
|
+
Version: 1.0.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
|
+
# FXMacroData Python SDK 🐍📊
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
The **FXMacroData Python SDK** provides a simple and efficient interface for fetching **macroeconomic indicators** and **forex price history** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
|
+
|
|
39
|
+
It includes both synchronous and asynchronous clients, supports free USD endpoints, and offers a free Forex Price API for exchange rate data.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🌟 Features
|
|
44
|
+
|
|
45
|
+
- Fetch:
|
|
46
|
+
- **Policy Rates**
|
|
47
|
+
- **Inflation & CPI**
|
|
48
|
+
- **GDP**
|
|
49
|
+
- **Unemployment**
|
|
50
|
+
- **Balance of Trade**
|
|
51
|
+
- **Government Bond Yields**
|
|
52
|
+
- Free access to **USD** macro data.
|
|
53
|
+
- Free **Forex Price API** (`get_fx_price`).
|
|
54
|
+
- API key required only for **non-USD** indicators.
|
|
55
|
+
- Full support for:
|
|
56
|
+
- **Synchronous client**
|
|
57
|
+
- **Asynchronous client**
|
|
58
|
+
- Lightweight: depends only on `requests` and `aiohttp`.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📦 Installation
|
|
63
|
+
|
|
64
|
+
Install from PyPI:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install fxmacrodata
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or install the latest version from GitHub:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install git+https://github.com/fxmacrodata/fxmacrodata.git
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🔧 Usage
|
|
79
|
+
|
|
80
|
+
### Synchronous
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from fxmacrodata import Client
|
|
84
|
+
|
|
85
|
+
client = Client(api_key="YOUR_API_KEY")
|
|
86
|
+
|
|
87
|
+
# Fetch macroeconomic indicators
|
|
88
|
+
data = client.get_indicator(
|
|
89
|
+
"aud", "policy_rate",
|
|
90
|
+
start_date="2023-01-01",
|
|
91
|
+
end_date="2023-11-01"
|
|
92
|
+
)
|
|
93
|
+
print(data)
|
|
94
|
+
|
|
95
|
+
# Free Forex Price Endpoint
|
|
96
|
+
fx = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
97
|
+
print(fx)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Asynchronous
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
import asyncio
|
|
106
|
+
from fxmacrodata import AsyncClient
|
|
107
|
+
|
|
108
|
+
async def main():
|
|
109
|
+
async with AsyncClient(api_key="YOUR_API_KEY") as client:
|
|
110
|
+
# Fetch macroeconomic indicators
|
|
111
|
+
data = await client.get_indicator("eur", "cpi")
|
|
112
|
+
print(data)
|
|
113
|
+
|
|
114
|
+
# Free Forex Price Endpoint
|
|
115
|
+
fx = await client.get_fx_price("usd", "jpy")
|
|
116
|
+
print(fx)
|
|
117
|
+
|
|
118
|
+
asyncio.run(main())
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📘 API Overview
|
|
124
|
+
|
|
125
|
+
### `get_indicator(currency, indicator, start_date=None, end_date=None)`
|
|
126
|
+
Fetches macroeconomic indicator time series data.
|
|
127
|
+
|
|
128
|
+
- `currency`: `"usd"`, `"aud"`, `"eur"`, `"gbp"`, `"cad"`, `"nok"`, `"nzd"`, `"jpy"`, etc.
|
|
129
|
+
- `indicator`: `"policy_rate"`, `"cpi"`, `"inflation"`, `"gdp"`, `"unemployment"`, `"trade_balance"`, `"current_account"`, etc.
|
|
130
|
+
- **API key required for non-USD.**
|
|
131
|
+
|
|
132
|
+
### `get_fx_price(base, quote, start_date=None, end_date=None)`
|
|
133
|
+
Fetches historical FX prices between two currencies. **No API key needed for USD-based queries.**
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 💹 Supported Currencies & Indicators
|
|
138
|
+
|
|
139
|
+
| Category | Metric | USD | EUR | AUD | GBP |
|
|
140
|
+
|---------|--------|-----|-----|-----|-----|
|
|
141
|
+
| **Economy** | GDP Growth | ✓ | ✓ | ✓ | ✓ |
|
|
142
|
+
| | Inflation Rate | ✓ | ✓ | ✓ | ✓ |
|
|
143
|
+
| | Trade Balance | ✓ | ✓ | ✓ | ✓ |
|
|
144
|
+
| | Current Account Balance | ✓ | ✓ | ✓ | ✓ |
|
|
145
|
+
| **Labor Market** | Unemployment Rate | ✓ | ✓ | ✓ | ✓ |
|
|
146
|
+
| | Employment Level | ✓ | — | ✓ | ✓ |
|
|
147
|
+
| | Full-Time Employment | ✓ | — | ✓ | — |
|
|
148
|
+
| | Part-Time Employment | ✓ | — | ✓ | — |
|
|
149
|
+
| | Participation Rate | ✓ | — | ✓ | ✓ |
|
|
150
|
+
| | Non-Farm Payrolls | ✓ | — | — | — |
|
|
151
|
+
| **Monetary Policy** | Policy Rate | ✓ | ✓ | ✓ | ✓ |
|
|
152
|
+
| | Interbank Rate | ✓ | ✓ | ✓ | ✓ |
|
|
153
|
+
| **Government Bond Yields** | 2-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
154
|
+
| | 3-Year Govt Bond | ✓ | ✓ | ✓ | — |
|
|
155
|
+
| | 5-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
156
|
+
| | 10-Year Govt Bond | ✓ | ✓ | ✓ | ✓ |
|
|
157
|
+
| | Inflation-Linked Bond | ✓ | — | ✓ | ✓ |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 📄 License
|
|
162
|
+
|
|
163
|
+
MIT License © FXMacroData
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 🌐 Links
|
|
168
|
+
|
|
169
|
+
- Website: https://fxmacrodata.com
|
|
170
|
+
- API Docs: https://fxmacrodata.com/docs
|
|
171
|
+
- GitHub: https://github.com/fxmacrodata/fxmacrodata
|
|
172
|
+
- PyPI: https://pypi.org/project/fxmacrodata/
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fxmacrodata"
|
|
7
|
-
version = "
|
|
7
|
+
version = "1.0.0"
|
|
8
8
|
description = "Python client for the FXMacroData API, providing forex macroeconomic data for traders, quants, and analysts."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -20,25 +20,34 @@ def client_without_key():
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def test_usd_endpoint_no_key(client_without_key):
|
|
23
|
-
"""USD endpoint should work without API key."""
|
|
24
|
-
result = client_without_key.
|
|
23
|
+
"""USD indicator endpoint should work without API key."""
|
|
24
|
+
result = client_without_key.get_indicator("usd", "gdp")
|
|
25
25
|
assert result["currency"] == "USD"
|
|
26
26
|
assert result["indicator"] == "gdp"
|
|
27
27
|
assert isinstance(result["data"], list)
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def test_non_usd_endpoint_no_key(client_without_key):
|
|
31
|
-
"""Non-USD endpoint should raise FXMacroDataError without API key."""
|
|
31
|
+
"""Non-USD indicator endpoint should raise FXMacroDataError without API key."""
|
|
32
32
|
with pytest.raises(FXMacroDataError) as exc:
|
|
33
|
-
client_without_key.
|
|
33
|
+
client_without_key.get_indicator("aud", "gdp")
|
|
34
34
|
assert "API key required" in str(exc.value)
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def test_non_usd_endpoint_with_key(client_with_key):
|
|
38
|
-
"""Non-USD endpoint should succeed with API key."""
|
|
39
|
-
result = client_with_key.
|
|
38
|
+
"""Non-USD indicator endpoint should succeed with API key."""
|
|
39
|
+
result = client_with_key.get_indicator(
|
|
40
40
|
"aud", "gdp", start_date="2023-01-01", end_date="2023-12-31"
|
|
41
41
|
)
|
|
42
42
|
assert result["currency"] == "AUD"
|
|
43
43
|
assert result["indicator"] == "gdp"
|
|
44
44
|
assert isinstance(result["data"], list)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_free_fx_price_endpoint():
|
|
48
|
+
"""Free forex price endpoint should return data without API key."""
|
|
49
|
+
client = Client() # no key needed for forex endpoints
|
|
50
|
+
result = client.get_fx_price("usd", "gbp", start_date="2025-01-01")
|
|
51
|
+
assert result["base"] == "USD"
|
|
52
|
+
assert result["quote"] == "GBP"
|
|
53
|
+
assert isinstance(result["data"], dict)
|
fxmacrodata-0.1.0/PKG-INFO
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fxmacrodata
|
|
3
|
-
Version: 0.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
|
-
# FXMacroData Python SDK 🐍📊
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-

|
|
34
|
-

|
|
35
|
-

|
|
36
|
-
|
|
37
|
-
The **FXMacroData Python SDK** is a lightweight, easy-to-use client for fetching **forex macroeconomic data** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
|
-
|
|
39
|
-
It supports **synchronous** and **asynchronous** requests, provides ready-to-use JSON responses, and enforces API keys only for non-USD endpoints. Perfect for developers, quants, and algo traders.
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 🌟 Features
|
|
44
|
-
|
|
45
|
-
- Fetch **policy rates, CPI, inflation, GDP, unemployment**, and other macroeconomic indicators.
|
|
46
|
-
- Supports **USD (free)** and **other currencies via RapidAPI key**.
|
|
47
|
-
- **Async-first** design for bulk data fetching.
|
|
48
|
-
- Works with **Python 3.9+**.
|
|
49
|
-
- Compatible with **TradingBots, Jupyter Notebooks, Backtests**.
|
|
50
|
-
- Minimal dependencies: `requests`, `aiohttp`.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 📦 Installation
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
pip install fxmacrodata
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Or install the latest version from GitHub:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
pip install git+https://github.com/yourusername/fxmacrodata.git
|
|
64
|
-
```
|
fxmacrodata-0.1.0/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# FXMacroData Python SDK 🐍📊
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
The **FXMacroData Python SDK** is a lightweight, easy-to-use client for fetching **forex macroeconomic data** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
9
|
-
|
|
10
|
-
It supports **synchronous** and **asynchronous** requests, provides ready-to-use JSON responses, and enforces API keys only for non-USD endpoints. Perfect for developers, quants, and algo traders.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 🌟 Features
|
|
15
|
-
|
|
16
|
-
- Fetch **policy rates, CPI, inflation, GDP, unemployment**, and other macroeconomic indicators.
|
|
17
|
-
- Supports **USD (free)** and **other currencies via RapidAPI key**.
|
|
18
|
-
- **Async-first** design for bulk data fetching.
|
|
19
|
-
- Works with **Python 3.9+**.
|
|
20
|
-
- Compatible with **TradingBots, Jupyter Notebooks, Backtests**.
|
|
21
|
-
- Minimal dependencies: `requests`, `aiohttp`.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 📦 Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
pip install fxmacrodata
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Or install the latest version from GitHub:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
pip install git+https://github.com/yourusername/fxmacrodata.git
|
|
35
|
-
```
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fxmacrodata
|
|
3
|
-
Version: 0.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
|
-
# FXMacroData Python SDK 🐍📊
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-

|
|
34
|
-

|
|
35
|
-

|
|
36
|
-
|
|
37
|
-
The **FXMacroData Python SDK** is a lightweight, easy-to-use client for fetching **forex macroeconomic data** from [FXMacroData](https://fxmacrodata.com/?utm_source=github&utm_medium=readme&utm_campaign=python_sdk).
|
|
38
|
-
|
|
39
|
-
It supports **synchronous** and **asynchronous** requests, provides ready-to-use JSON responses, and enforces API keys only for non-USD endpoints. Perfect for developers, quants, and algo traders.
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 🌟 Features
|
|
44
|
-
|
|
45
|
-
- Fetch **policy rates, CPI, inflation, GDP, unemployment**, and other macroeconomic indicators.
|
|
46
|
-
- Supports **USD (free)** and **other currencies via RapidAPI key**.
|
|
47
|
-
- **Async-first** design for bulk data fetching.
|
|
48
|
-
- Works with **Python 3.9+**.
|
|
49
|
-
- Compatible with **TradingBots, Jupyter Notebooks, Backtests**.
|
|
50
|
-
- Minimal dependencies: `requests`, `aiohttp`.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 📦 Installation
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
pip install fxmacrodata
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Or install the latest version from GitHub:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
pip install git+https://github.com/yourusername/fxmacrodata.git
|
|
64
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|