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 os
__version__ = "0.2.1"
__version__ = "0.2.2"
__author__ = "Terence Lau"

View File

@ -9,15 +9,18 @@ from urllib.parse import quote, urlencode
from fake_useragent import UserAgent
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(
instrument: str,
startdate: str,
enddate: str,
timeframe: str,
pricetype: str,
utc: int,
volume: bool,
flat: bool):
tmp_url = url["dukascopy"]
@ -28,22 +31,25 @@ def dukascopy(
"startdate": "{}".format(startdate),
"enddate": "{}".format(enddate),
"timeframe": "{}".format(timeframe),
"utc": "{}".format(utc),
"pricetype": "{}".format(pricetype),
"volume": "{}".format(volume),
"flat": "{}".format(flat)
"volume": "{}".format(str(volume).lower()),
"flat": "{}".format(str(flat).lower())
}
r = requests.get(tmp_url, params=request_params, headers=request_header)
data_text = r.text
data_json = demjson.decode(data_text)
df = pd.DataFrame(data_json['result'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df.columns = [
"Date",
"Open",
"High",
"Low",
"Close",
"Volume"
]
return df
output_file = demjson.decode(data_text)
return pd.json_normalize(output_file)
# example:
"""
df = dukascopy(instrument = "btcusd",
startdate = "2020-01-01",
enddate = "2021-01-01",
timeframe = "d1",
pricetype = "bid",
utc = 0,
volume = True,
flat = True)
"""

View File

@ -45,11 +45,11 @@ Please check [Wiki](https://github.com/TerenceLiu98/CEDApy/wiki)
```txt
@software{terencelau_2021_5229506,
author = {TerenceLau},
title = {TerenceLiu98/CEDApy: V0.2.1},
title = {TerenceLiu98/CEDApy: V0.2.2},
month = aug,
year = 2021,
publisher = {Zenodo},
version = {V0.2.1},
version = {V0.2.2},
doi = {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
setup(
name = "CEDApy",
version = "0.2.1",
version = "0.2.2",
keywords = "quantitative economic data",
long_description = open(
os.path.join(