| | |
| | | fdata["delegates"]["sell"] = delegates[3] |
| | | deals = trade_data_manager.AccountMoneyManager().get_deal_count_info() |
| | | fdata["deals"] = {} |
| | | fdata["deals"]["stock"]={"count": deals[0][1], "price": 5, "money": round(5 * deals[0][1], 2)} |
| | | fdata["deals"]["sh_cb"]={"count": deals[1][1], "price": 1, "money": round(1 * deals[1][1], 2)} |
| | | fdata["deals"]["sz_cb"]={"count": deals[2][1], "price": 0, "money": round(0 * deals[2][1], 2)} |
| | | fdata["deals"]["stock"] = {"count": deals[0][1], "price": 5, "money": round(5 * deals[0][1], 2)} |
| | | fdata["deals"]["sh_cb"] = {"count": deals[1][1], "price": 1, "money": round(1 * deals[1][1], 2)} |
| | | fdata["deals"]["sz_cb"] = {"count": deals[2][1], "price": 0, "money": round(0 * deals[2][1], 2)} |
| | | fdata["commission"] = trade_data_manager.AccountMoneyManager().get_commission_cache() |
| | | response_data = json.dumps({"code": 0, "data": fdata}) |
| | | except Exception as e: |
| | |
| | | |
| | | self.__kplDataManager.save_data(type_, result_list) |
| | | elif type_ == KPLDataType.LIMIT_UP.value: |
| | | result_list = kpl_util.parseLimitUpData(data["data"]) |
| | | self.__data_process_thread_pool.submit(lambda: do_limit_up(result_list)) |
| | | # 记录涨停日志 |
| | | logger_kpl_limit_up.info(result_list) |
| | | result_list, day = kpl_util.parseLimitUpData(data["data"]) |
| | | if day and day != tool.get_now_date_str(): |
| | | pass |
| | | else: |
| | | self.__data_process_thread_pool.submit(lambda: do_limit_up(result_list)) |
| | | # 记录涨停日志 |
| | | logger_kpl_limit_up.info(result_list) |
| | | elif type_ == KPLDataType.OPEN_LIMIT_UP.value: |
| | | result_list = kpl_util.parseDaBanData(data["data"], kpl_util.DABAN_TYPE_OPEN_LIMIT_UP) |
| | | if result_list: |
| | |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from third_data import kpl_block_util, kpl_api, kpl_util, kpl_data_constant, huaxin_l1_data_manager |
| | | from settings.trade_setting import MarketSituationManager |
| | | from third_data.kpl_data_constant import LimitUpDataConstant |
| | | from third_data.kpl_data_constant import LimitUpDataConstant, LimitUpCodesBlockRecordManager |
| | | from third_data.third_blocks_manager import BlockMapManager, CodeThirdBlocksManager |
| | | from trade.buy_money_count_setting import RadicalBuyBlockCodeCountManager |
| | | from trade.order_statistic import DealAndDelegateWithBuyModeDataManager |
| | |
| | | @param code: |
| | | @return: 过滤后的板块,过滤前的板块 |
| | | """ |
| | | blocks = cls.get_code_kpl_blocks(code) |
| | | match_blocks, info = CodeThirdBlocksManager().get_intersection_blocks_info(code, blocks) |
| | | match_blocks -= constant.KPL_INVALID_BLOCKS |
| | | fblocks = match_blocks & RealTimeKplMarketData.get_top_market_jingxuan_blocks() |
| | | if not fblocks: |
| | | fblocks = set() |
| | | match_blocks_3, info = CodeThirdBlocksManager().get_intersection_blocks_info(code, blocks, same_count=3) |
| | | if match_blocks_3: |
| | | match_blocks_3 -= constant.KPL_INVALID_BLOCKS |
| | | fblocks |= match_blocks_3 |
| | | # 获取开盘啦历史涨停原因 |
| | | kpl_history_blocks = CodesHisReasonAndBlocksManager().get_history_blocks_cache(code) |
| | | if kpl_history_blocks: |
| | | fblocks |= BlockMapManager().filter_blocks(kpl_history_blocks) |
| | | jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks() |
| | | if jx_out_blocks: |
| | | fblocks -= jx_out_blocks |
| | | # blocks = cls.get_code_kpl_blocks(code) |
| | | # match_blocks, info = CodeThirdBlocksManager().get_intersection_blocks_info(code, blocks) |
| | | # match_blocks -= constant.KPL_INVALID_BLOCKS |
| | | # fblocks = match_blocks & RealTimeKplMarketData.get_top_market_jingxuan_blocks() |
| | | # if not fblocks: |
| | | # fblocks = set() |
| | | # match_blocks_3, info = CodeThirdBlocksManager().get_intersection_blocks_info(code, blocks, same_count=3) |
| | | # if match_blocks_3: |
| | | # match_blocks_3 -= constant.KPL_INVALID_BLOCKS |
| | | # fblocks |= match_blocks_3 |
| | | # # 获取开盘啦历史涨停原因 |
| | | # kpl_history_blocks = CodesHisReasonAndBlocksManager().get_history_blocks_cache(code) |
| | | # if kpl_history_blocks: |
| | | # fblocks |= BlockMapManager().filter_blocks(kpl_history_blocks) |
| | | # jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks() |
| | | # if jx_out_blocks: |
| | | # fblocks -= jx_out_blocks |
| | | # |
| | | # return fblocks, match_blocks |
| | | |
| | | return fblocks, match_blocks |
| | | # 新版本 |
| | | before_fblocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(code) |
| | | if before_fblocks: |
| | | before_fblocks = set() |
| | | fblocks = BlockMapManager().filter_blocks(before_fblocks) |
| | | if fblocks: |
| | | fblocks -= constant.KPL_INVALID_BLOCKS |
| | | return fblocks, before_fblocks |
| | | |
| | | @classmethod |
| | | def is_radical_buy(cls, code, yesterday_limit_up_codes): |
| | |
| | | msges.append(f"【{b}】:{result[1]}") |
| | | fmsges.append("板块回封判断##" + ",".join(msges)) |
| | | |
| | | # 如果能扫入就需要获取代码在板块中的身位,此规则暂时不生效 |
| | | # 如果能扫入就需要获取代码在板块中的身位 |
| | | # if can_buy_blocks: |
| | | # excude_codes = set() |
| | | # if kpl_data_constant.open_limit_up_code_dict_for_radical_buy: |
| | |
| | | def getLimitUpInfoNew(): |
| | | pids = [(1, "首板"), (2, "2连板"), (3, "3连板"), (4, "4连板"), (5, "")] |
| | | fresults = [] |
| | | day = '' |
| | | for pid_info in pids: |
| | | results = [] |
| | | for i in range(100): |
| | |
| | | r[i] = kpl_util.filter_block(r[i]) |
| | | fresults.extend(results) |
| | | |
| | | return json.dumps({"errcode": 0, "list": fresults}) |
| | | return json.dumps({"errcode": 0, "list": fresults, "day": day}) |
| | | |
| | | |
| | | def getLimitUpInfo(): |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | # print(getLimitUpInfoNew()) |
| | | print(getLimitUpInfoNew()) |
| | | |
| | | # __getConceptBK("300564") |
| | | data = (getMarketJingXuanRealRankingInfo(False)) |
| | |
| | | from db import redis_manager_delegate as redis_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | |
| | | |
| | | from utils import tool |
| | | from utils.kpl_data_db_util import KPLLimitUpDataUtil |
| | | |
| | | # 用于计算激进买开1的板数:{"代码":(几版,{板块})} |
| | | open_limit_up_code_dict_for_radical_buy = None |
| | | |
| | |
| | | __limit_up_reasons_dict = {} |
| | | # 涨停推荐原因 |
| | | __limit_up_recommend_reasons_dict = {} |
| | | # 激进买的原因 |
| | | __radical_buy_reasons_dict = {} |
| | | |
| | | __instance = None |
| | | |
| | |
| | | for code in limit_up_recommend_block_dict: |
| | | cls.__limit_up_recommend_reasons_dict[code] = set(limit_up_recommend_block_dict[code]) |
| | | |
| | | # 加载为扫入买匹配的代码板块 |
| | | kpl_results = KPLLimitUpDataUtil.get_latest_block_infos(min_day=tool.date_sub(tool.get_now_date_str(), 365)) |
| | | kpl_block_dict = {} |
| | | for r in kpl_results: |
| | | if r[2] in constant.KPL_INVALID_BLOCKS: |
| | | continue |
| | | code = r[0] |
| | | if code not in kpl_block_dict: |
| | | kpl_block_dict[code] = [] |
| | | kpl_block_dict[code].append((r[2], r[1])) # (板块, 时间) |
| | | for code in kpl_block_dict: |
| | | block_infos = kpl_block_dict.get(code) |
| | | block_infos.sort(key=lambda x: x[1], reverse=True) |
| | | temp_dict = {} # {"板块":[出现次数, 最近出现时间]} |
| | | for b in block_infos: |
| | | if b[0] not in temp_dict: |
| | | temp_dict[b[0]] = [0, b[1]] |
| | | temp_dict[b[0]][0] += 1 |
| | | temp_list = [(k, temp_dict[k][0], temp_dict[k][1]) for k in temp_dict] |
| | | # 按照涨停次数与最近涨停时间排序 |
| | | temp_list.sort(key=lambda x: (x[1], x[2]), reverse=True) |
| | | blocks = {temp_list[0][0]} |
| | | if len(temp_list) > 1: |
| | | if temp_list[1][1] >= 2: |
| | | blocks.add(temp_list[1][0]) |
| | | cls.__radical_buy_reasons_dict[code] = blocks |
| | | |
| | | |
| | | |
| | | def get_limit_up_reasons(self, code): |
| | | """ |
| | | 获取涨停原因 |
| | |
| | | blocks |= self.__limit_up_recommend_reasons_dict[code] |
| | | return blocks |
| | | |
| | | def get_radical_buy_blocks(self, code): |
| | | """ |
| | | 获取涨停买判断的板块 |
| | | @param code: |
| | | @return: |
| | | """ |
| | | return self.__radical_buy_reasons_dict.get(code) |
| | | |
| | | |
| | | class TodayLimitUpReasonChangeManager: |
| | | """ |
| | |
| | | pdata = __parseLimitUpItemData(d) |
| | | if pdata: |
| | | fresult_.append(pdata) |
| | | return fresult_ |
| | | return fresult_, data.get("day") |
| | | |
| | | |
| | | def parseFengKou(data): |
| | |
| | | from db.mysql_data_delegate import Mysqldb |
| | | from third_data.history_k_data_util import HistoryKDatasUtils |
| | | from utils import tool |
| | | |
| | | |
| | |
| | | mysqldb = Mysqldb() |
| | | results = mysqldb.select_all(sql) |
| | | return results |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | # 删除不是交易日期的数据 |
| | | days = HistoryKDatasUtils.get_latest_trading_date(300) |
| | | for day in days: |
| | | pass |
| | | print(days) |
| | | mysqldb = Mysqldb() |
| | | results = mysqldb.select_all(f"SELECT _id, _day from kpl_limit_up_record r where r._day>='{days[-1]}'") |
| | | ids = [] |
| | | for result in results: |
| | | if result[1] not in days: |
| | | ids.append(result[0]) |
| | | # print("删除:", result) |
| | | if len(ids) > 10: |
| | | sql = f"delete from kpl_limit_up_record where " + ' or '.join([f"_id='{x}'" for x in ids]) |
| | | mysqldb.execute(sql) |
| | | ids.clear() |
| | | pass |