From 8535f56dbf6e410b4a09f02f95d4d49bcc8753f2 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 27 三月 2023 18:58:54 +0800 Subject: [PATCH] 看盘页面数据调整 --- trade/l2_trade_factor.py | 98 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 80 insertions(+), 18 deletions(-) diff --git a/trade/l2_trade_factor.py b/trade/l2_trade_factor.py index 9aec3cb..1702ab7 100644 --- a/trade/l2_trade_factor.py +++ b/trade/l2_trade_factor.py @@ -13,45 +13,105 @@ # 涓嬪崟鍙傛暟 class L2PlaceOrderParamsManager: + + # 寰楀垎 + def __init__(self, code, is_first_code, volume_rate, volume_rate_index, score): + self.code = code + self.is_first_code = is_first_code + score_ranks = [200, 190, 180, 100] + self.score = score[0] + # 涓哄垎鏁拌缃瓑绾� + score_index = -1 + for i in range(0, len(score_ranks)): + if self.score >= score_ranks[i]: + score_index = i + break + self.score_index = score_index + self.volume_rate = volume_rate + self.volume_rate_index = volume_rate_index + # 鑾峰彇淇″彿杩炵画涔扮瑪鏁� - @staticmethod - def get_begin_continue_buy_count(volume_rate_index): + + def get_begin_continue_buy_count(self): counts = [3, 3, 3, 2, 2, 2, 2] - if volume_rate_index >= len(counts): + volume_rate_index = self.volume_rate_index + if self.volume_rate_index >= len(counts): volume_rate_index = -1 return counts[volume_rate_index] # 鑾峰彇鏃堕棿璁$畻鑼冨洿锛岃繑鍥瀞 - @staticmethod - def get_time_range(volume_rate_index): + def get_time_range(self): ts = [pow(3, 1), pow(3, 1), pow(3, 1), pow(3, 2), pow(3, 2), pow(3, 3), pow(3, 3), pow(3, 3)] - if volume_rate_index >= len(ts): + volume_rate_index = self.volume_rate_index + if self.volume_rate_index >= len(ts): volume_rate_index = -1 return ts[volume_rate_index] # 鑾峰彇闇�瑕佺殑澶у崟涓暟 - @staticmethod - def get_big_num_count(volume_rate_index): + def get_big_num_count(self): + if self.is_first_code: + if self.score_index == 0: + return 0 + elif self.score_index == 1: + return 0 + elif self.score_index == 2: + return 1 + elif self.score_index < 0: + return 65535 counts = [3, 1, 1, 1, 0, 0, 0, 0] - if volume_rate_index >= len(counts): + volume_rate_index = self.volume_rate_index + if self.volume_rate_index >= len(counts): volume_rate_index = -1 return counts[volume_rate_index] # 鑾峰彇瀹夊叏绗旀暟褰卞搷姣斾緥 - @staticmethod - def get_safe_count_rate(volume_rate_index): + def get_safe_count_rate(self): rates = [0, -0.1, -0.2, -0.4, -0.6, -0.8, -0.8, -0.8] - if volume_rate_index >= len(rates): + volume_rate_index = self.volume_rate_index + if self.volume_rate_index >= len(rates): volume_rate_index = -1 return rates[volume_rate_index] + def get_safe_count(self): + if self.is_first_code: + if 3 > self.score_index > -1: + return 0 + elif self.score_index < 0: + return 65535 + base_count, min_count, max_count = L2TradeFactorUtil.get_safe_buy_count(self.code, True) + rate = self.get_safe_count_rate() + count = int(round(base_count * (1 + rate))) + return count + # 鑾峰彇m鍊煎奖鍝嶆瘮渚� - @staticmethod - def get_m_val_rate(volume_rate_index): + @classmethod + def get_m_val_rate(cls, volume_rate_index): rates = [0.0, 0.0, 0.0, -0.3, -0.4, -0.5, -0.6, -0.7] if volume_rate_index >= len(rates): volume_rate_index = -1 return rates[volume_rate_index] + + # 鑾峰彇m鍊� + def get_m_val(self): + if self.is_first_code: + if self.score_index == 0: + return 0, "" + elif self.score_index == 1: + return 1000 * 10000, "" + elif self.score_index == 2: + return 1000 * 10000, "" + elif self.score_index < 0: + return 65535 * 10000, "" + # 鑾峰彇鍥哄畾m鍊� + zyltgb = global_util.zyltgb_map.get(self.code) + if zyltgb is None: + global_data_loader.load_zyltgb() + zyltgb = global_util.zyltgb_map.get(self.code) + + base_m = L2TradeFactorUtil.get_base_safe_val(zyltgb) + rate = self.get_m_val_rate(self.volume_rate_index) + m = round(base_m * (1 + rate)) + return m, "" # S鎾ゅ弬鏁� @@ -105,11 +165,13 @@ # 鑾峰彇鍩虹m鍊硷紝杩斿洖鍗曚綅涓哄厓 @classmethod def get_base_safe_val(cls, zyltgb): + if zyltgb is None: + return 10000000 yi = round(zyltgb / 100000000) if yi < 1: yi = 1 m = 5000000 + (yi - 1) * 500000 - return round(m*(1-0.3)) + return round(m * (1 - 0.3)) # 鑾峰彇琛屼笟褰卞搷姣斾緥 # total_limit_percent涓虹粺璁$殑姣斾緥涔嬪拰涔樹互100 @@ -144,8 +206,8 @@ if today is None: return 0 old_volumn = int(yest) - if int(day60_max) > int(yest): - old_volumn = int(day60_max) + if int(day60_max[0]) > int(yest): + old_volumn = int(day60_max[0]) r = round(int(today) / old_volumn, 2) if r < 0.01: r = 0.01 @@ -325,7 +387,7 @@ MAX_VAL = 13 if not gb: # 榛樿8绗� - return MIN_VAL + return MIN_VAL,MIN_VAL, MAX_VAL count = gb // 100000000 if True: if count < 8: -- Gitblit v1.8.0