Administrator
2025-06-03 f82aab768e4bc361eac69e1ae69b36a9bec2970c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import threading
 
from code_attribute.code_data_util import ZYLTGBUtil
from huaxin_client import l1_subscript_codes_manager
from third_data import history_k_data_util, kpl_api
from utils import tool
 
 
def update_all_zylt_volumes():
    """
    更新所有目标代码的自由流通股本
    @return:
    """
    # 判断当前是否是交易日
    previous_trading_date = history_k_data_util.HistoryKDatasUtils.get_previous_trading_date(tool.get_now_date_str())
    if history_k_data_util.HistoryKDatasUtils.get_next_trading_date(previous_trading_date) != tool.get_now_date_str():
        # 非交易日
        return 0
 
    def update_zylt_volume(codes):
        # 获取最近的价格
        price_datas = history_k_data_util.JueJinApi.get_gp_current_info(codes, "symbol,price")
        price_dict = {x['symbol'].split(".")[1]: x['price'] for x in price_datas}
        for code in price_dict:
            try:
                zylt = kpl_api.getZYLTAmount(code)
                ZYLTGBUtil.save_volume(code, int(zylt / price_dict[code]))
            except:
                pass
 
    # 刷新目标代码的自由流通量
    codes_sh, codes_sz = l1_subscript_codes_manager.get_codes(False)
    codes = set()
    if codes_sh:
        for code_byte in codes_sh:
            codes.add(code_byte.decode())
        for code_byte in codes_sz:
            codes.add(code_byte.decode())
 
    updated_codes = ZYLTGBUtil.get_today_updated_volume_codes()
    codes = codes - set(updated_codes)
    threading.Thread(target=lambda: update_zylt_volume(codes), daemon=True).start()
    return len(codes)
 
 
if __name__ == "__main__":
    # previous_trading_date = history_k_data_util.HistoryKDatasUtils.get_previous_trading_date(tool.get_now_date_str())
    # if history_k_data_util.HistoryKDatasUtils.get_next_trading_date(previous_trading_date) != tool.get_now_date_str():
    #     print("非交易日")
    # else:
    #     print("交易日")
    # zylt = kpl_api.getZYLTAmount("000333")
    # print(zylt)
    update_all_zylt_volumes()
    input()