新增实盘策略:ITrendStrategy(SA)
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Optional, Any, List, Dict
|
||||
|
||||
from src.core_data import Bar, Order
|
||||
from src.indicators.base_indicators import Indicator
|
||||
from src.indicators.indicators import Empty
|
||||
from src.indicators.indicators import Empty, ADX
|
||||
from src.strategies.base_strategy import Strategy
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ class DualModeKalmanStrategy(Strategy):
|
||||
bar_history = self.get_bar_history()
|
||||
if len(bar_history) < max(self.atr_period, self.atr_lookback) + 2: return
|
||||
|
||||
self.cancel_all_pending_orders(symbol)
|
||||
|
||||
# --- 通用数据计算 ---
|
||||
highs = np.array([b.high for b in bar_history], dtype=float)
|
||||
lows = np.array([b.low for b in bar_history], dtype=float)
|
||||
@@ -196,6 +198,7 @@ class DualModeKalmanStrategy(Strategy):
|
||||
def evaluate_entry_signal(self, current_bar: Bar, kalman_price: float, current_atr: float):
|
||||
deviation = current_bar.close - kalman_price
|
||||
deviation_in_atr = deviation / current_atr
|
||||
self.log(f'deviation_in_atr: {deviation_in_atr:.4f}')
|
||||
|
||||
direction = None
|
||||
|
||||
@@ -219,7 +222,7 @@ class DualModeKalmanStrategy(Strategy):
|
||||
|
||||
if direction:
|
||||
self.log(
|
||||
f"{self.strategy_mode} Mode: Catalyst Fired. Direction: {direction}. Deviation: {deviation_in_atr:.2f} ATRs.")
|
||||
f"{self.strategy_mode} Mode: Catalyst Fired. Direction: {direction}. Deviation: {deviation_in_atr:.2f} ATRs., entry_threshold_atr: {self.entry_threshold_atr}")
|
||||
entry_price = current_bar.close + (1 if direction == "BUY" else -1)
|
||||
stop_loss_price = entry_price - self.initial_stop_atr_multiplier * current_atr if direction in ["BUY",
|
||||
"CLOSE_SHORT"] else entry_price + self.initial_stop_atr_multiplier * current_atr
|
||||
|
||||
Reference in New Issue
Block a user