Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# fetch NFP times from Bloomberg
md_request = MarketDataRequest(
start_date=start_date, # start date
finish_date=finish_date, # finish date
category="events",
freq='daily', # daily data
data_source='bloomberg', # use Bloomberg as data source
tickers=['NFP'],
fields=['release-date-time-full'], # which fields to download
vendor_tickers=['NFP TCH Index'], # ticker (Bloomberg)
cache_algo='internet_load_return') # how to return data
df_event_times = market.fetch_market(md_request)
df_event_times = pandas.DataFrame(index=df_event_times['NFP.release-date-time-full'])
es = EventStudy()
# work out cumulative asset price moves moves over the event
df_event = es.get_intraday_moves_over_custom_event(df, df_event_times)
# create an average move
df_event['Avg'] = df_event.mean(axis=1)
# plotting spot over economic data event
style = Style()
style.scale_factor = 3
style.file_output = 'usdjpy-nfp.png'
style.title = 'USDJPY spot moves over recent NFP'
# plot in shades of blue (so earlier releases are lighter, later releases are darker)
style.color = 'Blues';