排查加log

This commit is contained in:
zhangkun9038@dingtalk.com 2025-11-27 09:55:56 +08:00
parent 789b4e10eb
commit d6c347b46a
2 changed files with 26 additions and 5 deletions

View File

@ -7,7 +7,7 @@
"dry_run": false, "dry_run": false,
"timeframe": "1h", "timeframe": "1h",
"position_adjustment_enable": true, "position_adjustment_enable": true,
"process_only_new_candles": false, "process_only_new_candles": true,
"max_entry_position_adjustment": -1, "max_entry_position_adjustment": -1,
"exchange": { "exchange": {
"name": "okx", "name": "okx",

View File

@ -1,6 +1,9 @@
# /freqtrade/user_data/strategies/StaticGrid.py # /freqtrade/user_data/strategies/StaticGrid.py
from freqtrade.strategy import IStrategy from freqtrade.strategy import IStrategy
from pandas import DataFrame from pandas import DataFrame
import logging
logger = logging.getLogger(__name__)
class StaticGrid(IStrategy): class StaticGrid(IStrategy):
INTERFACE_VERSION = 3 INTERFACE_VERSION = 3
@ -28,17 +31,30 @@ class StaticGrid(IStrategy):
""" """
dataframe['enter_long'] = False 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 # Generate all grid points
num_grids = int((self.UPPER - self.LOWER) / self.STEP) + 1 num_grids = int((self.UPPER - self.LOWER) / self.STEP) + 1
entry_count = 0
for i in range(num_grids): for i in range(num_grids):
grid_price = self.LOWER + i * self.STEP grid_price = self.LOWER + i * self.STEP
# Buy if low touches this grid point (with 0.1% tolerance) # Buy if low touches this grid point (with 0.1% tolerance)
dataframe.loc[ mask = (dataframe['low'] <= grid_price * 1.001) & (dataframe['volume'] > 0)
(dataframe['low'] <= grid_price * 1.001) & (dataframe['volume'] > 0), entries = mask.sum()
'enter_long'
] = True 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 return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> 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) Exit logic: Sell when price bounces back (any upward movement = profit)
""" """
dataframe['exit_long'] = (dataframe['close'] > dataframe['close'].shift(1)).fillna(False) 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 return dataframe
def custom_stake_amount(self, **kwargs) -> float: def custom_stake_amount(self, **kwargs) -> float: