Skip to content

Commit

Permalink
V0.2.2 modify dukas
Browse files Browse the repository at this point in the history
  • Loading branch information
TerenceLiu98 committed Dec 31, 2021
1 parent fe5836c commit 73e7182
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CEDA/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import os

__version__ = "0.2.1"
__version__ = "0.2.2"
__author__ = "Terence Lau"


Expand Down
36 changes: 21 additions & 15 deletions CEDA/market/duka.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
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"]
Expand All @@ -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)
"""
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
setup(
name = "CEDApy",
version = "0.2.1",
version = "0.2.2",
keywords = "quantitative economic data",
long_description = open(
os.path.join(
Expand Down

0 comments on commit 73e7182

Please sign in to comment.