admin
2025-01-15 f84dcf456dbfa318f490d6cf878be5d5d5262718
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
"""
该模块下进行卖出策略的编写
"""
# import decimal
import datetime
# import time
# 引入掘金API
# from gm.api import *
from strategy import basic_methods
from strategy import data_cache
 
# import account_management
from strategy import order_methods
from strategy.logging_config import get_logger
 
# 获取logger实例
logger = get_logger()
 
 
# 构建获取个股记录下来的实时当日开盘价函数
def get_symbol_current_open(symbol):
    if data_cache.all_stocks_current_open.get(symbol) is not None:
        return data_cache.all_stocks_current_open[symbol]['current_open']
    else:
        return None
 
 
# 构建获取个股记录下来的实时当日最高价函数
def get_symbol_current_high(symbol):
    if data_cache.all_stocks_current_high_and_low.get(symbol) is not None:
        return data_cache.all_stocks_current_high_and_low[symbol]['current_high']
    else:
        return None
 
 
# 构建获取个股记录下来的实时当日最低价函数
def get_symbol_current_low(symbol):
    if data_cache.all_stocks_current_high_and_low.get(symbol) is not None:
        return data_cache.all_stocks_current_high_and_low[symbol]['current_low']
    else:
        return None
 
 
# 构建一个更新当前最新总成交量的对象
class VolumeTracker:
    # 初始化 前一个当前总成交量
    def __init__(self):
        self.__previous_current_volume = 0
        self.__last_deal_volume = 0
 
    # 更新 当前总成交量的函数
    def update_current_volume(self, new_current_volume):
        """
        设置最新量
        :param new_current_volume:
        :return:
        """
        # 更新previous_current_volume为新的current_volume
        self.__last_deal_volume = new_current_volume - self.__previous_current_volume
        self.__previous_current_volume = new_current_volume
        return self.__last_deal_volume
 
    def get_last_deal_volume(self):
        """
        获取瞬时成交量
        :return:
        """
        return self.__last_deal_volume
 
    def get_previous_current_volume(self):
        return self.__previous_current_volume
 
 
# 创建一个字典来存储每只股票的VolumeTracker实例
symbol_volume_trackers = {}
 
 
# 更新个股成交量函数
def update_symbol_volume(symbol, new_volume):
    # 确保股票代码在字典中有对应的VolumeTracker实例
    if symbol not in symbol_volume_trackers:
        symbol_volume_trackers[symbol] = VolumeTracker()
    # 检索对应的VolumeTracker实例并更新成交量
    tracker: VolumeTracker = symbol_volume_trackers[symbol]
    # 获取上一个交易量
    previous_current_volume = tracker.get_previous_current_volume()
    # 计算顺势交易量
    last_volume = tracker.update_current_volume(new_volume)
    # if last_volume:
    #     print(
    #         f"瞬时量变 {symbol}: 上一个:{previous_current_volume} -> 最新:{new_volume}    瞬时成交量 {last_volume}")
    return last_volume
 
 
# 分时变化策略
def instantaneous_change_strategy(context, current_info):
    # 设定当前时间点
    now_time = datetime.datetime.now().strftime("%H:%M:%S")
    symbol_code = current_info[0]  # 券商接口为纯数字编号
    symbol = basic_methods.format_stock_symbol(symbol_code)  # 掘金数据来源的股票代码
    # symbol_code = symbol.split('.')[1]  # 将掘金格式的股票代码转化为纯数字类型
    # print(f"symbol==={symbol}")
    pre_close = current_info[1]  # 昨日收盘价
    current_price = current_info[2]  # 获取当前最新价
    current_open = get_symbol_current_open(symbol)  # 当日开盘价
    current_high = get_symbol_current_high(symbol)  # 当日当时最高价
    current_low = get_symbol_current_low(symbol)  # 当日当时最低价
    current_volume = current_info[3]  # 当日当时的总成交量
    current_last_volume = update_symbol_volume(symbol, current_volume)  # 获取瞬时交易量
    # current_last_volume = result[0]  # 获取上一个当日当时的总成交量
    current_amount = current_info[4]  # 当日当时的总成交额
    current_quotes_buy = current_info[5]  # 买5档数据
    current_quotes_sell = current_info[6]  # 卖5档数据
    current_created_at = current_info[7]  # 当前信息创建时间
    # print(
    #     f"买一价:{current_quotes_buy[0][0]},买二价:{current_quotes_buy[1][0]},买三价:{current_quotes_buy[2][0]},买四价:{current_quotes_buy[3][0]},买五价:{current_quotes_buy[4][0]}")
    # print(
    #     f"卖一价:{current_quotes_sell[0][0]},卖二价:{current_quotes_sell[1][0]},卖三价:{current_quotes_sell[2][0]},卖四价:{current_quotes_sell[3][0]},卖五价:{current_quotes_sell[4][0]}")
    # print(
    #     f"买一量:{current_quotes_buy[0][1]},卖二量:{current_quotes_buy[1][1]},卖三量:{current_quotes_buy[2][1]},卖四量:{current_quotes_buy[3][1]},卖五量:{current_quotes_buy[4][1]}")
    # print(
    #     f"卖一量:{current_quotes_sell[0][1]},买二量:{current_quotes_sell[1][1]},买三量:{current_quotes_sell[2][1]},买四量:{current_quotes_sell[3][1]},买五量:{current_quotes_sell[4][1]}")
    # 如果在持仓可用里面有 当前current_data循环到的个股tick 就开始做具体的逻辑判断
    # print(f"data_cache.account_positions=={data_cache.account_positions}")
    # import test
    # test_data = test.test_data
    for index, element in enumerate(data_cache.account_positions):
        if element['symbol'] == symbol:  # 当循环到的持仓代码正好是current_data的代码时,即取得了持仓个股的行情快照数据
            # logger.info(f"index = {index}")
            # logger.info(f"element = {element}")
            account_positions_symbol = element['symbol']  # 当前循环到的持仓个股代码
            # print(f"account_positions_symbol==={account_positions_symbol}")
            # available_now = element['available_now']  # 当前个股可用金额
            # price = d['price']   #当前行情价,,,非最新价,没有实际意义不要用!!!
            vwap = element['vwap']  # 当前个股持仓均价/成本价
            position_volume = element['volume']  # 当前个股持仓量
            position_volume_today = element['volume_today']  # 今日持仓量
            position_volume_yesterday = position_volume - position_volume_today  # 昨日持仓量(可用持仓量)
            # print(symbol,available_now, price, vwap)
            # print(f"current_open=={current_open}")
            # print(f"current_price=={current_price}")
            # print(f"current_high=={current_high}")
            # print(f"current_low=={current_low}")
            # print(f"current_amount 总成交额 ==={round(current_amount / 10000, 2)} 万")
            # print(f"current_volume 总成交量 ==={round(current_volume / 10000, 2)} 万")
            # # print(f"current_last_volume 上一刻 总成交量 === {round(current_last_volume/10000, 2)} 万")
            # print(f"last_volume  瞬时成交量==={round(current_last_volume, 2)}")
            # print(f"current_quotes_buy=={current_quotes_buy}")
            # print(f"current_quotes_sell=={current_quotes_sell}")
 
            # 在字典K线下的查询当前个股的K线并赋值以便使用
            k_line_data = data_cache.all_stocks_all_K_line_property_dict.get(account_positions_symbol, None)
 
            # 处理行情订阅中持仓金额>0的个股(或者直接把先把指数的数据过滤掉放进来)
            if position_volume_yesterday > 0:  # 如果可用资金不等于0 且 持仓数量大于0 (不知名原因导致有些票会获取到零值导致后续公式报错,阻止intraday_growth函数正常运行)
                # 进入集合竞价前和收盘前作持仓可用交易,在此时间为不生效
                if data_cache.before_open_bidding_time < now_time < data_cache.after_closing_time:
                    # logger.info(f"account_positions_element = 【{k_line_data[0]['sec_name']}】  代码:{element['symbol']}  股持仓均价:{element['vwap']}    持仓量:{element['volume']} ")
                    # print(f"available_now_index===={index}")
                    # 调用涨幅公式计算对应的股票tick瞬时涨幅
                    tick_growth = basic_methods.tick_growth(symbol, current_price)
                    # 计算当日当时涨幅
                    today_growth = basic_methods.intraday_growth(current_price, k_line_data[0]['close'])
                    # 计算当日开盘涨幅(如果计算时获取到的最新价为0,进入容错模式,只有当开盘价不为0时才正常计算,如果为0,那么将开盘涨幅设置为0.01【因为如果设置为0,昨日未涨停的票大概率会默认抛掉】)
                    if current_open != 0:
                        today_open_growth = basic_methods.intraday_growth(current_open, k_line_data[0]['close'])
                    else:
                        today_open_growth = 0.01
                    # 计算当时浮动盈亏
                    floating_profit_and_loss = basic_methods.intraday_growth(current_price, vwap)
                    # 计算昨日涨停价 目前函数中的pre_close应该传入前天的收盘价,而非昨天的
                    # yesterday_limit_up_price = basic_methods.limit_up_price(k_line_data[1]['close'])
                    # 计算今日涨停价
                    today_limit_up_price = basic_methods.limit_up_price(k_line_data[0]['close'])
                    # 计算今日跌停价
                    today_limit_down_price = basic_methods.limit_down_price(k_line_data[0]['close'])
                    # print(
                    #     f"今日可用持仓股票数量=================================================================【{len(data_cache.available_symbols_set)}】")
                    # print(f"持仓可用股{symbol}")
                    # print(
                    #     f"【{k_line_data[0]['sec_name']}】上个交易日 最高{history_data[1]['high']},收盘{history_data[1]['close']}")
 
                    # 由于会存在分时L1数据中最新价为0导致current_low==0的情况,所以当出现这一情况时,将它直接赋值为昨收价(目前没有办法根本解决)
                    if current_low == 0:
                        current_low = k_line_data[0]['close']
 
                    '''
                    集合竞价阶段决断(只判断一次)
                    '''
                    if data_cache.after_open_bidding_time < now_time < data_cache.opening_time and data_cache.execution_times < len(
                            data_cache.available_symbols_set):
                        # 每进入该条件分支一次就把进入次数自加1
                        data_cache.execution_times += 1
                        logger.info(f"这个分支逻辑已经执行次数:{data_cache.execution_times}")
                        logger.info(
                            f"【集合竞价】【{k_line_data[0]['sec_name']}】,开盘涨幅:{today_open_growth}%,当日当时涨幅:{today_growth},瞬时涨幅{tick_growth},当日当时浮动盈亏{floating_profit_and_loss}。当日开盘价:{current_open},昨日收盘价:{k_line_data[0]['close']}")
                        # 昨日起飞失败
                        if k_line_data[0]['attribute'] not in (
                                data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                            if floating_profit_and_loss > 0:
                                if today_open_growth < -1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮盈】【低开】,低开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                            if floating_profit_and_loss <= 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之三仓】")
                                    order_methods.sell_order_by_part_volume(0.3, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                                # 平开视界 +- 1
                                if -1 < today_open_growth < 1:
                                    logger.info(
                                        f"【集合竞价】【平开】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'],
                                                                            index)
                                # 低开视界
                                if today_open_growth <= -1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日起飞失败】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日涨停视界
                        if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                            if floating_profit_and_loss > 0:
                                pass
                            if floating_profit_and_loss <= 0:
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【无,集合竞价阶段不决策】")
                                # 低开视界
                                if today_open_growth <= -1:
                                    # 小低开视界
                                    if -4 < today_open_growth <= -1:
                                        logger.info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    # 中低开/大低开视界
                                    if today_open_growth <= -4:
                                        logger.info(
                                            f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日涨停】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                        order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'], index)
                            #  如果昨日集合竞价最后时刻炸板的股票【开盘啦昨日炸板但通过K线数据计算涨停的股票代码列表】
                            if symbol in data_cache.yesterday_frying_plate_last_minute_list:
                                # 开盘涨幅小于9.6%
                                if today_open_growth < 9.6:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日K线涨停,开盘啦炸板】【非触摸板状态】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日炸板视界
                        if k_line_data[0]['attribute'] in data_cache.frying_plate_type:
                            if floating_profit_and_loss > 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【二十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.05, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之一仓】")
                                    order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小低开视界
                                if -4 < today_open_growth <= -1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮盈】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之七仓】")
                                    order_methods.sell_order_by_part_volume(0.7, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 中低开/大低开视界
                                if today_open_growth <= -4:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
 
                            if floating_profit_and_loss <= 0:
                                # 中高开/大高开视界
                                if today_open_growth >= 4:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中高开/大高开】,高开:{today_open_growth}%,设定委卖数量【十分之二仓】")
                                    order_methods.sell_order_by_part_volume(0.2, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小高开视界
                                if 4 > today_open_growth >= 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小高开】,高开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 平开视界 < ±1%
                                if -1 < today_open_growth < 1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【平开】,平开:{today_open_growth}%,设定委卖数量【十分之五仓】")
                                    order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 小低开视界
                                if -4 < today_open_growth <= -1:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【小低开】,低开:{today_open_growth}%,设定委卖数量【十分之七仓】")
                                    order_methods.sell_order_by_part_volume(0.7, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                                # 中低开/大低开视界
                                if today_open_growth <= -4:
                                    logger.info(
                                        f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日炸板】【浮亏】【中低开/大低开】,低开:{today_open_growth}%,设定委卖数量【全仓】")
                                    order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                            today_limit_down_price,
                                                                            k_line_data[0]['sec_name'], index)
                        # 昨日跌停视界
                        if k_line_data[0]['attribute'] in data_cache.limit_down_type:
                            logger.info(
                                f"【集合竞价】【{k_line_data[0]['sec_name']}】【昨日跌停】【无论开盘涨幅多少!!!】,开盘涨幅:{today_open_growth}%,设定委卖数量【全仓】")
                            order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                    today_limit_down_price,
                                                                    k_line_data[0]['sec_name'], index)
 
                    '''
                    开盘阶段临机决策
                    '''
                    if data_cache.opening_time < now_time < data_cache.after_closing_time:
                        # 当日未涨停视界
                        if today_limit_up_price != current_high:
                            # 昨日起飞失败视界
                            if k_line_data[0]['attribute'] not in (
                                    data_cache.limit_up_type + data_cache.frying_plate_type + data_cache.limit_down_type):
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and current_price <= current_low:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol, position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'], index)
                                    if tick_growth < -0.1 and today_growth < 0 and current_price <= current_low:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'], index)
                            # 昨日涨停视界
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and today_growth < -4:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅 <-4%】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    if tick_growth < -0.1 and today_growth < 0 and current_price <= current_low:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                            # 昨日炸板视界
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                # 浮动盈亏【盈】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -1 and today_growth < 0 and current_price <= current_low:
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                # 浮动盈亏【亏】
                                if floating_profit_and_loss < 0:
                                    if tick_growth < -0.1 and current_price <= current_low:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-0.1%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【十分之一仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.1, symbol,
                                                                                position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                                    if tick_growth < -0.1 and today_growth < 0 and current_price <= current_low:
                                        logger.info(
                                            f"【开盘临机】【浮动盈亏当前亏】【瞬时跌幅 <-1%】【当日当时涨幅小于0%】【当日新低】【{k_line_data[0]['sec_name']}】,设定委卖数量【全仓】,【瞬时跌幅:{round(tick_growth, 2)}%】,当日当时涨幅:{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(1, symbol,
                                                                                position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'],
                                                                                index)
                            # 昨日跌停视界
                            if k_line_data[0]['attribute'] in data_cache.limit_up_type:
                                # 执行与集合竞价一致,全仓出,不再复写
                                pass
 
                        # 当日涨停视界(板上盯 有时间限制  9:30:00 ---  14:36:00)
                        if data_cache.opening_time < now_time < data_cache.watch_disk_end_time:
                            if today_limit_up_price == current_high:
                                logger.info(
                                    f"【开盘临机】【{k_line_data[0]['sec_name']}】 触及涨停! 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                # 如果 买一总金额 < 200000   买一总金额 在L1情况下估计的炸板前最后一刻的最低买一额无法缩小到更小,其本身跨度也因股票因时间因往下砸的力度而异,不然无法观察到结果。
                                if current_quotes_buy[0][1] * current_quotes_buy[0][0] < 1000000:
                                    logger.info(
                                        f"【开盘临机】【炸板风险!!】【{k_line_data[0]['sec_name']}】 买盘金额小于100万! 买一额:【{current_quotes_buy[0][1]}】,当日当时量:{current_volume}")
                                    if current_volume < k_line_data[0]['volume'] * 0.6:
                                        logger.info(
                                            f"【开盘临机】【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 买盘小于1万 且 今日量小于昨日量的 0.6,设定委卖数量【十分之一仓】,当日当时量:{current_volume}")
                                        # # 设定委卖数量【十分之一仓】
                                        # order_methods.sell_order_by_part_volume(0.1, symbol,
                                        #                                         position_volume_yesterday,
                                        #                                         today_limit_down_price,
                                        #                                         k_line_data[0]['sec_name'],
                                        #                                         index)
                                else:
                                    logger.info(f"【开盘临机】【{k_line_data[0]['sec_name']}】 涨停封板!!")
                                # 如果 卖一 量 为零
                                if current_quotes_sell[0][1] * current_quotes_sell[0][0] == 0:
                                    logger.info(
                                        f"【开盘临机】【强势封板!!!】【{k_line_data[0]['sec_name']}】 买一总金额:{round(current_quotes_buy[0][1] * current_quotes_buy[0][0] / 10000, 2)} 万,当日当时量:{current_volume}")
                                else:
                                    if current_volume < k_line_data[0]['volume'] * 0.6:
                                        logger.info(
                                            f"【开盘临机】【 炸板中!!且当日量不足】【{k_line_data[0]['sec_name']}】 卖一数量不等于0,设定委卖数量【十分之一仓】,当日当时量:{current_volume}")
                                        # order_methods.sell_order_by_part_volume(0.1, symbol,
                                        #                                         position_volume_yesterday,
                                        #                                         today_limit_down_price,
                                        #                                         k_line_data[0]['sec_name'],
                                        #                                         index)
                                    # 如果 卖二 量炸出来了,那么就是彻底炸开了。
                                    if current_quotes_sell[1][1] != 0:
                                        logger.info(
                                            f"【开盘临机】【 炸板炸开了!!】【{k_line_data[0]['sec_name']}】 卖二数量不等于0,设定委卖数量【十分之二仓】,当日当时量:{current_volume}")
                                        # order_methods.sell_order_by_part_volume(0.2, symbol,
                                        #                                         position_volume_yesterday,
                                        #                                         today_limit_down_price,
                                        #                                         k_line_data[0]['sec_name'],
                                        #                                         index)
                                        if current_volume < k_line_data[0]['volume'] * 0.8:
                                            logger.info(
                                                f"【开盘临机】【 炸板!!且当日量不足】【{k_line_data[0]['sec_name']}】 买盘小于1万 且 今日量小于昨日量的 0.8,设定委卖数量【全仓】,当日当时量:{current_volume}")
                                            # order_methods.sell_order_by_part_volume(1, symbol,
                                            #                                         position_volume_yesterday,
                                            #                                         today_limit_down_price,
                                            #                                         k_line_data[0]['sec_name'],
                                            #                                         index)
 
                        # 当前时间超过午盘时间【午盘决策】
                        if now_time > data_cache.noon_market_time:
                            # 进入当前最新价低于当日最低价 且 瞬时下跌
                            if current_price <= current_low and tick_growth < -0.2:
                                # 进入昨日首板涨停视界(昨日涨停但前日未涨停)且 当日当前量未超昨日量
                                if k_line_data[0]['attribute'] in data_cache.limit_up_type and k_line_data[1]['attribute'] not in data_cache.limit_up_type and current_volume <= k_line_data[0]['volume']:
                                    if today_limit_up_price != current_high or today_growth < 7:
                                        logger.info(
                                            f"【午盘决策】【昨日涨停】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【十分之五仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                        order_methods.sell_order_by_part_volume(0.5, symbol, position_volume_yesterday,
                                                                                today_limit_down_price,
                                                                                k_line_data[0]['sec_name'], index)
                        # 当前时间超过平仓时间【尾盘决断】
                        if now_time > data_cache.close_position_time:
                            if today_limit_up_price != current_high or today_growth < 7:
                                logger.info(
                                    f"【尾盘决断】【当日未涨停 或 当日当时涨幅小于7%】【{k_line_data[0]['sec_name']}】 设定委卖数量【全仓】,当日当时涨幅为{today_growth}。最新价::{current_price},昨日收盘价:{k_line_data[0]['close']}")
                                order_methods.sell_order_by_part_volume(1, symbol, position_volume_yesterday,
                                                                        today_limit_down_price,
                                                                        k_line_data[0]['sec_name'], index)