示例#1
0
    def __init__(self, parent, logger=None):
        super(Configuration, self).__init__(parent)  # Initializing object
        uic.loadUi(configurationUi, self)  # Loading the main UI
        self.parent = parent
        self.threadPool = QThreadPool()
        self.logger = logger
        self.data = None
        self.dataType = None
        self.downloadThread = None
        self.tokenPass = False
        self.chatPass = False
        self.credentialsFolder = "Credentials"
        self.configFolder = 'Configuration'
        self.basicFilePath = os.path.join(helpers.ROOT_DIR, 'state.json')
        self.categoryTabs = [
            self.mainConfigurationTabWidget,
            self.simulationConfigurationTabWidget,
            self.backtestConfigurationTabWidget,
        ]

        self.strategies = get_strategies_dictionary(Strategy.__subclasses__())
        self.strategyDict = {}  # We will store all the strategy slot information in this dictionary.
        self.lossDict = {}  # We will store stop loss settings here.
        self.takeProfitDict = {}  # We will store take profit settings here.

        self.load_combo_boxes()  # Primarily used for backtest interval changer logic.
        self.load_slots()  # Loads stop loss, take profit, and strategies slots.
        self.load_credentials()  # Load credentials if they exist.
示例#2
0
    def __init__(self,
                 startingBalance: float,
                 data: list,
                 strategies: list,
                 strategyInterval: Union[str, None] = None,
                 symbol: str = None,
                 marginEnabled: bool = True,
                 startDate: datetime = None,
                 endDate: datetime = None,
                 drawdownPercentage: int = 100,
                 precision: int = 4,
                 outputTrades: bool = True,
                 logger: Logger = None):
        super().__init__(symbol=symbol,
                         precision=precision,
                         startingBalance=startingBalance,
                         marginEnabled=marginEnabled)
        convert_all_dates_to_datetime(data)
        self.data = data
        self.check_data()
        self.outputTrades: bool = outputTrades  # Boolean that'll determine whether trades are outputted to file or not.
        self.interval = self.get_interval()
        self.intervalMinutes = get_interval_minutes(self.interval)
        self.pastActivity = [
        ]  # We'll add previous data here when hovering through graph in GUI.
        self.drawdownPercentageDecimal = drawdownPercentage / 100  # Percentage of loss at which bot exits backtest.
        self.optimizerRows = []
        self.logger = logger

        if len(strategyInterval.split()) == 1:
            strategyInterval = convert_small_interval(strategyInterval)

        self.allStrategies = get_strategies_dictionary(
            Strategy.__subclasses__())
        self.strategyInterval = self.interval if strategyInterval is None else strategyInterval
        self.strategyIntervalMinutes = get_interval_minutes(
            self.strategyInterval)
        self.intervalGapMinutes = self.strategyIntervalMinutes - self.intervalMinutes
        self.intervalGapMultiplier = self.strategyIntervalMinutes // self.intervalMinutes
        if self.intervalMinutes > self.strategyIntervalMinutes:
            raise RuntimeError(
                f"Your strategy interval ({self.strategyIntervalMinutes} minute(s)) can't be smaller "
                f"than the data interval ({self.intervalMinutes} minute(s)).")

        self.ema_dict = {}
        self.rsi_dictionary = {}
        self.setup_strategies(strategies)
        self.startDateIndex = self.get_start_index(startDate)
        self.endDateIndex = self.get_end_index(endDate)
示例#3
0
    def __init__(self,
                 startingBalance: float,
                 data: list,
                 strategies: list,
                 strategyInterval: Union[str, None] = None,
                 symbol: str = None,
                 marginEnabled: bool = True,
                 startDate: datetime = None,
                 endDate: datetime = None,
                 precision: int = 4,
                 outputTrades: bool = True):
        super().__init__(symbol=symbol,
                         precision=precision,
                         startingBalance=startingBalance)
        self.marginEnabled = marginEnabled
        self.outputTrades: bool = outputTrades  # Boolean that'll determine whether trades are outputted to file or not.

        convert_all_dates_to_datetime(data)
        self.data = data
        self.check_data()
        self.interval = self.get_interval()
        self.intervalMinutes = get_interval_minutes(self.interval)
        self.pastActivity = [
        ]  # We'll add previous data here when hovering through graph in GUI.

        if len(strategyInterval.split()) == 1:
            strategyInterval = convert_small_interval(strategyInterval)

        self.allStrategies = get_strategies_dictionary(
            Strategy.__subclasses__())
        self.strategyInterval = self.interval if strategyInterval is None else strategyInterval
        self.strategyIntervalMinutes = get_interval_minutes(
            self.strategyInterval)
        self.intervalGapMinutes = self.strategyIntervalMinutes - self.intervalMinutes
        self.intervalGapMultiplier = self.strategyIntervalMinutes // self.intervalMinutes
        if self.intervalMinutes > self.strategyIntervalMinutes:
            raise RuntimeError(
                "Your strategy interval can't be smaller than the data interval."
            )

        self.ema_dict = {}
        self.rsi_dictionary = {}
        self.setup_strategies(strategies)
        self.startDateIndex = self.get_start_index(startDate)
        self.endDateIndex = self.get_end_index(endDate)
示例#4
0
    def __init__(self, parent: QMainWindow, logger: Logger = None):
        super(Configuration, self).__init__(parent)  # Initializing object
        uic.loadUi(configurationUi, self)  # Loading the main UI
        self.parent = parent
        self.threadPool = QThreadPool()
        self.logger = logger

        self.optimizer_backtest_dict = {
            BACKTEST: {
                'startDate': self.backtestStartDate,
                'endDate': self.backtestEndDate,
                'tickers': self.backtestTickerLineEdit,
                'intervals': self.backtestIntervalComboBox,
                'data': None,
                'dataIntervalComboBox': self.backtestIntervalComboBox,
                'dataInterval': None,
                'dataType': None,
                'infoLabel': self.backtestInfoLabel,
                'dataLabel': self.backtestDataLabel,
                'downloadThread': None,
                'downloadLabel': self.backtestDownloadLabel,
                'downloadButton': self.backtestDownloadDataButton,
                'stopDownloadButton': self.backtestStopDownloadButton,
                'importButton': self.backtestImportDataButton,
                'downloadProgress': self.backtestDownloadProgressBar
            },
            OPTIMIZER: {
                'startDate': self.optimizerStartDate,
                'endDate': self.optimizerEndDate,
                'tickers': self.optimizerTickerLineEdit,
                'intervals': self.optimizerIntervalComboBox,
                'data': None,
                'dataIntervalComboBox': self.optimizerIntervalComboBox,
                'dataInterval': None,
                'dataType': None,
                'infoLabel': self.optimizerInfoLabel,
                'dataLabel': self.optimizerDataLabel,
                'downloadThread': None,
                'downloadLabel': self.optimizerDownloadLabel,
                'downloadButton': self.optimizerDownloadDataButton,
                'stopDownloadButton': self.optimizerStopDownloadButton,
                'importButton': self.optimizerImportDataButton,
                'downloadProgress': self.optimizerDownloadProgressBar
            }
        }

        self.lossTypes = ("Trailing", "Stop")
        self.takeProfitTypes = ('Stop',)
        self.lossOptimizerTypes = ('lossPercentage', 'stopLossCounter')
        self.takeProfitOptimizerTypes = ('takeProfitPercentage',)

        # Telegram
        self.tokenPass = False
        self.chatPass = False

        # Folders and files
        self.credentialsFolder = "Credentials"
        self.configFolder = 'Configuration'
        self.stateFilePath = os.path.join(helpers.ROOT_DIR, 'state.json')

        self.categoryTabs = [
            self.mainConfigurationTabWidget,
            self.simulationConfigurationTabWidget,
            self.backtestConfigurationTabWidget,
            self.optimizerConfigurationTabWidget
        ]

        self.strategies = get_strategies_dictionary(Strategy.__subclasses__())
        self.strategyDict = {}  # We will store all the strategy slot information in this dictionary.
        self.lossDict = {}  # We will store stop loss settings here.
        self.takeProfitDict = {}  # We will store take profit settings here.

        load_slots(self)  # Loads stop loss, take profit, and strategies slots.
        load_credentials(self)  # Load credentials if they exist.