# source: https://raw.githubusercontent.com/kingdemond434-cpu/quant/cc0392e251165ce472db8cfba1d33fb83046f65e/desks/mt5/tests/fixtures/cell_emitter/synthetic_freqtrade_funding.py
# directory_url: https://github.com/kingdemond434-cpu/quant/blob/master/desks/mt5/tests/fixtures/cell_emitter/
# User: kingdemond434-cpu
# Repository: quant
# --------------------# SYNTHETIC FIXTURE -- written for desks/mt5/tests/test_cell_emitter.py, not recorded from any site.
# An exchange-native mechanism: it reads the venue funding rate, which no CFD has.
from freqtrade.strategy import IStrategy
import talib.abstract as ta


class Github_kingdemond434_cpu_quant__synthetic_freqtrade_funding__20261031_170805(IStrategy):
    def populate_indicators(self, dataframe, metadata):
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        dataframe['funding'] = self.dp.funding_rate(metadata['pair'])
        return dataframe

    def populate_entry_trend(self, dataframe, metadata):
        dataframe.loc[(dataframe['funding'] < -0.01) & (dataframe['rsi'] < 30), 'enter_long'] = 1
        return dataframe
