def plot_strategy_group_benchmark_pnl(self): pf = PlotFactory() gp = GraphProperties() gp.title = self.FINAL_STRATEGY gp.display_legend = True gp.scale_factor = self.SCALE_FACTOR #gp.color = 'RdYlGn' gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - cumulative).png' # plot cumulative line of returns pf.plot_line_graph(self.reduce_plot( self._strategy_group_benchmark_pnl), adapter='pythalesians', gp=gp) keys = self._strategy_group_benchmark_tsd.keys() ir = [] for key in keys: ir.append(self._strategy_group_benchmark_tsd[key].inforatio()[0]) ret_stats = pandas.DataFrame(index=keys, data=ir, columns=['IR']) ret_stats = ret_stats.sort() gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - IR).png' gp.display_brand_label = False # plot ret stats pf.plot_bar_graph(ret_stats, adapter='pythalesians', gp=gp)
def plot_strategy_group_benchmark_pnl(self): pf = PlotFactory() gp = GraphProperties() gp.title = self.FINAL_STRATEGY gp.display_legend = True gp.scale_factor = self.SCALE_FACTOR #gp.color = 'RdYlGn' gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - cumulative).png' # plot cumulative line of returns pf.plot_line_graph(self.reduce_plot(self._strategy_group_benchmark_pnl), adapter = 'pythalesians', gp = gp) # needs write stats flag turned on try: keys = self._strategy_group_benchmark_tsd.keys() ir = [] for key in keys: ir.append(self._strategy_group_benchmark_tsd[key].inforatio()[0]) ret_stats = pandas.DataFrame(index = keys, data = ir, columns = ['IR']) ret_stats = ret_stats.sort_index() gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - IR).png' gp.display_brand_label = False # plot ret stats pf.plot_bar_graph(ret_stats, adapter = 'pythalesians', gp = gp) except: pass
def plot_strategy_group_benchmark_pnl(self, strip=None): pf = PlotFactory() gp = GraphProperties() gp.title = self.FINAL_STRATEGY gp.display_legend = True gp.scale_factor = self.SCALE_FACTOR #gp.color = 'RdYlGn' gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - cumulative).png' strat_list = self._strategy_group_benchmark_pnl.columns.sort_values() for line in strat_list: self.logger.info(line) # plot cumulative line of returns pf.plot_line_graph(self.reduce_plot( self._strategy_group_benchmark_pnl), adapter='pythalesians', gp=gp) # needs write stats flag turned on try: keys = self._strategy_group_benchmark_tsd.keys() ir = [] for key in keys: ir.append( self._strategy_group_benchmark_tsd[key].inforatio()[0]) if strip is not None: keys = [k.replace(strip, '') for k in keys] ret_stats = pandas.DataFrame(index=keys, data=ir, columns=['IR']) ret_stats = ret_stats.sort_index() gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - IR).png' gp.display_brand_label = False # plot ret stats pf.plot_bar_graph(ret_stats, adapter='pythalesians', gp=gp) except: pass
# first use PyThalesians matplotlib wrapper pf.plot_line_graph(daily_vals, adapter='pythalesians', gp=gp) pf.plot_generic_graph(daily_vals, gp=gp, type='line') # use modified 538 Matplotlib stylesheet gp.style_sheet = '538-pythalesians' pf.plot_line_graph(daily_vals, adapter='pythalesians', gp=gp) # use miletus matplotlib stylesheet gp.style_sheet = 'miletus-pythalesians' pf.plot_line_graph(daily_vals, adapter='pythalesians', gp=gp) # use ggplot matplotlib styleheet gp.scale_factor = 1 gp.display_brand_label = False gp.display_source = False gp.style_sheet = 'ggplot-pythalesians' gp.display_mpld3 = True gp.html_file_output = 'output_data/demo.htm' pf.plot_line_graph(daily_vals, adapter='pythalesians', gp=gp) # now use PyThalesians bokeh wrapper (still needs a lot of work!) gp.scale_factor = 2 gp.html_file_output = 'output_data/demo_bokeh.htm' pf.plot_line_graph(daily_vals, adapter='bokeh', gp=gp) # test simple PyThalesians bar charts - calculate yearly returns for various assets if False: ltsf = LightTimeSeriesFactory()
gp.scale_factor = 2 gp.style_sheet = 'pythalesians' # first use PyThalesians matplotlib wrapper pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp) pf.plot_generic_graph(daily_vals, gp = gp, type = 'line') # use modified 538 Matplotlib stylesheet gp.style_sheet = '538-pythalesians' pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp) # use miletus matplotlib stylesheet gp.style_sheet = 'miletus-pythalesians' pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp) # use ggplot matplotlib styleheet gp.scale_factor = 1 gp.display_brand_label = False gp.display_source = False gp.style_sheet = 'ggplot-pythalesians' gp.display_mpld3 = True gp.html_file_output = 'demo.htm' pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp) # now use PyThalesians bokeh wrapper (still needs a lot of work!) gp.scale_factor = 2 gp.html_file_output = 'demo_bokeh.htm' pf.plot_line_graph(daily_vals, adapter = 'bokeh', gp = gp) pass