Administrator
2024-04-09 521058f11b090d704268c9b7d09ea38e99aecc75
当前总卖额统计卖1信息
4个文件已修改
1个文件已添加
88 ■■■■ 已修改文件
l2/l2_data_manager_new.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_sell_manager.py 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_process_time.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_sell.py 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py
@@ -1650,7 +1650,7 @@
        if (can_buy_result and can_buy_result[0] and can_buy_result[5]) or constant.ALL_ACTIVE_BUY:
            # 有可买板块,有激进买板块
            # 第一步: 计算总卖额
            threshold_money = refer_sell_data[1]
            threshold_money, sell_1_price = refer_sell_data[1], refer_sell_data[3][0]
            for i in range(start_index - 1, -1, -1):
                val = total_datas[i]["val"]
                if tool.compare_time(val["time"], refer_sell_data[0]) <= 0:
@@ -1660,8 +1660,9 @@
                elif L2DataUtil.is_sell_cancel(val):
                    threshold_money -= val["num"] * int(float(val["price"]) * 100)
                elif L2DataUtil.is_buy(val):
                    # TODO 判断价格(大于买1) 被买吃掉
                    threshold_money -= val["num"] * int(float(val["price"]) * 100)
                    # 判断价格(大于卖1) 被买吃掉
                    if round( float(val["price"]),2) - sell_1_price >=0:
                        threshold_money -= val["num"] * int(float(val["price"]) * 100)
            # 第二步:计算起始信号
            second_930 = 9 * 3600 + 30 * 60 + 0
            total_datas = local_today_datas.get(code)
l2/l2_sell_manager.py
@@ -63,12 +63,12 @@
            RedisUtils.delete_async(self.__db, k)
    # 设置当前的总卖
    def set_current_total_sell_data(self, code, time_str, money, volume):
    def set_current_total_sell_data(self, code, time_str, money, volume, sell_1_info):
        # 记录日志
        async_log_util.info(logger_l2_market_sell, f"{code}: {time_str}-{money}")
        async_log_util.info(logger_l2_market_sell, f"{code}: {time_str}-{money} {sell_1_info}")
        if code in self.__current_total_sell_data_cache:
            self.__last_total_sell_data_cache[code] = self.__current_total_sell_data_cache.get(code)
        self.__current_total_sell_data_cache[code] = (time_str, round(money), volume)
        self.__current_total_sell_data_cache[code] = (time_str, round(money), volume, sell_1_info)
    def get_current_total_sell_data(self, code):
        return self.__current_total_sell_data_cache.get(code)
test/test_process_time.py
New file
@@ -0,0 +1,23 @@
"""
处理耗时
"""
def print_big_use_time():
    with open(file="D:/logs/gp/l2/l2_process.2024-04-09.log", mode='r',encoding="utf-8") as f:
        while True:
            line = f.readline()
            if not line:
                break
            datas = line.split(" ")
            for d in datas:
                if d.find("code:") > -1:
                    code = d.replace("code:", "")
                if d.find("处理时间:") > -1:
                    use_time = int(d.replace("处理时间:", ""))
            if use_time > 5:
                print(line)
if __name__ == "__main__":
    print_big_use_time()
test/test_sell.py
@@ -1,16 +1,50 @@
from l2.huaxin import l2_huaxin_util
from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager
from l2 import l2_data_util
from log_module import log_export, async_log_util
from utils import tool
def statistic_buy_order():
    code = "600768"
    data_map = log_export.load_huaxin_transaction_map(date=tool.get_now_date_str())
    datas = data_map.get(code)
    __latest_buy_order_dict = {}
    total_money = 0
    for data in datas:
        for d in data:
            if code not in __latest_buy_order_dict:
                # 格式:[买单号,手数,单价]
                __latest_buy_order_dict[code] = [d[6], d[2], d[1], (d[3], d[1]), (d[3], d[1])]
            else:
                if __latest_buy_order_dict[code][0] == d[6]:
                    __latest_buy_order_dict[code][1] += d[2]
                    __latest_buy_order_dict[code][2] = d[1]
                    __latest_buy_order_dict[code][4] = (d[3], d[1])
                else:
                    info = __latest_buy_order_dict[code]
                    # 上个卖单成交完成
                    # 封存数据,计算新起点
                    # 大于50w的卖单才会保存
                    # 大于50w加入卖单
                    money = info[1] * info[2]
                    # if 101328000 > info[3] > 101324000:
                    if tool.trade_time_sub(l2_huaxin_util.convert_time(info[3][0]), "10:08:30") >= 0 and info[2] >= 11.54:
                        total_money += money
                        print(int(total_money), round(money / 10000, 1), info)
                    if money >= 500000:
                        pass
                    __latest_buy_order_dict[code] = [d[6], d[2], d[1], (d[3], d[1]), (d[3], d[1])]
# 卖单统计
def statistic_sell_order():
    code = "000888"
    code = "600768"
    data_map = log_export.load_huaxin_transaction_map(date=tool.get_now_date_str())
    datas = data_map.get(code)
    __latest_sell_order_dict = {}
    total_money = 0
    for data in datas:
        for d in data:
            if code not in __latest_sell_order_dict:
@@ -28,8 +62,10 @@
                    # 大于50w的卖单才会保存
                    # 大于50w加入卖单
                    money = info[1] * info[2]
                    if 101328000 > info[3][0] > 101324000 and info[0] > 12265084:
                        print(money, info)
                    if tool.trade_time_sub(l2_huaxin_util.convert_time(info[3][0]), "10:08:30") >= 0:
                        if info[2] >= 11.54:
                            total_money += money
                            print(money, round(total_money), info)
                    if money >= 500000:
                        pass
                    __latest_sell_order_dict[code] = [d[7], d[2], d[1], (d[3], d[6]), (d[3], d[6])]
@@ -65,4 +101,4 @@
if __name__ == '__main__':
    statistic_sell_order()
    statistic_buy_order()
trade/huaxin/huaxin_trade_server.py
@@ -491,9 +491,11 @@
            threading.Thread(target=lambda: update_kpl_jx_block(code, buy_1_price, limit_up_price), daemon=True).start()
        async_log_util.info(hx_logger_l2_market_data, f"{code}#{data}")
        sell_1_info = data["sell"][0] if data.get("sell") else None
        L2MarketSellManager().set_current_total_sell_data(code, time_str,
                                                          data["totalAskVolume"] * data["avgAskPrice"],
                                                          data["totalAskVolume"])
                                                          data["totalAskVolume"], sell_1_info)
    @classmethod
    def trading_order_canceled(cls, code, order_no):
@@ -1649,7 +1651,7 @@
                if money > 30000:
                    raise Exception("最多只能设置3w")
                constant.BUY_MONEY_PER_CODE = money
                self.send_response({"code": 0, "data": {"money":  constant.BUY_MONEY_PER_CODE}}, client_id, request_id)
                self.send_response({"code": 0, "data": {"money": constant.BUY_MONEY_PER_CODE}}, client_id, request_id)
            elif ctype == "get_per_code_buy_money":
                self.send_response({"code": 0, "data": {"money": constant.BUY_MONEY_PER_CODE}}, client_id, request_id)
        except Exception as e: