| | |
| | | # l2交易因子 |
| | | |
| | | import big_money_num_manager |
| | | import constant |
| | | import global_data_loader |
| | | import global_util |
| | | import limit_up_time_manager |
| | |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb is None: |
| | | print("没有获取到自由流通市值") |
| | | return 10000000 |
| | | return 10000000, "" |
| | | zyltgb = cls.get_base_safe_val(zyltgb) |
| | | rate, msg = cls.compute_rate_by_code(code) |
| | | # print("m值获取:", code, round(zyltgb * rate)) |
| | | return round(zyltgb * rate), msg |
| | | |
| | | @classmethod |
| | | def get_h_cancel_min_count(cls, code): |
| | | volumn_day60_max, volumn_yest, volumn_today = cls.__get_volumns(code) |
| | | if volumn_day60_max is None or volumn_yest is None or volumn_today is None: |
| | | return constant.H_CANCEL_MIN_COUNT |
| | | rate = round(int(volumn_today) / max(int(volumn_day60_max), int(volumn_yest)), 2) |
| | | counts = [40, 36, 32, 28, 24, 20, 16] |
| | | rates = [0.3, 0.55, 0.8, 1.05, 1.3, 1.55, 10] |
| | | for index in range(0,len(rates)): |
| | | if rate < rates[index]: |
| | | return counts[index] |
| | | return counts[0] |
| | | |
| | | # 获取安全笔数 |
| | | @classmethod |
| | | def get_safe_buy_count(cls, code): |
| | | def get_safe_buy_count(cls, code, is_first=False): |
| | | gb = cls.get_zyltgb(code) |
| | | return cls.get_safe_buy_count_by_gp(gb, is_first) |
| | | |
| | | @classmethod |
| | | def get_safe_buy_count_by_gp(cls, gb, is_first=False): |
| | | MIN_VAL = 8 |
| | | MAX_VAL = 16 |
| | | if is_first: |
| | | MIN_VAL = 5 |
| | | MAX_VAL = 13 |
| | | if not gb: |
| | | # 默认8笔 |
| | | return 8 |
| | | return MIN_VAL |
| | | count = gb // 100000000 |
| | | if count <= 6: |
| | | count = 8 |
| | | elif count < 32: |
| | | count = round(8 + 0.5 * (count - 6)) |
| | | else: |
| | | count = 21 |
| | | |
| | | # volumn_day60_max, volumn_yest, volumn_today = cls.__get_volumns(code) |
| | | # rate = cls.get_volumn_rate(volumn_day60_max, volumn_yest, volumn_today) |
| | | # 取大单影响值与行业影响值的较大值 |
| | | # count = round(count * (1 - rate)) |
| | | if count < 8: |
| | | count = 8 |
| | | elif count > 21: |
| | | count = 21 |
| | | return count |
| | | if True: |
| | | if count < 8: |
| | | count = MIN_VAL |
| | | elif count < 11: |
| | | count = MIN_VAL + 1 |
| | | elif count < 14: |
| | | count = MIN_VAL + 2 |
| | | elif count < 17: |
| | | count = MIN_VAL + 3 |
| | | elif count < 20: |
| | | count = MIN_VAL + 4 |
| | | elif count < 23: |
| | | count = MIN_VAL + 5 |
| | | elif count < 26: |
| | | count = MIN_VAL + 6 |
| | | elif count < 29: |
| | | count = MIN_VAL + 7 |
| | | else: |
| | | count = MAX_VAL |
| | | if count < MIN_VAL: |
| | | count = MIN_VAL |
| | | elif count > MAX_VAL: |
| | | count = MAX_VAL |
| | | return count, MIN_VAL, MAX_VAL |
| | | |
| | | |
| | | # l2因子归因数据 |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | print(L2TradeFactorUtil.get_safe_buy_count("003005")) |
| | | # print(L2TradeFactorUtil.get_safe_buy_count("003005")) |
| | | # print(L2TradeFactorUtil.get_rate_factors("003004")) |
| | | # print(L2TradeFactorUtil.factors_to_string("003004")) |
| | | print(L2TradeFactorUtil.get_safe_buy_count("002864")) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 4)) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 7)) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 10)) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 16)) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 22)) |
| | | print(L2TradeFactorUtil.get_safe_buy_count_by_gp(100000000 * 31)) |
| | | # print(L2TradeFactorUtil.get_limit_up_time_rate("11:30:00")) |
| | | # print(L2TradeFactorUtil.get_limit_up_time_rate("13:00:00")) |
| | | # print(L2TradeFactorUtil.get_limit_up_time_rate("13:48:00")) |