def plot_profit_and_loss_lines(self): """Plot the profit and loss of the portfolio for the entire time period as a line plot. Args: group: Whether to aggregate based on symbol_groups in config. """ profit_and_loss = self._get_profit_and_loss() title = ('Cumulative P&L | ' + self._TITLE_DOLLAR_FORMAT + ( '\n')).format(profit_and_loss[-1]) plot = profit_and_loss.plot(kind='line', ax=plt.gca()) plot.set_title(title, color=self._TEXT_COLOR) plot_utils.format_x_ticks_as_dates(plot) plot_utils.format_y_ticks_as_dollars(plot) return plot
def plot_profit_and_loss_lines(self): """Plot the profit and loss of the portfolio for the entire time period as a line plot. Args: group: Whether to aggregate based on symbol_groups in config. """ profit_and_loss = self._get_profit_and_loss() title = ('Cumulative P&L | ' + self._TITLE_DOLLAR_FORMAT + ('\n')).format(profit_and_loss[-1]) plot = profit_and_loss.plot(kind='line', ax=plt.gca()) plot.set_title(title, color=self._TEXT_COLOR) plot_utils.format_x_ticks_as_dates(plot) plot_utils.format_y_ticks_as_dollars(plot) return plot
def plot_dollar_value_lines(self, group=False): """Plot the dollar value of portfolio holdings for the entire time period as a line plot. Args: group: Whether to aggregate based on symbol_groups in config. """ dollar_values = self._get_dollar_values(group) dollar_values['TOTAL'] = dollar_values.sum(1) title = ('Portfolio Value | ' + self._TITLE_DOLLAR_FORMAT + ( '\n')).format(dollar_values['TOTAL'].ix[-1]) plot = dollar_values.plot(kind='line', ax=plt.gca()) plot.set_title(title, color=self._TEXT_COLOR) plot_utils.format_x_ticks_as_dates(plot) plot_utils.format_y_ticks_as_dollars(plot) plot_utils.format_legend(plot, self._TEXT_COLOR) return plot
def plot_dollar_value_bars(self, group=False): """Plot the dollar value of portfolio holdings for the most recent day as a bar plot. Args: group: Whether to aggregate based on symbol_groups in config. """ dollar_values = self._get_dollar_values(group).ix[-1, :] percents = dollar_values / np.sum(dollar_values) labels = plot_utils.get_percent_strings(percents) title = 'Portfolio Weights\n' plot = dollar_values.plot(kind='bar', alpha=self._BAR_ALPHA) plot.set_title(title, color=self._TEXT_COLOR) plot.set_xticklabels(dollar_values.index, rotation=0) plot_utils.format_y_ticks_as_dollars(plot) plot_utils.add_bar_labels(plot, labels, self._TEXT_COLOR) return plot
def plot_dollar_value_lines(self, group=False): """Plot the dollar value of portfolio holdings for the entire time period as a line plot. Args: group: Whether to aggregate based on symbol_groups in config. """ dollar_values = self._get_dollar_values(group) dollar_values['TOTAL'] = dollar_values.sum(1) title = ('Portfolio Value | ' + self._TITLE_DOLLAR_FORMAT + ('\n')).format(dollar_values['TOTAL'].ix[-1]) plot = dollar_values.plot(kind='line', ax=plt.gca()) plot.set_title(title, color=self._TEXT_COLOR) plot_utils.format_x_ticks_as_dates(plot) plot_utils.format_y_ticks_as_dollars(plot) plot_utils.format_legend(plot, self._TEXT_COLOR) return plot
def plot_dollar_change_bars(self, group=False): """Plot the change in dollars for the most recent day as a bar plot. Args: group: Whether to aggregate based on symbol_groups in config. """ dollar_values = self._get_dollar_values(group).ix[-1, :] dollar_returns = self._get_dollar_returns(group).ix[-1, :] percent_returns = dollar_returns / dollar_values labels = plot_utils.get_percent_strings(percent_returns) bar_colors = plot_utils.get_conditional_colors( percent_returns, self._BAR_ALPHA) title = ('1-Day Change | ' + self._TITLE_DOLLAR_FORMAT + ( '\n')).format(np.sum(dollar_returns)) plot = dollar_returns.plot(kind='bar', color=bar_colors) plot.set_title(title, color=self._TEXT_COLOR) plot.set_xticklabels(dollar_returns.index, rotation=0) plot_utils.format_y_ticks_as_dollars(plot) plot_utils.add_bar_labels(plot, labels, self._TEXT_COLOR) return plot
def plot_dollar_change_bars(self, group=False): """Plot the change in dollars for the most recent day as a bar plot. Args: group: Whether to aggregate based on symbol_groups in config. """ dollar_values = self._get_dollar_values(group).ix[-1, :] dollar_returns = self._get_dollar_returns(group).ix[-1, :] percent_returns = dollar_returns / dollar_values labels = plot_utils.get_percent_strings(percent_returns) bar_colors = plot_utils.get_conditional_colors(percent_returns, self._BAR_ALPHA) title = ('1-Day Change | ' + self._TITLE_DOLLAR_FORMAT + ('\n')).format(np.sum(dollar_returns)) plot = dollar_returns.plot(kind='bar', color=bar_colors) plot.set_title(title, color=self._TEXT_COLOR) plot.set_xticklabels(dollar_returns.index, rotation=0) plot_utils.format_y_ticks_as_dollars(plot) plot_utils.add_bar_labels(plot, labels, self._TEXT_COLOR) return plot