def load_interval_combo_boxes(config_obj): """ This function currently only handles combo boxes for backtester/optimizer interval logic. It'll update the strategy interval combo-box depending on what the data interval combo-box has as its current value. :param config_obj: Configuration QDialog object (from configuration.py) """ intervals = helpers.get_interval_strings(startingIndex=0) config_obj.intervalComboBox.addItems(intervals) config_obj.simulationIntervalComboBox.addItems(intervals) config_obj.backtestStrategyIntervalCombobox.addItems(intervals) config_obj.backtestIntervalComboBox.addItems(intervals) config_obj.backtestIntervalComboBox.currentTextChanged.connect(lambda: reset_strategy_interval_comboBox( strategy_combobox=config_obj.backtestStrategyIntervalCombobox, interval_combobox=config_obj.backtestIntervalComboBox )) config_obj.optimizerStrategyIntervalCombobox.addItems(intervals) config_obj.optimizerIntervalComboBox.addItems(intervals) config_obj.optimizerStrategyIntervalEndCombobox.addItems(intervals) config_obj.optimizerIntervalComboBox.currentTextChanged.connect(lambda: reset_strategy_interval_comboBox( strategy_combobox=config_obj.optimizerStrategyIntervalCombobox, interval_combobox=config_obj.optimizerIntervalComboBox )) config_obj.optimizerStrategyIntervalCombobox.currentTextChanged.connect(lambda: reset_strategy_interval_comboBox( strategy_combobox=config_obj.optimizerStrategyIntervalEndCombobox, interval_combobox=config_obj.optimizerStrategyIntervalCombobox, start_index=config_obj.optimizerIntervalComboBox.currentIndex(), divisor=helpers.get_interval_minutes(config_obj.optimizerIntervalComboBox.currentText()) ))
def load_combo_boxes(self): """ This function currently only handles combo boxes for backtester interval logic. It'll update the strategy interval combo-box depending on what the data interval combo-box has as its current value. """ intervals = helpers.get_interval_strings(startingIndex=0) self.backtestIntervalComboBox.addItems(intervals) self.backtestIntervalComboBox.currentTextChanged.connect(self.reset_strategy_interval_comboBox) self.backtestStrategyIntervalCombobox.addItems(intervals)
def reset_strategy_interval_comboBox(self): """ This function will reset the strategy interval combo-box. """ childText = self.backtestStrategyIntervalCombobox.currentText() parentIndex = self.backtestIntervalComboBox.currentIndex() intervals = helpers.get_interval_strings(startingIndex=parentIndex) self.backtestStrategyIntervalCombobox.clear() self.backtestStrategyIntervalCombobox.addItems(intervals) previousChildIndex = self.backtestStrategyIntervalCombobox.findText(childText) if previousChildIndex != -1: self.backtestStrategyIntervalCombobox.setCurrentIndex(previousChildIndex)
def reset_strategy_interval_comboBox(strategy_combobox: QComboBox, interval_combobox: QComboBox): """ This function will reset the strategy combobox based on what interval is picked in the interval combobox. """ childText = strategy_combobox.currentText() parentIndex = interval_combobox.currentIndex() intervals = helpers.get_interval_strings(startingIndex=parentIndex) strategy_combobox.clear() strategy_combobox.addItems(intervals) previousChildIndex = strategy_combobox.findText(childText) if previousChildIndex != -1: strategy_combobox.setCurrentIndex(previousChildIndex)
def reset_strategy_interval_comboBox(strategy_combobox: QComboBox, interval_combobox: QComboBox, start_index: int = 0, filter_intervals: bool = True, divisor: int = None): """ This function will reset the strategy combobox based on what interval is picked in the interval combobox. :param strategy_combobox: Combobox to modify based on the interval combobox. :param interval_combobox: Interval combobox that will trigger this function. :param start_index: Optional start index to start from when getting interval strings. :param filter_intervals: Boolean on whether to filter tickers or not. :param divisor: Divisor to use for filtering intervals. If none is provided, it will use data interval minutes. """ dataInterval = interval_combobox.currentText() if not dataInterval: return # Means text is empty, so just return. dataIntervalMinutes = get_interval_minutes(dataInterval) dataIndex = interval_combobox.currentIndex() strategyInterval = strategy_combobox.currentText() intervals = get_interval_strings(startingIndex=start_index + dataIndex) if filter_intervals: divisor = divisor if divisor is not None else dataIntervalMinutes intervals = [ interval for interval in intervals if get_interval_minutes(interval) % divisor == 0 ] strategy_combobox.clear() strategy_combobox.addItems(intervals) previousStrategyIntervalIndex = strategy_combobox.findText( strategyInterval) if previousStrategyIntervalIndex != -1: strategy_combobox.setCurrentIndex(previousStrategyIntervalIndex)