Administrator
2024-12-23 258d64ba21cc0c65a13a1458e713b00f30655968
utils/kpl_data_db_util.py
@@ -12,7 +12,7 @@
        @param code: 代码
        @return: 最近的涨停板块信息
        """
        sql = f"SELECT r.`_code`, r.`_day`, r.`_hot_block_name`, r.`_blocks` FROM `kpl_limit_up_record` r WHERE r.`_day`>='{min_day}' and r.`_day` <'{max_day}'"
        sql = f"SELECT r.`_code`, r.`_day`, r.`_hot_block_name`, r.`_blocks`,  r.`_open` FROM `kpl_limit_up_record` r WHERE r.`_day`>='{min_day}' and r.`_day` <'{max_day}'"
        if code:
            sql += f" AND _code='{code}'"
@@ -29,22 +29,7 @@
        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
    datas = KPLLimitUpDataUtil.get_latest_block_infos()
    len(datas)