| | |
| | | break |
| | | continue |
| | | # 与当前时间相差3s的结束 |
| | | if tool.trade_time_sub_with_ms(end_time_with_ms, l2_data_util.L2DataUtil.get_time_with_ms(val)) > 6000: |
| | | if tool.trade_time_sub_with_ms(end_time_with_ms, l2_data_util.L2DataUtil.get_time_with_ms(val)) > 10000: |
| | | break |
| | | |
| | | cancel_count += 1 |
| | |
| | | # today = get_today_volumn(code) |
| | | # max60, yesterday = get_histry_volumn(code) |
| | | try: |
| | | today_volume = code_volumn_manager.get_today_volumn_cache(code) |
| | | histry_volumn = code_volumn_manager.get_histry_volumn(code) |
| | | today_volume = code_volumn_manager.CodeVolumeManager().get_today_volumn_cache(code) |
| | | histry_volumn = code_volumn_manager.CodeVolumeManager().get_histry_volumn(code) |
| | | if not today_volume or not histry_volumn: |
| | | return False, "尚未获取到量" |
| | | threshhold_volume = (histry_volumn[0][0] - today_volume) // 3 |
| | |
| | | @param end_index: |
| | | @return:(是否是量化, 下次可以下单时间) |
| | | """ |
| | | THRESHOLD_BUY_COUNT = 20 |
| | | if end_index - start_index + 1 < THRESHOLD_BUY_COUNT: |
| | | # 总数小于阈值 |
| | | return False, None |
| | | |
| | | # 阈值的取值范围 |
| | | THRESHOLD_MONEY_RANGE = 1e5, 3e5 |
| | | today_volume = code_volumn_manager.CodeVolumeManager().get_today_volumn_cache(code) |
| | | histry_volumn = code_volumn_manager.CodeVolumeManager().get_histry_volumn(code) |
| | | if not today_volume or not histry_volumn: |
| | | return False, "尚未获取到量" |
| | | threshhold_volume = (histry_volumn[0][0] - today_volume) // 6 // 100 |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | threshhold_volumes_range = int(THRESHOLD_MONEY_RANGE[0] / limit_up_price), int( |
| | | THRESHOLD_MONEY_RANGE[1] / limit_up_price) |
| | | if threshhold_volume < threshhold_volumes_range[0]: |
| | | threshhold_volume = threshhold_volumes_range[0] |
| | | if threshhold_volume > threshhold_volumes_range[1]: |
| | | threshhold_volume = threshhold_volumes_range[1] |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | |
| | | time_as_ms = tool.trade_time_sub_with_ms( |
| | | L2DataUtil.get_time_with_ms(total_datas[end_index]["val"]), |
| | | L2DataUtil.get_time_with_ms(total_datas[start_index]["val"])) |
| | | if time_as_ms > (10 if tool.is_sz_code(code) else 100): |
| | | return False, "非量化" |
| | | |
| | | limit_up_price = gpcode_manager.get_limit_up_price_as_num(code) |
| | | |
| | | buy_count = 0 |
| | | total_buy_nums = 0 |
| | | min_num = int(5000 / limit_up_price) |
| | | trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) |
| | | if trade_index is None: |
| | | trade_index = 0 |
| | | # 获取成交进度位 |
| | | for i in range(start_index, end_index + 1): |
| | | val = total_datas[i]["val"] |
| | |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | buy_count += 1 |
| | | if buy_count > THRESHOLD_BUY_COUNT: |
| | | total_buy_nums += val["num"] |
| | | if total_buy_nums > threshhold_volume: |
| | | break |
| | | if buy_count > THRESHOLD_BUY_COUNT: |
| | | if total_buy_nums > threshhold_volume: |
| | | # 判断是否为量化 |
| | | time_as_ms = tool.trade_time_sub_with_ms( |
| | | L2DataUtil.get_time_with_ms(total_datas[end_index]["val"]), |
| | | L2DataUtil.get_time_with_ms(total_datas[start_index]["val"])) |
| | | if time_as_ms <= 10 if tool.is_sz_code(code) else 100: |
| | | # 深证10ms内,上证100ms内就判定为量化 |
| | | HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) |
| | | next_buy_time = time.time() + buy_condition_util.get_cancel_and_buy_space_time( |
| | | code) / 1000 |
| | | # 如果是首次下单,增加一次下单次数 |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | if place_order_count == 0: |
| | | trade_data_manager.PlaceOrderCountManager().place_order(code) |
| | | return True, next_buy_time, f"执行位批次数据量({buy_count})大于{THRESHOLD_BUY_COUNT} {start_index}-{end_index}" |
| | | return False, None |
| | | # 深证10ms内,上证100ms内就判定为量化 |
| | | HuaXinSellOrderStatisticManager.clear_latest_deal_volume(code) |
| | | next_buy_time = time.time() + buy_condition_util.get_cancel_and_buy_space_time( |
| | | code) / 1000 |
| | | # 如果是首次下单,增加一次下单次数 |
| | | place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | if place_order_count == 0: |
| | | trade_data_manager.PlaceOrderCountManager().place_order(code) |
| | | return True, next_buy_time, f"执行位批次数据量({total_buy_nums})大于{threshhold_volume} {start_index}-{end_index}" |
| | | else: |
| | | return False, None |
| | | |