Exemple #1
0
def get_strategy(strategy: str, config=Depends(get_config)):

    config = deepcopy(config)
    from freqtrade.resolvers.strategy_resolver import StrategyResolver
    try:
        strategy_obj = StrategyResolver._load_strategy(
            strategy, config, extra_dir=config.get('strategy_path'))
    except OperationalException:
        raise HTTPException(status_code=404, detail='Strategy not found')

    return {
        'strategy': strategy_obj.get_strategy_name(),
        'code': strategy_obj.__source__,
    }
    def _get_strategy(self, strategy: str):
        """
        Get a single strategy
        get:
          parameters:
            - strategy: Only get this strategy
        """
        config = deepcopy(self._config)
        from freqtrade.resolvers.strategy_resolver import StrategyResolver
        try:
            strategy_obj = StrategyResolver._load_strategy(
                strategy, config, extra_dir=config.get('strategy_path'))
        except OperationalException:
            return self.rest_error("Strategy not found.", 404)

        return jsonify({
            'strategy': strategy_obj.get_strategy_name(),
            'code': strategy_obj.__source__,
        })