# source: https://raw.githubusercontent.com/Jarrodsz/freqtrade-test/cf097a5fb3b3fe11821b879cf214bd2b08b83b4b/test.py
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401
# isort: skip_file
# --- Do not remove these libs ---
import numpy as np  # noqa
import pandas as pd  # noqa
# --------------------------------
# Add your lib to import here
import talib.abstract as ta
from pandas import DataFrame

import freqtrade.vendor.qtpylib.indicators as qtpylib
from freqtrade.strategy import (IStrategy, IntParameter)


class github_Jarrodsz_freqtrade_test__test__20230404_182214(IStrategy):

    INTERFACE_VERSION = 3

    can_short: bool = False
    minimal_roi = {
        "60": 0.01,
        "30": 0.02,
        "0": 0.04
    }

    stoploss = -0.10
    trailing_stop = False
    timeframe = '5m'
    process_only_new_candles = True
    use_exit_signal = True
    exit_profit_only = False
    ignore_roi_if_entry_signal = False
    startup_candle_count: int = 30

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # Add 14 empty rows to the end of the dataframe
        future_df = pd.DataFrame(index=range(len(dataframe), len(dataframe) + 14), columns=dataframe.columns)
        dataframe = pd.concat([dataframe, future_df], axis=0)

        dataframe['adx'] = ta.ADX(dataframe)

        # Calculate the indicators with a rolling window
        for window in [15, 30, 50, 100, 200]:
            dataframe[f'mean_close_{window}'] = dataframe['close'].rolling(window=window).mean()
            dataframe[f'std_close_{window}'] = dataframe['close'].rolling(window=window).std()

        # Drop the rows from the future dataframe
        dataframe = dataframe[:-14]

        # Add predicted candles
        for i in range(1, 15):
            close = dataframe['close'].iloc[-1]  # Use the last close price as the basis for the future candles
            high = close * 1.01
            low = close * 0.99
            open_price = close * 1.005
            volume = 0  # Set volume to 0 for the future candles
            row = {'open': open_price, 'high': high, 'low': low, 'close': close, 'volume': volume}
            dataframe = dataframe.append(row, ignore_index=True)

        return dataframe


    def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
        df.loc[:, 'enter_long'] = 0
        df.loc[:, 'enter_short'] = 0
        return df

    def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
        df.loc[:, 'enter_long'] = 0
        df.loc[:, 'enter_short'] = 0
        return df
