def modify_tab(self, valueDictionary, tabType): """ Modifies tab. :param valueDictionary: Dictionary with values. :param tabType: Tab type to be modified. """ innerTabs = self.tabs[tabType]['innerTabs'] # live/widgets self.set_profit_or_loss_label(valueDictionary=valueDictionary, innerTabs=innerTabs) for categoryKey in valueDictionary: if categoryKey not in innerTabs: tab = self.tabs[tabType]['tab'] self.add_category_and_children_keys(categoryKey, valueDictionary, innerTabs, tab) else: innerWidgets = innerTabs[categoryKey] # live/widgets/general for mainKey in valueDictionary[categoryKey]: if mainKey in innerWidgets: innerWidgets[mainKey]['value'].setText(str(valueDictionary[categoryKey][mainKey])) else: label = QLabel(get_label_string(str(mainKey))) value = QLabel(str(valueDictionary[categoryKey][mainKey])) value.setAlignment(QtCore.Qt.AlignRight) layout = innerTabs[categoryKey]['tab'].layout() layout.addRow(label, value) innerWidgets[mainKey] = {'label': label, 'value': value}
def add_category_and_children_keys(categoryKey, valueDictionary, innerTabs, tab): """ Modifies instance tabs variable with new values from valueDictionary. :param categoryKey: Category to modify. :param valueDictionary: Dictionary with values to put in. :param innerTabs: Inner tabs of tab to tbe modified. E.g. Simulation's inner tabs can be general, averages, etc. :param tab: Tab to be modified. For instance, this tab can be the simulation tab. """ innerLayout = QFormLayout() innerTabs[categoryKey] = {'tab': QTabWidget()} for mainKey in valueDictionary[categoryKey]: label = QLabel(get_label_string(str(mainKey))) value = QLabel(str(valueDictionary[categoryKey][mainKey])) value.setAlignment(QtCore.Qt.AlignRight) innerLayout.addRow(label, value) innerTabs[categoryKey][mainKey] = {'label': label, 'value': value} innerTabs[categoryKey]['tab'].setLayout(innerLayout) tab.addTab(innerTabs[categoryKey]['tab'], get_label_string(categoryKey))
def get_advanced_statistics(self) -> str: """ Returns a lot more statistics from trader object. :return: String of huge statistics. """ trader: SimulationTrader = self.gui.trader statDict = trader.get_grouped_statistics() total = '' for categoryKey in statDict: total += get_label_string(categoryKey) + ':\n' for key in statDict[categoryKey]: value = statDict[categoryKey][key] total += f'\t\t {get_label_string(key)} : {get_label_string(value)} \n' return total