| | |
| | | import limit_up_time_manager |
| | | |
| | | |
| | | # 下单参数 |
| | | class L2PlaceOrderParamsManager: |
| | | # 获取信号连续买笔数 |
| | | @staticmethod |
| | | def get_begin_continue_buy_count(volume_rate_index): |
| | | counts = [3, 3, 3, 2, 2, 2, 2] |
| | | if volume_rate_index >= len(counts): |
| | | volume_rate_index = -1 |
| | | return counts[volume_rate_index] |
| | | |
| | | # 获取时间计算范围,返回s |
| | | @staticmethod |
| | | def get_time_range(volume_rate_index): |
| | | 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 = -1 |
| | | return ts[volume_rate_index] |
| | | |
| | | # 获取需要的大单个数 |
| | | @staticmethod |
| | | def get_big_num_count(volume_rate_index): |
| | | counts = [4, 3, 2, 1, 1, 1, 1] |
| | | if volume_rate_index >= len(counts): |
| | | volume_rate_index = -1 |
| | | return counts[volume_rate_index] |
| | | |
| | | # 获取安全笔数影响比例 |
| | | @staticmethod |
| | | def get_safe_count_rate(volume_rate_index): |
| | | 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 = -1 |
| | | return rates[volume_rate_index] |
| | | |
| | | # 获取m值影响比例 |
| | | @staticmethod |
| | | def get_m_val_rate(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] |
| | | |
| | | |
| | | # S撤参数 |
| | | class SCancelParamsManager: |
| | | # 剔除前几的点火大单 |
| | | @staticmethod |
| | | def get_max_exclude_count(volume_rate_index): |
| | | counts = [5, 4, 3, 2, 1, 1, 1, 1] |
| | | if volume_rate_index >= len(counts): |
| | | volume_rate_index = -1 |
| | | return counts[volume_rate_index] |
| | | |
| | | # 获取买时间范围(距离执行位),返回s |
| | | @staticmethod |
| | | def get_buy_time_range(volume_rate_index): |
| | | seconds = [pow(2, 1), pow(2, 2), pow(2, 3), pow(2, 4), pow(2, 4), pow(2, 5), pow(2, 6), pow(2, 6)] |
| | | if volume_rate_index >= len(seconds): |
| | | volume_rate_index = -1 |
| | | return seconds[volume_rate_index] |
| | | |
| | | # 获取撤销比例 |
| | | @staticmethod |
| | | def get_cancel_rate(volume_rate_index): |
| | | rates = [0.39, 0.49, 0.59, 0.69, 0.69, 0.79, 0.79, 0.79] |
| | | if volume_rate_index >= len(rates): |
| | | volume_rate_index = -1 |
| | | return rates[volume_rate_index] |
| | | |
| | | |
| | | # H撤参数 |
| | | class HCancelParamsManager: |
| | | |
| | | # 获取最大的观察笔数 |
| | | @staticmethod |
| | | def get_max_watch_count(volume_rate_index): |
| | | counts = [40, 36, 32, 28, 24, 20, 16, 12] |
| | | if volume_rate_index >= len(counts): |
| | | volume_rate_index = -1 |
| | | return counts[volume_rate_index] |
| | | |
| | | # 获取撤销比例 |
| | | @staticmethod |
| | | def get_cancel_rate(volume_rate_index): |
| | | rates = [0.39, 0.49, 0.59, 0.69, 0.69, 0.79, 0.79, 0.79] |
| | | if volume_rate_index >= len(rates): |
| | | volume_rate_index = -1 |
| | | return rates[volume_rate_index] |
| | | |
| | | |
| | | class L2TradeFactorUtil: |
| | | # 获取基础m值,返回单位为元 |
| | | @classmethod |
| | |
| | | if yi < 1: |
| | | yi = 1 |
| | | m = 5000000 + (yi - 1) * 500000 |
| | | return round(m * 0.7) |
| | | return round(m) |
| | | |
| | | # 获取行业影响比例 |
| | | # total_limit_percent为统计的比例之和乘以100 |
| | |
| | | return zyltgb |
| | | |
| | | @classmethod |
| | | def compute_m_value(cls, code): |
| | | def compute_m_value(cls, code,volume_rate): |
| | | zyltgb = global_util.zyltgb_map.get(code) |
| | | if zyltgb is None: |
| | | global_data_loader.load_zyltgb() |
| | |
| | | print("没有获取到自由流通市值") |
| | | return 10000000, "" |
| | | zyltgb = cls.get_base_safe_val(zyltgb) |
| | | rate, msg = cls.compute_rate_by_code(code) |
| | | # 暂时注释 |
| | | # rate, msg = cls.compute_rate_by_code(code) |
| | | # print("m值获取:", code, round(zyltgb * rate)) |
| | | return round(zyltgb * rate), msg |
| | | rate = L2PlaceOrderParamsManager.get_m_val_rate(volume_rate) |
| | | |
| | | @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] |
| | | return round(zyltgb * (1+rate)), "" |
| | | |
| | | # 获取安全笔数 |
| | | @classmethod |
| | |
| | | # 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_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)) |
| | | for i in range(2, 151): |
| | | print(i, L2TradeFactorUtil.get_base_safe_val(100000000 * i)) |
| | | # 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")) |