short_dates = df[["EURUSDV1M", "USDJPYV1M"]] long_dates = df[["EURUSDV1Y", "USDJPYV1Y"]] short_dates, long_dates = short_dates.align(long_dates, join='left', axis=0) slope = pandas.DataFrame(data=short_dates.values - long_dates.values, index=short_dates.index, columns=["EURUSDV1M-1Y", "USDJPYV1M-1Y"]) # resample fand calculate average over month slope_monthly = slope.resample('M', how='mean') slope_monthly.index = [ str(x.year) + '/' + str(x.month) for x in slope_monthly.index ] pf = PlotFactory() gp = GraphProperties() gp.source = 'Thalesians/BBG' gp.title = 'Vol slopes in EUR/USD and USD/JPY recently' gp.scale_factor = 2 gp.display_legend = True gp.chart_type = 'bar' gp.x_title = 'Dates' gp.y_title = 'Pc' # plot using Cufflinks pf.plot_bar_graph(slope_monthly, adapter='bokeh', gp=gp)
daily_vals = daily_vals.resample('BM') daily_vals = daily_vals / daily_vals.shift(1) - 1 daily_vals.index = [str(x.year) + '/' + str(x.month) for x in daily_vals.index] daily_vals = daily_vals.drop(daily_vals.head(1).index) pf = PlotFactory() gp = GraphProperties() gp.source = 'Thalesians/BBG (created with PyThalesians Python library)' gp.html_file_output = "output_data/equities.htm" gp.title = 'Recent monthly changes in equity markets' gp.scale_factor = 2 gp.display_legend = True gp.chart_type = ['bar', 'scatter', 'line'] gp.x_title = 'Dates' gp.y_title = 'Pc' # plot using Bokeh then PyThalesians pf.plot_bar_graph(daily_vals * 100, adapter = 'bokeh', gp = gp) pf.plot_bar_graph(daily_vals * 100, adapter = 'pythalesians', gp = gp) # plot daily changes in FX if True: from datetime import timedelta ltsf = LightTimeSeriesFactory() end = datetime.datetime.utcnow() start = end - timedelta(days=5)
vendor_tickers=vendor_tickers, # ticker (Bloomberg) vendor_fields=["PX_LAST"], # which Bloomberg fields to download cache_algo="internet_load_return", ) # how to return data daily_vals = ltsf.harvest_time_series(time_series_request) # resample for end of month daily_vals = daily_vals.resample("BM") daily_vals = daily_vals / daily_vals.shift(1) - 1 daily_vals.index = [str(x.year) + "/" + str(x.month) for x in daily_vals.index] daily_vals = daily_vals.drop(daily_vals.head(1).index) pf = PlotFactory() gp = GraphProperties() gp.source = "Thalesians/BBG" gp.html_file_output = "output_data/equities.htm" gp.title = "Recent monthly changes in equity markets" gp.scale_factor = 2 gp.display_legend = True gp.chart_type = ["bar", "scatter", "line"] gp.x_title = "Dates" gp.y_title = "Pc" # plot using Bokeh then PyThalesians pf.plot_bar_graph(daily_vals * 100, adapter="bokeh", gp=gp) pf.plot_bar_graph(daily_vals * 100, adapter="pythalesians", gp=gp)
vendor_tickers=vendor_tickers, # ticker (Bloomberg) vendor_fields=['PX_LAST'], # which Bloomberg fields to download cache_algo='internet_load_return') # how to return data daily_vals = ltsf.harvest_time_series(time_series_request) # resample for end of month daily_vals = daily_vals.resample('BM') daily_vals = daily_vals / daily_vals.shift(1) - 1 daily_vals.index = [ str(x.year) + '/' + str(x.month) for x in daily_vals.index ] daily_vals = daily_vals.drop(daily_vals.head(1).index) pf = PlotFactory() gp = GraphProperties() gp.source = 'Thalesians/BBG' gp.html_file_output = "output_data/equities.htm" gp.title = 'Recent monthly changes in equity markets' gp.scale_factor = 2 gp.display_legend = True gp.chart_type = ['bar', 'scatter', 'line'] gp.x_title = 'Dates' gp.y_title = 'Pc' # plot using Bokeh then PyThalesians pf.plot_bar_graph(daily_vals * 100, adapter='bokeh', gp=gp) pf.plot_bar_graph(daily_vals * 100, adapter='pythalesians', gp=gp)
import pandas df.columns = [x.replace('.close', '') for x in df.columns.values] short_dates = df[["EURUSDV1M", "USDJPYV1M"]] long_dates = df[["EURUSDV1Y", "USDJPYV1Y"]] short_dates, long_dates = short_dates.align(long_dates, join='left', axis = 0) slope = pandas.DataFrame(data = short_dates.values - long_dates.values, index = short_dates.index, columns = ["EURUSDV1M-1Y", "USDJPYV1M-1Y"]) # resample fand calculate average over month slope_monthly = slope.resample('M', how='mean') slope_monthly.index = [str(x.year) + '/' + str(x.month) for x in slope_monthly.index] pf = PlotFactory() gp = GraphProperties() gp.source = 'Thalesians/BBG' gp.title = 'Vol slopes in EUR/USD and USD/JPY recently' gp.scale_factor = 2 gp.display_legend = True gp.chart_type = 'bar' gp.x_title = 'Dates' gp.y_title = 'Pc' # plot using Cufflinks pf.plot_bar_graph(slope_monthly, adapter = 'bokeh', gp = gp)
df.columns = [x.replace(".close", "") for x in df.columns.values] short_dates = df[["EURUSDV1M", "USDJPYV1M"]] long_dates = df[["EURUSDV1Y", "USDJPYV1Y"]] short_dates, long_dates = short_dates.align(long_dates, join="left", axis=0) slope = pandas.DataFrame( data=short_dates.values - long_dates.values, index=short_dates.index, columns=["EURUSDV1M-1Y", "USDJPYV1M-1Y"] ) # resample fand calculate average over month slope_monthly = slope.resample("M", how="mean") slope_monthly.index = [str(x.year) + "/" + str(x.month) for x in slope_monthly.index] pf = PlotFactory() gp = GraphProperties() gp.source = "Thalesians/BBG" gp.title = "Vol slopes in EUR/USD and USD/JPY recently" gp.scale_factor = 2 gp.display_legend = True gp.chart_type = "bar" gp.x_title = "Dates" gp.y_title = "Pc" # plot using Cufflinks pf.plot_bar_graph(slope_monthly, adapter="cufflinks", gp=gp)