1、准备更新order单前备份
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -141,7 +141,6 @@ class SimpleLimitBuyStrategyLong(Strategy):
|
||||
pnl_per_unit = open - avg_entry_price # 当前浮动盈亏(以收盘价计算)
|
||||
|
||||
stop_position_points = range_1_ago * self.profit_factor
|
||||
stop_position_points = 20
|
||||
|
||||
self.log(
|
||||
f"[{current_datetime}] PnL per unit: {pnl_per_unit:.2f}, 目标: {stop_position_points:.2f}"
|
||||
@@ -656,7 +655,7 @@ class SimpleLimitBuyStrategy(Strategy):
|
||||
pnl_per_unit = open - avg_entry_price # 当前浮动盈亏(以收盘价计算)
|
||||
|
||||
self.log(
|
||||
f"[{current_datetime}] 止盈信号 - PnL per unit: {pnl_per_unit:.2f}, 目标: {self.take_profit_points:.2f}, 止损: {-self.stop_loss_points:.2f}"
|
||||
f"[{current_datetime}] 止盈信号 - PnL per unit: {pnl_per_unit:.2f}, 目标: {range_1_ago * self.profit_factor_l:.2f}, 止损: {-self.stop_loss_points:.2f}"
|
||||
)
|
||||
|
||||
# 止盈条件
|
||||
@@ -712,7 +711,7 @@ class SimpleLimitBuyStrategy(Strategy):
|
||||
pnl_per_unit = avg_entry_price - open # 当前浮动盈亏(以收盘价计算)
|
||||
|
||||
self.log(
|
||||
f"[{current_datetime}] 止盈信号 - PnL per unit: {pnl_per_unit:.2f}, 目标: {self.take_profit_points:.2f}, 止损: {-self.stop_loss_points:.2f}"
|
||||
f"[{current_datetime}] 止盈信号 - PnL per unit: {pnl_per_unit:.2f}, 目标: {range_1_ago * self.profit_factor_l:.2f}, 止损: {-self.stop_loss_points:.2f}"
|
||||
)
|
||||
|
||||
# 止盈条件
|
||||
|
||||
@@ -5,6 +5,8 @@ from datetime import datetime
|
||||
import math
|
||||
from typing import Dict, Any, Optional, List, TYPE_CHECKING
|
||||
|
||||
import numpy as np
|
||||
|
||||
# 使用 TYPE_CHECKING 避免循环导入,但保留类型提示
|
||||
from ..backtest_context import BacktestContext # 转发引用 BacktestEngine
|
||||
from ..core_data import Bar, Order, Trade # 导入必要的类型
|
||||
@@ -201,3 +203,12 @@ class Strategy(ABC):
|
||||
|
||||
def get_price_history(self, key: str):
|
||||
return self.context.get_price_history(key)
|
||||
|
||||
def get_indicator_tuple(self):
|
||||
close = np.array(self.get_price_history("close"))
|
||||
open = np.array(self.get_price_history("open"))
|
||||
high = np.array(self.get_price_history("high"))
|
||||
low = np.array(self.get_price_history("low"))
|
||||
volume = np.array(self.get_price_history("volume"))
|
||||
|
||||
return (close, open, high, low, volume)
|
||||
|
||||
Reference in New Issue
Block a user