-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (22 loc) · 814 Bytes
/
example.py
File metadata and controls
31 lines (22 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# example.py
from dataquery_api import DQInterface
import pandas as pd
client_id = "<your_client_id>" # replace with your client id & secret
client_secret = "<your_client_secret>"
# initialize the DQInterface object with your client id & secret
dq: DQInterface = DQInterface(client_id, client_secret)
# check that you have a valid token and can access the API
assert dq.heartbeat(), "DataQuery API Heartbeat failed."
# create a list of expressions
expressions = [
"DB(JPMAQS,USD_EQXR_VT10,value)",
"DB(JPMAQS,AUD_EXALLOPENNESS_NSA_1YMA,value)",
]
# dates as strings in the format YYYY-MM-DD
start_date: str = "2020-01-25"
end_date: str = "2023-02-05"
# download the data
data: pd.DataFrame = dq.download(
expressions=expressions, start_date=start_date, end_date=end_date
)
print(data.head())