去掉trim data,修改check_fx回去
This commit is contained in:
+13
-13
@@ -1339,17 +1339,17 @@ def analyze():
|
||||
'end_price': bi.end_klc.high if convert_direction(bi.dir) == 1 else bi.end_klc.low if bi.end_klc else None,
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in analysis_result['bi_list'] if bi.end_klc],
|
||||
} for bi in analysis_result['bi_list'] if bi.is_sure],
|
||||
# 添加未完成笔列表
|
||||
'uncompleted_bi_list': [{
|
||||
'start_time': bi.start_klc.end_time if isinstance(bi.start_klc.end_time, str) else bi.start_klc.end_time.astimezone(client_tz).isoformat(),
|
||||
'end_time': None, # 未完成笔没有结束时间
|
||||
'end_time': bi.end_time, # 未完成笔没有结束时间
|
||||
'sure_time': format_time_safely(bi.sure_time, client_tz) if bi.sure_time else None,
|
||||
'start_price': bi.start_klc.low if convert_direction(bi.dir) == 1 else bi.start_klc.high,
|
||||
'end_price': None, # 未完成笔没有结束价格
|
||||
'end_price': bi.end_klc.low if convert_direction(bi.dir) == 1 else bi.end_klc.high, # 未完成笔没有结束价格
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in analysis_result['bi_list'] if not bi.end_klc],
|
||||
} for bi in analysis_result['bi_list'] if not bi.is_sure],
|
||||
'seg_list': [{
|
||||
'start_time': seg.start_bi.start_klc.end_time if isinstance(seg.start_bi.start_klc.end_time, str) else seg.start_bi.start_klc.end_time.astimezone(client_tz).isoformat(),
|
||||
'end_time': (seg.end_bi.end_klc.end_time if isinstance(seg.end_bi.end_klc.end_time, str) else seg.end_bi.end_klc.end_time.astimezone(client_tz).isoformat()) if seg.end_bi else None,
|
||||
@@ -1368,7 +1368,7 @@ def analyze():
|
||||
'gg': zs.gg,
|
||||
'dd': zs.dd,
|
||||
'is_sure': zs.is_sure # 添加中枢是否完成的标志
|
||||
} for zs in analysis_result['zs_list'] if zs.end_klc],
|
||||
} for zs in analysis_result['zs_list'] if zs.is_sure],
|
||||
# 添加主周期BI中枢列表(已完成)
|
||||
'bi_zs_list': [{
|
||||
'start_time': (
|
||||
@@ -1534,17 +1534,17 @@ def analyze():
|
||||
'end_price': bi.end_klc.high if convert_direction(bi.dir) == 1 else bi.end_klc.low if bi.end_klc else None,
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in element_analysis['bi_list'] if bi.end_klc]
|
||||
} for bi in element_analysis['bi_list'] if bi.is_sure]
|
||||
# 添加次周期未完成笔列表
|
||||
result['element_uncompleted_bi_list'] = [{
|
||||
'start_time': bi.start_klc.end_time if isinstance(bi.start_klc.end_time, str) else bi.start_klc.end_time.astimezone(client_tz).isoformat(),
|
||||
'end_time': None, # 未完成笔没有结束时间
|
||||
'end_time': bi.end_time, # 未完成笔没有结束时间
|
||||
'sure_time': format_time_safely(bi.sure_time, client_tz) if bi.sure_time else None,
|
||||
'start_price': bi.start_klc.low if convert_direction(bi.dir) == 1 else bi.start_klc.high,
|
||||
'end_price': None, # 未完成笔没有结束价格
|
||||
'end_price': bi.end_klc.low if convert_direction(bi.dir) == 1 else bi.end_klc.high, # 未完成笔没有结束价格
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in element_analysis['bi_list'] if not bi.end_klc]
|
||||
} for bi in element_analysis['bi_list'] if not bi.is_sure]
|
||||
|
||||
# 添加小周期K线数据
|
||||
result['element_kline_data'] = clean_dataframe_for_json(element_df).to_dict('records')
|
||||
@@ -1674,16 +1674,16 @@ def analyze():
|
||||
'end_price': bi.end_klc.high if convert_direction(bi.dir) == 1 else bi.end_klc.low if bi.end_klc else None,
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in sub_sub_analysis['bi_list'] if bi.end_klc]
|
||||
} for bi in sub_sub_analysis['bi_list'] if bi.is_sure]
|
||||
result['sub_sub_uncompleted_bi_list'] = [{
|
||||
'start_time': bi.start_klc.end_time if isinstance(bi.start_klc.end_time, str) else bi.start_klc.end_time.astimezone(client_tz).isoformat(),
|
||||
'end_time': None,
|
||||
'end_time': bi.end_time,
|
||||
'sure_time': format_time_safely(bi.sure_time, client_tz) if bi.sure_time else None,
|
||||
'start_price': bi.start_klc.low if convert_direction(bi.dir) == 1 else bi.start_klc.high,
|
||||
'end_price': None,
|
||||
'end_price': bi.end_klc.low if convert_direction(bi.dir) == 1 else bi.end_klc.high,
|
||||
'direction': convert_direction(bi.dir),
|
||||
'macd_div': float(bi.macd_div) if hasattr(bi, 'macd_div') else 0
|
||||
} for bi in sub_sub_analysis['bi_list'] if not bi.end_klc]
|
||||
} for bi in sub_sub_analysis['bi_list'] if not bi.is_sure]
|
||||
# 次次周期 KLC 列表
|
||||
result['sub_sub_klc_list'] = [{
|
||||
'date': klc.end_time if isinstance(klc.end_time, str) else klc.end_time.astimezone(client_tz).isoformat(),
|
||||
|
||||
@@ -1256,47 +1256,6 @@
|
||||
// ======= 趋势筛选(币对) =======
|
||||
let trendTable = null;
|
||||
|
||||
// 不在前端截断数据,保留完整历史,避免K线数量限制
|
||||
function trimDataInPlace(payload, maxLen = 2000) {
|
||||
if (!payload || typeof payload !== 'object') return;
|
||||
delete payload.original_kline_data;
|
||||
delete payload.original_macd;
|
||||
|
||||
// 截断大型数组,只保留最新 maxLen 条数据
|
||||
const arrayKeys = [
|
||||
'kline_data', 'element_kline_data', 'sub_sub_kline_data',
|
||||
'bi_list', 'element_bi_list', 'sub_sub_bi_list',
|
||||
'seg_list', 'element_seg_list', 'sub_sub_seg_list',
|
||||
'zs_list', 'element_zs_list', 'sub_sub_zs_list',
|
||||
'uncompleted_bi_list', 'uncompleted_seg_list', 'uncompleted_zs_list',
|
||||
'element_uncompleted_bi_list', 'element_uncompleted_seg_list', 'element_uncompleted_zs_list',
|
||||
'bsp_list', 'element_bsp_list', 'sub_sub_bsp_list',
|
||||
'trade_points', 'element_trade_points'
|
||||
];
|
||||
for (const key of arrayKeys) {
|
||||
if (Array.isArray(payload[key]) && payload[key].length > maxLen) {
|
||||
payload[key] = payload[key].slice(-maxLen);
|
||||
}
|
||||
}
|
||||
// 截断 MACD 子数组
|
||||
const macdKeys = ['macd', 'element_macd', 'sub_sub_macd'];
|
||||
for (const mk of macdKeys) {
|
||||
const m = payload[mk];
|
||||
if (m && typeof m === 'object') {
|
||||
for (const sub of ['macd', 'signal', 'histogram']) {
|
||||
if (Array.isArray(m[sub]) && m[sub].length > maxLen) {
|
||||
m[sub] = m[sub].slice(-maxLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 截断 ATR 数组
|
||||
for (const ak of ['atr', 'element_atr', 'sub_sub_atr']) {
|
||||
if (Array.isArray(payload[ak]) && payload[ak].length > maxLen) {
|
||||
payload[ak] = payload[ak].slice(-maxLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
let trendDetailTable = null;
|
||||
let trendChart = null;
|
||||
|
||||
@@ -2081,16 +2040,21 @@
|
||||
}
|
||||
ensureSubSubLteElement();
|
||||
});
|
||||
let _lastKlinePeriod = 'main';
|
||||
function updateChartDisplay() {
|
||||
if (currentData) {
|
||||
// 保存当前的可见逻辑范围
|
||||
// 检测K线周期是否切换
|
||||
const curPeriod = $('#subSubPeriodKline').is(':checked') ? 'subsub' :
|
||||
($('#elementPeriodKline').is(':checked') ? 'element' : 'main');
|
||||
const periodChanged = (curPeriod !== _lastKlinePeriod);
|
||||
_lastKlinePeriod = curPeriod;
|
||||
|
||||
// 保存当前的可见逻辑范围(周期切换时不保留,避免范围越界)
|
||||
let logicalRange = null;
|
||||
let visibleRange = null;
|
||||
|
||||
if (tvWidget && tvWidget.mainChart) {
|
||||
// 优先使用逻辑范围,这样在缩放级别上更准确
|
||||
if (!periodChanged && tvWidget && tvWidget.mainChart) {
|
||||
logicalRange = tvWidget.mainChart.timeScale().getVisibleLogicalRange();
|
||||
// 备用方案,获取实际时间戳范围
|
||||
visibleRange = tvWidget.mainChart.timeScale().getVisibleRange();
|
||||
}
|
||||
|
||||
@@ -2279,9 +2243,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 截断数据以限制内存占用
|
||||
trimDataInPlace(data, 2000);
|
||||
|
||||
// 保存当前数据
|
||||
if (currentData) {
|
||||
// 覆盖前断开旧引用,帮助GC尽快回收
|
||||
|
||||
Reference in New Issue
Block a user