chore: 清理分析脚本和图表文件
删除不再使用的分析脚本check_buy1_price_decline.py和相关图表文件 更新分析文档"分析.md"内容
This commit is contained in:
parent
e5dd5b5593
commit
2bd0cb7432
@ -1,194 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
检查买1量大于99的挂单后是否出现低于当前价格的数据
|
||||
|
||||
详细分析买1量大单出现后的价格行为,验证是否真的全部上涨
|
||||
"""
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
def check_buy1_price_decline():
|
||||
"""检查买1量大单后的价格下跌情况"""
|
||||
|
||||
# 加载数据
|
||||
data_file = 'data/au2512_20251013.parquet'
|
||||
if not os.path.exists(data_file):
|
||||
print(f"数据文件不存在: {data_file}")
|
||||
return
|
||||
|
||||
print("正在加载数据...")
|
||||
df = pd.read_parquet(data_file)
|
||||
print(f"数据加载成功: {len(df):,} 条记录")
|
||||
|
||||
# 确保按数列号排序
|
||||
if '数列号' in df.columns:
|
||||
df = df.sort_values('数列号').reset_index(drop=True)
|
||||
|
||||
# 找到买1量列
|
||||
buy1_col = None
|
||||
for col in df.columns:
|
||||
if '买1量' in col:
|
||||
buy1_col = col
|
||||
break
|
||||
|
||||
if buy1_col is None:
|
||||
print("未找到买1量列")
|
||||
return
|
||||
|
||||
print(f"使用买1量列: {buy1_col}")
|
||||
|
||||
# 筛选买1量大于99的数据
|
||||
threshold = 99
|
||||
large_buy1_mask = df[buy1_col] > threshold
|
||||
large_buy1_orders = df[large_buy1_mask].copy().reset_index(drop=True)
|
||||
|
||||
print(f"\n买1量 > {threshold} 的记录数: {len(large_buy1_orders):,}")
|
||||
print(f"占总记录比例: {len(large_buy1_orders)/len(df)*100:.2f}%")
|
||||
|
||||
if len(large_buy1_orders) == 0:
|
||||
print("未找到符合条件的记录")
|
||||
return
|
||||
|
||||
# 详细分析每个大单后的价格行为
|
||||
print(f"\n" + "="*80)
|
||||
print("买1量大单后价格行为详细分析")
|
||||
print("="*80)
|
||||
|
||||
decline_100_count = 0
|
||||
decline_200_count = 0
|
||||
detailed_results = []
|
||||
|
||||
for idx, row in large_buy1_orders.iterrows():
|
||||
current_seq_num = row['数列号'] if '数列号' in row else idx
|
||||
current_price = row['成交价']
|
||||
buy1_volume = row[buy1_col]
|
||||
|
||||
# 获取后续100笔数据
|
||||
future_mask_100 = df['数列号'] >= current_seq_num + 1
|
||||
future_data_100 = df[future_mask_100].head(100)
|
||||
|
||||
# 获取后续200笔数据
|
||||
future_mask_200 = df['数列号'] >= current_seq_num + 1
|
||||
future_data_200 = df[future_mask_200].head(200)
|
||||
|
||||
# 分析100笔内的价格行为
|
||||
if len(future_data_100) > 0:
|
||||
min_price_100 = future_data_100['成交价'].min()
|
||||
max_price_100 = future_data_100['成交价'].max()
|
||||
price_decline_100 = current_price - min_price_100 # 价格下跌幅度
|
||||
price_rise_100 = max_price_100 - current_price # 价格上涨幅度
|
||||
|
||||
# 检查是否出现低于当前价格的情况
|
||||
has_decline_100 = min_price_100 < current_price
|
||||
|
||||
if has_decline_100:
|
||||
decline_100_count += 1
|
||||
decline_info_100 = f"是 (最低: {min_price_100:.2f}, 下跌: {price_decline_100:.2f})"
|
||||
else:
|
||||
decline_info_100 = f"否 (最低: {min_price_100:.2f})"
|
||||
|
||||
# 分析200笔内的价格行为
|
||||
if len(future_data_200) > 0:
|
||||
min_price_200 = future_data_200['成交价'].min()
|
||||
max_price_200 = future_data_200['成交价'].max()
|
||||
price_decline_200 = current_price - min_price_200 # 价格下跌幅度
|
||||
price_rise_200 = max_price_200 - current_price # 价格上涨幅度
|
||||
|
||||
# 检查是否出现低于当前价格的情况
|
||||
has_decline_200 = min_price_200 < current_price
|
||||
|
||||
if has_decline_200:
|
||||
decline_200_count += 1
|
||||
decline_info_200 = f"是 (最低: {min_price_200:.2f}, 下跌: {price_decline_200:.2f})"
|
||||
else:
|
||||
decline_info_200 = f"否 (最低: {min_price_200:.2f})"
|
||||
|
||||
# 记录详细结果
|
||||
detailed_results.append({
|
||||
'序号': idx + 1,
|
||||
'数列号': current_seq_num,
|
||||
'当前价格': current_price,
|
||||
'买1量': buy1_volume,
|
||||
'100笔样本数': len(future_data_100),
|
||||
'100笔最低价': min_price_100 if len(future_data_100) > 0 else None,
|
||||
'100笔最高价': max_price_100 if len(future_data_100) > 0 else None,
|
||||
'100笔是否下跌': has_decline_100 if len(future_data_100) > 0 else None,
|
||||
'100笔下跌幅度': price_decline_100 if len(future_data_100) > 0 else None,
|
||||
'100笔上涨幅度': price_rise_100 if len(future_data_100) > 0 else None,
|
||||
'200笔样本数': len(future_data_200),
|
||||
'200笔最低价': min_price_200 if len(future_data_200) > 0 else None,
|
||||
'200笔最高价': max_price_200 if len(future_data_200) > 0 else None,
|
||||
'200笔是否下跌': has_decline_200 if len(future_data_200) > 0 else None,
|
||||
'200笔下跌幅度': price_decline_200 if len(future_data_200) > 0 else None,
|
||||
'200笔上涨幅度': price_rise_200 if len(future_data_200) > 0 else None,
|
||||
})
|
||||
|
||||
# 保存详细结果
|
||||
results_df = pd.DataFrame(detailed_results)
|
||||
results_df.to_csv('large_orders/buy1_detailed_price_analysis.csv', index=False, encoding='utf-8-sig')
|
||||
|
||||
# 打印汇总统计
|
||||
print(f"\n【汇总统计】")
|
||||
print(f"总样本数: {len(large_buy1_orders)}")
|
||||
print(f"100笔内出现价格下跌的样本数: {decline_100_count} ({decline_100_count/len(large_buy1_orders)*100:.1f}%)")
|
||||
print(f"200笔内出现价格下跌的样本数: {decline_200_count} ({decline_200_count/len(large_buy1_orders)*100:.1f}%)")
|
||||
|
||||
# 打印详细分析
|
||||
print(f"\n【详细分析 - 前15个样本】")
|
||||
print(f"{'序号':>4} {'数列号':>8} {'当前价格':>10} {'买1量':>8} {'100笔下跌?':>12} {'200笔下跌?':>12}")
|
||||
print("-" * 80)
|
||||
|
||||
for i, result in enumerate(detailed_results[:15]):
|
||||
decline_100_status = "是" if result['100笔是否下跌'] else "否"
|
||||
decline_200_status = "是" if result['200笔是否下跌'] else "否"
|
||||
|
||||
print(f"{result['序号']:>4} {result['数列号']:>8.0f} {result['当前价格']:>10.2f} "
|
||||
f"{result['买1量']:>8.0f} {decline_100_status:>12} {decline_200_status:>12}")
|
||||
|
||||
# 分析下跌样本的详细信息
|
||||
decline_samples_100 = [r for r in detailed_results if r['100笔是否下跌']]
|
||||
decline_samples_200 = [r for r in detailed_results if r['200笔是否下跌']]
|
||||
|
||||
if decline_samples_100:
|
||||
print(f"\n【100笔内出现价格下跌的样本详情】")
|
||||
for result in decline_samples_100:
|
||||
print(f"序号{result['序号']}: 当前价格={result['当前价格']:.2f}, "
|
||||
f"最低价格={result['100笔最低价']:.2f}, "
|
||||
f"下跌幅度={result['100笔下跌幅度']:.2f}元, "
|
||||
f"买1量={result['买1量']:.0f}手")
|
||||
|
||||
if decline_samples_200:
|
||||
print(f"\n【200笔内出现价格下跌的样本详情】")
|
||||
for result in decline_samples_200:
|
||||
print(f"序号{result['序号']}: 当前价格={result['当前价格']:.2f}, "
|
||||
f"最低价格={result['200笔最低价']:.2f}, "
|
||||
f"下跌幅度={result['200笔下跌幅度']:.2f}元, "
|
||||
f"买1量={result['买1量']:.0f}手")
|
||||
|
||||
# 价格波动统计
|
||||
print(f"\n【价格波动统计】")
|
||||
if len(detailed_results) > 0:
|
||||
all_declines_100 = [r['100笔下跌幅度'] for r in detailed_results if r['100笔下跌幅度'] is not None]
|
||||
all_rises_100 = [r['100笔上涨幅度'] for r in detailed_results if r['100笔上涨幅度'] is not None]
|
||||
|
||||
if all_declines_100:
|
||||
avg_decline_100 = np.mean(all_declines_100)
|
||||
max_decline_100 = np.max(all_declines_100)
|
||||
print(f"100笔内平均下跌幅度: {avg_decline_100:.3f}元")
|
||||
print(f"100笔内最大下跌幅度: {max_decline_100:.3f}元")
|
||||
|
||||
if all_rises_100:
|
||||
avg_rise_100 = np.mean(all_rises_100)
|
||||
max_rise_100 = np.max(all_rises_100)
|
||||
print(f"100笔内平均上涨幅度: {avg_rise_100:.3f}元")
|
||||
print(f"100笔内最大上涨幅度: {max_rise_100:.3f}元")
|
||||
|
||||
print(f"\n分析完成!详细结果已保存到: large_orders/buy1_detailed_price_analysis.csv")
|
||||
|
||||
return decline_100_count, decline_200_count
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_buy1_price_decline()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 475 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 MiB |
Loading…
Reference in New Issue
Block a user