添加小周期勾选
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
sys.path.append(os.path.abspath("/Users/jack/Documents/GitHub/chan.py"))
|
#sys.path.append(os.path.abspath("/Users/jack/Documents/GitHub/chan.py"))
|
||||||
#sys.path.append(os.path.abspath("/Users/jack/Project/chan.py"))
|
sys.path.append(os.path.abspath("/Users/jack/Project/chan.py"))
|
||||||
from Chan import CChan
|
from Chan import CChan
|
||||||
from BuySellPoint.BS_Point import CBS_Point
|
from BuySellPoint.BS_Point import CBS_Point
|
||||||
from ChanConfig import CChanConfig
|
from ChanConfig import CChanConfig
|
||||||
|
|||||||
+2
-2
@@ -288,11 +288,11 @@ def add_indicators(df):
|
|||||||
df['bb_middle'] = bb['middleband'].fillna(0)
|
df['bb_middle'] = bb['middleband'].fillna(0)
|
||||||
df['bb_lower'] = bb['lowerband'].fillna(0)
|
df['bb_lower'] = bb['lowerband'].fillna(0)
|
||||||
bb30 = ta.BBANDS(df, timeperiod=41, nbdevup=2.3, nbdevdn=2.3, matype=0)
|
bb30 = ta.BBANDS(df, timeperiod=41, nbdevup=2.3, nbdevdn=2.3, matype=0)
|
||||||
bb30 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
#bb30 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||||
df['bbup30'] = bb30['upperband'].fillna(0)
|
df['bbup30'] = bb30['upperband'].fillna(0)
|
||||||
df['bblow30'] = bb30['lowerband'].fillna(0)
|
df['bblow30'] = bb30['lowerband'].fillna(0)
|
||||||
bb302 = ta.BBANDS(df, timeperiod=41, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
bb302 = ta.BBANDS(df, timeperiod=41, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||||
bb302 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
#bb302 = ta.BBANDS(df, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
|
||||||
df['bbup302'] = bb302['upperband'].fillna(0)
|
df['bbup302'] = bb302['upperband'].fillna(0)
|
||||||
df['bblow302'] = bb302['lowerband'].fillna(0)
|
df['bblow302'] = bb302['lowerband'].fillna(0)
|
||||||
# 计算次周期布林带 (14周期,2标准差)
|
# 计算次周期布林带 (14周期,2标准差)
|
||||||
|
|||||||
+64
-37
@@ -909,14 +909,14 @@
|
|||||||
<input class="form-check-input" type="checkbox" id="showKluFxType">
|
<input class="form-check-input" type="checkbox" id="showKluFxType">
|
||||||
<label class="form-check-label" for="showKluFxType">KLU分型</label>
|
<label class="form-check-label" for="showKluFxType">KLU分型</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="checkbox" id="toggleUOnMain" checked>
|
|
||||||
<label class="form-check-label" for="toggleUOnMain">主图显示U</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="checkbox" id="showMainBollinger">
|
<input class="form-check-input" type="checkbox" id="showMainBollinger">
|
||||||
<label class="form-check-label" for="showMainBollinger">布林带</label>
|
<label class="form-check-label" for="showMainBollinger">布林带</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input class="form-check-input" type="checkbox" id="toggleUOnMain" checked>
|
||||||
|
<label class="form-check-label" for="toggleUOnMain">显示U</label>
|
||||||
|
</div>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
<input class="form-check-input" type="checkbox" id="showMacd" checked>
|
<input class="form-check-input" type="checkbox" id="showMacd" checked>
|
||||||
<label class="form-check-label" for="showMacd">ChanMACD</label>
|
<label class="form-check-label" for="showMacd">ChanMACD</label>
|
||||||
@@ -956,6 +956,10 @@
|
|||||||
<input class="form-check-input" type="checkbox" id="showElementBollinger">
|
<input class="form-check-input" type="checkbox" id="showElementBollinger">
|
||||||
<label class="form-check-label" for="showElementBollinger">布林带</label>
|
<label class="form-check-label" for="showElementBollinger">布林带</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input class="form-check-input" type="checkbox" id="toggleUOnElement">
|
||||||
|
<label class="form-check-label" for="toggleUOnElement">显示U</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
@@ -2899,7 +2903,7 @@
|
|||||||
hasKlineData: !!currentData.kline_data,
|
hasKlineData: !!currentData.kline_data,
|
||||||
isArray: Array.isArray(currentData.kline_data)
|
isArray: Array.isArray(currentData.kline_data)
|
||||||
});
|
});
|
||||||
if (showMacd && chanMacdChart && currentData.macd && currentData.kline_data && Array.isArray(currentData.kline_data)) {
|
if (showMacd && chanMacdChart && ((useElementPeriod && currentData.element_macd) || currentData.macd) && (useElementPeriod ? currentData.element_kline_data : currentData.kline_data)) {
|
||||||
console.log('✅ 开始创建 ChanMACD 系列');
|
console.log('✅ 开始创建 ChanMACD 系列');
|
||||||
// 创建ChanMACD线系列
|
// 创建ChanMACD线系列
|
||||||
const chanMacdLineSeries = chanMacdChart.addLineSeries({
|
const chanMacdLineSeries = chanMacdChart.addLineSeries({
|
||||||
@@ -2942,11 +2946,9 @@
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 使用相同的MACD数据源
|
// 使用与主图一致的数据源(小周期开启时使用小周期MACD与K线)
|
||||||
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
|
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
|
||||||
const macdDataSource = useElementPeriod ?
|
const macdDataSource = useElementPeriod ? (currentData.element_macd || currentData.macd) : currentData.macd;
|
||||||
(currentData.element_macd || currentData.macd) :
|
|
||||||
currentData.macd;
|
|
||||||
|
|
||||||
// 准备ChanMACD数据
|
// 准备ChanMACD数据
|
||||||
const chanMacdData = [];
|
const chanMacdData = [];
|
||||||
@@ -3019,32 +3021,36 @@
|
|||||||
console.log('✅ ChanMACD图表系列已保存到tvWidget');
|
console.log('✅ ChanMACD图表系列已保存到tvWidget');
|
||||||
|
|
||||||
// 添加ChanMACD分析标注
|
// 添加ChanMACD分析标注
|
||||||
if (currentData.chan_macd) {
|
// 根据主/次周期开关与各自的“显示U”独立控制
|
||||||
|
const cm = useElementPeriod ? (currentData.element_chan_macd || currentData.chan_macd) : currentData.chan_macd;
|
||||||
|
const allowU = useElementPeriod ? (typeof window.showUOnElement === 'undefined' ? true : window.showUOnElement)
|
||||||
|
: (typeof window.showUOnMain === 'undefined' ? true : window.showUOnMain);
|
||||||
|
if (cm && allowU) {
|
||||||
console.log('添加ChanMACD分析标注:', {
|
console.log('添加ChanMACD分析标注:', {
|
||||||
segListLength: currentData.chan_macd.seg_list ? currentData.chan_macd.seg_list.length : 0,
|
segListLength: cm.seg_list ? cm.seg_list.length : 0,
|
||||||
unittfListLength: currentData.chan_macd.unittf_list ? currentData.chan_macd.unittf_list.length : 0,
|
unittfListLength: cm.unittf_list ? cm.unittf_list.length : 0,
|
||||||
histsetListLength: currentData.chan_macd.histset_list ? currentData.chan_macd.histset_list.length : 0
|
histsetListLength: cm.histset_list ? cm.histset_list.length : 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// 详细检查段数据
|
// 详细检查段数据
|
||||||
if (currentData.chan_macd.seg_list && currentData.chan_macd.seg_list.length > 0) {
|
if (cm.seg_list && cm.seg_list.length > 0) {
|
||||||
console.log('段数据详情:', currentData.chan_macd.seg_list.slice(0, 3)); // 显示前3个段
|
console.log('段数据详情:', cm.seg_list.slice(0, 3)); // 显示前3个段
|
||||||
} else {
|
} else {
|
||||||
console.log('⚠️ 段数据为空或不存在');
|
console.log('⚠️ 段数据为空或不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
addAllChanMacdMarkers(
|
addAllChanMacdMarkers(
|
||||||
currentData.chan_macd.seg_list || [],
|
cm.seg_list || [],
|
||||||
currentData.chan_macd.unittf_list || [],
|
cm.unittf_list || [],
|
||||||
currentData.chan_macd.histset_list || [],
|
cm.histset_list || [],
|
||||||
{
|
{
|
||||||
high_position_list: currentData.chan_macd.high_position_list || [],
|
high_position_list: cm.high_position_list || [],
|
||||||
high_empty_list: currentData.chan_macd.high_empty_list || [],
|
high_empty_list: cm.high_empty_list || [],
|
||||||
low_position_list: currentData.chan_macd.low_position_list || [],
|
low_position_list: cm.low_position_list || [],
|
||||||
low_empty_list: currentData.chan_macd.low_empty_list || [],
|
low_empty_list: cm.low_empty_list || [],
|
||||||
return_zero_list: currentData.chan_macd.return_zero_list || [],
|
return_zero_list: cm.return_zero_list || [],
|
||||||
cross0_up_list: currentData.chan_macd.cross0_up_list || [],
|
cross0_up_list: cm.cross0_up_list || [],
|
||||||
cross0_down_list: currentData.chan_macd.cross0_down_list || []
|
cross0_down_list: cm.cross0_down_list || []
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -5694,7 +5700,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新 ChanMACD 数据与自定义标注
|
// 更新 ChanMACD 数据与自定义标注
|
||||||
if (tvWidget.series.chanMacdLineSeries && currentData.macd && currentData.kline_data && Array.isArray(currentData.kline_data)) {
|
if (tvWidget.series.chanMacdLineSeries && ((useElementPeriod && currentData.element_macd) || currentData.macd) && (useElementPeriod ? currentData.element_kline_data : currentData.kline_data)) {
|
||||||
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
|
const klineDataSource = useElementPeriod ? currentData.element_kline_data : currentData.kline_data;
|
||||||
const macdDataSource = useElementPeriod ? (currentData.element_macd || currentData.macd) : currentData.macd;
|
const macdDataSource = useElementPeriod ? (currentData.element_macd || currentData.macd) : currentData.macd;
|
||||||
if (macdDataSource && macdDataSource.macd && macdDataSource.signal && macdDataSource.histogram) {
|
if (macdDataSource && macdDataSource.macd && macdDataSource.signal && macdDataSource.histogram) {
|
||||||
@@ -5719,19 +5725,20 @@
|
|||||||
// 重新应用自定义标注(段/UnitTF/HistSet/状态点)
|
// 重新应用自定义标注(段/UnitTF/HistSet/状态点)
|
||||||
try {
|
try {
|
||||||
if (typeof clearChanMacdMarkers === 'function') clearChanMacdMarkers();
|
if (typeof clearChanMacdMarkers === 'function') clearChanMacdMarkers();
|
||||||
if (currentData.chan_macd) {
|
const cm = useElementPeriod ? (currentData.element_chan_macd || currentData.chan_macd) : currentData.chan_macd;
|
||||||
|
if (cm) {
|
||||||
addAllChanMacdMarkers(
|
addAllChanMacdMarkers(
|
||||||
currentData.chan_macd.seg_list || [],
|
cm.seg_list || [],
|
||||||
currentData.chan_macd.unittf_list || [],
|
cm.unittf_list || [],
|
||||||
currentData.chan_macd.histset_list || [],
|
cm.histset_list || [],
|
||||||
{
|
{
|
||||||
high_position_list: currentData.chan_macd.high_position_list || [],
|
high_position_list: cm.high_position_list || [],
|
||||||
high_empty_list: currentData.chan_macd.high_empty_list || [],
|
high_empty_list: cm.high_empty_list || [],
|
||||||
low_position_list: currentData.chan_macd.low_position_list || [],
|
low_position_list: cm.low_position_list || [],
|
||||||
low_empty_list: currentData.chan_macd.low_empty_list || [],
|
low_empty_list: cm.low_empty_list || [],
|
||||||
return_zero_list: currentData.chan_macd.return_zero_list || [],
|
return_zero_list: cm.return_zero_list || [],
|
||||||
cross0_up_list: currentData.chan_macd.cross0_up_list || [],
|
cross0_up_list: cm.cross0_up_list || [],
|
||||||
cross0_down_list: currentData.chan_macd.cross0_down_list || []
|
cross0_down_list: cm.cross0_down_list || []
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -6020,6 +6027,20 @@
|
|||||||
function setupTooltip(mainChart, buyMarkers = [], sellMarkers = [], mainChartContainer, volumeChartContainer, atrChartContainer, macdChartContainer, chanMacdChartContainer, volumeChart, atrChart, macdChart, chanMacdChart, showMacd) {
|
function setupTooltip(mainChart, buyMarkers = [], sellMarkers = [], mainChartContainer, volumeChartContainer, atrChartContainer, macdChartContainer, chanMacdChartContainer, volumeChart, atrChart, macdChart, chanMacdChart, showMacd) {
|
||||||
// 调试变量
|
// 调试变量
|
||||||
window.debugMode = true;
|
window.debugMode = true;
|
||||||
|
// 初始化 U 显示状态(主/次周期分开控制)
|
||||||
|
const isShowUMain = $('#toggleUOnMain').is(':checked');
|
||||||
|
const isShowUElement = $('#toggleUOnElement').is(':checked');
|
||||||
|
window.showUOnMain = isShowUMain;
|
||||||
|
window.showUOnElement = isShowUElement;
|
||||||
|
if (!isShowUMain && !isShowUElement) {
|
||||||
|
// 隐藏时清空子图上的 U 标记
|
||||||
|
if (tvWidget.series && tvWidget.series.chanMacdLineSeries) {
|
||||||
|
try { tvWidget.series.chanMacdLineSeries.setMarkers([]); } catch (e) {}
|
||||||
|
}
|
||||||
|
if (tvWidget.series && tvWidget.series.chanMacdSignalSeries) {
|
||||||
|
try { tvWidget.series.chanMacdSignalSeries.setMarkers([]); } catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 添加买卖点悬浮提示元素
|
// 添加买卖点悬浮提示元素
|
||||||
const tooltipElement = document.createElement('div');
|
const tooltipElement = document.createElement('div');
|
||||||
@@ -7460,6 +7481,12 @@
|
|||||||
window.showUOnMain = $('#toggleUOnMain').is(':checked');
|
window.showUOnMain = $('#toggleUOnMain').is(':checked');
|
||||||
refreshChartOnly();
|
refreshChartOnly();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 次周期 U 显示开关
|
||||||
|
$('#toggleUOnElement').change(function() {
|
||||||
|
window.showUOnElement = $('#toggleUOnElement').is(':checked');
|
||||||
|
refreshChartOnly();
|
||||||
|
});
|
||||||
|
|
||||||
// 在控制台输出当前显示状态
|
// 在控制台输出当前显示状态
|
||||||
console.log('当前显示状态:', {
|
console.log('当前显示状态:', {
|
||||||
|
|||||||
Reference in New Issue
Block a user