# source: https://raw.githubusercontent.com/Edogor/GAFreqTrade/ca9ddbc95545bea0d895084bb9bbb58568226d55/ga_core/strategy_template.py
"""
Strategy Template for GA-Generated Freqtrade Strategies

This module provides the base template string for generating Freqtrade strategies.
"""

STRATEGY_TEMPLATE = '''# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401
# isort: skip_file
# AUTO-GENERATED STRATEGY - DO NOT EDIT MANUALLY
# Generated: {generation_date}
# Generation: {generation}
# Strategy ID: {strategy_id}

import numpy as np
import pandas as pd
from datetime import datetime, timedelta, timezone
from pandas import DataFrame
from typing import Dict, Optional, Union, Tuple

from freqtrade.strategy import (
    IStrategy,
    Trade,
    Order,
    PairLocks,
    informative,
    BooleanParameter,
    CategoricalParameter,
    DecimalParameter,
    IntParameter,
    RealParameter,
    timeframe_to_minutes,
    timeframe_to_next_date,
    timeframe_to_prev_date,
    merge_informative_pair,
    stoploss_from_absolute,
    stoploss_from_open,
    AnnotationType,
)

import talib.abstract as ta
from technical import qtpylib


class Github_Edogor_GAFreqTrade__strategy_template__20260213_023107(IStrategy):
    """
    {strategy_description}
    
    AUTO-GENERATED by GAFreqTrade
    Generation: {generation}
    Parent Strategies: {parents}
    """
    
    INTERFACE_VERSION = 3
    
    # Basic Settings
    timeframe = "{timeframe}"
    can_short: bool = False
    
    # ROI table
    minimal_roi = {minimal_roi}
    
    # Stoploss
    stoploss = {stoploss}
    
    # Trailing stoploss
    trailing_stop = {trailing_stop}
    trailing_stop_positive = {trailing_stop_positive}
    trailing_stop_positive_offset = {trailing_stop_positive_offset}
    trailing_only_offset_is_reached = {trailing_only_offset_is_reached}
    
    # Run "populate_indicators()" only for new candle
    process_only_new_candles = True
    
    # Exit signal
    use_exit_signal = True
    exit_profit_only = False
    ignore_roi_if_entry_signal = False
    
    # Number of candles the strategy requires before producing valid signals
    startup_candle_count: int = {startup_candle_count}
    
    # Strategy parameters
{hyperopt_parameters}
    
    # Order types
    order_types = {{
        "entry": "limit",
        "exit": "limit",
        "stoploss": "market",
        "stoploss_on_exchange": False
    }}
    
    order_time_in_force = {{
        "entry": "GTC",
        "exit": "GTC"
    }}
    
    def informative_pairs(self):
        return []
    
    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Adds TA indicators to the given DataFrame
        """
{indicator_calculations}
        
        return dataframe
    
    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the entry signal for the given dataframe
        """
        conditions = []
        
{entry_conditions}
        
        if conditions:
            dataframe.loc[
                reduce(lambda x, y: x & y, conditions),
                'enter_long'
            ] = 1
        
        return dataframe
    
    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the exit signal for the given dataframe
        """
        conditions = []
        
{exit_conditions}
        
        if conditions:
            dataframe.loc[
                reduce(lambda x, y: x & y, conditions),
                'exit_long'
            ] = 1
        
        return dataframe
'''


def get_template() -> str:
    """Return the strategy template string"""
    return STRATEGY_TEMPLATE
