Example #1
0
    def set_routes(self, routes: List[Any]) -> None:
        self._reset()

        self.routes = []

        for r in routes:
            # validate strategy
            strategy_name = r[3]
            if jh.is_unit_testing():
                exists = jh.file_exists(sys.path[0] + '/jesse/strategies/{}/__init__.py'.format(strategy_name))
            else:
                exists = jh.file_exists('strategies/{}/__init__.py'.format(strategy_name))

            if not exists:
                raise exceptions.InvalidRoutes(
                    'A strategy with the name of "{}" could not be found.'.format(r[3]))

            # validate timeframe
            timeframe = r[2]
            if timeframe not in ['1m', '3m', '5m', '15m', '30m', '45m', '1h', '2h', '3h', '4h', '6h', '8h', '12h', '1D', '3D', '1W'']:
                raise exceptions.InvalidRoutes(
                    'Timeframe "{}" is invalid. Supported timeframes are 1m, 3m, 5m, 15m, 30m, 45m, 1h, 2h, 3h, 4h, 6h, 8h, 12h, 1D, 3D, 1W'.format(
                        timeframe)
                )

            self.routes.append(Route(*r))
Example #2
0
    def set_routes(self, routes: List[Any]) -> None:
        self._reset()

        self.routes = []

        for r in routes:
            # validate strategy
            strategy_name = r[3]
            if jh.is_unit_testing():
                exists = jh.file_exists(
                    f"{sys.path[0]}/jesse/strategies/{strategy_name}/__init__.py"
                )
            else:
                exists = jh.file_exists(
                    f'strategies/{strategy_name}/__init__.py')

            if not exists:
                raise exceptions.InvalidRoutes(
                    f'A strategy with the name of "{r[3]}" could not be found.'
                )

            # validate timeframe
            route_timeframe = r[2]
            all_timeframes = [
                timeframe for timeframe in jh.class_iter(timeframes)
            ]
            if route_timeframe not in all_timeframes:
                raise exceptions.InvalidRoutes(
                    f'Timeframe "{route_timeframe}" is invalid. Supported timeframes are {", ".join(all_timeframes)}'
                )

            self.routes.append(Route(*r))
Example #3
0
    def set_routes(self, routes):
        self.routes = []

        for r in routes:
            # validate strategy
            import jesse.helpers as jh
            from jesse import exceptions

            strategy_name = r[3]
            if jh.is_unit_testing():
                exists = jh.file_exists(
                    'jesse/strategies/{}/__init__.py'.format(strategy_name))
            else:
                exists = jh.file_exists(
                    'strategies/{}/__init__.py'.format(strategy_name))

            if not exists:
                raise exceptions.InvalidRoutes(
                    'A strategy with the name of "{}" could not be found.'.
                    format(r[3]))

            # validate timeframe
            timeframe = r[2]
            if timeframe not in [
                    '1m', '3m', '5m', '15m', '30m', '1h', '2h', '3h', '4h',
                    '6h', '8h', '1D'
            ]:
                raise exceptions.InvalidRoutes(
                    'Timeframe "{}" is invalid. Supported timeframes are 1m, 3m, 5m, 15m, 30m, 1h, 2h, 3h, 4h, 6h, 8h, 1D'
                    .format(timeframe))

            self.routes.append(Route(*r))
Example #4
0
    def set_routes(self, routes: List[Any]) -> None:
        self._reset()

        self.routes = []

        for r in routes:
            # validate strategy
            strategy_name = r[3]
            if jh.is_unit_testing():
                exists = jh.file_exists(sys.path[0] + '/jesse/strategies/{}/__init__.py'.format(strategy_name))
            else:
                exists = jh.file_exists('strategies/{}/__init__.py'.format(strategy_name))

            if not exists:
                raise exceptions.InvalidRoutes(
                    'A strategy with the name of "{}" could not be found.'.format(r[3]))

            # validate timeframe
            route_timeframe = r[2]
            all_timeframes = [timeframe for timeframe in jh.class_iter(timeframes)]
            if route_timeframe not in all_timeframes:
                raise exceptions.InvalidRoutes(
                    'Timeframe "{}" is invalid. Supported timeframes are {}'.format(
                        route_timeframe, ', '.join(all_timeframes))
                )

            self.routes.append(Route(*r))
Example #5
0
    def set_routes(self, routes: List[Any]) -> None:
        self._reset()

        self.routes = []

        for r in routes:
            # validate strategy that the strategy file exists (if sent as a string)
            if isinstance(r["strategy"], str):
                strategy_name = r["strategy"]
                if jh.is_unit_testing():
                    path = sys.path[0]
                    # live plugin
                    if path.endswith('jesse-live'):
                        strategies_dir = f'{sys.path[0]}/tests/strategies'
                    # main framework
                    else:
                        strategies_dir = f'{sys.path[0]}/jesse/strategies'
                    exists = jh.file_exists(
                        f"{strategies_dir}/{strategy_name}/__init__.py")
                else:
                    exists = jh.file_exists(
                        f'strategies/{strategy_name}/__init__.py')
            else:
                exists = True

            if not exists and isinstance(r["strategy"], str):
                raise exceptions.InvalidRoutes(
                    f'A strategy with the name of "{r["strategy"]}" could not be found.'
                )

            self.routes.append(
                Route(r["exchange"], r["symbol"], r["timeframe"],
                      r["strategy"], None))