| | |
| | | from l2 import l2_log, l2_data_source_util |
| | | from l2.l2_data_util import L2DataUtil, local_today_num_operate_map, local_today_datas, local_today_buyno_map, \ |
| | | local_today_canceled_buyno_map |
| | | from log_module.log import logger_buy_1_volumn, logger_l2_l_cancel, logger_l2_h_cancel, logger_l2_s_cancel |
| | | from log_module.log import logger_buy_1_volumn, logger_l2_l_cancel, logger_l2_h_cancel, logger_l2_s_cancel, logger_debug |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | | |
| | |
| | | total_count += 1 |
| | | total_num += val["num"] |
| | | return total_count, total_num |
| | | |
| | | @classmethod |
| | | def compute_end_index(cls, code, start_index, end_index, limit_up_price, max_count, min_money=500000): |
| | | """ |
| | | 计算结束索引 |
| | | @param code: 代码 |
| | | @param start_index:起始索引(包含) |
| | | @param end_index: 结束索引(包含) |
| | | @param limit_up_price: 涨停价 |
| | | @param max_count: 最大数量 |
| | | @param min_money: 最小的资金 |
| | | @return:结束索引 |
| | | """ |
| | | min_volume = min_money // int(limit_up_price * 100) |
| | | total_datas = local_today_datas.get(code) |
| | | canceled_buyno_map = local_today_canceled_buyno_map.get(code) |
| | | total_count = 0 |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data['val'] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val['num'] < min_volume: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i, |
| | | total_datas, |
| | | canceled_buyno_map) |
| | | if left_count > 0: |
| | | total_count += 1 |
| | | if total_count>=max_count: |
| | | return i |
| | | return end_index |
| | | |
| | | |
| | | |
| | | class SCancelBigNumComputer: |
| | |
| | | |
| | | zyltgb = l2_trade_factor.L2TradeFactorUtil.get_zyltgb(code) |
| | | zyltgb_unit_y = round(zyltgb / 100000000, 1) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | limit_up_price = round(float(limit_up_price), 2) |
| | | # 有超大单砸 |
| | | threshold_big_deal = (2 * zyltgb_unit_y + 339) * 10000 |
| | | if total_deal_money >= threshold_big_deal: |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | | # S撤重砸必撤的金额满足以后,以前是无脑撤。现在优化一下,看成交进度位---真实下单位的区间额≤重砸金额*5倍,就撤。 |
| | | try: |
| | | need_compute = False |
| | | trade_index, is_default = TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | if real_order_index_info and not real_order_index_info[1]: |
| | | need_compute = True |
| | | |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if need_compute: |
| | | total_count, total_num = L2DataComputeUtil.compute_left_buy_order(code, trade_index, |
| | | real_order_index_info[0], |
| | | limit_up_price) |
| | | if total_num * limit_up_price * 100 < 5 * total_deal_money: |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | | else: |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | | except Exception as e: |
| | | l2_log.info(code, logger_debug, f"S快计算出错:{str(e)}") |
| | | |
| | | # 判断是否为激进下单 |
| | | threash_money_w, threash_money_danger_w = self.__get_fast_threshold_value(code) |
| | | total_fast_num = 0 |
| | |
| | | if val["num"] < min_num: |
| | | continue |
| | | |
| | | |
| | | cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, |
| | | j, |
| | | total_datas, |
| | |
| | | # 获取真实下单位后面10笔大单 |
| | | try: |
| | | # 真实下单位置后面的数据就只看大单 |
| | | big_min_num = int(29900 / (float(gpcode_manager.get_limit_up_price(code)))) |
| | | MIN_NUM = int(5000 / (float(gpcode_manager.get_limit_up_price(code)))) |
| | | real_place_order_info = self.__real_place_order_index_dict.get(code) |
| | | if real_place_order_info and not real_place_order_info[1]: |
| | |
| | | code)) |
| | | if left_count > 0: |
| | | after_count+=1 |
| | | if val['num']>=big_min_num: |
| | | if l2_data_util.is_big_money(val): |
| | | watch_indexes.add(i) |
| | | except Exception as e: |
| | | pass |
| | |
| | | watch_indexes.add(data["index"]) |
| | | l2_log.l_cancel_debug(code, f"L后有成交重新囊括:成交索引-{index} 囊括索引-{data['index']}") |
| | | break |
| | | # 从真实下单位置往后囊括大单 |
| | | try: |
| | | left_count_after = 0 |
| | | for j in range(real_place_order_info[0] + 1, total_datas[-1]["index"]): |
| | | data = total_datas[j] |
| | | val = data['val'] |
| | | if left_count_after > 10: |
| | | break |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | j, |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | left_count_after += 1 |
| | | if l2_data_util.is_big_money(val) and j not in watch_indexes: |
| | | watch_indexes.add(j) |
| | | break |
| | | except: |
| | | pass |
| | | |
| | | self.__set_watch_indexes(code, watch_indexes_info[0], watch_indexes_info[1], watch_indexes) |
| | | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code): |
| | |
| | | # 实际下单位后方所有涨停纯买额≤1000万或没有任何大单(≥299万) |
| | | return True, f"P撤:封单纯买额-{round(left_money / 100, 1)}万 大单数量-{total_big_num_count} 下单位-{real_order_index} 成交位-{real_trade_index}" |
| | | return False, "不满足撤单条件" |
| | | # w撤 |
| | | def need_cancel_for_w(self,code): |
| | | real_order_index_info = self.__get_real_order_index_cache(code) |
| | | if not real_order_index_info: |
| | | return False, "没找到真实下单位" |
| | | if real_order_index_info[1]: |
| | | return False, "真实下单位为默认" |
| | | trade_index, is_default = TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | return False, "没获取到成交进度位" |
| | | |
| | | real_order_index = real_order_index_info[0] |
| | | total_datas = local_today_datas.get(code) |
| | | if tool.trade_time_sub(total_datas[-1]['val']['time'], total_datas[real_order_index]['val']['time']) > 60: |
| | | return False, "超过守护时间" |
| | | limit_up_price = round(float(gpcode_manager.get_limit_up_price(code)) , 2) |
| | | end_index = L2DataComputeUtil.compute_end_index(code, real_order_index+1, total_datas[-1]["index"],limit_up_price, 10) |
| | | # 从成交进度位到截至位置计算大单 |
| | | min_money = l2_data_util.get_big_money_val(limit_up_price) |
| | | left_count, left_money = L2DataComputeUtil.compute_left_buy_order(code,trade_index,end_index,limit_up_price,min_money=min_money) |
| | | if left_count < 1: |
| | | return True, f"大单数量:{left_count}" |
| | | return False, "大单数量够" |
| | | |
| | | # ---------------------------------G撤------------------------------- |
| | | class GCancelBigNumComputer: |
| | |
| | | total_datas = local_today_datas.get(code) |
| | | if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_place_order_index]['val']['time']) > 300: |
| | | return False, "超过生效时间" |
| | | total_left_count, total_left_num = L2DataComputeUtil.compute_left_buy_order(code, trade_index, real_place_order_index,limit_up_price, 299*10000) |
| | | total_left_count, total_left_num = L2DataComputeUtil.compute_left_buy_order(code, trade_index, |
| | | real_place_order_index, |
| | | limit_up_price, 299 * 10000) |
| | | if total_left_count > 0: |
| | | return False, '有大单' |
| | | return True, f'无大单:{trade_index}-{real_place_order_index}' |
| | |
| | | |
| | | def place_order_success(self, code): |
| | | self.__clear_data(code) |
| | | |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |