| | |
| | | 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) |
| | | # 有超大单砸 |
| | | # 有超大单砸 S重砸 |
| | | threshold_big_deal = (2 * zyltgb_unit_y + 339) * 10000 |
| | | if total_deal_money >= threshold_big_deal: |
| | | # S撤重砸必撤的金额满足以后,以前是无脑撤。现在优化一下,看成交进度位---真实下单位的区间额≤重砸金额*5倍,就撤。 |
| | | # S重砸必撤的金额满足以后,以前是无脑撤。现在优化一下,看成交进度位---真实下单位的区间额≤重砸金额*3.3倍,就撤。 |
| | | try: |
| | | need_compute = False |
| | | trade_index, is_default = TradeBuyQueue().get_traded_index(code) |
| | |
| | | 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: |
| | | if total_deal_money / (total_num * limit_up_price * 100) >= 0.3: |
| | | # 大单成交额占总剩余总囊括的30% |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | | else: |
| | | return True, f"1s内大于{threshold_big_deal}大卖单({total_deal_money})" |
| | |
| | | # 1.当前成交价为涨停价 |
| | | # 2.总卖额为0 |
| | | if abs(float(limit_up_price) - float(trade_price)) < 0.001: |
| | | sell_data = cls.__L2MarketSellManager.get_current_total_sell_data(code) |
| | | if sell_data and sell_data[1] <= 0: |
| | | # 板上放量,判断是否有放量,放量才会下单 |
| | | # 获取最近1s的主动卖金额 |
| | | min_time = total_data[order_begin_pos.buy_single_index]['val']['time'] |
| | | min_time = tool.trade_time_add_second(min_time, -1) |
| | | sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code, |
| | | min_deal_time=min_time) |
| | | sell_order_num = sum([x[1] for x in sell_orders]) |
| | | sell_money = int(float(limit_up_price) * sell_order_num) |
| | | if sell_money < 200000: |
| | | return False, True, f"板上放量金额不足,近1s总卖:{sell_money}小于20w" |
| | | # 获取最近的非涨停价成交时间 |
| | | not_limit_up_info = current_price_process_manager.get_trade_not_limit_up_info(code) |
| | | if not not_limit_up_info or tool.trade_time_sub( total_data[-1]['val']['time'], not_limit_up_info[1])>10: |
| | | # 非涨停价成交10s后才有可能判断为板上放量 |
| | | sell_data = cls.__L2MarketSellManager.get_current_total_sell_data(code) |
| | | if sell_data and sell_data[1] <= 0: |
| | | # 板上放量,判断是否有放量,放量才会下单 |
| | | # 获取最近1s的主动卖金额 |
| | | min_time = total_data[order_begin_pos.buy_single_index]['val']['time'] |
| | | min_time = tool.trade_time_add_second(min_time, -1) |
| | | sell_orders = HuaXinSellOrderStatisticManager.get_latest_transaction_datas(code, |
| | | min_deal_time=min_time) |
| | | sell_order_num = sum([x[1] for x in sell_orders]) |
| | | sell_money = int(float(limit_up_price) * sell_order_num) |
| | | if sell_money < 200000: |
| | | return False, True, f"板上放量金额不足,近1s总卖:{sell_money}小于20w" |
| | | # 判断成交进度是否距离我们的位置很近 |
| | | trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code) |
| | | if False and not is_default and trade_index: |
| | |
| | | return False |
| | | |
| | | |
| | | # 是否为大单 |
| | | def is_big_money(val): |
| | | price = float(val["price"]) |
| | | money = price * int(val["num"]) |
| | | if price > 3.0: |
| | | if money >= 29900: |
| | | return True |
| | | else: |
| | | return False |
| | | else: |
| | | max_money = price * 10000 |
| | | if money >= max_money * 0.95: |
| | | return True |
| | | else: |
| | | return False |
| | | |
| | | |
| | | class L2DataUtil: |
| | | @classmethod |
| | | def is_same_time(cls, time1, time2): |
| | |
| | | @classmethod |
| | | def process_huaxin_transaction_datas(cls, code, datas): |
| | | __start_time = time.time() |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if limit_up_price: |
| | | limit_up_price = round(float(limit_up_price), 2) |
| | | # 设置成交价 |
| | | current_price_process_manager.set_trade_price(code, datas[-1][1]) |
| | | try: |
| | | current_price_process_manager.set_trade_price(code, datas[-1][1], l2_huaxin_util.convert_time( datas[-1][3]), limit_up_price) |
| | | except: |
| | | pass |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | use_time_list = [] |
| | | try: |
| | |
| | | |
| | | big_sell_order_info = None |
| | | try: |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if limit_up_price: |
| | | limit_up_price = round(float(limit_up_price), 2) |
| | | |
| | | # 统计卖单 |
| | | big_sell_order_info = HuaXinSellOrderStatisticManager.add_transaction_datas(code, datas, limit_up_price) |
| | | |
| | |
| | | price = float(val["price"]) |
| | | money = price * val["num"] |
| | | if price > 3.0: |
| | | if money >= 29900: |
| | | if money >= 29900 or val["num"] >= 7999: |
| | | return True |
| | | else: |
| | | return False |
| | |
| | | # 获取大资金的金额 |
| | | def get_big_money_val(limit_up_price): |
| | | if limit_up_price > 3.0: |
| | | return 299 * 10000 |
| | | return min(299 * 10000, round(limit_up_price * 7999)) |
| | | else: |
| | | max_money = limit_up_price * 10000 |
| | | return max_money * 0.95 |
| | |
| | | if abs(get_time_as_seconds(time_str) - get_time_as_seconds(time_)) > 3: |
| | | continue |
| | | if same_time_nums[time_] > 20: |
| | | RedisUtils.setex(l2_data_manager._redisManager.getRedis(), "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(), |
| | | RedisUtils.setex(l2_data_manager._redisManager.getRedis(), |
| | | "big_data-{}-{}".format(code, int(round(time.time() * 1000))), tool.get_expire(), |
| | | d1) |
| | | break |
| | | |
| | |
| | | |
| | | # 获取最新数据条数 |
| | | def get_l2_latest_data_number(code): |
| | | num =RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code)) |
| | | num = RedisUtils.get(l2_data_manager._redisManager.getRedis(), "l2_latest_data_num-{}".format(code)) |
| | | if num is not None: |
| | | return int(num) |
| | | return None |
| | |
| | | # 即将成交 |
| | | from code_attribute import gpcode_manager |
| | | from l2 import l2_data_source_util, l2_data_util |
| | | import l2 |
| | | import l2_data_util |
| | | from l2.l2_data_util import L2DataUtil |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_kp_msg |
| | |
| | | |
| | | # 即将成交 |
| | | def almost_deal(code, real_order_index, trade_index): |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | total_datas = l2.l2_data_util.local_today_datas.get(code) |
| | | if trade_index > real_order_index: |
| | | return |
| | | # 下单3s过后再提醒 |
| | |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | i, |
| | | total_datas, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | left_count = l2.l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | i, |
| | | total_datas, |
| | | l2.l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_left_count += left_count |
| | | total_left_money += val["num"] * left_count * float(val["price"]) * 100 |
| | |
| | | if total_left_count <= 10: |
| | | push_msg_manager.push_order_almost_deal(code, code_name, real_order_index, f"剩余:{total_left_count}笔", |
| | | ctype="count") |
| | | async_log_util.info(logger_kp_msg, f"{code}即将成交:trade_index-{trade_index},real_order_index-{real_order_index},剩余:{total_left_count}笔,结尾:{total_datas[-1]['index']}") |
| | | async_log_util.info(logger_kp_msg, |
| | | f"{code}即将成交:trade_index-{trade_index},real_order_index-{real_order_index},剩余:{total_left_count}笔,结尾:{total_datas[-1]['index']}") |
| | | |
| | | elif total_left_money < 1500 * 10000: |
| | | push_msg_manager.push_order_almost_deal(code, code_name, real_order_index, |
| | |
| | | def follow_not_enough(code, buy_exec_index, real_order_index): |
| | | if buy_exec_index > real_order_index: |
| | | return |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | total_datas = l2.l2_data_util.local_today_datas.get(code) |
| | | # 下单3s过后再提醒 |
| | | if tool.trade_time_sub(total_datas[-1]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) <= 5: |
| | | return |
| | |
| | | if not l2_data_util.is_big_money(val): |
| | | continue |
| | | |
| | | canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, |
| | | i, |
| | | total_datas, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | canceled_data = l2.l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, |
| | | i, |
| | | total_datas, |
| | | l2.l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if not canceled_data: |
| | | real_place_order_after_count += 1 |
| | | real_place_order_after_money += val["num"] * float(val["price"]) * 100 |
| | |
| | | trade_index = 0 |
| | | threshold_before_count = max_count // 2 |
| | | |
| | | fresults = __get_trade_queue(code, real_place_order_index, trade_index - 1,real_place_order_index, threshold_before_count, -1) |
| | | fresults = __get_trade_queue(code, real_place_order_index, trade_index - 1, real_place_order_index, |
| | | threshold_before_count, -1) |
| | | fresults.reverse() |
| | | fresults.extend(__get_trade_queue(code, real_place_order_index+1, total_datas[-1]['index'] + 1, real_place_order_index, max_count - threshold_before_count, 1)) |
| | | fresults.extend( |
| | | __get_trade_queue(code, real_place_order_index + 1, total_datas[-1]['index'] + 1, real_place_order_index, |
| | | max_count - threshold_before_count, 1)) |
| | | return fresults |
| | | |
| | | |
| | |
| | | trade_index = 0 |
| | | # 前面最多取5条数据 |
| | | fresults = [] |
| | | fresults.extend(__get_trade_queue(code, trade_index, total_datas[-1]['index'] + 1,real_place_order_index, max_count, 1)) |
| | | fresults.extend( |
| | | __get_trade_queue(code, trade_index, total_datas[-1]['index'] + 1, real_place_order_index, max_count, 1)) |
| | | return fresults |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | __trade_price_dict = {} |
| | | |
| | | # 最近的非涨停价成交的信息,数据结构:{code:(价格,时间)} |
| | | __trade_price_not_limit_up_info_dict = {} |
| | | |
| | | |
| | | # 设置成交价 |
| | | def set_trade_price(code, price): |
| | | def set_trade_price(code, price, time_str, limit_up_price): |
| | | __trade_price_dict[code] = price |
| | | # 需要记录最近一次非涨停价成交的时间 |
| | | if limit_up_price and abs(limit_up_price - price) > 0.001: |
| | | # 非涨停价成交 |
| | | __trade_price_not_limit_up_info_dict[code] = (price, time_str) |
| | | |
| | | |
| | | # 获取成交价 |
| | | def get_trade_price(code): |
| | | return __trade_price_dict.get(code) |
| | | |
| | | |
| | | def get_trade_not_limit_up_info(code): |
| | | """ |
| | | 获取最近的非涨停价成交的信息 |
| | | @param code: |
| | | @return:(价格,时间) |
| | | """ |
| | | return __trade_price_not_limit_up_info_dict.get(code) |
| | |
| | | from third_data.kpl_util import KPLDataType |
| | | from trade import trade_manager, l2_trade_util, \ |
| | | l2_trade_factor, trade_data_manager |
| | | from trade.deal_big_money_manager import DealOrderNoManager |
| | | import l2_data_util as l2_data_util_old |
| | | |
| | | from trade.huaxin import huaxin_trade_api as trade_api, huaxin_trade_api, huaxin_trade_data_update, \ |
| | | huaxin_trade_record_manager, huaxin_trade_order_processor, huaxin_sell_util |
| | |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 是不是大单 |
| | | if not l2_data_util.is_big_money(val): |
| | | if not l2_data_util_old.is_big_money(val): |
| | | continue |
| | | |
| | | canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2( |
| | |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 是不是大单 |
| | | if not l2_data_util.is_big_money(val): |
| | | if not l2_data_util_old.is_big_money(val): |
| | | continue |
| | | |
| | | canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2( |
| | |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 是不是大单 |
| | | if not l2_data_util.is_big_money(val): |
| | | if not l2_data_util_old.is_big_money(val): |
| | | continue |
| | | |
| | | canceled_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2( |
| | |
| | | if real_place_order_index is not None: |
| | | trade_queue = l2_output_util.get_trade_queue_at_near_place_order(code, |
| | | real_place_order_index, |
| | | 11) |
| | | 9) |
| | | fdata['trade_queue'] = trade_queue |
| | | except: |
| | | pass |
| | |
| | | if count is None: |
| | | count = 100 |
| | | real_place_order_index = SCancelBigNumComputer().get_real_place_order_index_cache(code) |
| | | if real_place_order_index is not None: |
| | | trade_queue = l2_output_util.get_trade_queue(code, real_place_order_index, count) |
| | | self.send_response({"code": 0, "data": trade_queue}, client_id, request_id) |
| | | else: |
| | | raise Exception("没获取到真实下单位") |
| | | trade_queue = l2_output_util.get_trade_queue(code, real_place_order_index, count) |
| | | self.send_response({"code": 0, "data": trade_queue}, client_id, request_id) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | self.send_response({"code": 1, "msg": f"数据处理出错:{e}"}, client_id, request_id) |