-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoldAPIDemo.py
32 lines (25 loc) · 1.19 KB
/
GoldAPIDemo.py
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
32
from MetalPrice.GoldAPI.Client import GoldAPIClient, GoldPriceClient, SilverPriceClient, PlatinumPriceClient
import ssl
import pandas as pd
ssl._create_default_https_context = ssl._create_unverified_context
# client = GoldAPIClient("goldapi-14sk9jtkxqaji16-io")
# # datas = client.getJsonStatus()
# datas = client.getJsonPrice("20211228")
# print(datas)
# df = pd.read_csv('./GoldPrice_2021-01-01-2021-12-28.csv')
# df.to_csv('./GoldPriceCache.csv', index=False)
api_key = "goldapi-14sk9jtkxqaji16-io" # nccu
# api_key = "goldapi-2rdpxtkxtumogz-io" # nccu-g
# api_key = "goldapi-31ny7fitkxwbzc7l-io"
since = "2021-07-01"
until = "2022-01-11"
gold_price_client = GoldPriceClient(api_key)
df_price = gold_price_client.getGoldAPIPriceDataFrame(since=since, desig_col_list=["date", "price"])
gold_price_client.close()
print(df_price)
# silver_price_client = SilverPriceClient(api_key)
# df_price = silver_price_client.getGoldAPIPriceDataFrame(since=since, until=until, desig_col_list=["date", "price"])
# print(df_price)
# platinum_price_client = PlatinumPriceClient(api_key)
# df_price = platinum_price_client.getGoldAPIPriceDataFrame(since=since, until=until, desig_col_list=["date", "price"])
# print(df_price)