V0.2.2 modify dukas

This commit is contained in:
TerenceLiu98 2022-01-01 03:03:50 +08:00
parent fe5836c74b
commit 73e7182f2a
4 changed files with 25 additions and 19 deletions

View File

@ -1,7 +1,7 @@
import sys import sys
import os import os
__version__ = "0.2.1" __version__ = "0.2.2"
__author__ = "Terence Lau" __author__ = "Terence Lau"

View File

@ -9,15 +9,18 @@ from urllib.parse import quote, urlencode
from fake_useragent import UserAgent from fake_useragent import UserAgent
url = { url = {
"dukascopy": "http://data.uicstat.com/api_1.0" "dukascopy": "http://data.deluxelau.com/forex/api/v1.0/getdata?"
} }
#?instrument=usdcnh&startdate=2014-01-01&enddate=2014-12-31&timeframe=d1&pricetype=ask&utc=0&volume=false&flat=false
def dukascopy( def dukascopy(
instrument: str, instrument: str,
startdate: str, startdate: str,
enddate: str, enddate: str,
timeframe: str, timeframe: str,
pricetype: str, pricetype: str,
utc: int,
volume: bool, volume: bool,
flat: bool): flat: bool):
tmp_url = url["dukascopy"] tmp_url = url["dukascopy"]
@ -28,22 +31,25 @@ def dukascopy(
"startdate": "{}".format(startdate), "startdate": "{}".format(startdate),
"enddate": "{}".format(enddate), "enddate": "{}".format(enddate),
"timeframe": "{}".format(timeframe), "timeframe": "{}".format(timeframe),
"utc": "{}".format(utc),
"pricetype": "{}".format(pricetype), "pricetype": "{}".format(pricetype),
"volume": "{}".format(volume), "volume": "{}".format(str(volume).lower()),
"flat": "{}".format(flat) "flat": "{}".format(str(flat).lower())
} }
r = requests.get(tmp_url, params=request_params, headers=request_header) r = requests.get(tmp_url, params=request_params, headers=request_header)
data_text = r.text data_text = r.text
data_json = demjson.decode(data_text) output_file = demjson.decode(data_text)
df = pd.DataFrame(data_json['result']) return pd.json_normalize(output_file)
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df.columns = [ # example:
"Date", """
"Open", df = dukascopy(instrument = "btcusd",
"High", startdate = "2020-01-01",
"Low", enddate = "2021-01-01",
"Close", timeframe = "d1",
"Volume" pricetype = "bid",
] utc = 0,
return df volume = True,
flat = True)
"""

View File

@ -45,11 +45,11 @@ Please check [Wiki](https://github.com/TerenceLiu98/CEDApy/wiki)
```txt ```txt
@software{terencelau_2021_5229506, @software{terencelau_2021_5229506,
author = {TerenceLau}, author = {TerenceLau},
title = {TerenceLiu98/CEDApy: V0.2.1}, title = {TerenceLiu98/CEDApy: V0.2.2},
month = aug, month = aug,
year = 2021, year = 2021,
publisher = {Zenodo}, publisher = {Zenodo},
version = {V0.2.1}, version = {V0.2.2},
doi = {10.5281/zenodo.5229506}, doi = {10.5281/zenodo.5229506},
url = {https://doi.org/10.5281/zenodo.5229506} url = {https://doi.org/10.5281/zenodo.5229506}
} }

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
import os import os
setup( setup(
name = "CEDApy", name = "CEDApy",
version = "0.2.1", version = "0.2.2",
keywords = "quantitative economic data", keywords = "quantitative economic data",
long_description = open( long_description = open(
os.path.join( os.path.join(