WhaleStrategy
♡
Basics
mode: spot
timeframe: 5m
interface version: 3
Settings
stoploss: -0.12
has minimal roi
trailing
process only new candles: false
startup candle count: 50
hyperopt
Indicators
OBV
SMA
talib
technical
Concepts
trailing
15 related strategies (⧉ identical code, ≈ similar name)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # strategy_whale.py # 鲸鱼策略 - 捕捉大资金吸筹与派发 from freqtrade.strategy.interface import IStrategy from pandas import DataFrame import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib import pandas as pd pd.options.mode.chained_assignment = None import technical.indicators as ftt from functools import reduce import numpy as np class WhaleStrategy(IStrategy): INTERFACE_VERSION = 3 '\n 鲸鱼策略 (Whale)\n 核心:捕捉大资金行为,识别吸筹/派发\n 指标:OBV、成交量突变、价格相对位置\n 入场:价格处于低位 + OBV走强 + 成交量放大\n 出场:价格处于高位 + OBV走弱 + 成交量萎缩\n ' # 价格接近近期最低点的阈值(2%内) # 近期低点回溯周期 buy_params = {'obv_ma_short': 5, 'obv_ma_long': 20, 'volume_ma_period': 20, 'volume_spike_factor': 1.5, 'price_low_percentile': 0.02, 'lookback_period': 20} # 价格接近近期最高点的阈值 sell_params = {'price_high_percentile': 0.98, 'obv_ma_short': 5, 'obv_ma_long': 20} minimal_roi = {'0': 0.1, '30': 0.05, '60': 0.02, '120': 0} stoploss = -0.12 timeframe = '5m' startup_candle_count = 50 process_only_new_candles = False trailing_stop = True trailing_stop_positive = 0.02 trailing_stop_positive_offset = 0.03 trailing_only_offset_is_reached = True use_exit_signal = True exit_profit_only = False ignore_roi_if_entry_signal = False plot_config = {'main_plot': {}, 'subplots': {'OBV': {'obv': {}, 'obv_ma_short': {}, 'obv_ma_long': {}}, 'Volume': {'volume': {}, 'volume_ma': {}}}} def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # 能量潮 OBV dataframe['obv'] = ta.OBV(dataframe['close'], dataframe['volume']) dataframe['obv_ma_short'] = ta.SMA(dataframe['obv'], timeperiod=self.buy_params['obv_ma_short']) dataframe['obv_ma_long'] = ta.SMA(dataframe['obv'], timeperiod=self.buy_params['obv_ma_long']) # 成交量均线 dataframe['volume_ma'] = ta.SMA(dataframe['volume'], timeperiod=self.buy_params['volume_ma_period']) # 价格相对位置:近期低点和高点 dataframe['min_lookback'] = ta.MIN(dataframe['close'], timeperiod=self.buy_params['lookback_period']) dataframe['max_lookback'] = ta.MAX(dataframe['close'], timeperiod=self.buy_params['lookback_period']) # 价格接近低点标志 dataframe['near_low'] = dataframe['close'] <= dataframe['min_lookback'] * (1 + self.buy_params['price_low_percentile']) # 价格接近高点标志 dataframe['near_high'] = dataframe['close'] >= dataframe['max_lookback'] * self.sell_params['price_high_percentile'] # 成交量突变 dataframe['volume_spike'] = dataframe['volume'] > dataframe['volume_ma'] * self.buy_params['volume_spike_factor'] return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # 吸筹条件:价格在低位,OBV短期均线上穿长期均线(量能先行),成交量放大 conditions = [dataframe['near_low'] == True, qtpylib.crossed_above(dataframe['obv_ma_short'], dataframe['obv_ma_long']), dataframe['volume_spike'] == True] dataframe.loc[reduce(lambda x, y: x & y, conditions), 'enter_long'] = 1 return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # 派发条件:价格在高位,OBV短期均线下穿长期均线,成交量缩小(可选) conditions = [dataframe['near_high'] == True, qtpylib.crossed_below(dataframe['obv_ma_short'], dataframe['obv_ma_long'])] # 可附加成交量缩小条件:dataframe['volume'] < dataframe['volume_ma'] dataframe.loc[reduce(lambda x, y: x & y, conditions), 'exit_long'] = 1 return dataframe |
Strategy League — fixed backtest that feeds the ranking
The fixed-params backtest (33 pairs · 20210101-20260101) — the only run that feeds the Strategy League ranking.
Backtests — over a market period
Backtest this strategy over a chosen crypto-cycle period. These don't affect the League ranking, and need that period's candle data downloaded.
Log in or sign up to run backtests.
| Period | Range | Total % | Win % | Max DD | Trades | |
|---|---|---|---|---|---|---|
| 2020 · DeFi Summer & Pre-Halving Rally | 20200101-20210101 | not run | ||||
| 2021 · Institutional Bull Market | 20210101-20220101 | not run | ||||
| 2022 · Post-Bull Crash & Macro Tightening | 20220101-20230101 | not run | ||||
| 2023–2024 · Recovery & ETF Anticipation | 20230101-20250101 | not run | ||||
| 2025–2026 · Current Cycle | 20250101-20260101 | not run | ||||
Walk forward
Out-of-sample backtest on recent data · 33 pairs · 20260101-20260701.
Backtest trust check
Static source analysis — instant, does not run the strategy. Flags future-data leaks, backtest-realism problems, and indicators worth a second look.
Lookahead analysis
freqtrade lookahead-analysis: detects strategies peeking at future candles.