排查没有n笔交易+1
This commit is contained in:
parent
9efed63da6
commit
6708fa6ffc
@ -39,6 +39,8 @@
|
|||||||
"entry": 5,
|
"entry": 5,
|
||||||
"exit": 15
|
"exit": 15
|
||||||
},
|
},
|
||||||
|
"cooldown_volume": 0,
|
||||||
|
"action_space": "default",
|
||||||
"entry_pricing": {
|
"entry_pricing": {
|
||||||
"price_side": "other",
|
"price_side": "other",
|
||||||
"use_order_book": true,
|
"use_order_book": true,
|
||||||
|
|||||||
@ -15,6 +15,9 @@ class StaticGrid(IStrategy):
|
|||||||
use_exit_signal = True
|
use_exit_signal = True
|
||||||
position_adjustment_enable = True
|
position_adjustment_enable = True
|
||||||
max_entry_position_adjustment = -1
|
max_entry_position_adjustment = -1
|
||||||
|
|
||||||
|
# Lock configuration - disable lockout to allow immediate re-entry
|
||||||
|
cooldown_candles = 0 # No cooldown between trades
|
||||||
|
|
||||||
# Grid parameters
|
# Grid parameters
|
||||||
LOWER = 1500.0 # Minimum price
|
LOWER = 1500.0 # Minimum price
|
||||||
@ -33,9 +36,10 @@ class StaticGrid(IStrategy):
|
|||||||
|
|
||||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
"""
|
"""
|
||||||
Grid Entry Logic:
|
Dynamic Grid Entry Logic:
|
||||||
- Buy at each grid level when price drops to it
|
- Automatically calculates grid levels based on current price
|
||||||
- Grid levels: 1500, 1550, 1600, ..., 4500 (step 50)
|
- Creates grid points with fixed percentage step (e.g., 1.5% apart)
|
||||||
|
- Works for any price range (BTC, ETH, SOL, etc.)
|
||||||
"""
|
"""
|
||||||
dataframe['enter_long'] = False
|
dataframe['enter_long'] = False
|
||||||
|
|
||||||
@ -46,19 +50,27 @@ class StaticGrid(IStrategy):
|
|||||||
current_price = dataframe['close'].iloc[-1]
|
current_price = dataframe['close'].iloc[-1]
|
||||||
print(f"[StaticGrid] Current price: {current_price:.2f}", file=sys.stderr, flush=True)
|
print(f"[StaticGrid] Current price: {current_price:.2f}", file=sys.stderr, flush=True)
|
||||||
|
|
||||||
# Check which grid level price is closest to or below
|
# Dynamic grid: use percentage-based steps instead of fixed price steps
|
||||||
# If price is near any grid level, buy
|
# Grid step: 1.5% (you can adjust this)
|
||||||
for i in range(int((self.UPPER - self.LOWER) / self.STEP) + 1):
|
grid_step_pct = 0.015 # 1.5%
|
||||||
grid_price = self.LOWER + i * self.STEP
|
|
||||||
|
# Create grid levels around current price
|
||||||
|
# Generate grid points below current price (for buying)
|
||||||
|
num_levels_below = 10 # Generate 10 levels below current price
|
||||||
|
|
||||||
|
for i in range(num_levels_below):
|
||||||
|
grid_price = current_price * ((1 - grid_step_pct) ** (i + 1))
|
||||||
|
|
||||||
# Buy if we're at this grid level (within 2% tolerance)
|
# Buy if price drops to or below this grid level
|
||||||
# This allows buying at intermediate prices too
|
if dataframe['low'].iloc[-1] <= grid_price * 1.01:
|
||||||
if current_price <= grid_price * 1.02:
|
dataframe['enter_long'] = True
|
||||||
# Mark this candle and recent candles for entry
|
print(f"[StaticGrid] Buy signal at grid level {i+1}: {grid_price:.2f}", file=sys.stderr, flush=True)
|
||||||
dataframe.loc[dataframe['close'] <= grid_price * 1.02, 'enter_long'] = True
|
break # Only buy at one level per candle
|
||||||
|
|
||||||
entries = dataframe['enter_long'].sum()
|
entries = dataframe['enter_long'].sum()
|
||||||
print(f"[StaticGrid] Entry signals: {entries}", file=sys.stderr, flush=True)
|
if entries > 0:
|
||||||
|
print(f"[StaticGrid] Entry signals: {entries}", file=sys.stderr, flush=True)
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user