| | |
| | | |
| | | # 下单参数 |
| | | 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] |
| | | |
| | | # 获取时间计算范围,返回s |
| | | @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撤参数 |
| | |
| | | # 获取基础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 |
| | |
| | | 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 |
| | |
| | | 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: |