This commit is contained in:
Ubuntu 2025-11-27 09:46:58 +08:00
parent e337769b94
commit 0e09c1dfee
3 changed files with 92 additions and 73 deletions

View File

@ -1,72 +1,76 @@
{ {
"strategy": "EthTrueStaticGrid", "strategy": "StaticGrid",
"max_open_trades": 150, "max_open_trades": 150,
"stake_currency": "USDT", "stake_currency": "USDT",
"stake_amount": 40, "stake_amount": 40,
"tradable_balance_ratio": 0.99, "tradable_balance_ratio": 0.99,
"dry_run": false, "dry_run": false,
"timeframe": "1h", "timeframe": "1h",
"position_adjustment_enable": false, "position_adjustment_enable": true,
"max_entry_position_adjustment": -1, "process_only_new_candles": false,
"exchange": { "max_entry_position_adjustment": -1,
"name": "okx", "exchange": {
"key": "cbda9fde-b9e3-4a2d-94f9-e5c3705dfb5c", "name": "okx",
"secret": "CD3B7DB459CBBD540E0926E5C48150E1", "key": "cbda9fde-b9e3-4a2d-94f9-e5c3705dfb5c",
"password": "c^-d:g;P2S9?Q#^", "secret": "CD3B7DB459CBBD540E0926E5C48150E1",
"enable_ws": false, "password": "c^-d:g;P2S9?Q#^",
"ccxt_config": { "enable_ws": false,
"enableRateLimit": true, "ccxt_config": {
"rateLimit": 500, "enableRateLimit": true,
"options": { "rateLimit": 500,
"defaultType": "spot" "options": {
} "defaultType": "spot"
}, }
"ccxt_async_config": {
"enableRateLimit": true,
"rateLimit": 3000,
"timeout": 20000
},
"pair_whitelist": [
"ETH/USDT"
],
"pair_blacklist": [
"OKB/USDT"
]
}, },
"unfilledtimeout": { "ccxt_async_config": {
"entry": 5, "enableRateLimit": true,
"exit": 15 "rateLimit": 3000,
"timeout": 20000
}, },
"pair_whitelist": [
"entry_pricing": { "ETH/USDT"
"price_side": "other", ],
"use_order_book": true, "pair_blacklist": [
"order_book_top": 1 "OKB/USDT"
}, ]
"exit_pricing": { },
"price_side": "other", "unfilledtimeout": {
"use_order_book": true, "entry": 5,
"order_book_top": 1 "exit": 15
}, },
"pairlists": [{"method": "StaticPairList"}], "entry_pricing": {
"bot_name": "ETH-1500to4500-Grid", "price_side": "other",
"api_server": { "use_order_book": true,
"enabled": true, "order_book_top": 1
"listen_ip_address": "0.0.0.0", },
"listen_port": 8080, "exit_pricing": {
"verbosity": "error", "price_side": "other",
"enable_openapi": false, "use_order_book": true,
"jwt_secret_key": "6a599ab046dbb419014807dffd7b8823bfa7e5df56b17d545485deb87331b4ca", "order_book_top": 1
"ws_token": "6O5pBDiRigiZrmIsofaE2rkKMJtf9h8zVQ", },
"CORS_origins": [], "pairlists": [
"username": "freqAdmin", {
"password": "admin" "method": "StaticPairList"
},
"initial_state": "running",
"force_entry_enable": false,
"internals": {
"process_throttle_secs": 5,
"heartbeat_interval": 20,
"loglevel": "DEBUG"
} }
],
"bot_name": "ETH-1500to4500-Grid",
"api_server": {
"enabled": true,
"listen_ip_address": "0.0.0.0",
"listen_port": 8080,
"verbosity": "error",
"enable_openapi": false,
"jwt_secret_key": "6a599ab046dbb419014807dffd7b8823bfa7e5df56b17d545485deb87331b4ca",
"ws_token": "6O5pBDiRigiZrmIsofaE2rkKMJtf9h8zVQ",
"CORS_origins": [],
"username": "freqAdmin",
"password": "admin"
},
"initial_state": "running",
"force_entry_enable": false,
"internals": {
"process_throttle_secs": 5,
"heartbeat_interval": 20,
"loglevel": "DEBUG"
}
} }

View File

@ -0,0 +1,10 @@
def populate_indicators(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
import numpy as np
dataframe['ema_short'] = dataframe['close'].ewm(span=self.ema_short_period.value, adjust=False).mean()
dataframe['ema_long'] = dataframe['close'].ewm(span=self.ema_long_period.value, adjust=False).mean()
dataframe['rsi'] = ta.RSI(np.array(dataframe['close']), timeperiod=14)
return dataframe

View File

@ -18,18 +18,23 @@ class StaticGrid(IStrategy):
STEP = 50.0 STEP = 50.0
STAKE = 40.0 STAKE = 40.0
# 必须加这一行!否则报抽象类错误
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
return dataframe return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
for price in [self.LOWER + i * self.STEP for i in range(int((self.UPPER - self.LOWER) // self.STEP) + 3)]: # 终极触发:只要这根 1h K 线的 low 曾经跌到过任何一个网格价,就立刻补单
dataframe.loc[dataframe['low'] <= price, 'enter_long'] = True # 当前价 3025 → 下面所有 1500~3000 的网格价,只要历史 low 触碰过,就全部挂上
for level in range(int((self.UPPER - self.LOWER) // self.STEP) + 5):
grid_price = self.LOWER + level * self.STEP
if grid_price <= 3025 + 200: # 当前价附近 200 刀内优先挂
dataframe.loc[dataframe['low'] <= grid_price, 'enter_long'] = 1
return dataframe return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
for price in [self.LOWER + i * self.STEP for i in range(int((self.UPPER - self.LOWER) // self.STEP) + 3)]: for level in range(int((self.UPPER - self.LOWER) // self.STEP) + 5):
dataframe.loc[dataframe['high'] >= price, 'exit_long'] = True grid_price = self.LOWER + level * self.STEP
if grid_price >= 3025 - 200:
dataframe.loc[dataframe['high'] >= grid_price, 'exit_long'] = 1
return dataframe return dataframe
def custom_stake_amount(self, **kwargs) -> float: def custom_stake_amount(self, **kwargs) -> float: