Add Top and Bottom

This commit is contained in:
jackyu66git
2025-04-24 19:31:01 +08:00
parent b849ce8ec8
commit 9cb242f706
7 changed files with 142 additions and 17 deletions
+22 -3
View File
@@ -17,7 +17,7 @@ from pytz import timezone
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from ChanLun import ChanLun
from ChanEnum import Chan_BI_DIR, Chan_SEG_DIR
from ChanEnum import Chan_BI_DIR, Chan_SEG_DIR, Chan_KLC_FX, Chan_FX_TYPE
# 添加买卖点枚举类型
class TRADE_POINT_TYPE:
@@ -180,12 +180,24 @@ def analyze_chan(df):
# 添加买卖点识别
buy_sell_points = identify_trade_points(bi_list, seg_list, zs_list)
# 提取K线分型信息
klc_fx_info = []
for klc in klc_list:
if hasattr(klc, 'klc_fx_type') and klc.klc_fx_type != Chan_KLC_FX.UNKNOWN:
klc_fx_info.append({
'time': klc.end_time,
'price': klc.low if klc.fx == Chan_FX_TYPE.BOTTOM else klc.high,
'fx_type': str(klc.klc_fx_type).replace("Chan_KLC_FX.", ""),
'is_bottom': klc.fx == Chan_FX_TYPE.BOTTOM
})
return {
'klc_list': klc_list,
'bi_list': bi_list,
'seg_list': seg_list,
'zs_list': zs_list,
'trade_points': buy_sell_points
'trade_points': buy_sell_points,
'klc_fx_info': klc_fx_info # 添加分型信息
}
def identify_trade_points(bi_list, seg_list, zs_list):
@@ -426,7 +438,14 @@ def analyze():
'price': point['price'],
'desc': point['desc']
} for point in analysis_result['trade_points']],
'macd': macd_data
'macd': macd_data,
# 添加K线分型信息
'klc_fx_info': [{
'time': format_time_safely(point['time'], client_tz),
'price': point['price'],
'fx_type': point['fx_type'],
'is_bottom': point['is_bottom']
} for point in analysis_result['klc_fx_info']]
})
else:
print(f"只请求元素数据,跳过主周期数据处理 (elements_only={elements_only})")