Skip to content

Commit

Permalink
fix bug, when saving report, previous strategies also has been saved
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelHub committed Jun 16, 2021
1 parent d714691 commit 76ce6da
Show file tree
Hide file tree
Showing 6 changed files with 4,333 additions and 2,463 deletions.
4,323 changes: 4,323 additions & 0 deletions data/btc_usdt_test_v1.csv

Large diffs are not rendered by default.

867 changes: 0 additions & 867 deletions data/data.csv

This file was deleted.

723 changes: 0 additions & 723 deletions data/data_dotusdt.csv

This file was deleted.

867 changes: 0 additions & 867 deletions data/trx.csv

This file was deleted.

1 change: 1 addition & 0 deletions main_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, parent=None):
self.load_data_button.clicked.connect(lambda: self.load_data_from_file())
self.next_page_btn.clicked.connect(lambda: self.display_next_stacked_widget())
self.previous_page_btn.clicked.connect(lambda: self.display_previous_stacked_widget())
self.save_button.clicked.connect(lambda: self.summary_page.generate_html_report())

# Strategy page
self.strategy_page.p2_add_buy_rule.clicked.connect(
Expand Down
15 changes: 9 additions & 6 deletions pages/summary_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, parent=None):
self.setWindowTitle('BackTesting Application')
self.buy_rules_treeWidget.setHeaderItem(QtWidgets.QTreeWidgetItem(['Buy rules', 'Rule ID']))
self.sell_rules_treeWidget.setHeaderItem(QtWidgets.QTreeWidgetItem(['Sell rules', 'Rule ID']))
self.trades_dict = ''
self.html_of_graphs = ''


def display_buy_and_sell_rules(self, buy_rules, sell_rules, sell_simulation_settings):
Expand Down Expand Up @@ -206,10 +208,11 @@ def format_and_display_text(self, trades_dict, pip_position, main_window_object)
balance_list,
currency_2_symbol)
self.summary_balance_graph.setHtml(html_of_graphs)
main_window_object.save_button.clicked.connect(lambda: self.generate_html_report(html_of_graphs, trades_dict))
self.html_of_graphs = html_of_graphs
self.trades_dict = trades_dict


def generate_html_report(self, html_of_graphs, trades_dict):
def generate_html_report(self):
path_to_file = QFileDialog.getSaveFileName(self,
'Save simulation report',
current_dir[:-5] + "\data\\reports",
Expand All @@ -219,11 +222,11 @@ def generate_html_report(self, html_of_graphs, trades_dict):
if not path_to_file[0]:
return False

if trades_dict['buy_trades'][-1]['index'] > trades_dict['sell_trades'][-1]['index']:
max_spaces = len(str(trades_dict['buy_trades'][-1]['index'])) + 4
if self.trades_dict['buy_trades'][-1]['index'] > self.trades_dict['sell_trades'][-1]['index']:
max_spaces = len(str(self.trades_dict['buy_trades'][-1]['index'])) + 4
else:
max_spaces = len(str(trades_dict['sell_trades'][-1]['index'])) + 4
generate_html_report_to_file(self, html_of_graphs, max_spaces, path_to_file[0])
max_spaces = len(str(self.trades_dict['sell_trades'][-1]['index'])) + 4
generate_html_report_to_file(self, self.html_of_graphs, max_spaces, path_to_file[0])


if __name__ == '__main__':
Expand Down

0 comments on commit 76ce6da

Please sign in to comment.