You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1088 lines
120 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 涨停后,各个场景买入后,第二天开盘卖出的成功率
import pandas as pd
import pymysql
from sqlalchemy import create_engine
import matplotlib.pyplot as plt
import os
# 计算盈亏, -6以上,-6,-3,0,3,6,6以上
def count_change(diff, loss_over_6, loss_6_to_3, loss_3_to_0,profit_0_to_3,profit_3_to_6,profit_over_6):
if diff <= -6:
loss_over_6 += 1
elif diff > -6 and diff <= -3:
loss_6_to_3 += 1
elif diff > -3 and diff <= 0:
loss_3_to_0 += 1
elif diff > 0 and diff <= 3:
profit_0_to_3 += 1
elif diff > 3 and diff <= 6:
profit_3_to_6 += 1
else:
profit_over_6 += 1
return loss_over_6, loss_6_to_3, loss_3_to_0,profit_0_to_3,profit_3_to_6,profit_over_6
# 创建数据库连接
engine = create_engine('mysql+pymysql://root:1qazse42W3@192.168.0.222:3306/ry')
# 执行SQL查询来获取日期列表
# 假设你的数据表中有一个date字段表示日期
date_df = pd.read_sql_query('select date from trade_dates where trade = "trading" and date between "2022-01-01" and "2023-01-06" order by date', engine)
# 将date字段转换为日期类型
date_df['date'] = pd.to_datetime(date_df['date'])
# 获取日期列表
date_list = date_df['date'].tolist()
counters = {
'total': 0,
# 买入日的开盘价分布
'open': {'low_over_6': 0,'low_6_to_3': 0,'low_3_to_0': 0, 'high_0_to_3': 0, 'high_3_to_6': 0, 'high_over_6': 0},
# 买入日的收盘价分布
'close': {'low_over_6': 0,'low_6_to_3': 0,'low_3_to_0': 0, 'high_0_to_3': 0, 'high_3_to_6': 0, 'high_over_6': 0},
# 清仓日的开盘价分布
'sale_open': {'low_over_6': 0,'low_6_to_3': 0,'low_3_to_0': 0, 'high_0_to_3': 0, 'high_3_to_6': 0, 'high_over_6': 0},
# 清仓日的收盘价分布
'sale_close': {'low_over_6': 0,'low_6_to_3': 0,'low_3_to_0': 0, 'high_0_to_3': 0, 'high_3_to_6': 0, 'high_over_6': 0},
# 清仓日开盘清仓盈亏分布-开盘建仓
'profit_open_sale_open': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
# 清仓日开盘清仓盈亏分布-收盘建仓
'profit_close_sale_open': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
# 清仓日收盘清仓盈亏分布-开盘建仓
'profit_open_sale_close': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
# 清仓日收盘清仓盈亏分布-收盘建仓
'profit_close_sale_close': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
# 不同场景的统计
'scenarios': {
'low_over_6_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_over_6_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_over_6_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_over_6_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_over_6_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_over_6_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6': 0},
'low_6_to_3_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0': 0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3': 0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_open_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_6_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_3_to_0_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_0_to_3_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_3_to_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_over_6_open_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0,'profit_0_to_3': 0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_over_6_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_6_to_3_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'low_3_to_0_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0,'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_0_to_3_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_3_to_6_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_6_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_low_3_to_0_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_0_to_3_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_3_to_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0},
'high_over_6_close_high_over_6_close_sale': {'loss_over_6': 0, 'loss_6_to_3':0,'loss_3_to_0':0, 'profit_0_to_3':0, 'profit_3_to_6': 0, 'profit_over_6':0}
}
}
total_count = 0
# 低于-3%的开盘价计数
low_open_count = 0
# 正常开盘,介于-3%和3%之间的计数
normal_open_count = 0
# 高于3%的开盘价计数
high_open_count = 0
# 低于-3%的收盘价计数
low_close_count = 0
# 正常收盘,介于-3%和3%之间的计数
normal_close_count = 0
# 高于3%的收盘价计数
high_close_count = 0
# 开盘清仓低于3%的清仓计数
low_sale_open_count = 0
# 开盘清仓高于3%的清仓计数
high_sale_open_count = 0
# 开盘清仓,正常清仓计数
normal_sale_open_count = 0
# 收盘清仓低于3%的清仓计数
low_sale_close_count = 0
# 收盘清仓高于3%的清仓计数
high_sale_close_count = 0
# 收盘清仓,正常清仓计数
normal_sale_close_count = 0
##########基于开盘、收盘买入的整体盈亏分布############
# 盈利高于5%的清仓开盘价计数
high_profit_sale_open_count = 0
# 盈利低于5%的清仓开盘价计数
low_profit_sale_open_count = 0
# 亏损低于5%的清仓开盘价计数
low_loss_sale_open_count = 0
# 亏损高于5%的清仓开盘价计数
high_loss_sale_open_count = 0
# 盈利高于5%的清仓收盘价计数
high_profit_sale_close_count = 0
# 盈利低于5%的清仓收盘价计数
low_profit_sale_close_count = 0
# 亏损低于5%的清仓收盘价计数
low_loss_sale_close_count = 0
# 亏损高于5%的清仓收盘价计数
high_loss_sale_close_count = 0
#####################################
# 组合场景 低开盘-低清仓 低开盘-高清仓 低开盘-正常清仓 正常开盘-低清仓 正常开盘-高清仓 正常开盘-正常清仓 高开盘-低清仓 高开盘-高清仓 高开盘-正常清仓
low_open_low_sale_count = 0
low_open_high_sale_count = 0
low_open_normal_sale_count = 0
normal_open_low_sale_count = 0
normal_open_high_sale_count = 0
normal_open_normal_sale_count = 0
high_open_low_sale_count = 0
high_open_high_sale_count = 0
high_open_normal_sale_count = 0
# 各组合场景的收益情况 如 低开盘-高清仓盈利高于5%的清仓收盘价计数 盈利低于5%的清仓收盘价计数 亏损低于5%的清仓收盘价计数 亏损高于5%的清仓收盘价计数
low_open_low_sale_high_profit_count = 0
low_open_low_sale_low_profit_count = 0
low_open_low_sale_low_loss_count = 0
low_open_low_sale_high_loss_count = 0
low_open_high_sale_high_profit_count = 0
low_open_high_sale_low_profit_count = 0
low_open_high_sale_low_loss_count = 0
low_open_high_sale_high_loss_count = 0
low_open_normal_sale_high_profit_count = 0
low_open_normal_sale_low_profit_count = 0
low_open_normal_sale_low_loss_count = 0
low_open_normal_sale_high_loss_count = 0
normal_open_low_sale_high_profit_count = 0
normal_open_low_sale_low_profit_count = 0
normal_open_low_sale_low_loss_count = 0
normal_open_low_sale_high_loss_count = 0
normal_open_high_sale_high_profit_count = 0
normal_open_high_sale_low_profit_count = 0
normal_open_high_sale_low_loss_count = 0
normal_open_high_sale_high_loss_count = 0
normal_open_normal_sale_high_profit_count = 0
normal_open_normal_sale_low_profit_count = 0
normal_open_normal_sale_low_loss_count = 0
normal_open_normal_sale_high_loss_count = 0
high_open_low_sale_high_profit_count = 0
high_open_low_sale_low_profit_count = 0
high_open_low_sale_low_loss_count = 0
high_open_low_sale_high_loss_count = 0
high_open_high_sale_high_profit_count = 0
high_open_high_sale_low_profit_count = 0
high_open_high_sale_low_loss_count = 0
high_open_high_sale_high_loss_count = 0
high_open_normal_sale_high_profit_count = 0
high_open_normal_sale_low_profit_count = 0
high_open_normal_sale_low_loss_count = 0
high_open_normal_sale_high_loss_count = 0
# 组合场景 低收盘-低清仓 低收盘-高清仓 低收盘-正常清仓 正常收盘-低清仓 正常收盘-高清仓 正常收盘-正常清仓 高收盘-低清仓 高收盘-高清仓 高收盘-正常清仓
low_close_low_sale_count = 0
low_close_high_sale_count = 0
low_close_normal_sale_count = 0
normal_close_low_sale_count = 0
normal_close_high_sale_count = 0
normal_close_normal_sale_count = 0
high_close_low_sale_count = 0
high_close_high_sale_count = 0
high_close_normal_sale_count = 0
# 各组合场景的收益情况 如 低收盘-高清仓盈利高于5%的清仓收盘价计数 盈利低于5%的清仓收盘价计数 亏损低于5%的清仓收盘价计数 亏损高于5%的清仓收盘价计数
low_close_low_sale_high_profit_count = 0
low_close_low_sale_low_profit_count = 0
low_close_low_sale_low_loss_count = 0
low_close_low_sale_high_loss_count = 0
low_close_high_sale_high_profit_count = 0
low_close_high_sale_low_profit_count = 0
low_close_high_sale_low_loss_count = 0
low_close_high_sale_high_loss_count = 0
low_close_normal_sale_high_profit_count = 0
low_close_normal_sale_low_profit_count = 0
low_close_normal_sale_low_loss_count = 0
low_close_normal_sale_high_loss_count = 0
normal_close_low_sale_high_profit_count = 0
normal_close_low_sale_low_profit_count = 0
normal_close_low_sale_low_loss_count = 0
normal_close_low_sale_high_loss_count = 0
normal_close_high_sale_high_profit_count = 0
normal_close_high_sale_low_profit_count = 0
normal_close_high_sale_low_loss_count = 0
normal_close_high_sale_high_loss_count = 0
normal_close_normal_sale_high_profit_count = 0
normal_close_normal_sale_low_profit_count = 0
normal_close_normal_sale_low_loss_count = 0
normal_close_normal_sale_high_loss_count = 0
high_close_low_sale_high_profit_count = 0
high_close_low_sale_low_profit_count = 0
high_close_low_sale_low_loss_count = 0
high_close_low_sale_high_loss_count = 0
high_close_high_sale_high_profit_count = 0
high_close_high_sale_low_profit_count = 0
high_close_high_sale_low_loss_count = 0
high_close_high_sale_high_loss_count = 0
high_close_normal_sale_high_profit_count = 0
high_close_normal_sale_low_profit_count = 0
high_close_normal_sale_low_loss_count = 0
high_close_normal_sale_high_loss_count = 0
# 遍历日期列表
for i, date in enumerate(date_list):
if i+2 < len(date_list):
# 将日期转换为字符串格式以便在SQL查询中使用
date_str = date.strftime('%Y-%m-%d')
if os.path.exists(f'D:/calculate_data/{date_str}_stock.csv'):
df = pd.read_csv(f'D:/calculate_data/{date_str}_stock.csv')
limit_list = df['code'].tolist()
for code in limit_list:
# 总统计数
counters['total'] += 1
print(f'正在处理{date_str} - {code}的数据-从文件获取')
saleopen = df.loc[df['code'] == code, 'saleprice_open']
saleclose = df.loc[df['code'] == code, 'saleprice_close']
nextclose = df.loc[df['code'] == code, 'next_close']
# 计算清仓日开盘、收盘价
saleprice_open_differrange = 100 * (saleopen - df.loc[df['code'] == code, 'next_open'])/df.loc[df['code'] == code, 'next_open']
saleprice_close_differrange = 100 * (saleclose - nextclose)/nextclose
# 第二日开盘价分布
next_open_diff = df.loc[df['code'] == code, 'next_open_diff'].values[0]
counters['open']['low_over_6'],counters['open']['low_6_to_3'], counters['open']['low_3_to_0'], counters['open']['high_0_to_3'], counters['open']['high_3_to_6'], counters['open']['high_over_6'] = count_change(next_open_diff, counters['open']['low_over_6'], counters['open']['low_6_to_3'], counters['open']['low_3_to_0'], counters['open']['high_0_to_3'], counters['open']['high_3_to_6'], counters['open']['high_over_6'])
# 第二日收盘价分布
next_close_differrange = df.loc[df['code'] == code, 'next_close_differrange'].values[0]
counters['close']['low_over_6'],counters['close']['low_6_to_3'], counters['close']['low_3_to_0'], counters['close']['high_0_to_3'], counters['close']['high_3_to_6'], counters['close']['high_over_6'] = count_change(next_close_differrange, counters['close']['low_over_6'], counters['close']['low_6_to_3'], counters['close']['low_3_to_0'], counters['close']['high_0_to_3'], counters['close']['high_3_to_6'], counters['close']['high_over_6'])
# 清仓日的开盘价分布
counters['sale_open']['low_over_6'],counters['sale_open']['low_6_to_3'], counters['sale_open']['low_3_to_0'], counters['sale_open']['high_0_to_3'], counters['sale_open']['high_3_to_6'], counters['sale_open']['high_over_6'] = count_change(saleprice_open_differrange, counters['sale_open']['low_over_6'], counters['sale_open']['low_6_to_3'], counters['sale_open']['low_3_to_0'], counters['sale_open']['high_0_to_3'], counters['sale_open']['high_3_to_6'], counters['sale_open']['high_over_6'])
# 清仓日的收盘价分布
counters['sale_close']['low_over_6'],counters['sale_close']['low_6_to_3'], counters['sale_close']['low_3_to_0'], counters['sale_close']['high_0_to_3'], counters['sale_close']['high_3_to_6'], counters['sale_close']['high_over_6'] = count_change(saleprice_close_differrange, counters['sale_close']['low_over_6'], counters['sale_close']['low_6_to_3'], counters['sale_close']['low_3_to_0'], counters['sale_close']['high_0_to_3'], counters['sale_close']['high_3_to_6'], counters['sale_close']['high_over_6'])
# 清仓日开盘清仓盈亏分布-开盘建仓
open_sale_open_differrange = 100 * (saleopen - df.loc[df['code'] == code, 'next_open'])/df.loc[df['code'] == code, 'next_open']
counters['profit_open_sale_open']['low_over_6'],counters['profit_open_sale_open']['low_6_to_3'], counters['profit_open_sale_open']['low_3_to_0'], counters['profit_open_sale_open']['high_0_to_3'], counters['profit_open_sale_open']['high_3_to_6'], counters['profit_open_sale_open']['high_over_6'] = count_change(open_sale_open_differrange, counters['profit_open_sale_open']['low_over_6'], counters['profit_open_sale_open']['low_6_to_3'], counters['profit_open_sale_open']['low_3_to_0'], counters['profit_open_sale_open']['high_0_to_3'], counters['profit_open_sale_open']['high_3_to_6'], counters['profit_open_sale_open']['high_over_6'])
# 清仓日开盘清仓盈亏分布-收盘建仓
open_sale_close_differrange = 100 * (saleopen - nextclose)/nextclose
counters['profit_open_sale_close']['low_over_6'],counters['profit_open_sale_close']['low_6_to_3'], counters['profit_open_sale_close']['low_3_to_0'], counters['profit_open_sale_close']['high_0_to_3'], counters['profit_open_sale_close']['high_3_to_6'], counters['profit_open_sale_close']['high_over_6'] = count_change(open_sale_close_differrange, counters['profit_open_sale_close']['low_over_6'], counters['profit_open_sale_close']['low_6_to_3'], counters['profit_open_sale_close']['low_3_to_0'], counters['profit_open_sale_close']['high_0_to_3'], counters['profit_open_sale_close']['high_3_to_6'], counters['profit_open_sale_close']['high_over_6'])
# 清仓日收盘清仓盈亏分布-开盘建仓
close_sale_open_differrange = 100 * (saleclose - df.loc[df['code'] == code, 'next_open'])/df.loc[df['code'] == code, 'next_open']
counters['profit_close_sale_open']['low_over_6'],counters['profit_close_sale_open']['low_6_to_3'], counters['profit_close_sale_open']['low_3_to_0'], counters['profit_close_sale_open']['high_0_to_3'], counters['profit_close_sale_open']['high_3_to_6'], counters['profit_close_sale_open']['high_over_6'] = count_change(close_sale_open_differrange, counters['profit_close_sale_open']['low_over_6'], counters['profit_close_sale_open']['low_6_to_3'], counters['profit_close_sale_open']['low_3_to_0'], counters['profit_close_sale_open']['high_0_to_3'], counters['profit_close_sale_open']['high_3_to_6'], counters['profit_close_sale_open']['high_over_6'])
# 清仓日收盘清仓盈亏分布-收盘建仓
close_sale_close_differrange = 100 * (saleclose - nextclose)/nextclose
counters['profit_close_sale_close']['low_over_6'],counters['profit_close_sale_close']['low_6_to_3'], counters['profit_close_sale_close']['low_3_to_0'], counters['profit_close_sale_close']['high_0_to_3'], counters['profit_close_sale_close']['high_3_to_6'], counters['profit_close_sale_close']['high_over_6'] = count_change(close_sale_close_differrange, counters['profit_close_sale_close']['low_over_6'], counters['profit_close_sale_close']['low_6_to_3'], counters['profit_close_sale_close']['low_3_to_0'], counters['profit_close_sale_close']['high_0_to_3'], counters['profit_close_sale_close']['high_3_to_6'], counters['profit_close_sale_close']['high_over_6'])
# 组合场景: 开盘建仓 清仓日开盘清仓 盈亏分布
if next_open_diff < -6 and saleprice_open_differrange < -6:
counters['low_over_6_open_low_over_6_open_sale']['low_over_6'],counters['low_over_6_open_low_over_6_open_sale']['low_6_to_3'], counters['low_over_6_open_low_over_6_open_sale']['low_3_to_0'], counters['low_over_6_open_low_over_6_open_sale']['high_0_to_3'], counters['low_over_6_open_low_over_6_open_sale']['high_3_to_6'], counters['low_over_6_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_over_6_open_sale']['low_over_6'], counters['low_over_6_open_low_over_6_open_sale']['low_6_to_3'], counters['low_over_6_open_low_over_6_open_sale']['low_3_to_0'], counters['low_over_6_open_low_over_6_open_sale']['high_0_to_3'], counters['low_over_6_open_low_over_6_open_sale']['high_3_to_6'], counters['low_over_6_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['low_over_6_open_low_6_to_3_open_sale']['low_over_6'],counters['low_over_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_over_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_over_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_over_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_over_6_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_6_to_3_open_sale']['low_over_6'], counters['low_over_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_over_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_over_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_over_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_over_6_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['low_over_6_open_low_3_to_0_open_sale']['low_over_6'],counters['low_over_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_over_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_over_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_over_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_over_6_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_3_to_0_open_sale']['low_over_6'], counters['low_over_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_over_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_over_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_over_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_over_6_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['low_over_6_open_high_0_to_3_open_sale']['low_over_6'],counters['low_over_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_over_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_over_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_over_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_over_6_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_0_to_3_open_sale']['low_over_6'], counters['low_over_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_over_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_over_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_over_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_over_6_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['low_over_6_open_high_3_to_6_open_sale']['low_over_6'],counters['low_over_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_over_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_over_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_over_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_over_6_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_3_to_6_open_sale']['low_over_6'], counters['low_over_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_over_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_over_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_over_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_over_6_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 6:
counters['low_over_6_open_high_over_6_open_sale']['low_over_6'],counters['low_over_6_open_high_over_6_open_sale']['low_6_to_3'], counters['low_over_6_open_high_over_6_open_sale']['low_3_to_0'], counters['low_over_6_open_high_over_6_open_sale']['high_0_to_3'], counters['low_over_6_open_high_over_6_open_sale']['high_3_to_6'], counters['low_over_6_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_over_6_open_sale']['low_over_6'], counters['low_over_6_open_high_over_6_open_sale']['low_6_to_3'], counters['low_over_6_open_high_over_6_open_sale']['low_3_to_0'], counters['low_over_6_open_high_over_6_open_sale']['high_0_to_3'], counters['low_over_6_open_high_over_6_open_sale']['high_3_to_6'], counters['low_over_6_open_high_over_6_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange < -6:
counters['low_6_to_3_open_low_over_6_open_sale']['low_over_6'],counters['low_6_to_3_open_low_over_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_over_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_over_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_over_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_over_6_open_sale']['low_over_6'], counters['low_6_to_3_open_low_over_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_over_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_over_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_over_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['low_6_to_3_open_low_6_to_3_open_sale']['low_over_6'],counters['low_6_to_3_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_6_to_3_open_sale']['low_over_6'], counters['low_6_to_3_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['low_6_to_3_open_low_3_to_0_open_sale']['low_over_6'],counters['low_6_to_3_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_3_to_0_open_sale']['low_over_6'], counters['low_6_to_3_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_6_to_3_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_6_to_3_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['low_6_to_3_open_high_0_to_3_open_sale']['low_over_6'],counters['low_6_to_3_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_high_0_to_3_open_sale']['low_over_6'], counters['low_6_to_3_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['low_6_to_3_open_high_3_to_6_open_sale']['low_over_6'],counters['low_6_to_3_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_high_3_to_6_open_sale']['low_over_6'], counters['low_6_to_3_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > 6:
counters['low_6_to_3_open_high_over_6_open_sale']['low_over_6'],counters['low_6_to_3_open_high_over_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_over_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_over_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_over_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_high_over_6_open_sale']['low_over_6'], counters['low_6_to_3_open_high_over_6_open_sale']['low_6_to_3'], counters['low_6_to_3_open_high_over_6_open_sale']['low_3_to_0'], counters['low_6_to_3_open_high_over_6_open_sale']['high_0_to_3'], counters['low_6_to_3_open_high_over_6_open_sale']['high_3_to_6'], counters['low_6_to_3_open_high_over_6_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange < -6:
counters['low_3_to_0_open_low_over_6_open_sale']['low_over_6'],counters['low_3_to_0_open_low_over_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_over_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_over_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_over_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_low_over_6_open_sale']['low_over_6'], counters['low_3_to_0_open_low_over_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_over_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_over_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_over_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['low_3_to_0_open_low_6_to_3_open_sale']['low_over_6'],counters['low_3_to_0_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_low_6_to_3_open_sale']['low_over_6'], counters['low_3_to_0_open_low_6_to_3_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_6_to_3_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['low_3_to_0_open_low_3_to_0_open_sale']['low_over_6'],counters['low_3_to_0_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_low_3_to_0_open_sale']['low_over_6'], counters['low_3_to_0_open_low_3_to_0_open_sale']['low_6_to_3'], counters['low_3_to_0_open_low_3_to_0_open_sale']['low_3_to_0'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_0_to_3'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_3_to_6'], counters['low_3_to_0_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['low_3_to_0_open_high_0_to_3_open_sale']['low_over_6'],counters['low_3_to_0_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_high_0_to_3_open_sale']['low_over_6'], counters['low_3_to_0_open_high_0_to_3_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_0_to_3_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['low_3_to_0_open_high_3_to_6_open_sale']['low_over_6'],counters['low_3_to_0_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_high_3_to_6_open_sale']['low_over_6'], counters['low_3_to_0_open_high_3_to_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_3_to_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff > -3 and next_open_diff < 0 and saleprice_open_differrange > 6:
counters['low_3_to_0_open_high_over_6_open_sale']['low_over_6'],counters['low_3_to_0_open_high_over_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_over_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_over_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_over_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_3_to_0_open_high_over_6_open_sale']['low_over_6'], counters['low_3_to_0_open_high_over_6_open_sale']['low_6_to_3'], counters['low_3_to_0_open_high_over_6_open_sale']['low_3_to_0'], counters['low_3_to_0_open_high_over_6_open_sale']['high_0_to_3'], counters['low_3_to_0_open_high_over_6_open_sale']['high_3_to_6'], counters['low_3_to_0_open_high_over_6_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange < -6:
counters['high_0_to_3_open_low_over_6_open_sale']['low_over_6'],counters['high_0_to_3_open_low_over_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_over_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_over_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_over_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_low_over_6_open_sale']['low_over_6'], counters['high_0_to_3_open_low_over_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_over_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_over_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_over_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['high_0_to_3_open_low_6_to_3_open_sale']['low_over_6'],counters['high_0_to_3_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_low_6_to_3_open_sale']['low_over_6'], counters['high_0_to_3_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['high_0_to_3_open_low_3_to_0_open_sale']['low_over_6'],counters['high_0_to_3_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_low_3_to_0_open_sale']['low_over_6'], counters['high_0_to_3_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_0_to_3_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_0_to_3_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['high_0_to_3_open_high_0_to_3_open_sale']['low_over_6'],counters['high_0_to_3_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_high_0_to_3_open_sale']['low_over_6'], counters['high_0_to_3_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['high_0_to_3_open_high_3_to_6_open_sale']['low_over_6'],counters['high_0_to_3_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_high_3_to_6_open_sale']['low_over_6'], counters['high_0_to_3_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff > 0 and next_open_diff < 3 and saleprice_open_differrange > 6:
counters['high_0_to_3_open_high_over_6_open_sale']['low_over_6'],counters['high_0_to_3_open_high_over_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_over_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_over_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_over_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_0_to_3_open_high_over_6_open_sale']['low_over_6'], counters['high_0_to_3_open_high_over_6_open_sale']['low_6_to_3'], counters['high_0_to_3_open_high_over_6_open_sale']['low_3_to_0'], counters['high_0_to_3_open_high_over_6_open_sale']['high_0_to_3'], counters['high_0_to_3_open_high_over_6_open_sale']['high_3_to_6'], counters['high_0_to_3_open_high_over_6_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange < -6:
counters['high_3_to_6_open_low_over_6_open_sale']['low_over_6'],counters['high_3_to_6_open_low_over_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_over_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_over_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_over_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_low_over_6_open_sale']['low_over_6'], counters['high_3_to_6_open_low_over_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_over_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_over_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_over_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['high_3_to_6_open_low_6_to_3_open_sale']['low_over_6'],counters['high_3_to_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_low_6_to_3_open_sale']['low_over_6'], counters['high_3_to_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['high_3_to_6_open_low_3_to_0_open_sale']['low_over_6'],counters['high_3_to_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_low_3_to_0_open_sale']['low_over_6'], counters['high_3_to_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_3_to_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_3_to_6_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['high_3_to_6_open_high_0_to_3_open_sale']['low_over_6'],counters['high_3_to_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_high_0_to_3_open_sale']['low_over_6'], counters['high_3_to_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['high_3_to_6_open_high_3_to_6_open_sale']['low_over_6'],counters['high_3_to_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_high_3_to_6_open_sale']['low_over_6'], counters['high_3_to_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff > 3 and next_open_diff < 6 and saleprice_open_differrange > 6:
counters['high_3_to_6_open_high_over_6_open_sale']['low_over_6'],counters['high_3_to_6_open_high_over_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_over_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_over_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_over_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_3_to_6_open_high_over_6_open_sale']['low_over_6'], counters['high_3_to_6_open_high_over_6_open_sale']['low_6_to_3'], counters['high_3_to_6_open_high_over_6_open_sale']['low_3_to_0'], counters['high_3_to_6_open_high_over_6_open_sale']['high_0_to_3'], counters['high_3_to_6_open_high_over_6_open_sale']['high_3_to_6'], counters['high_3_to_6_open_high_over_6_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange < -6:
counters['high_over_6_open_low_over_6_open_sale']['low_over_6'],counters['high_over_6_open_low_over_6_open_sale']['low_6_to_3'], counters['high_over_6_open_low_over_6_open_sale']['low_3_to_0'], counters['high_over_6_open_low_over_6_open_sale']['high_0_to_3'], counters['high_over_6_open_low_over_6_open_sale']['high_3_to_6'], counters['high_over_6_open_low_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_low_over_6_open_sale']['low_over_6'], counters['high_over_6_open_low_over_6_open_sale']['low_6_to_3'], counters['high_over_6_open_low_over_6_open_sale']['low_3_to_0'], counters['high_over_6_open_low_over_6_open_sale']['high_0_to_3'], counters['high_over_6_open_low_over_6_open_sale']['high_3_to_6'], counters['high_over_6_open_low_over_6_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['high_over_6_open_low_6_to_3_open_sale']['low_over_6'],counters['high_over_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_over_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_over_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_over_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_over_6_open_low_6_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_low_6_to_3_open_sale']['low_over_6'], counters['high_over_6_open_low_6_to_3_open_sale']['low_6_to_3'], counters['high_over_6_open_low_6_to_3_open_sale']['low_3_to_0'], counters['high_over_6_open_low_6_to_3_open_sale']['high_0_to_3'], counters['high_over_6_open_low_6_to_3_open_sale']['high_3_to_6'], counters['high_over_6_open_low_6_to_3_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['high_over_6_open_low_3_to_0_open_sale']['low_over_6'],counters['high_over_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_over_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_over_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_over_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_over_6_open_low_3_to_0_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_low_3_to_0_open_sale']['low_over_6'], counters['high_over_6_open_low_3_to_0_open_sale']['low_6_to_3'], counters['high_over_6_open_low_3_to_0_open_sale']['low_3_to_0'], counters['high_over_6_open_low_3_to_0_open_sale']['high_0_to_3'], counters['high_over_6_open_low_3_to_0_open_sale']['high_3_to_6'], counters['high_over_6_open_low_3_to_0_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['high_over_6_open_high_0_to_3_open_sale']['low_over_6'],counters['high_over_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_over_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_over_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_over_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_over_6_open_high_0_to_3_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_high_0_to_3_open_sale']['low_over_6'], counters['high_over_6_open_high_0_to_3_open_sale']['low_6_to_3'], counters['high_over_6_open_high_0_to_3_open_sale']['low_3_to_0'], counters['high_over_6_open_high_0_to_3_open_sale']['high_0_to_3'], counters['high_over_6_open_high_0_to_3_open_sale']['high_3_to_6'], counters['high_over_6_open_high_0_to_3_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['high_over_6_open_high_3_to_6_open_sale']['low_over_6'],counters['high_over_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_over_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_over_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_over_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_over_6_open_high_3_to_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_high_3_to_6_open_sale']['low_over_6'], counters['high_over_6_open_high_3_to_6_open_sale']['low_6_to_3'], counters['high_over_6_open_high_3_to_6_open_sale']['low_3_to_0'], counters['high_over_6_open_high_3_to_6_open_sale']['high_0_to_3'], counters['high_over_6_open_high_3_to_6_open_sale']['high_3_to_6'], counters['high_over_6_open_high_3_to_6_open_sale']['high_over_6'])
elif next_open_diff > 6 and saleprice_open_differrange > 6:
counters['high_over_6_open_high_over_6_open_sale']['low_over_6'],counters['high_over_6_open_high_over_6_open_sale']['low_6_to_3'], counters['high_over_6_open_high_over_6_open_sale']['low_3_to_0'], counters['high_over_6_open_high_over_6_open_sale']['high_0_to_3'], counters['high_over_6_open_high_over_6_open_sale']['high_3_to_6'], counters['high_over_6_open_high_over_6_open_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['high_over_6_open_high_over_6_open_sale']['low_over_6'], counters['high_over_6_open_high_over_6_open_sale']['low_6_to_3'], counters['high_over_6_open_high_over_6_open_sale']['low_3_to_0'], counters['high_over_6_open_high_over_6_open_sale']['high_0_to_3'], counters['high_over_6_open_high_over_6_open_sale']['high_3_to_6'], counters['high_over_6_open_high_over_6_open_sale']['high_over_6'])
# 组合场景: 开盘建仓 清仓日开盘清仓 盈亏分布
if next_open_diff < -6 and saleprice_open_differrange < -6:
counters['low_over_6_open_low_over_6_close_sale']['low_over_6'],counters['low_over_6_open_low_over_6_close_sale']['low_6_to_3'], counters['low_over_6_open_low_over_6_close_sale']['low_3_to_0'], counters['low_over_6_open_low_over_6_close_sale']['high_0_to_3'], counters['low_over_6_open_low_over_6_close_sale']['high_3_to_6'], counters['low_over_6_open_low_over_6_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_over_6_close_sale']['low_over_6'], counters['low_over_6_open_low_over_6_close_sale']['low_6_to_3'], counters['low_over_6_open_low_over_6_close_sale']['low_3_to_0'], counters['low_over_6_open_low_over_6_close_sale']['high_0_to_3'], counters['low_over_6_open_low_over_6_close_sale']['high_3_to_6'], counters['low_over_6_open_low_over_6_close_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['low_over_6_open_low_6_to_3_close_sale']['low_over_6'],counters['low_over_6_open_low_6_to_3_close_sale']['low_6_to_3'], counters['low_over_6_open_low_6_to_3_close_sale']['low_3_to_0'], counters['low_over_6_open_low_6_to_3_close_sale']['high_0_to_3'], counters['low_over_6_open_low_6_to_3_close_sale']['high_3_to_6'], counters['low_over_6_open_low_6_to_3_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_6_to_3_close_sale']['low_over_6'], counters['low_over_6_open_low_6_to_3_close_sale']['low_6_to_3'], counters['low_over_6_open_low_6_to_3_close_sale']['low_3_to_0'], counters['low_over_6_open_low_6_to_3_close_sale']['high_0_to_3'], counters['low_over_6_open_low_6_to_3_close_sale']['high_3_to_6'], counters['low_over_6_open_low_6_to_3_close_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['low_over_6_open_low_3_to_0_close_sale']['low_over_6'],counters['low_over_6_open_low_3_to_0_close_sale']['low_6_to_3'], counters['low_over_6_open_low_3_to_0_close_sale']['low_3_to_0'], counters['low_over_6_open_low_3_to_0_close_sale']['high_0_to_3'], counters['low_over_6_open_low_3_to_0_close_sale']['high_3_to_6'], counters['low_over_6_open_low_3_to_0_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_low_3_to_0_close_sale']['low_over_6'], counters['low_over_6_open_low_3_to_0_close_sale']['low_6_to_3'], counters['low_over_6_open_low_3_to_0_close_sale']['low_3_to_0'], counters['low_over_6_open_low_3_to_0_close_sale']['high_0_to_3'], counters['low_over_6_open_low_3_to_0_close_sale']['high_3_to_6'], counters['low_over_6_open_low_3_to_0_close_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['low_over_6_open_high_0_to_3_close_sale']['low_over_6'],counters['low_over_6_open_high_0_to_3_close_sale']['low_6_to_3'], counters['low_over_6_open_high_0_to_3_close_sale']['low_3_to_0'], counters['low_over_6_open_high_0_to_3_close_sale']['high_0_to_3'], counters['low_over_6_open_high_0_to_3_close_sale']['high_3_to_6'], counters['low_over_6_open_high_0_to_3_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_0_to_3_close_sale']['low_over_6'], counters['low_over_6_open_high_0_to_3_close_sale']['low_6_to_3'], counters['low_over_6_open_high_0_to_3_close_sale']['low_3_to_0'], counters['low_over_6_open_high_0_to_3_close_sale']['high_0_to_3'], counters['low_over_6_open_high_0_to_3_close_sale']['high_3_to_6'], counters['low_over_6_open_high_0_to_3_close_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['low_over_6_open_high_3_to_6_close_sale']['low_over_6'],counters['low_over_6_open_high_3_to_6_close_sale']['low_6_to_3'], counters['low_over_6_open_high_3_to_6_close_sale']['low_3_to_0'], counters['low_over_6_open_high_3_to_6_close_sale']['high_0_to_3'], counters['low_over_6_open_high_3_to_6_close_sale']['high_3_to_6'], counters['low_over_6_open_high_3_to_6_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_3_to_6_close_sale']['low_over_6'], counters['low_over_6_open_high_3_to_6_close_sale']['low_6_to_3'], counters['low_over_6_open_high_3_to_6_close_sale']['low_3_to_0'], counters['low_over_6_open_high_3_to_6_close_sale']['high_0_to_3'], counters['low_over_6_open_high_3_to_6_close_sale']['high_3_to_6'], counters['low_over_6_open_high_3_to_6_close_sale']['high_over_6'])
elif next_open_diff < -6 and saleprice_open_differrange > 6:
counters['low_over_6_open_high_over_6_close_sale']['low_over_6'],counters['low_over_6_open_high_over_6_close_sale']['low_6_to_3'], counters['low_over_6_open_high_over_6_close_sale']['low_3_to_0'], counters['low_over_6_open_high_over_6_close_sale']['high_0_to_3'], counters['low_over_6_open_high_over_6_close_sale']['high_3_to_6'], counters['low_over_6_open_high_over_6_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_over_6_open_high_over_6_close_sale']['low_over_6'], counters['low_over_6_open_high_over_6_close_sale']['low_6_to_3'], counters['low_over_6_open_high_over_6_close_sale']['low_3_to_0'], counters['low_over_6_open_high_over_6_close_sale']['high_0_to_3'], counters['low_over_6_open_high_over_6_close_sale']['high_3_to_6'], counters['low_over_6_open_high_over_6_close_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange < -6:
counters['low_6_to_3_open_low_over_6_close_sale']['low_over_6'],counters['low_6_to_3_open_low_over_6_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_over_6_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_over_6_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_over_6_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_over_6_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_over_6_close_sale']['low_over_6'], counters['low_6_to_3_open_low_over_6_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_over_6_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_over_6_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_over_6_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_over_6_close_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > -6 and saleprice_open_differrange < -3:
counters['low_6_to_3_open_low_6_to_3_close_sale']['low_over_6'],counters['low_6_to_3_open_low_6_to_3_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_6_to_3_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_6_to_3_close_sale']['low_over_6'], counters['low_6_to_3_open_low_6_to_3_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_6_to_3_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_6_to_3_close_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > -3 and saleprice_open_differrange < 0:
counters['low_6_to_3_open_low_3_to_0_close_sale']['low_over_6'],counters['low_6_to_3_open_low_3_to_0_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_3_to_0_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_low_3_to_0_close_sale']['low_over_6'], counters['low_6_to_3_open_low_3_to_0_close_sale']['low_6_to_3'], counters['low_6_to_3_open_low_3_to_0_close_sale']['low_3_to_0'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_0_to_3'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_3_to_6'], counters['low_6_to_3_open_low_3_to_0_close_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > 0 and saleprice_open_differrange < 3:
counters['low_6_to_3_open_high_0_to_3_close_sale']['low_over_6'],counters['low_6_to_3_open_high_0_to_3_close_sale']['low_6_to_3'], counters['low_6_to_3_open_high_0_to_3_close_sale']['low_3_to_0'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_0_to_3'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_3_to_6'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_high_0_to_3_close_sale']['low_over_6'], counters['low_6_to_3_open_high_0_to_3_close_sale']['low_6_to_3'], counters['low_6_to_3_open_high_0_to_3_close_sale']['low_3_to_0'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_0_to_3'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_3_to_6'], counters['low_6_to_3_open_high_0_to_3_close_sale']['high_over_6'])
elif next_open_diff > -6 and next_open_diff < -3 and saleprice_open_differrange > 3 and saleprice_open_differrange < 6:
counters['low_6_to_3_open_high_3_to_6_close_sale']['low_over_6'],counters['low_6_to_3_open_high_3_to_6_close_sale']['low_6_to_3'], counters['low_6_to_3_open_high_3_to_6_close_sale']['low_3_to_0'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_0_to_3'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_3_to_6'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_over_6'] = count_change(saleprice_open_differrange, counters['low_6_to_3_open_high_3_to_6_close_sale']['low_over_6'], counters['low_6_to_3_open_high_3_to_6_close_sale']['low_6_to_3'], counters['low_6_to_3_open_high_3_to_6_close_sale']['low_3_to_0'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_0_to_3'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_3_to_6'], counters['low_6_to_3_open_high_3_to_6_close_sale']['high_over_6'])
# 组合场景 低开盘-低清仓 低开盘-高清仓 低开盘-正常清仓 正常开盘-低清仓 正常开盘-高清仓 正常开盘-正常清仓 高开盘-低清仓 高开盘-高清仓 高开盘-正常清仓
# 组合之类再进行计算盈亏分布
if next_open_diff < -6 :
if saleprice_open_differrange < -3:
low_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
low_open_high_sale_count += 1
else:
low_open_normal_sale_count += 1
if saleprice_open_differrange < -3:
if saleprice_open_differrange < -5:
low_open_low_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
low_open_low_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
low_open_low_sale_low_profit_count += 1
else:
low_open_low_sale_high_profit_count += 1
elif saleprice_open_differrange > 3:
if saleprice_open_differrange < -5:
low_open_high_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
low_open_high_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
low_open_high_sale_low_profit_count += 1
else:
low_open_high_sale_high_profit_count += 1
else:
if saleprice_open_differrange < -5:
low_open_normal_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
low_open_normal_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
low_open_normal_sale_low_profit_count += 1
else:
low_open_normal_sale_high_profit_count += 1
elif next_open_diff > 3:
if saleprice_open_differrange < -3:
high_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
high_open_high_sale_count += 1
else:
high_open_normal_sale_count += 1
if saleprice_open_differrange < -3:
if saleprice_open_differrange < -5:
high_open_low_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
high_open_low_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
high_open_low_sale_low_profit_count += 1
else:
high_open_low_sale_high_profit_count += 1
elif saleprice_open_differrange > 3:
if saleprice_open_differrange < -5:
high_open_high_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
high_open_high_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
high_open_high_sale_low_profit_count += 1
else:
high_open_high_sale_high_profit_count += 1
else:
if saleprice_open_differrange < -5:
high_open_normal_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
high_open_normal_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
high_open_normal_sale_low_profit_count += 1
else:
high_open_normal_sale_high_profit_count += 1
else:
if saleprice_open_differrange < -3:
normal_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
normal_open_high_sale_count += 1
else:
normal_open_normal_sale_count += 1
if saleprice_open_differrange < -3:
if saleprice_open_differrange < -5:
normal_open_low_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
normal_open_low_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
normal_open_low_sale_low_profit_count += 1
else:
normal_open_low_sale_high_profit_count += 1
elif saleprice_open_differrange > 3:
if saleprice_open_differrange < -5:
normal_open_high_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
normal_open_high_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
normal_open_high_sale_low_profit_count += 1
else:
normal_open_high_sale_high_profit_count += 1
else:
if saleprice_open_differrange < -5:
normal_open_normal_sale_high_loss_count += 1
elif saleprice_open_differrange > -5 and saleprice_open_differrange < 0:
normal_open_normal_sale_low_loss_count += 1
elif saleprice_open_differrange > 0 and saleprice_open_differrange < 5:
normal_open_normal_sale_low_profit_count += 1
else:
normal_open_normal_sale_high_profit_count += 1
# 组合场景 低收盘-低清仓 低收盘-高清仓 低收盘-正常清仓 正常收盘-低清仓 正常收盘-高清仓 正常收盘-正常清仓 高收盘-低清仓 高收盘-高清仓 高收盘-正常清仓
if next_close_differrange < -3 :
if saleprice_close_differrange < -3:
low_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
low_close_high_sale_count += 1
else:
low_close_normal_sale_count += 1
if saleprice_close_differrange < -3:
if saleprice_close_differrange < -5:
low_close_low_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
low_close_low_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
low_close_low_sale_low_profit_count += 1
else:
low_close_low_sale_high_profit_count += 1
elif saleprice_close_differrange > 3:
if saleprice_close_differrange < -5:
low_close_high_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
low_close_high_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
low_close_high_sale_low_profit_count += 1
else:
low_close_high_sale_high_profit_count += 1
else:
if saleprice_close_differrange < -5:
low_close_normal_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
low_close_normal_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
low_close_normal_sale_low_profit_count += 1
else:
low_close_normal_sale_high_profit_count += 1
elif next_close_differrange > 3:
if saleprice_close_differrange < -3:
high_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
high_close_high_sale_count += 1
else:
high_close_normal_sale_count += 1
if saleprice_close_differrange < -3:
if saleprice_close_differrange < -5:
high_close_low_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
high_close_low_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
high_close_low_sale_low_profit_count += 1
else:
high_close_low_sale_high_profit_count += 1
elif saleprice_close_differrange > 3:
if saleprice_close_differrange < -5:
high_close_high_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
high_close_high_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
high_close_high_sale_low_profit_count += 1
else:
high_close_high_sale_high_profit_count += 1
else:
if saleprice_close_differrange < -5:
high_close_normal_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
high_close_normal_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
high_close_normal_sale_low_profit_count += 1
else:
high_close_normal_sale_high_profit_count += 1
else:
if saleprice_close_differrange < -3:
normal_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
normal_close_high_sale_count += 1
else:
normal_close_normal_sale_count += 1
if saleprice_close_differrange < -3:
if saleprice_close_differrange < -5:
normal_close_low_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
normal_close_low_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
normal_close_low_sale_low_profit_count += 1
else:
normal_close_low_sale_high_profit_count += 1
elif saleprice_close_differrange > 3:
if saleprice_close_differrange < -5:
normal_close_high_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
normal_close_high_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
normal_close_high_sale_low_profit_count += 1
else:
normal_close_high_sale_high_profit_count += 1
else:
if saleprice_close_differrange < -5:
normal_close_normal_sale_high_loss_count += 1
elif saleprice_close_differrange > -5 and saleprice_close_differrange < 0:
normal_close_normal_sale_low_loss_count += 1
elif saleprice_close_differrange > 0 and saleprice_close_differrange < 5:
normal_close_normal_sale_low_profit_count += 1
else:
normal_close_normal_sale_high_profit_count += 1
else:
nextdate_str = date_list[i+1].strftime('%Y-%m-%d')#买入日
saledate_str = date_list[i+2].strftime('%Y-%m-%d')#卖出日
print(f'正在处理{date_str}的数据')
# 执行SQL查询这只是一个示例你需要根据你的实际需求和数据库结构进行修改
query = f'select code,open,close,high,low, volumn,amount,differrange10,differrange20,differrange60 from stocks where islimit = "" and trade_day = "{date_str}"'
df = pd.read_sql_query(query, engine)
limit_list = df['code'].tolist()
for code in limit_list:
# 总统计数
total_count += 1
print(f'正在处理{date_str} - {code}的数据')
query = f'select code,open,close,differrange from stocks where trade_day = "{nextdate_str}" and code = "{code}"'
dfnext = pd.read_sql_query(query,engine)
if dfnext.size <= 0:
total_count -= 1
continue
# 处理数据...
open = df.loc[df['code'] == code, 'open'].values[0]
nextopen = dfnext.loc[dfnext['code'] == code, 'open'].values[0]
nextclose = dfnext.loc[dfnext['code'] == code, 'close'].values[0]
nextdifferrange = dfnext.loc[dfnext['code'] == code, 'differrange'].values[0]
df.loc[df['code'] == code, 'next_open'] = nextopen
df.loc[df['code'] == code, 'next_open_diff'] = 100 * (nextopen - open)/open
df.loc[df['code'] == code, 'next_close'] = nextclose
df.loc[df['code'] == code, 'next_close_differrange'] = nextdifferrange
query = f'select code,open,close,differrange from stocks where trade_day = "{saledate_str}" and code = "{code}"'
dfsale = pd.read_sql_query(query,engine)
if dfsale.size <= 0:
total_count -= 1
continue
saleopen = dfsale.loc[dfsale['code'] == code, 'open'].values[0]
saleclose = dfsale.loc[dfsale['code'] == code, 'close'].values[0]
df.loc[df['code'] == code, 'saleprice_open'] = saleopen
df.loc[df['code'] == code, 'saleprice_close'] = saleclose
# 清仓盈亏
df.loc[df['code'] == code, 'saleprice_open_differrange'] = 100 * (saleopen - nextopen)/nextopen
df.loc[df['code'] == code, 'saleprice_close_differrange'] = 100 * (saleclose - nextclose)/nextclose
# 第二日开盘价分布
next_open_diff = df.loc[df['code'] == code, 'next_open_diff'].values[0]
if next_open_diff < -3:
low_open_count += 1
elif next_open_diff > 3:
high_open_count += 1
else:
normal_open_count += 1
# 第二日收盘价分布
next_close_differrange = df.loc[df['code'] == code, 'next_close_differrange'].values[0]
if next_close_differrange < -3:
low_close_count += 1
elif next_close_differrange > 3:
high_close_count += 1
else:
normal_close_count += 1
# 清仓盈亏分布-开盘清仓
saleprice_open_differrange = df.loc[df['code'] == code, 'saleprice_open_differrange'].values[0]
if saleprice_open_differrange < -3: # 亏损大于-3
low_sale_open_count += 1
elif saleprice_open_differrange > 0: # 盈利大于0
high_sale_open_count += 1
else:
normal_sale_open_count += 1 # 亏损小于-3
# 清仓盈亏分布-收盘清仓
saleprice_close_differrange = df.loc[df['code'] == code, 'saleprice_close_differrange'].values[0]
if saleprice_close_differrange < -3:
low_sale_close_count += 1
elif saleprice_close_differrange > 3:
high_sale_close_count += 1
else:
normal_sale_close_count += 1
# 组合场景 低开盘-低清仓 低开盘-高清仓 低开盘-正常清仓 正常开盘-低清仓 正常开盘-高清仓 正常开盘-正常清仓 高开盘-低清仓 高开盘-高清仓 高开盘-正常清仓
if next_open_diff < -3 :
if saleprice_open_differrange < -3:
low_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
low_open_high_sale_count += 1
else:
low_open_normal_sale_count += 1
elif next_open_diff > 3:
if saleprice_open_differrange < -3:
high_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
high_open_high_sale_count += 1
else:
high_open_normal_sale_count += 1
else:
if saleprice_open_differrange < -3:
normal_open_low_sale_count += 1
elif saleprice_open_differrange > 3:
normal_open_high_sale_count += 1
else:
normal_open_normal_sale_count += 1
# 组合场景 低收盘-低清仓 低收盘-高清仓 低收盘-正常清仓 正常收盘-低清仓 正常收盘-高清仓 正常收盘-正常清仓 高收盘-低清仓 高收盘-高清仓 高收盘-正常清仓
if next_close_differrange < -3 :
if saleprice_close_differrange < -3:
low_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
low_close_high_sale_count += 1
else:
low_close_normal_sale_count += 1
elif next_close_differrange > 3:
if saleprice_close_differrange < -3:
high_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
high_close_high_sale_count += 1
else:
high_close_normal_sale_count += 1
else:
if saleprice_close_differrange < -3:
normal_close_low_sale_count += 1
elif saleprice_close_differrange > 3:
normal_close_high_sale_count += 1
else:
normal_close_normal_sale_count += 1
# 将数据框保存到磁盘
df.to_csv(f'D:/calculate_data/{date_str}_stock.csv', index=False)
# # 从磁盘加载数据框
# df = pd.read_csv('df_distribution.csv')
print(f'总统计数:{total_count}')
print(f'低于-3%的开盘价计数:{low_open_count}')
print(f'正常开盘,介于-3%和3%之间的计数:{normal_open_count}')
print(f'高于3%的开盘价计数:{high_open_count}')
print(f'低于-3%的收盘价计数:{low_close_count}')
print(f'正常收盘,介于-3%和3%之间的计数:{normal_close_count}')
print(f'高于3%的收盘价计数:{high_close_count}')
print(f'低开盘-低清仓:{low_open_low_sale_count}')
print(f'低开盘-高清仓:{low_open_high_sale_count}')
print(f'低开盘-正常清仓:{low_open_normal_sale_count}')
print(f'正常开盘-低清仓:{normal_open_low_sale_count}')
print(f'正常开盘-高清仓:{normal_open_high_sale_count}')
print(f'正常开盘-正常清仓:{normal_open_normal_sale_count}')
print(f'高开盘-低清仓:{high_open_low_sale_count}')
print(f'高开盘-高清仓:{high_open_high_sale_count}')
print(f'高开盘-正常清仓:{high_open_normal_sale_count}')
print(f'低收盘-低清仓:{low_close_low_sale_count}')
print(f'低收盘-高清仓:{low_close_high_sale_count}')
print(f'低收盘-正常清仓:{low_close_normal_sale_count}')
print(f'正常收盘-低清仓:{normal_close_low_sale_count}')
print(f'正常收盘-高清仓:{normal_close_high_sale_count}')
print(f'正常收盘-正常清仓:{normal_close_normal_sale_count}')
print(f'高收盘-低清仓:{high_close_low_sale_count}')
print(f'高收盘-高清仓:{high_close_high_sale_count}')
print(f'高收盘-正常清仓:{high_close_normal_sale_count}')
print(f'低开盘-低清仓-盈利高于5%{low_open_low_sale_high_profit_count}')
print(f'低开盘-低清仓-盈利低于5%{low_open_low_sale_low_profit_count}')
print(f'低开盘-低清仓-亏损低于5%{low_open_low_sale_low_loss_count}')
print(f'低开盘-低清仓-亏损高于5%{low_open_low_sale_high_loss_count}')
print(f'低开盘-高清仓-盈利高于5%{low_open_high_sale_high_profit_count}')
print(f'低开盘-高清仓-盈利低于5%{low_open_high_sale_low_profit_count}')
print(f'低开盘-高清仓-亏损低于5%{low_open_high_sale_low_loss_count}')
print(f'低开盘-高清仓-亏损高于5%{low_open_high_sale_high_loss_count}')
print(f'低开盘-正常清仓-盈利高于5%{low_open_normal_sale_high_profit_count}')
print(f'低开盘-正常清仓-盈利低于5%{low_open_normal_sale_low_profit_count}')
print(f'低开盘-正常清仓-亏损低于5%{low_open_normal_sale_low_loss_count}')
print(f'低开盘-正常清仓-亏损高于5%{low_open_normal_sale_high_loss_count}')
print(f'正常开盘-低清仓-盈利高于5%{normal_open_low_sale_high_profit_count}')
print(f'正常开盘-低清仓-盈利低于5%{normal_open_low_sale_low_profit_count}')
print(f'正常开盘-低清仓-亏损低于5%{normal_open_low_sale_low_loss_count}')
print(f'正常开盘-低清仓-亏损高于5%{normal_open_low_sale_high_loss_count}')
print(f'正常开盘-高清仓-盈利高于5%{normal_open_high_sale_high_profit_count}')
print(f'正常开盘-高清仓-盈利低于5%{normal_open_high_sale_low_profit_count}')
print(f'正常开盘-高清仓-亏损低于5%{normal_open_high_sale_low_loss_count}')
print(f'正常开盘-高清仓-亏损高于5%{normal_open_high_sale_high_loss_count}')
print(f'正常开盘-正常清仓-盈利高于5%{normal_open_normal_sale_high_profit_count}')
print(f'正常开盘-正常清仓-盈利低于5%{normal_open_normal_sale_low_profit_count}')
print(f'正常开盘-正常清仓-亏损低于5%{normal_open_normal_sale_low_loss_count}')
print(f'正常开盘-正常清仓-亏损高于5%{normal_open_normal_sale_high_loss_count}')
print(f'高开盘-低清仓-盈利高于5%{high_open_low_sale_high_profit_count}')
print(f'高开盘-低清仓-盈利低于5%{high_open_low_sale_low_profit_count}')
print(f'高开盘-低清仓-亏损低于5%{high_open_low_sale_low_loss_count}')
print(f'高开盘-低清仓-亏损高于5%{high_open_low_sale_high_loss_count}')
print(f'高开盘-高清仓-盈利高于5%{high_open_high_sale_high_profit_count}')
print(f'高开盘-高清仓-盈利低于5%{high_open_high_sale_low_profit_count}')
print(f'高开盘-高清仓-亏损低于5%{high_open_high_sale_low_loss_count}')
print(f'高开盘-高清仓-亏损高于5%{high_open_high_sale_high_loss_count}')
print(f'高开盘-正常清仓-盈利高于5%{high_open_normal_sale_high_profit_count}')
print(f'高开盘-正常清仓-盈利低于5%{high_open_normal_sale_low_profit_count}')
print(f'高开盘-正常清仓-亏损低于5%{high_open_normal_sale_low_loss_count}')
print(f'高开盘-正常清仓-亏损高于5%{high_open_normal_sale_high_loss_count}')
print(f'低收盘-低清仓-盈利高于5%{low_close_low_sale_high_profit_count}')
print(f'低收盘-低清仓-盈利低于5%{low_close_low_sale_low_profit_count}')
print(f'低收盘-低清仓-亏损低于5%{low_close_low_sale_low_loss_count}')
print(f'低收盘-低清仓-亏损高于5%{low_close_low_sale_high_loss_count}')
print(f'低收盘-高清仓-盈利高于5%{low_close_high_sale_high_profit_count}')
print(f'低收盘-高清仓-盈利低于5%{low_close_high_sale_low_profit_count}')
print(f'低收盘-高清仓-亏损低于5%{low_close_high_sale_low_loss_count}')
print(f'低收盘-高清仓-亏损高于5%{low_close_high_sale_high_loss_count}')
print(f'低收盘-正常清仓-盈利高于5%{low_close_normal_sale_high_profit_count}')
print(f'低收盘-正常清仓-盈利低于5%{low_close_normal_sale_low_profit_count}')
print(f'低收盘-正常清仓-亏损低于5%{low_close_normal_sale_low_loss_count}')
print(f'低收盘-正常清仓-亏损高于5%{low_close_normal_sale_high_loss_count}')
print(f'正常收盘-低清仓-盈利高于5%{normal_close_low_sale_high_profit_count}')
print(f'正常收盘-低清仓-盈利低于5%{normal_close_low_sale_low_profit_count}')
print(f'正常收盘-低清仓-亏损低于5%{normal_close_low_sale_low_loss_count}')
print(f'正常收盘-低清仓-亏损高于5%{normal_close_low_sale_high_loss_count}')
print(f'正常收盘-高清仓-盈利高于5%{normal_close_high_sale_high_profit_count}')
print(f'正常收盘-高清仓-盈利低于5%{normal_close_high_sale_low_profit_count}')
print(f'正常收盘-高清仓-亏损低于5%{normal_close_high_sale_low_loss_count}')
print(f'正常收盘-高清仓-亏损高于5%{normal_close_high_sale_high_loss_count}')
print(f'正常收盘-正常清仓-盈利高于5%{normal_close_normal_sale_high_profit_count}')
print(f'正常收盘-正常清仓-盈利低于5%{normal_close_normal_sale_low_profit_count}')
print(f'正常收盘-正常清仓-亏损低于5%{normal_close_normal_sale_low_loss_count}')
print(f'正常收盘-正常清仓-亏损高于5%{normal_close_normal_sale_high_loss_count}')
print(f'高收盘-低清仓-盈利高于5%{high_close_low_sale_high_profit_count}')
print(f'高收盘-低清仓-盈利低于5%{high_close_low_sale_low_profit_count}')
print(f'高收盘-低清仓-亏损低于5%{high_close_low_sale_low_loss_count}')
print(f'高收盘-低清仓-亏损高于5%{high_close_low_sale_high_loss_count}')
print(f'高收盘-高清仓-盈利高于5%{high_close_high_sale_high_profit_count}')
print(f'高收盘-高清仓-盈利低于5%{high_close_high_sale_low_profit_count}')
print(f'高收盘-高清仓-亏损低于5%{high_close_high_sale_low_loss_count}')
print(f'高收盘-高清仓-亏损高于5%{high_close_high_sale_high_loss_count}')
print(f'高收盘-正常清仓-盈利高于5%{high_close_normal_sale_high_profit_count}')
print(f'高收盘-正常清仓-盈利低于5%{high_close_normal_sale_low_profit_count}')
print(f'高收盘-正常清仓-亏损低于5%{high_close_normal_sale_low_loss_count}')
print(f'高收盘-正常清仓-亏损高于5%{high_close_normal_sale_high_loss_count}')
df_distribution = pd.DataFrame({'test':[1]})
df_distribution['total_count'] = total_count
df_distribution['low_open_count'] = low_open_count
df_distribution['normal_open_count'] = normal_open_count
df_distribution['high_open_count'] = high_open_count
df_distribution['low_close_count'] = low_close_count
df_distribution['normal_close_count'] = normal_close_count
df_distribution['high_close_count'] = high_close_count
df_distribution['low_open_low_sale_count'] = low_open_low_sale_count
df_distribution['low_open_high_sale_count'] = low_open_high_sale_count
df_distribution['low_open_normal_sale_count'] = low_open_normal_sale_count
df_distribution['normal_open_low_sale_count'] = normal_open_low_sale_count
df_distribution['normal_open_high_sale_count'] = normal_open_high_sale_count
df_distribution['normal_open_normal_sale_count'] = normal_open_normal_sale_count
df_distribution['high_open_low_sale_count'] = high_open_low_sale_count
df_distribution['high_open_high_sale_count'] = high_open_high_sale_count
df_distribution['high_open_normal_sale_count'] = high_open_normal_sale_count
df_distribution['low_close_low_sale_count'] = low_close_low_sale_count
df_distribution['low_close_high_sale_count'] = low_close_high_sale_count
df_distribution['low_close_normal_sale_count'] = low_close_normal_sale_count
df_distribution['normal_close_low_sale_count'] = normal_close_low_sale_count
df_distribution['normal_close_high_sale_count'] = normal_close_high_sale_count
df_distribution['normal_close_normal_sale_count'] = normal_close_normal_sale_count
df_distribution['high_close_low_sale_count'] = high_close_low_sale_count
df_distribution['high_close_high_sale_count'] = high_close_high_sale_count
df_distribution['high_close_normal_sale_count'] = high_close_normal_sale_count
df_distribution['low_open_low_sale_high_profit_count'] = low_open_low_sale_high_profit_count
df_distribution['low_open_low_sale_low_profit_count'] = low_open_low_sale_low_profit_count
df_distribution['low_open_low_sale_low_loss_count'] = low_open_low_sale_low_loss_count
df_distribution['low_open_low_sale_high_loss_count'] = low_open_low_sale_high_loss_count
df_distribution['low_open_high_sale_high_profit_count'] = low_open_high_sale_high_profit_count
df_distribution['low_open_high_sale_low_profit_count'] = low_open_high_sale_low_profit_count
df_distribution['low_open_high_sale_low_loss_count'] = low_open_high_sale_low_loss_count
df_distribution['low_open_high_sale_high_loss_count'] = low_open_high_sale_high_loss_count
df_distribution['low_open_normal_sale_high_profit_count'] = low_open_normal_sale_high_profit_count
df_distribution['low_open_normal_sale_low_profit_count'] = low_open_normal_sale_low_profit_count
df_distribution['low_open_normal_sale_low_loss_count'] = low_open_normal_sale_low_loss_count
df_distribution['low_open_normal_sale_high_loss_count'] = low_open_normal_sale_high_loss_count
df_distribution['normal_open_low_sale_high_profit_count'] = normal_open_low_sale_high_profit_count
df_distribution['normal_open_low_sale_low_profit_count'] = normal_open_low_sale_low_profit_count
df_distribution['normal_open_low_sale_low_loss_count'] = normal_open_low_sale_low_loss_count
df_distribution['normal_open_low_sale_high_loss_count'] = normal_open_low_sale_high_loss_count
df_distribution['normal_open_high_sale_high_profit_count'] = normal_open_high_sale_high_profit_count
df_distribution['normal_open_high_sale_low_profit_count'] = normal_open_high_sale_low_profit_count
df_distribution['normal_open_high_sale_low_loss_count'] = normal_open_high_sale_low_loss_count
df_distribution['normal_open_high_sale_high_loss_count'] = normal_open_high_sale_high_loss_count
df_distribution['normal_open_normal_sale_high_profit_count'] = normal_open_normal_sale_high_profit_count
df_distribution['normal_open_normal_sale_low_profit_count'] = normal_open_normal_sale_low_profit_count
df_distribution['normal_open_normal_sale_low_loss_count'] = normal_open_normal_sale_low_loss_count
df_distribution['normal_open_normal_sale_high_loss_count'] = normal_open_normal_sale_high_loss_count
df_distribution['high_open_low_sale_high_profit_count'] = high_open_low_sale_high_profit_count
df_distribution['high_open_low_sale_low_profit_count'] = high_open_low_sale_low_profit_count
df_distribution['high_open_low_sale_low_loss_count'] = high_open_low_sale_low_loss_count
df_distribution['high_open_low_sale_high_loss_count'] = high_open_low_sale_high_loss_count
df_distribution['high_open_high_sale_high_profit_count'] = high_open_high_sale_high_profit_count
df_distribution['high_open_high_sale_low_profit_count'] = high_open_high_sale_low_profit_count
df_distribution['high_open_high_sale_low_loss_count'] = high_open_high_sale_low_loss_count
df_distribution['high_open_high_sale_high_loss_count'] = high_open_high_sale_high_loss_count
df_distribution['high_open_normal_sale_high_profit_count'] = high_open_normal_sale_high_profit_count
df_distribution['high_open_normal_sale_low_profit_count'] = high_open_normal_sale_low_profit_count
df_distribution['high_open_normal_sale_low_loss_count'] = high_open_normal_sale_low_loss_count
df_distribution['high_open_normal_sale_high_loss_count'] = high_open_normal_sale_high_loss_count
df_distribution['low_close_low_sale_high_profit_count'] = low_close_low_sale_high_profit_count
df_distribution['low_close_low_sale_low_profit_count'] = low_close_low_sale_low_profit_count
df_distribution['low_close_low_sale_low_loss_count'] = low_close_low_sale_low_loss_count
df_distribution['low_close_low_sale_high_loss_count'] = low_close_low_sale_high_loss_count
df_distribution['low_close_high_sale_high_profit_count'] = low_close_high_sale_high_profit_count
df_distribution['low_close_high_sale_low_profit_count'] = low_close_high_sale_low_profit_count
df_distribution['low_close_high_sale_low_loss_count'] = low_close_high_sale_low_loss_count
df_distribution['low_close_high_sale_high_loss_count'] = low_close_high_sale_high_loss_count
df_distribution['low_close_normal_sale_high_profit_count'] = low_close_normal_sale_high_profit_count
df_distribution['low_close_normal_sale_low_profit_count'] = low_close_normal_sale_low_profit_count
df_distribution['low_close_normal_sale_low_loss_count'] = low_close_normal_sale_low_loss_count
df_distribution['low_close_normal_sale_high_loss_count'] = low_close_normal_sale_high_loss_count
df_distribution['normal_close_low_sale_high_profit_count'] = normal_close_low_sale_high_profit_count
df_distribution['normal_close_low_sale_low_profit_count'] = normal_close_low_sale_low_profit_count
df_distribution['normal_close_low_sale_low_loss_count'] = normal_close_low_sale_low_loss_count
df_distribution['normal_close_low_sale_high_loss_count'] = normal_close_low_sale_high_loss_count
df_distribution['normal_close_high_sale_high_profit_count'] = normal_close_high_sale_high_profit_count
df_distribution['normal_close_high_sale_low_profit_count'] = normal_close_high_sale_low_profit_count
df_distribution['normal_close_high_sale_low_loss_count'] = normal_close_high_sale_low_loss_count
df_distribution['normal_close_high_sale_high_loss_count'] = normal_close_high_sale_high_loss_count
df_distribution['normal_close_normal_sale_high_profit_count'] = normal_close_normal_sale_high_profit_count
df_distribution['normal_close_normal_sale_low_profit_count'] = normal_close_normal_sale_low_profit_count
df_distribution['normal_close_normal_sale_low_loss_count'] = normal_close_normal_sale_low_loss_count
df_distribution['normal_close_normal_sale_high_loss_count'] = normal_close_normal_sale_high_loss_count
df_distribution['high_close_low_sale_high_profit_count'] = high_close_low_sale_high_profit_count
df_distribution['high_close_low_sale_low_profit_count'] = high_close_low_sale_low_profit_count
df_distribution['high_close_low_sale_low_loss_count'] = high_close_low_sale_low_loss_count
df_distribution['high_close_low_sale_high_loss_count'] = high_close_low_sale_high_loss_count
df_distribution['high_close_high_sale_high_profit_count'] = high_close_high_sale_high_profit_count
df_distribution['high_close_high_sale_low_profit_count'] = high_close_high_sale_low_profit_count
df_distribution['high_close_high_sale_low_loss_count'] = high_close_high_sale_low_loss_count
df_distribution['high_close_high_sale_high_loss_count'] = high_close_high_sale_high_loss_count
df_distribution['high_close_normal_sale_high_profit_count'] = high_close_normal_sale_high_profit_count
df_distribution['high_close_normal_sale_low_profit_count'] = high_close_normal_sale_low_profit_count
df_distribution['high_close_normal_sale_low_loss_count'] = high_close_normal_sale_low_loss_count
df_distribution['high_close_normal_sale_high_loss_count'] = high_close_normal_sale_high_loss_count
# 删除'test'列
df_distribution = df_distribution.drop(columns=['test'])
# 创建一个新的图形
fig, ax = plt.subplots()
# 创建一个条形图
df_distribution.plot(kind='bar', ax=ax)
# 设置图形的标题和轴标签
ax.set_title('Distribution')
ax.set_xlabel('Category')
ax.set_ylabel('Count')
# 显示图形
plt.show()