diff --git a/config_examples/staticgrid.json b/config_examples/staticgrid.json index 7396855..adf1ff3 100644 --- a/config_examples/staticgrid.json +++ b/config_examples/staticgrid.json @@ -7,7 +7,7 @@ "dry_run": false, "timeframe": "1h", "position_adjustment_enable": true, - "process_only_new_candles": false, + "process_only_new_candles": true, "max_entry_position_adjustment": -1, "exchange": { "name": "okx", diff --git a/freqtrade/templates/staticgrid.py b/freqtrade/templates/staticgrid.py index aee4d33..9c1522a 100644 --- a/freqtrade/templates/staticgrid.py +++ b/freqtrade/templates/staticgrid.py @@ -1,6 +1,9 @@ # /freqtrade/user_data/strategies/StaticGrid.py from freqtrade.strategy import IStrategy from pandas import DataFrame +import logging + +logger = logging.getLogger(__name__) class StaticGrid(IStrategy): INTERFACE_VERSION = 3 @@ -28,17 +31,30 @@ class StaticGrid(IStrategy): """ dataframe['enter_long'] = False + # Debug: Check if we have data + if len(dataframe) == 0: + logger.warning("[StaticGrid] Empty dataframe!") + return dataframe + + logger.info(f"[StaticGrid] Processing {len(dataframe)} candles. Latest close: {dataframe['close'].iloc[-1]:.2f}") + # Generate all grid points num_grids = int((self.UPPER - self.LOWER) / self.STEP) + 1 + entry_count = 0 + for i in range(num_grids): grid_price = self.LOWER + i * self.STEP # Buy if low touches this grid point (with 0.1% tolerance) - dataframe.loc[ - (dataframe['low'] <= grid_price * 1.001) & (dataframe['volume'] > 0), - 'enter_long' - ] = True + mask = (dataframe['low'] <= grid_price * 1.001) & (dataframe['volume'] > 0) + entries = mask.sum() + + if entries > 0: + dataframe.loc[mask, 'enter_long'] = True + entry_count += entries + logger.debug(f"[StaticGrid] Grid {grid_price:.0f}: {entries} entries") + logger.info(f"[StaticGrid] Total entries marked: {entry_count}") return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: @@ -46,6 +62,11 @@ class StaticGrid(IStrategy): Exit logic: Sell when price bounces back (any upward movement = profit) """ dataframe['exit_long'] = (dataframe['close'] > dataframe['close'].shift(1)).fillna(False) + + exit_count = dataframe['exit_long'].sum() + if exit_count > 0: + logger.debug(f"[StaticGrid] Exit signals: {exit_count}") + return dataframe def custom_stake_amount(self, **kwargs) -> float: