From f03eb72394a3fac097bb3ab1f956a83f99f7bd0e Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 03 十一月 2022 17:11:37 +0800 Subject: [PATCH] 优化撤单与动态m值计算 --- l2_trade_factor.py | 58 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 28 deletions(-) diff --git a/l2_trade_factor.py b/l2_trade_factor.py index 0694c38..906b5df 100644 --- a/l2_trade_factor.py +++ b/l2_trade_factor.py @@ -16,12 +16,15 @@ yi = round(zyltgb / 100000000) if yi < 1: yi = 1 - return 5000000 + (yi - 1) * 500000 + m = 5000000 + (yi - 1) * 500000 + return round(m * 0.7) # 鑾峰彇琛屼笟褰卞搷姣斾緥 # total_limit_percent涓虹粺璁$殑姣斾緥涔嬪拰涔樹互100 @classmethod def get_industry_rate(cls, total_limit_percent): + if total_limit_percent is None: + return 0 t = total_limit_percent / 10 if t < 0.9: return 0 @@ -29,26 +32,15 @@ return 0.2 elif t <= 1.6: return 0 - elif t <= 2.1: - return 0.03 - elif t <= 2.6: - return 0.06 - elif t <= 3.1: - return 0.09 - elif t <= 3.6: - return 0.12 - elif t <= 4.1: - return 0.15 - elif t <= 4.6: - return 0.18 - elif t <= 5.1: - return 0.21 - elif t <= 5.6: - return 0.24 - elif t <= 6.1: - return 0.27 else: - return 0.30 + rate = 0 + for i in range(0, 30): + if t <= 2.1 + 0.5 * i: + rate = 0.03 * (i + 1) + break + if rate > 0.9: + rate = 0.9 + return rate # 鑾峰彇閲忓奖鍝嶆瘮渚� @classmethod @@ -138,9 +130,9 @@ factors = cls.__get_rate_factors(code) return cls.compute_rate(factors[0], factors[1], factors[2], factors[3], factors[4], factors[5], factors[6]) + # 鑾峰彇浠g爜褰撳墠鎵�鍦ㄧ殑琛屼笟鐑害 @classmethod - def __get_rate_factors(cls, code): - zyltgb = global_util.zyltgb_map.get(code) + def __get_industry_limit_percent(cls, code): # 鑾峰彇琛屼笟鐑害 industry = global_util.code_industry_map.get(code) if industry is None: @@ -149,10 +141,16 @@ total_industry_limit_percent = global_util.industry_hot_num.get(industry) if industry is not None else None # 褰撳墠绁ㄦ槸鍚︽定鍋� - if total_industry_limit_percent is not None: - if code in global_util.limit_up_codes_percent: - total_industry_limit_percent -= global_util.limit_up_codes_percent[code] + # if total_industry_limit_percent is not None: + # if code in global_util.limit_up_codes_percent: + # # 鍑忓幓褰撳墠绁ㄧ殑娑ㄥ箙 + # total_industry_limit_percent -= global_util.limit_up_codes_percent[code] + return total_industry_limit_percent + @classmethod + def __get_rate_factors(cls, code): + zyltgb = global_util.zyltgb_map.get(code) + total_industry_limit_percent = cls.__get_industry_limit_percent(code) # 鑾峰彇閲� volumn_day60_max, volumn_yest, volumn_today = global_util.max60_volumn.get( code), global_util.yesterday_volumn.get(code), global_util.today_volumn.get(code) @@ -208,9 +206,9 @@ return 8 count = gb // 100000000 if count > 30: - return 30 + count = 30 if count < 5: - return 5 + count = 5 big_money_num = global_util.big_money_num.get(code) if big_money_num is None: @@ -219,7 +217,11 @@ if big_money_num is not None: rate = cls.get_big_money_rate(big_money_num) - return round(count*(1-rate/2)) + # 鑾峰彇琛屼笟鐑害瀵瑰簲鐨勬瘮渚� + total_industry_limit_percent = cls.__get_industry_limit_percent(code) + industry_rate = cls.get_industry_rate(total_industry_limit_percent) + # 鍙栧ぇ鍗曞奖鍝嶅�间笌琛屼笟褰卞搷鍊肩殑杈冨ぇ鍊� + return round(count * (1 - max(rate, industry_rate))) # l2鍥犲瓙褰掑洜鏁版嵁 -- Gitblit v1.8.0