| | |
| | | total_deal_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1] // 100) |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | deal_money = int(total_deal_num * float(limit_up_price) * 100) |
| | | if deal_money >= order_position.sell_info[1] * 2 and order_position.sell_info[1] > 500*10000: |
| | | if deal_money >= order_position.sell_info[1] * 2 and order_position.sell_info[1] > 1000*10000: |
| | | return True, f"成交金额:{deal_money}/{order_position.sell_info[1] * 2}" |
| | | return False, "成交金额不满足" |
| | | except Exception as e: |
| | |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | if limit_up_price is None: |
| | | raise Exception("涨停价无法获取") |
| | | limit_up_price = float(limit_up_price) |
| | | |
| | | threshold_num = None |
| | | # 大目标手数(满足这个就不需要看安全笔数) |
| | | threshold_max_num = None |
| | | |
| | | # 目标订单数量 |
| | | threshold_count = cls.__l2PlaceOrderParamsManagerDict[code].get_safe_count() |
| | | |
| | | # 最大间隔时间ms |
| | | max_space_time_ms = cls.__l2PlaceOrderParamsManagerDict[code].get_time_range() * 1000 |
| | | |
| | | # ----------------调整板上下单的m值与安全笔数---------------- |
| | | if at_limit_up: |
| | | # 板上买,获取最近一次闪电下单的总卖额 |
| | |
| | | # 总卖的一半作为m值 |
| | | threshold_num = int(sell_data[1] / (limit_up_price * 100)) // 2 |
| | | threshold_max_num = 1 |
| | | # 信号为之前有待成交的大单(不是正在成交) |
| | | trade_index,is_default = cls.__TradeBuyQueue.get_traded_index(code) |
| | | if not is_default and trade_index is not None: |
| | | temp_big_num = int(30000/limit_up_price) |
| | | for i in range(trade_index+1, buy_single_index): |
| | | data = total_datas[i] |
| | | val = data['val'] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | # 判断是否有大单未成交 |
| | | if temp_big_num > val["num"]: |
| | | continue |
| | | |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | data[ |
| | | "index"], |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | # 安全笔数与囊括时间范围修改 |
| | | threshold_count = 3 |
| | | max_space_time_ms = 9*1000 |
| | | break |
| | | |
| | | |
| | | |
| | | if not threshold_num: |
| | | # 目标手数 |
| | |
| | | threshold_max_num = int(threshold_num * 1.2) |
| | | |
| | | # place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code) |
| | | # 目标订单数量 |
| | | threshold_count = cls.__l2PlaceOrderParamsManagerDict[code].get_safe_count() |
| | | |
| | | |
| | | # buy_single_time_seconds = L2DataUtil.get_time_as_second(total_datas[buy_single_index]["val"]["time"]) |
| | | |
| | | # 可以触发买,当有涨停买信号时才会触发买 |
| | | trigger_buy = True |
| | | |
| | | # 最大间隔时间ms |
| | | max_space_time_ms = cls.__l2PlaceOrderParamsManagerDict[code].get_time_range() * 1000 |
| | | |
| | | # 如果大单含有率大于50%,则时间囊括范围提高到3s |
| | | if max_num_set and origin_count: |
| | | if len(max_num_set) / origin_count > 0.5: |
| | |
| | | filter=lambda record: record["extra"].get("name") == "kpl_block_can_buy", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | logger.add(self.get_path("kpl", "kpl_open_limit_up"), |
| | | filter=lambda record: record["extra"].get("name") == "kpl_open_limit_up", |
| | | rotation="00:00", compression="zip", enqueue=True) |
| | | |
| | | # 看盘日志 |
| | | logger.add(self.get_path("kp", "kp_msg"), |
| | | filter=lambda record: record["extra"].get("name") == "kp_msg", |
| | |
| | | |
| | | logger_kpl_block_can_buy = __mylogger.get_logger("kpl_block_can_buy") |
| | | |
| | | logger_kpl_open_limit_up = __mylogger.get_logger("kpl_open_limit_up") |
| | | |
| | | logger_kp_msg = __mylogger.get_logger("kp_msg") |
| | | |
| | | logger_redis_debug = __mylogger.get_logger("redis_debug") |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | close_print() |
| | | logger_local_huaxin_l1.info("测试") |
| | | input() |
| | | open_limit_up_codes = set({"000333","000222"}) |
| | | logger_kpl_open_limit_up.info(f"炸板代码:{open_limit_up_codes}") |
| | |
| | | return fdatas |
| | | |
| | | |
| | | def load_kpl_open_limit_up(): |
| | | path = f"{constant.get_path_prefix()}/logs/gp/kpl/kpl_open_limit_up.{tool.get_now_date_str()}.log" |
| | | fdatas = [] |
| | | lines = __load_file_content(path) |
| | | for line in lines: |
| | | if line.find("炸板") > 0: |
| | | time_str = __get_log_time(line) |
| | | data = line[line.find(":") + 1:] |
| | | codes = eval(data) |
| | | fdatas.append((time_str, codes)) |
| | | return fdatas |
| | | |
| | | # 加载华鑫本地买入订单号 |
| | | def load_huaxin_local_buy_no(): |
| | | path = f"{constant.get_path_prefix()}/logs/huaxin_local/l2/l2_buy_no.{tool.get_now_date_str()}.log" |
| | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | fdatas = get_l2_cant_buy_reasons("002731") |
| | | fdatas = load_kpl_open_limit_up() |
| | | print(len(fdatas)) |
| | | # print(get_h_cancel_compute_info("603912")) |
| | | |
| | |
| | | code_info[5] = 1 |
| | | |
| | | response_data = json.dumps({"code": 0, "data": codes_info}) |
| | | elif url.path == "/kpl/get_open_limit_up_count_rank": |
| | | # 获取炸板次数排行 |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) |
| | | code = ps_dict.get("code") |
| | | results = log_export.load_kpl_open_limit_up() |
| | | statistic = {} |
| | | for result in results: |
| | | for c in result[1]: |
| | | if code and code != c: |
| | | continue |
| | | if c not in statistic: |
| | | statistic[c] = 0 |
| | | statistic[c] += 1 |
| | | # 倒序排 |
| | | statistic_list = [(k, statistic[k]) for k in statistic] |
| | | statistic_list.sort(key=lambda x: x[1], reverse=True) |
| | | fresults = [] |
| | | for x in statistic_list: |
| | | fresults.append((x[0], gpcode_manager.get_code_name(x[0]), x[1])) |
| | | response_data = json.dumps({"code": 0, "data": fresults}) |
| | | elif url.path == "/get_h_cancel_data": |
| | | ps_dict = dict([(k, v[0]) for k, v in parse_qs(url.query).items()]) |
| | | code = ps_dict["code"] |
| | |
| | | |
| | | # 开盘啦历史涨停数据管理 |
| | | from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up |
| | | from log_module.log import logger_kpl_limit_up_reason_change, logger_debug, logger_kpl_limit_up, \ |
| | | logger_kpl_open_limit_up |
| | | from third_data import kpl_util, kpl_api |
| | | from third_data.code_plate_key_manager import LimitUpCodesPlateKeyManager, CodesHisReasonAndBlocksManager |
| | | |
| | |
| | | |
| | | @classmethod |
| | | def save_record(cls, day, records): |
| | | # 统计炸板 |
| | | try: |
| | | last_codes = set() |
| | | if cls.latest_origin_datas: |
| | | last_codes = set([x[0] for x in cls.latest_origin_datas]) |
| | | now_codes = set() |
| | | if records: |
| | | now_codes = set([x[0] for x in records]) |
| | | open_limit_up_codes = last_codes - now_codes |
| | | if open_limit_up_codes: |
| | | logger_kpl_open_limit_up.info(f"炸板代码:{open_limit_up_codes}") |
| | | except Exception as e: |
| | | pass |
| | | |
| | | # 统计代码所属板块 |
| | | code_block_dict = {} |
| | | for data in records: |
| | |
| | | code_block_dict[code] = set() |
| | | code_block_dict[code].add(b) |
| | | # 设置涨停数据 |
| | | |
| | | if records: |
| | | cls.latest_origin_datas = records |
| | | cls.__LimitUpCodesPlateKeyManager.set_today_limit_up([(r[0], r[5]) for r in records]) |