'AUDUSD'], fields = ['close'], # which fields to download vendor_tickers = ['EURUSD BGN Curncy', # ticker (Bloomberg) 'GBPUSD BGN Curncy', 'AUDUSD BGN Curncy'], vendor_fields = ['PX_LAST'], # which Bloomberg fields to download cache_algo = 'internet_load_return') # how to return data ltsf = LightTimeSeriesFactory() df = None df = ltsf.harvest_time_series(time_series_request) tsc = TimeSeriesCalcs() df = tsc.calculate_returns(df) df = tsc.rolling_corr(df['EURUSD.close'], 20, data_frame2 = df[['GBPUSD.close', 'AUDUSD.close']]) gp = GraphProperties() gp.title = "1M FX rolling correlations" gp.scale_factor = 3 pf = PlotFactory() pf.plot_line_graph(df, adapter = 'pythalesians', gp = gp) ###### download daily data from Bloomberg for AUD/JPY, NZD/JPY spot with S&P500, then calculate correlation if True: time_series_request = TimeSeriesRequest( start_date="01 Jan 2015", # start date finish_date=datetime.date.today(), # finish date freq='daily', # daily data data_source='bloomberg', # use Bloomberg as data source
'EURUSD BGN Curncy', # ticker (Bloomberg) 'GBPUSD BGN Curncy', 'AUDUSD BGN Curncy' ], vendor_fields=['PX_LAST'], # which Bloomberg fields to download cache_algo='internet_load_return') # how to return data ltsf = LightTimeSeriesFactory() df = None df = ltsf.harvest_time_series(time_series_request) tsc = TimeSeriesCalcs() df = tsc.calculate_returns(df) df = tsc.rolling_corr(df['EURUSD.close'], 20, data_frame2=df[['GBPUSD.close', 'AUDUSD.close']]) gp = GraphProperties() gp.title = "1M FX rolling correlations" gp.scale_factor = 3 pf = PlotFactory() pf.plot_line_graph(df, adapter='pythalesians', gp=gp) ###### download daily data from Bloomberg for AUD/JPY, NZD/JPY spot with S&P500, then calculate correlation if True: time_series_request = TimeSeriesRequest( start_date="01 Jan 2015", # start date finish_date=datetime.date.today(), # finish date freq='daily', # daily data
time_series_request = TimeSeriesRequest( start_date = "01 Jan 2014", # start date finish_date = datetime.date.today(), # finish date freq = 'daily', # daily data data_source = 'bloomberg', # use Bloomberg as data source tickers = ['EURUSD', # ticker (Thalesians) 'GBPUSD', 'AUDUSD'], fields = ['close'], # which fields to download vendor_tickers = ['EURUSD BGN Curncy', # ticker (Bloomberg) 'GBPUSD BGN Curncy', 'AUDUSD BGN Curncy'], vendor_fields = ['PX_LAST'], # which Bloomberg fields to download cache_algo = 'internet_load_return') # how to return data ltsf = LightTimeSeriesFactory() df = None df = ltsf.harvest_time_series(time_series_request) tsc = TimeSeriesCalcs() df = tsc.calculate_returns(df) df = tsc.rolling_corr(df['EURUSD.close'], 20, data_frame2 = df[['GBPUSD.close', 'AUDUSD.close']]) gp = GraphProperties() gp.title = "1M FX rolling correlations" pf = PlotFactory() pf.plot_line_graph(df, adapter = 'pythalesians', gp = gp)