# 代码行业映射
|
import pymongo
|
|
import mongo_data
|
import code_volumn_manager
|
import gpcode_manager
|
import ths_industry_util
|
|
TEST = False
|
|
code_industry_map = {}
|
# 行业代码映射
|
industry_codes_map = {}
|
# 自由流通市值映射
|
zyltgb_map = {}
|
# 今日涨停代码隐射
|
today_limit_up_codes = {}
|
# 行业热度指数
|
industry_hot_num = {}
|
# 今日量
|
today_volumn = {}
|
# 60日最大量
|
max60_volumn = {}
|
# 昨日量
|
yesterday_volumn = {}
|
# 大单
|
big_money_num = {}
|
# 涨停时间
|
limit_up_time = {}
|
|
|
def init():
|
load_volumn()
|
load_zyltgb()
|
load_industry()
|
|
|
# 加载行业数据
|
def load_industry():
|
_code_industry_map, _industry_codes_map = ths_industry_util.get_code_industry_maps()
|
code_industry_map.clear()
|
code_industry_map.update(_code_industry_map)
|
industry_codes_map.clear()
|
industry_codes_map.update(_industry_codes_map)
|
|
|
# 加载目标标的的自由流通股本
|
def load_zyltgb():
|
codes = gpcode_manager.get_gp_list()
|
for code in codes:
|
results = mongo_data.find("ths-zylt", {"_id": code})
|
if results is not None:
|
results = [doc for doc in results]
|
if len(results) > 0:
|
result = results[0]
|
if result["zyltgb_unit"] == 0:
|
zyltgb_map[code] = round(float(result["zyltgb"]) * 100000000)
|
else:
|
zyltgb_map[code] = round(float(result["zyltgb"]) * 10000)
|
|
|
# 加载量
|
def load_volumn():
|
codes = gpcode_manager.get_gp_list()
|
for code in codes:
|
max60, yesterday = code_volumn_manager.get_histry_volumn(code)
|
today = code_volumn_manager.get_today_volumn(code)
|
max60_volumn[code] = max60
|
yesterday_volumn[code] = yesterday
|
today_volumn[code] = today
|
|
|
# 添加今日涨停数据
|
def add_limit_up_codes(datas, clear=False):
|
if clear:
|
today_limit_up_codes.clear()
|
# 涨停数量
|
__dict = {}
|
for data in datas:
|
__dict[data["code"]] = data
|
# print(__dict)
|
today_limit_up_codes.update(__dict)
|
|
|
if __name__ == "__main__":
|
load_zyltgb()
|
print(zyltgb_map["002819"])
|