Skip to content

Commit

Permalink
Fixed overrides bug in BBG
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Dec 14, 2021
1 parent 9627517 commit e163f33
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 24 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ individual data providers)

# Coding log

* xx Oct 2021
* 14 Dec 2021
* Fixed bug in overrides for BBG
* Patched ticker for EUR1Y deposit rate
* 07 Oct 2021
* Fixed bug in downloading data for unusual categories
Expand Down
64 changes: 42 additions & 22 deletions findatapy/market/datavendorbbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,27 +748,25 @@ def fill_options(self, market_data_request):

options.overrides = market_data_request.overrides

# options_copy = OptionsBBG(options_bbg=options)

options_list = []

last_overide_combo = {}
override_dict = {}

if market_data_request.old_tickers is not None:

ticker_list = []
curr_options = OptionsBBG(options_bbg=options)
# curr_options = OptionsBBG(options_bbg=options)

## Special case for GDP where the advance, final and preliminary releases (but can define more
# in DataConstants)
# have the same ticker but different overrides
bbg_keyword_dict_override = constants.bbg_keyword_dict_override

for tick, old_tick in zip(market_data_request.tickers, market_data_request.old_tickers):
if old_tick is not None:

t = old_tick.lower()

## Special case for GDP where the advance, final and preliminary releases (but can define more
# in DataConstants)
# have the same ticker but different overrides
bbg_keyword_dict_override = constants.bbg_keyword_dict_override

# eg. RELEASE_STAGE_OVERRIDE
for bbg_override in bbg_keyword_dict_override.keys():

Expand All @@ -779,27 +777,49 @@ def fill_options(self, market_data_request):
# eg. ['gdp', 'advance']
keyword = keyword_dict[bbg_keyword]

# if this matches a case, we have override
if all(k.lower() in t for k in keyword):

if bbg_override in last_overide_combo:
if last_overide_combo[bbg_override] != bbg_keyword:
curr_options.security = ticker_list
options_list.append(curr_options)
# In case we have multiple overrides for this ticker
if tick in override_dict:
override_dict[tick][bbg_override] = bbg_keyword
else:
override_dict[tick] = {bbg_override: bbg_keyword}

ticker_list = []
## Add other special cases
if tick not in override_dict:
override_dict[tick] = {}

curr_options = OptionsBBG(options_bbg=options)
# if ticker_list != []:
# curr_options.security = ticker_list

last_overide_combo[bbg_override] = bbg_keyword
curr_options.overrides[bbg_override] = bbg_keyword
last_override = {}

## Add other special cases
ticker_list.append(tick)
def add_new_options(tick_):
curr_options = OptionsBBG(options_bbg=options)
curr_options.security = [tick_]

if override != {}:
curr_options.overrides = override

options_list.append(curr_options)

# Combine the securities into a list of options (each with common
# overrides)
for tick, override in override_dict.items():
if override == last_override:

if len(options_list) > 0:
options_list[-1].security.append(tick)
else:
add_new_options(tick)
else:
add_new_options(tick)

if ticker_list != []:
curr_options.security = ticker_list
last_override = override

options_list.append(curr_options)
print('stop')
# options_list.append(curr_options)
else:
options.security = market_data_request.tickers

Expand Down
3 changes: 2 additions & 1 deletion findatapy/market/ioengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def read_excel_data_frame(self, f_name, excel_sheet, freq, cutoff=None, datepars
return self.read_csv_data_frame(f_name, freq, cutoff=cutoff, dateparse=dateparse,
postfix=postfix, intraday_tz=intraday_tz, excel_sheet=excel_sheet)

def remove_time_series_cache_on_disk(self, fname, engine='hdf5_fixed', db_server='127.0.0.1', db_port='6379',
def remove_time_series_cache_on_disk(self, fname, engine='hdf5_fixed', db_server=constants.db_server,
db_port=constants.db_port,
timeout=10, username=None,
password=None):

Expand Down

0 comments on commit e163f33

Please sign in to comment.