Administrator
4 天以前 48fb7a00951f91bdc707e5dd2d196e5bccb752c3
test/test_sell.py
@@ -1,7 +1,9 @@
from cancel_strategy.s_l_h_cancel_strategy import SCancelBigNumComputer
from l2.huaxin import l2_huaxin_util
from l2.l2_data_manager import OrderBeginPosInfo
from l2.l2_transaction_data_manager import HuaXinSellOrderStatisticManager
from l2 import l2_data_util, cancel_buy_strategy
from l2 import l2_data_util
from l2.l2_transaction_data_processor import HuaXinTransactionDatasProcessor
from log_module import log_export, async_log_util
from utils import tool
@@ -54,18 +56,36 @@
# 卖单统计
def statistic_sell_order():
    code = "002248"
    def is_active_sell(sell_no, buy_no):
        return sell_no > buy_no
    code = "002660"
    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
    limit_up_price = 9.2
    last_type = -1
    for data in datas:
        for d in data:
            if d[7] == 559018:
                if d[7] > d[6]:
                    print("主动卖", d)
                else:
                    print("被动卖", d)
            if d[6] == 24975654:
                print(d[1] * d[2], d)
            type = -1
            if d[7] > d[6]:
                type = 0
            else:
                type = 1
            if type == 0 and last_type == 1 and d[1] == limit_up_price:
                print("被动卖变主动卖", d)
            last_type = type
            # if d[6] == 21296620:
            #     if d[7] > d[6]:
            #         print("主动卖", d)
            #     else:
            #         print("被动卖", d[1] * d[2], d)
            if code not in __latest_sell_order_dict:
                __latest_sell_order_dict[code] = [d[7], d[2], d[1], (d[3], d[6]), (d[3], d[6])]
            else:
@@ -75,18 +95,23 @@
                    __latest_sell_order_dict[code][4] = (d[3], d[6])
                else:
                    info = __latest_sell_order_dict[code]
                    money = info[1] * info[2]
                    if is_active_sell(info[0], info[3][1]) and 1000 * 10000 > money > 10 * 10000 and 7852775 > info[
                        0] > 7807625:
                        total_money += money
                        # print("主动卖:", round(money / 10000), total_money, info)
                    # 上个卖单成交完成
                    # 封存数据,计算新起点
                    # 大于50w的卖单才会保存
                    # 大于50w加入卖单
                    money = info[1] * info[2]
                    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
                    # 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])]
@@ -103,7 +128,7 @@
def test_sell_order_info():
    code = "002248"
    code = "600490"
    l2_data_util.load_l2_data(code, force=True)
    date = tool.get_now_date_str()
    data_map = log_export.load_huaxin_transaction_map(date=date)
@@ -114,14 +139,43 @@
        if big_sell_order_info[1] and big_sell_order_info[1][-1][0] == 559018:
            print(big_sell_order_info)
            cancel_buy_strategy.SCancelBigNumComputer().set_real_place_order_index(code, 208, False)
            cancel_buy_strategy.SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code, big_sell_order_info,
                                                                                           OrderBeginPosInfo(
                                                                                               mode=OrderBeginPosInfo.MODE_ACTIVE,buy_single_index=0,buy_exec_index=13))
            SCancelBigNumComputer().set_real_place_order_index(code, 208, False)
            SCancelBigNumComputer().set_big_sell_order_info_for_cancel(code, big_sell_order_info,
                                                                       OrderBeginPosInfo(
                                                                           mode=OrderBeginPosInfo.MODE_ACTIVE,
                                                                           buy_single_index=0,
                                                                           buy_exec_index=13))
        # if big_sell_order_info[0] < 50 * 10000:
        #     continue
        # print(i, sum([x[1] * x[2] for x in big_sell_order_info[1]]), big_sell_order_info)
def test_process_transaction_datas():
    data_map = log_export.load_huaxin_transaction_map(date="2024-04-17")
    code = "000035"
    datas = data_map.get(code)
    l2_data_util.load_l2_data(code)
    for data in datas:
        HuaXinTransactionDatasProcessor.statistic_big_order_infos(code, data)
    async_log_util.run_sync()
    # L2TradeSingleDataProcessor.add_l2_delegate_limit_up_sell(code, {"val": {"orderNo": 123123}, "index": 123})
    #
    # for data in datas:
    #     L2TradeSingleDataProcessor.process_passive_limit_up_sell_data(code, data, 5.78)
if __name__ == '__main__':
    test_sell_order_info()
    # s
    # real_order_time_ms = "09:30:47" + ".{0:0>3}".format(220)
    # big_sell_order_info = [1809599, [[7351750, 208000, 8.7, (11042670, 527268), (11042670, 527275)]]]
    # max_money = 0
    # for x in big_sell_order_info[1]:
    #     deal_time = l2_huaxin_util.convert_time(x[4][0], with_ms=True)
    #     if real_order_time_ms:
    #         if tool.trade_time_sub_with_ms(deal_time, real_order_time_ms) >= 0:
    #             print("123123")
    # test_process_transaction_datas()
    # BigOrderDealManager()
    pass