import json
|
import os
|
|
import constant
|
from strategy import data_cache
|
from log_module.log import logger_common
|
|
|
# 读取本地的所有带属性K线数据(所有个股K线及指数线)
|
def read_local_K_line_data():
|
# 先使用json.load()直接从文件中读取【已经存储在本地的K线指标属性字典】并解析JSON数据
|
if os.path.exists(constant.K_BARS_PATH):
|
with open(constant.K_BARS_PATH, 'r', encoding='utf-8') as f:
|
data_cache.all_stocks_all_K_line_property_dict = json.load(f)
|
# print(
|
# f"data_cache.all_stocks_all_K_line_property_dict的个数==={len(data_cache.all_stocks_all_K_line_property_dict)}")
|
|
# 先使用json.load()直接从文件中读取【已经存储在本地的K线指标属性字典】并解析JSON数据
|
if os.path.exists(constant.INDEX_K_BARS_PATH):
|
with open(constant.INDEX_K_BARS_PATH, 'r', encoding='utf-8') as f:
|
data_cache.all_index_k_line_property_dict = json.load(f)
|
all_index_k_line_property_dict = data_cache.all_index_k_line_property_dict
|
# print(
|
# f"data_cache.all_index_k_line_property_dict==={len(data_cache.all_index_k_line_property_dict)}")
|
return all_index_k_line_property_dict
|
|
|
# 读取本地的个股所属概念板块数据
|
def read_local_all_stocks_plate_data():
|
# 读取已经获取到并存储在本地的目标范围的个股的板块概念
|
# 读取JSON文件并解析为字典
|
if os.path.exists(constant.ALL_STOCKS_PLATE_PATH):
|
with open(constant.ALL_STOCKS_PLATE_PATH, 'r',
|
encoding='utf-8') as f:
|
json_data = f.read()
|
else:
|
json_data = "{}"
|
data_cache.all_stocks_plate_dict = json.loads(json_data)
|
logger_common.info(f"all_stocks_plate_dict的数量={len(data_cache.all_stocks_plate_dict)}")
|
|
|
if __name__ == '__main__':
|
all_index_k_line_property_dict = read_local_K_line_data()
|
print(f"all_index_k_line_property_dict=={all_index_k_line_property_dict}")
|
if all_index_k_line_property_dict['SHSE.000001'][1]['today_volume_shape'] == 'remained_down':
|
print(f"昨日平量下跌")
|