Administrator
2024-12-31 c7d03a456b203e43ff31aff63cc093ce741b82c9
K线接口修改
3个文件已修改
45 ■■■■■ 已修改文件
api/outside_api_command_callback.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/history_k_data_manager.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
third_data/history_k_data_util.py 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/outside_api_command_callback.py
@@ -36,7 +36,8 @@
    logger_trade, logger_trade_position_api_request, logger_request_api, \
    logger_real_place_order_position, logger_device
from output import l2_output_util
from third_data import kpl_util, history_k_data_manager, huaxin_l1_data_manager, third_blocks_manager, kpl_data_manager
from third_data import kpl_util, history_k_data_manager, huaxin_l1_data_manager, third_blocks_manager, kpl_data_manager, \
    history_k_data_util
from third_data.code_plate_key_manager import KPLCodeJXBlockManager, RealTimeKplMarketData
from third_data.history_k_data_manager import HistoryKDataManager
from third_data.history_k_data_util import JueJinApi, HistoryKDatasUtils
@@ -487,7 +488,8 @@
        try:
            fdata = {}
            try:
                date = HistoryKDatasUtils.get_trading_dates(tool.date_sub(tool.get_now_date_str(), 10) ,tool.get_now_date_str())
                date = HistoryKDatasUtils.get_trading_dates(tool.date_sub(tool.get_now_date_str(), 10),
                                                            tool.get_now_date_str())
                if date:
                    fdata["juejin"] = 1
            except Exception as e:
@@ -544,15 +546,7 @@
            # 获取今日K线的更新数量
            try:
                dates = HistoryKDatasUtils.get_latest_trading_date_cache(5)
                latest_trading_date = None
                if dates:
                    latest_trading_date = dates[0]
                if latest_trading_date is None:
                    raise Exception("没有获取到上一个交易日的日期")
                # 4点之后改为获取今日的数据
                if tool.get_now_time_as_int()>160000:
                    latest_trading_date = tool.get_now_date_str()
                latest_trading_date = history_k_data_util.get_k_bar_dead_date()
                codes = HistoryKDataManager().get_history_bars_codes(latest_trading_date)
                count = len(codes)
                logger_debug.info(f"K线代码数量:{count}")
@@ -1354,7 +1348,7 @@
                data = {
                    "radical_buy": {"price": (constant.MIN_CODE_RADICAL_BUY_PRICE, constant.MAX_CODE_RADICAL_BUY_PRICE),
                                    "zyltgb": constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES,
                                    "top_block_count_by_market_strong":constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG,
                                    "top_block_count_by_market_strong": constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG,
                                    "special_codes_max_block_in_rank": constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL
                                    }}
                self.send_response({"code": 0, "data": data, "msg": f""},
@@ -1368,7 +1362,8 @@
                    constant.MAX_CODE_RADICAL_BUY_PRICE = radical_buy["price"][1]
                    constant.RADICAL_BUY_ZYLTGB_AS_YI_RANGES = radical_buy["zyltgb"]
                    if radical_buy.get("top_block_count_by_market_strong"):
                        constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG = radical_buy.get("top_block_count_by_market_strong")
                        constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG = radical_buy.get(
                            "top_block_count_by_market_strong")
                    if radical_buy.get("special_codes_max_block_in_rank"):
                        constant.RADICAL_BUY_TOP_IN_INDEX_WITH_SPECIAL = radical_buy.get(
                            "special_codes_max_block_in_rank")
@@ -1411,7 +1406,7 @@
                    fblocks, before_fblocks = RadicalBuyBlockManager.get_code_blocks(code)
                    # 获取板块历史涨停
                    for b in fblocks:
                        codes =  LimitUpDataConstant.get_history_limit_up_block_codes(b)
                        codes = LimitUpDataConstant.get_history_limit_up_block_codes(b)
                        if codes:
                            if code not in block_codes:
                                block_codes[code] = {}
third_data/history_k_data_manager.py
@@ -29,9 +29,7 @@
            except Exception as e:
                logger_debug.exception(e)
    previous_trading_date = history_k_data_util.HistoryKDatasUtils.get_previous_trading_date(tool.get_now_date_str())
    if previous_trading_date is None:
        raise Exception("上一个交易日获取失败")
    latest_trading_date = history_k_data_util.get_k_bar_dead_date()
    # 刷新目标代码的自由流通量
    codes_sh, codes_sz = l1_subscript_codes_manager.get_codes(False)
    codes = set()
@@ -41,7 +39,7 @@
        for code_byte in codes_sz:
            codes.add(code_byte.decode())
    # 获取已经更新的数据
    codes_record = HistoryKDataManager().get_history_bars_codes(previous_trading_date)
    codes_record = HistoryKDataManager().get_history_bars_codes(latest_trading_date)
    codes = codes - codes_record
    threading.Thread(target=lambda: update(codes), daemon=True).start()
third_data/history_k_data_util.py
@@ -350,6 +350,22 @@
        return results
def get_k_bar_dead_date():
    """
    获取K线的截止日期
    @return:
    """
    dates = HistoryKDatasUtils.get_latest_trading_date_cache(5)
    latest_trading_date = None
    if dates:
        latest_trading_date = dates[0]
    if latest_trading_date is None:
        raise Exception("没有获取到上一个交易日的日期")
    # 4点之后改为获取今日的数据
    if tool.get_now_time_as_int() > 160000:
        latest_trading_date = tool.get_now_date_str()
    return latest_trading_date
if __name__ == "__main__":
    print(HistoryKDatasUtils.get_previous_trading_date("2024-12-31"))
    print(HistoryKDatasUtils.get_history_tick_n("000095", 10))