Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/StockBench/controllers/charting/multi/multi_charting_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def build_multi_overview_chart(self, results: List[dict], initial_balance: float
subplot_titles=chart_titles)

fig.add_trace(MultiChartingEngine.__build_overview_profit_loss_bar_subplot(results), row=1, col=1)
fig.add_trace(MultiChartingEngine.__overview_avg_effectiveness_gauge_subplot(results), row=1, col=2)
fig.add_trace(MultiChartingEngine.__build_overview_avg_effectiveness_gauge_subplot(results), row=1, col=2)
fig.add_trace(MultiChartingEngine.__build_overview_trades_made_bar_subplot(results), row=2, col=1)
fig.add_trace(MultiChartingEngine.__overview_avg_profit_loss_gauge(results, initial_balance), row=2, col=2)
fig.add_trace(MultiChartingEngine.__build_overview_avg_profit_loss_gauge_subplot(results, initial_balance),
row=2, col=2)

fig.update_layout(template=self.PLOTLY_THEME, title=f'Simulation Results for {len(results)} Symbols',
xaxis_rangeslider_visible=False, showlegend=False)
Expand All @@ -62,10 +63,12 @@ def __build_overview_profit_loss_bar_subplot(results: List[dict]) -> Bar:
return plotter.Bar(
x=MultiChartingEngine.__get_symbols_from_results(results),
y=MultiChartingEngine.__get_total_pl_per_symbol_from_results(results),
marker_color=color_df['colors'])
marker_color=color_df['colors'], # noqa
name='PL'
)

@staticmethod
def __overview_avg_effectiveness_gauge_subplot(results: List[dict]) -> Indicator:
def __build_overview_avg_effectiveness_gauge_subplot(results: List[dict]) -> Indicator:
"""Builds an overview average effectiveness gauge subplot."""
indicator_value = MultiChartingEngine.__calculate_avg_effectiveness_from_results(results)

Expand All @@ -84,7 +87,7 @@ def __overview_avg_effectiveness_gauge_subplot(results: List[dict]) -> Indicator
{'range': [50, 100], 'color': PLOTLY_DARK_BACKGROUND}]})

@staticmethod
def __overview_avg_profit_loss_gauge(results: List[dict], initial_balance: float) -> Indicator:
def __build_overview_avg_profit_loss_gauge_subplot(results: List[dict], initial_balance: float) -> Indicator:
"""Builds an overview average profit/loss gauge subplot."""
indicator_value = MultiChartingEngine.__calculate_avg_pl_from_results(results)
upper_bound = initial_balance
Expand All @@ -110,7 +113,9 @@ def __build_overview_trades_made_bar_subplot(results: List[dict]) -> Bar:
return plotter.Bar(
x=MultiChartingEngine.__get_symbols_from_results(results),
y=MultiChartingEngine.__get_trades_made_per_symbol_from_results(results),
marker=dict(color=OFF_BLUE))
marker=dict(color=OFF_BLUE),
name='Trades made'
)

@staticmethod
def __get_symbols_from_results(results: List[dict]) -> list:
Expand Down