Skip to content

Commit

Permalink
Fixed issue with Dukascopy
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed May 14, 2023
1 parent ba27b4b commit 4d6b719
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 121 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -115,6 +115,7 @@ individual data providers)

# Release Notes

* 0.1.29 - findatapy (14 May 2023)
* 0.1.28 - findatapy (19 Jul 2022)
* 0.1.27 - findatapy (20 May 2022)
* 0.1.26 - findatapy (07 Oct 2021)
Expand All @@ -135,6 +136,10 @@ individual data providers)

# Coding log

* 12 May 2023
* Fixed Dukascopy downloader
* 29 Aug 2022
* Reformatted text for line length
* 23 Aug 2022
* Simplified MarketDataRequest
* 12 Aug 2022
Expand Down
9 changes: 5 additions & 4 deletions findatapy/market/datavendorbbg.py
Expand Up @@ -162,7 +162,8 @@ def load_ticker(self, md_request):
md_request_vendor)

# if data_frame is not None:
# # Convert fields with release-dt to dates (special case!) and assume everything else numerical
# # Convert fields with release-dt to dates (special case!)
# # and assume everything else numerical
# for c in data_frame.columns:
# try:
# if 'release-dt' in c:
Expand Down Expand Up @@ -446,7 +447,7 @@ def download_intraday(self, md_request):
# Bloomberg OpenAPI implementation
low_level_loader = BBGLowLevelIntraday()

# by default we download all available fields!
# By default we download all available fields!
data_frame = low_level_loader.load_time_series(md_request)

# self.kill_session() # need to forcibly kill_session since can't
Expand All @@ -472,7 +473,7 @@ def download_ref(self, md_request):

md_request_vendor_selective = copy.copy(md_request)

# special case for future date releases
# Special case for future date releases
# if 'release-date-time-full' in md_request.fields:
# md_request_vendor_selective.fields = ['ECO_FUTURE_RELEASE_DATE_LIST']
#
Expand Down Expand Up @@ -706,7 +707,7 @@ def start_bloomberg_session(self):
logger = LoggerManager().getLogger(__name__)

# Try up to 5 times to start a session
while (tries < 5):
while tries < 5:
try:
# fill SessionOptions
sessionOptions = blpapi.SessionOptions()
Expand Down
27 changes: 22 additions & 5 deletions findatapy/market/datavendorweb.py
Expand Up @@ -1784,8 +1784,18 @@ def fetch_tick(self, tick_url, try_time):
# If URL has not been found try again
if tick_request.status_code == 404:
logger.warning(
"Error downloading.. " + tick_url + " returned 404 "
"URL not found message! Are you sure Dukascopy has this asset?")
"Error downloading.. "
+ tick_url + " returned 404 " +
"URL not found message! Are you sure Dukascopy has this asset?")

tick_request_content = None
tick_request.close()

break
elif tick_request.status_code == 503:
logger.warning(
"Error downloading.. " + tick_url +
" returned 503 and service unavailable")

tick_request_content = None
tick_request.close()
Expand All @@ -1798,13 +1808,13 @@ def fetch_tick(self, tick_url, try_time):

content_text = tick_request_content.decode("latin1")

# Can sometimes get back an error HTML page, in which
# Can sometimes get back an error HTML page, in which
# case retry
if 'error' not in str(content_text):
break
else:
logger.warning(
"Error downloading.. " + tick_url + " "
"Error downloading.. " + tick_url + " "
+ content_text + " will try again "
+ str(download_counter) + " occasion")
except Exception as e:
Expand Down Expand Up @@ -2811,6 +2821,8 @@ def download_data_frame(data_source):
data_frame = IOEngine().read_time_series_cache_from_disk(
full_path, engine=data_engine)

# data_frame.to_csv("temp.csv")

if data_frame is None or data_frame.index is []: return None

if data_frame is not None:
Expand All @@ -2831,8 +2843,13 @@ def download_data_frame(data_source):
data_frame.columns = ticker_combined
data_frame.index.name = "Date"

msg = str(ticker_combined)

if len(msg) > 100:
msg = msg[:99] + "...]"

logger.info("Completed request from " + str(
data_source) + " for " + str(ticker_combined))
data_source) + " for " + msg)

return data_frame

Expand Down

0 comments on commit 4d6b719

Please sign in to comment.