Administrator
3 天以前 5f034f7a6733b03e0d08d7920ec6de1b1517c421
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from code_attribute import code_volume_manager, gpcode_manager
from code_attribute.zyltgb_util import ZYLTGBUtil
from db.mysql_data_delegate import Mysqldb
from log_module.log import logger_codes_zyltgb
from utils import global_util, ths_industry_util
 
 
def init():
    load_volumn()
    load_zyltgb()
    load_industry()
    load_name_codes()
 
 
# 加载行业数据
def load_industry():
    _code_industry_map, _industry_codes_map = ths_industry_util.get_code_industry_maps()
    global_util.code_industry_map.clear()
    global_util.code_industry_map.update(_code_industry_map)
    global_util.industry_codes_map.clear()
    global_util.industry_codes_map.update(_industry_codes_map)
 
 
# 加载目标标的的自由流通股本
def load_zyltgb():
    codes = gpcode_manager.get_gp_list()
    for code in codes:
        result = ZYLTGBUtil.get(code)
        if result is not None:
            global_util.zyltgb_map[code] = result
 
 
def load_zyltgb_volume_from_db():
    # 拉取自由流通量
    mysqldb = Mysqldb()
    fresults = mysqldb.select_all("select code, zylt_volume from kpl_zylt_volume")
    if fresults:
        for result in fresults:
            global_util.zylt_volume_map[result[0]] = result[1]
        try:
            logger_codes_zyltgb.info(f"{global_util.zylt_volume_map}")
        except:
            pass
 
 
# 加载名称代码隐射
def load_name_codes():
    dict_ = gpcode_manager.get_name_codes()
    if dict_:
        for key in dict_:
            global_util.name_codes[key] = dict_[key]
 
 
# 加载量
def load_volumn():
    codes = gpcode_manager.get_gp_list()
    for code in codes:
        try:
            max60, yesterday = code_volume_manager.CodeVolumeManager().get_histry_volumn(code)
            today = code_volume_manager.CodeVolumeManager().get_today_volumn(code)
            global_util.max60_volumn[code] = max60
            global_util.yesterday_volumn[code] = yesterday
            global_util.today_volumn[code] = today
        except:
            pass
 
 
# 添加今日涨停数据
def add_limit_up_codes(datas, clear=False):
    if datas is None:
        return
    if clear:
        global_util.today_limit_up_codes.clear()
    # 涨停数量
    __dict = {}
    for data in datas:
        __dict[data["code"]] = data
    # print(__dict)
    global_util.today_limit_up_codes.update(__dict)