fewfef
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import calendar
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Dict, Optional
|
||||
from loguru import logger
|
||||
@@ -21,19 +22,19 @@ def is_bearish(c): # 阴线
|
||||
|
||||
def check_signal(prev, curr):
|
||||
"""
|
||||
包住形态信号判定(仅15分钟K线):
|
||||
- 前跌后涨包住 -> 做多
|
||||
- 前涨后跌包住 -> 做空
|
||||
包住形态信号判定(简化版):
|
||||
- 前跌后涨包住(涨包跌) -> 做多:涨的收盘价 > 跌的开盘价
|
||||
- 前涨后跌包住(跌包涨) -> 做空:跌的收盘价 < 涨的开盘价
|
||||
"""
|
||||
p_open, p_close = float(prev['open']), float(prev['close'])
|
||||
c_open, c_close = float(curr['open']), float(curr['close'])
|
||||
|
||||
# 前跌后涨包住 -> 做多
|
||||
if is_bullish(curr) and is_bearish(prev) and c_open <= p_close and c_close >= p_open:
|
||||
# 涨包跌(前跌后涨) -> 做多:涨的收盘价 > 跌的开盘价
|
||||
if is_bullish(curr) and is_bearish(prev) and c_close > p_open:
|
||||
return "long", "bear_bull_engulf"
|
||||
|
||||
# 前涨后跌包住 -> 做空
|
||||
if is_bearish(curr) and is_bullish(prev) and c_open >= p_close and c_close <= p_open:
|
||||
# 跌包涨(前涨后跌) -> 做空:跌的收盘价 < 涨的开盘价
|
||||
if is_bearish(curr) and is_bullish(prev) and c_close < p_open:
|
||||
return "short", "bull_bear_engulf"
|
||||
|
||||
return None, None
|
||||
@@ -186,9 +187,11 @@ def backtest_15m_trend_optimized(dates: List[str]):
|
||||
# ========================= 运行示例(优化版盈利计算) =========================
|
||||
if __name__ == '__main__':
|
||||
dates = []
|
||||
for i in range(1, 11):
|
||||
for i1 in range(1, 31):
|
||||
dates.append(f"2025-{f'0{i}' if len(str(i)) < 2 else i}-{f'0{i1}' if len(str(i1)) < 2 else i1}")
|
||||
for month in range(1, 11):
|
||||
# 获取该月的实际天数
|
||||
days_in_month = calendar.monthrange(2025, month)[1]
|
||||
for day in range(1, days_in_month + 1):
|
||||
dates.append(f"2025-{month:02d}-{day:02d}")
|
||||
|
||||
print(dates)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user