Administrator
2023-07-31 aba0821ae515ede073b2f4a2f62b846e5316eb85
增加些实时参数的缓存
5个文件已修改
50 ■■■■ 已修改文件
code_attribute/code_volumn_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/huaxin_target_codes_manager.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/deal_big_money_manager.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/first_code_score_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_volumn_manager.py
@@ -48,8 +48,8 @@
# 获取今日量
def get_today_volumn(code):
    _volumn = global_util.today_volumn.get(code)
    redis = __redis_manager.getRedis()
    if _volumn is None:
        redis = __redis_manager.getRedis()
        _volumn = redis.get("volumn_today-{}".format(code))
    return _volumn
l2/huaxin/huaxin_target_codes_manager.py
@@ -4,7 +4,7 @@
import json
import socket
from code_attribute import global_data_loader
from code_attribute import global_data_loader, code_volumn_manager
from code_attribute.code_data_util import ZYLTGBUtil
from db import redis_manager
from third_data import kpl_data_manager, kpl_api
@@ -79,12 +79,15 @@
                    # 保存自由流通股本
                    ZYLTGBUtil.save(code, zylt // 10000, 1)
                    global_util.zyltgb_map[code] = int(zylt)
            # 保存今日实时量
            code_volumn_manager.set_today_volumn(code, d[3])
            zyltgb = 0
            if code in global_util.zyltgb_map:
                zyltgb = global_util.zyltgb_map[code]
            fitem = {"code": code, "price": d[1], "volume": d[3] // 10000, "volumeUnit": 1, "time": "00:00:00",
                     "zyltgb": zyltgb//10000, "zyltgbUnit": 1}
            # 量的单位为手(不是股)
            fitem = {"code": code, "price": d[1], "volume": d[3] // (10000*100), "volumeUnit": 1, "time": "00:00:00",
                     "zyltgb": zyltgb // 10000, "zyltgbUnit": 1}
            flist.append(fitem)
        fdata = {"type": 22, "data": flist}
        print("首板代码数量", len(flist))
@@ -94,13 +97,6 @@
        sk.connect((addr, port))
        try:
            sk.sendall(socket_util.load_header(json.dumps(fdata).encode('utf-8')))
            # result, header = socket_util.recv_data(sk)
            # if result:
            #     result = json.loads(result)
            #     if result["code"] != 0:
            #         raise Exception(result["msg"])
            # result, header = socket_util.recv_data(sk)
        finally:
            sk.close()
@@ -123,4 +119,4 @@
    zyltgb = 0
    if code in global_util.zyltgb_map:
        zyltgb = global_util.zyltgb_map[code]
    print(zyltgb)
    print(zyltgb)
l2/l2_data_manager_new.py
@@ -246,15 +246,16 @@
            if len(datas) > 0:
                cls.process_add_datas(code, datas, 0, __start_time)
            else:
                lp = LineProfiler()
                lp.enable()
                lp_wrap = lp(cls.process_add_datas)
                lp_wrap(code, datas, 0, __start_time)
                output = io.StringIO()
                lp.print_stats(stream=output)
                lp.disable()
                with open(f"/home/logs/profile/{code}_{datas[0]['index']}_{datas[-1]['index']}.txt", 'w') as f:
                    f.write(output.getvalue())
                pass
                # lp = LineProfiler()
                # lp.enable()
                # lp_wrap = lp(cls.process_add_datas)
                # lp_wrap(code, datas, 0, __start_time)
                # output = io.StringIO()
                # lp.print_stats(stream=output)
                # lp.disable()
                # with open(f"/home/logs/profile/{code}_{datas[0]['index']}_{datas[-1]['index']}.txt", 'w') as f:
                #     f.write(output.getvalue())
            # lp.dump_stats(f"/home/logs/profile/{code}_{round(t.time() * 1000)}.txt")
        except Exception as e:
            print("huaxin L2数据处理异常", code, str(e))
trade/deal_big_money_manager.py
@@ -41,6 +41,10 @@
def get_traded_indexes(code):
    return __get_traded_indexes(code)
__deal_compute_progress_cache = {}
# 获取成交计算进度
def __get_deal_compute_progress(code):
    val = __get_redis().get(f"deal_compute_info-{code}")
@@ -53,6 +57,7 @@
# 设置成交进度
def __set_deal_compute_progress(code, index, money):
    __get_redis().setex(f"deal_compute_info-{code}", tool.get_expire(), json.dumps((index, money)))
    __deal_compute_progress_cache[code] = (index, money)
# 设置成交进度
@@ -81,5 +86,7 @@
def get_deal_big_money_num(code):
    if code in __deal_compute_progress_cache:
        return __deal_compute_progress_cache.get(code)[1]
    compute_index, num = __get_deal_compute_progress(code)
    return num
trade/first_code_score_manager.py
@@ -272,7 +272,7 @@
        }
    # 将代码本身的信息包含进去
    hot_block["limit_up_codes_count"] = hot_block["limit_up_codes_count"] + 1
    pre_close_price = gpcode_manager.get_price_pre(code)
    pre_close_price = gpcode_manager.get_price_pre_cache(code)
    hot_block["block_codes_rates_info"] = (
        hot_block["block_codes_rates_info"][0] + round((limit_price - pre_close_price) * 100 / pre_close_price, 2),
        hot_block["block_codes_rates_info"][1] + 1)