| | |
| | | p11 = __is_latest_open_limit_up(code, record_datas, 5) |
| | | # 90天内是否有涨停 |
| | | p12 = __has_limit_up(code, record_datas, 90) |
| | | # 最近5天是否跌停 |
| | | p13 = __is_latest_limit_down(code, record_datas, 5) |
| | | # 上个交易日是否跌幅过大 |
| | | p13 = __is_pre_day_limit_rate_too_low(code, record_datas) |
| | | # 60个交易日是否曾涨停 |
| | | p14 = __has_limited_up(code, record_datas, 60) |
| | | # 昨日是否涨停过 |
| | |
| | | return False |
| | | |
| | | |
| | | def __is_pre_day_limit_rate_too_low(code, datas): |
| | | """ |
| | | 上个交易日是否跌幅过大 |
| | | @param code: |
| | | @param datas: |
| | | @return: |
| | | """ |
| | | datas = copy.deepcopy(datas) |
| | | datas.sort(key=lambda x: x["bob"]) |
| | | items = datas[-1:] |
| | | for item in items: |
| | | # 是否有跌停 |
| | | # 获取当日涨幅 |
| | | rate = (item["close"] - item["pre_close"])/item["pre_close"] |
| | | threshold_rate_ = round(0 - ((1 - tool.get_limit_down_rate(code))*0.9), 2) |
| | | if rate < threshold_rate_: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # V字形 |
| | | def __is_v_model(code, datas): |
| | | datas = copy.deepcopy(datas) |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | HighIncreaseCodeManager().add_code("000333") |
| | | print(HighIncreaseCodeManager().is_in("000333")) |
| | | print(HighIncreaseCodeManager().is_in("000222")) |
| | | code = "000333" |
| | | threshold_rate = 0 - ((1 - tool.get_limit_down_rate(code)) * 0.9) |
| | | print(threshold_rate) |
| | |
| | | class CodesNameManager: |
| | | __mysqldb = Mysqldb() |
| | | __code_name_dict = {} |
| | | __instance = None |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | | cls.__instance = super(CodesNameManager, cls).__new__(cls, *args, **kwargs) |
| | | cls.__load_data() |
| | | return cls.__instance |
| | | |
| | | @classmethod |
| | | def __load_data(cls): |
| | | cls.__code_name_dict = cls.list_code_name_dict() |
| | | |
| | | @classmethod |
| | | def list_code_name_dict(cls): |
| | |
| | | # 想要买的代码 |
| | | class WantBuyCodesManager: |
| | | __instance = None |
| | | __db = 0 |
| | | redisManager = redis_manager.RedisManager(0) |
| | | __redis_key = "want_buy_codes" |
| | | |
| | |
| | | |
| | | def remove_code(self, code): |
| | | self.__want_buy_codes_cache.discard(code) |
| | | RedisUtils.srem(self.__get_redis(), self.__redis_key, code) |
| | | RedisUtils.srem_async(self.__db, self.__redis_key, code) |
| | | |
| | | def sync(self): |
| | | codes = self.list_code() |
| | |
| | | |
| | | def remove_code(self, code): |
| | | self.__codes_set.discard(code) |
| | | RedisUtils.srem(self.__get_redis(), "green-trade-codes", code) |
| | | RedisUtils.srem_async(self.__db, "green-trade-codes", code) |
| | | |
| | | def is_in(self, code): |
| | | return RedisUtils.sismember(self.__get_redis(), "green-trade-codes", code) |
| | |
| | | |
| | | # 获取代码的名称 |
| | | def get_code_name(code): |
| | | return CodesNameManager.get_code_name(code) |
| | | return CodesNameManager().get_code_name(code) |
| | | |
| | | |
| | | def get_name_codes(): |
| | |
| | | return False, True, f"14:57后不能交易", True |
| | | |
| | | if cls.__TradeTargetCodeModeManager.get_mode_cache() == TradeTargetCodeModeManager.MODE_ONLY_BUY_WANT_CODES: |
| | | if not cls.__WantBuyCodesManager.is_in_cache(code) and not gpcode_manager.GreenListCodeManager().is_in_cache(code): |
| | | if not cls.__WantBuyCodesManager.is_in_cache( |
| | | code) and not gpcode_manager.GreenListCodeManager().is_in_cache(code): |
| | | return False, True, f"只买想买:没在想买单和绿单", True |
| | | |
| | | return True, False, f"", False |
| | |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | # 是否有辨识度 |
| | | is_special = True if k_format and k_format[8][0] else False |
| | | # 上5个交易日有炸板之后 |
| | | has_open_limit_up_in_5 = True if k_format and len(k_format) >= 11 and k_format[10] else False |
| | | # 上5个交易日有跌停 |
| | | has_limit_down_in_5 = True if k_format and len(k_format) >= 13 and k_format[12] else False |
| | | |
| | | # 是否是强势10分钟 |
| | | is_in_strong_time = now_timestamp <= int("094000") |
| | | # 是否是强势30分钟 |
| | |
| | | max_num_set=set(), |
| | | buy_volume_rate=buy_volume_rate, |
| | | mode=OrderBeginPosInfo.MODE_RADICAL, |
| | | mode_desc="总抛压小扫入", |
| | | mode_desc=f"总抛压小扫入", |
| | | sell_info=sell_info, |
| | | threshold_money=threshold_money) |
| | | order_begin_pos_info.at_limit_up = cls.__is_at_limit_up_buy(code) |
| | |
| | | @param end_index: |
| | | @return: (是否获取到信号, 信号位置, 消息) |
| | | """ |
| | | |
| | | # 激进买信号的时间 |
| | | |
| | | def __can_order(): |
| | | # 判断是否是板上放量 |
| | | if cls.__is_at_limit_up_buy(code, start_index): |
| | | return False, None, "板上放量" |
| | | total_datas = local_today_datas[code] |
| | | min_num = int(29900 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | # 如果有大单成交就不需要看大单 |
| | | deal_money_list = BigOrderDealManager().get_total_buy_money_list(code) |
| | | if deal_money_list: |
| | | for m in deal_money_list: |
| | | if m >= 2990000: |
| | | min_num = int(5000 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | break |
| | | |
| | | single_index = None |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | single_index = i |
| | | break |
| | | if single_index is not None: |
| | | return True, single_index, "有大单" |
| | | return False, None, "无大单" |
| | | |
| | | radical_data = RadicalBuyDealCodesManager.buy_by_l2_delegate_expire_time_dict.get(code) |
| | | if not radical_data: |
| | | return False, None, "不满足激进买的条件" |
| | | if t.time() > radical_data[0]: |
| | | return False, None, "超过生效时间" |
| | | |
| | | # 判断是否是板上放量 |
| | | if cls.__is_at_limit_up_buy(code, start_index): |
| | | return False, None, "板上放量" |
| | | total_datas = local_today_datas[code] |
| | | min_num = int(29900 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | # 如果有大单成交就不需要看大单 |
| | | deal_money_list = BigOrderDealManager().get_total_buy_money_list(code) |
| | | if deal_money_list: |
| | | for m in deal_money_list: |
| | | if m >= 2990000: |
| | | min_num = int(5000 / gpcode_manager.get_limit_up_price_as_num(code)) |
| | | break |
| | | |
| | | single_index = None |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] < min_num: |
| | | continue |
| | | if int(val["orderNo"]) <= radical_data[1]: |
| | | # 主动买单后的数据不算 |
| | | continue |
| | | single_index = i |
| | | break |
| | | if single_index is not None: |
| | | return True, single_index, "有大单" |
| | | return False, None, "无大单" |
| | | result = __can_order() |
| | | l2_log.debug(code, f"L2扫入判断:{result}") |
| | | return result |
| | | |
| | | @classmethod |
| | | def test__compute_active_order_begin_pos(cls, code, continue_count, start_index, end_index): |
| | |
| | | from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer |
| | | from code_attribute import gpcode_manager, code_volumn_manager, global_data_loader, zyltgb_util, code_nature_analyse |
| | | from code_attribute.code_l1_data_manager import L1DataManager |
| | | from code_attribute.gpcode_manager import CodePrePriceManager |
| | | from code_attribute.gpcode_manager import CodePrePriceManager, CodesNameManager |
| | | from huaxin_client import l2_data_transform_protocol |
| | | from huaxin_client.trade_transform_protocol import TradeResponse |
| | | from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, transaction_progress, \ |
| | |
| | | # 获取level1的代码 |
| | | list_ = JueJinApi.get_exchanges_codes(["SHSE", "SZSE"]) |
| | | fdatas = [] |
| | | code_name_map = {} |
| | | for d in list_: |
| | | if not tool.is_target_code(d["sec_id"]): |
| | | continue |
| | |
| | | days=100)).timestamp() > datetime.datetime.now().timestamp(): |
| | | continue |
| | | fdatas.append(d["sec_id"]) |
| | | code_name_map[d["sec_id"]] = d["sec_name"] |
| | | # 保存代码名称 |
| | | for k in code_name_map: |
| | | CodesNameManager.add_code_name(k, code_name_map[k]) |
| | | |
| | | sk.sendall( |
| | | socket_util.load_header(json.dumps({"code": 0, "data": fdatas}).encode(encoding='utf-8'))) |
| | | |
| | |
| | | zyltgb_as_yi = round(zyltgb / 100000000, 2) |
| | | if zyltgb_as_yi > constant.MAX_CODE_RADICAL_BUY_ZYLTGB_AS_YI: |
| | | return False, "自由流通市值过大" |
| | | elif zyltgb_as_yi < constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI: |
| | | elif zyltgb_as_yi < constant.MIN_CODE_RADICAL_BUY_ZYLTGB_AS_YI: |
| | | return False, "自由流通市值过小" |
| | | # 判断昨日是否跌幅过大 |
| | | k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code) |
| | | if k_format and len(k_format) > 12 and k_format[12]: |
| | | return False, "上个交易日跌幅过大" |
| | | |
| | | if gpcode_manager.BlackListCodeManager().is_in_cache(code): |
| | | if deal_codes is not None and code in deal_codes: |
| | | pass |
| | |
| | | cls.__deal_big_order_nos_dict[code].clear() |
| | | |
| | | @classmethod |
| | | def add_big_buy_order_deal(cls, code, order_nos:list): |
| | | def add_big_buy_order_deal(cls, code, order_nos: list): |
| | | if code not in cls.__deal_big_order_nos_dict: |
| | | cls.__deal_big_order_nos_dict[code] = set() |
| | | for order_no in order_nos: |
| | |
| | | from cancel_strategy.s_l_h_cancel_strategy import HourCancelBigNumComputer |
| | | from cancel_strategy.s_l_h_cancel_strategy import LCancelBigNumComputer |
| | | from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer |
| | | from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager |
| | | from code_attribute.gpcode_manager import MustBuyCodesManager, GreenListCodeManager, WantBuyCodesManager |
| | | from l2 import l2_data_manager, place_order_single_data_manager |
| | | from l2.cancel_buy_strategy import FCancelBigNumComputer, \ |
| | | NewGCancelBigNumComputer, JCancelBigNumComputer, NBCancelBigNumComputer |
| | |
| | | __latest_cancel_l2_data_dict[code] = total_datas[-1] |
| | | |
| | | # 撤单成功需要移除红名单 |
| | | if not GreenListCodeManager().is_in_cache(code): |
| | | if GreenListCodeManager().is_in_cache(code): |
| | | GreenListCodeManager().remove_code(code) |
| | | if WantBuyCodesManager().is_in_cache(code): |
| | | WantBuyCodesManager().remove_code(code) |
| | | if MustBuyCodesManager().is_in_cache(code): |
| | | MustBuyCodesManager().remove_code(code) |
| | | |
| | | |
| | |
| | | if code not in __latest_cancel_l2_data_dict: |
| | | return True |
| | | threshold_time_space = buy_condition_util.get_cancel_and_buy_space_time(code) |
| | | if L2DataUtil.time_sub_as_ms(buy_exec_data["val"], __latest_cancel_l2_data_dict[code]["val"]) >= threshold_time_space: |
| | | if L2DataUtil.time_sub_as_ms(buy_exec_data["val"], |
| | | __latest_cancel_l2_data_dict[code]["val"]) >= threshold_time_space: |
| | | return True |
| | | return False |
| | | |