forked from white07S/TradingPatternScanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_utils.py
More file actions
27 lines (21 loc) · 1.13 KB
/
Copy pathverify_utils.py
File metadata and controls
27 lines (21 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
from tradingpatterns.hard_data import generate_data_head_shoulder
from tradingpatterns.tradingpatterns import detect_head_shoulder, detect_triangle_pattern
from tradingpatterns.pattern_utils import get_recent_bullish_patterns
def test_utils():
# 1. 生成包含头肩形态的模拟数据 (10组,每组20天,共200天)
# 模拟数据中会包含 Head and Shoulder 和 Inverse Head and Shoulder
df = generate_data_head_shoulder(1)
# 2. 运行探测函数
# 探测头肩形态
res_hs = detect_head_shoulder(df)
df['head_shoulder_pattern'] = res_hs['head_shoulder_pattern']
# 探测三角形形态 (模拟数据可能不一定能触发,但我们先跑一下)
res_tri = detect_triangle_pattern(df)
df['triangle_pattern'] = res_tri['triangle_pattern']
# 3. 验证筛选函数 (检查过去 50 天)
# 因为 generate_data_head_shoulder 注入了形态,最后一部分应该是 Inverse Head and Shoulder (看涨)
bullish = get_recent_bullish_patterns(df, 20)
print(f"最近 20 天发现的看涨形态: {bullish}")
if __name__ == "__main__":
test_utils()