| | |
| | | # 撤单错误回报 |
| | | def OnErrRtnOrderAction(self, pInputOrderActionField: "CTORATstpInputOrderActionField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | | logger_local_huaxin_trade_debug.info('OnErrRtnOrderAction: Error! [%d] [%d] [%d] [%s]' |
| | | % (nRequestID, pInputOrderActionField.OrderSysID, pRspInfoField.ErrorID, |
| | | pRspInfoField.ErrorMsg)) |
| | | if pInputOrderActionField and pRspInfoField: |
| | | logger_local_huaxin_trade_debug.info('OnErrRtnOrderAction: Error! [%d] [%d] [%d] [%s]' |
| | | % (nRequestID, pInputOrderActionField.OrderSysID, pRspInfoField.ErrorID, |
| | | pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRspInquiryJZFund(self, pRspInquiryJZFundField: "CTORATstpRspInquiryJZFundField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | |
| | | # _start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - _start_time, "m值阈值计算") |
| | | |
| | | # 买入纯买额统计 |
| | | compute_index, buy_nums, buy_count, rebegin_buy_pos, max_num_set_new = cls.__sum_buy_num_for_order_3(code, |
| | | new_buy_exec_index, buy_nums, buy_count, rebegin_buy_pos, max_num_set_new = cls.__sum_buy_num_for_order_3(code, |
| | | start_process_index, |
| | | compute_end_index, |
| | | num, count, |
| | |
| | | is_first_code, False) |
| | | return |
| | | |
| | | if compute_index is not None: |
| | | l2_log.debug(code, "获取到买入执行位置:{} m值:{} 纯买手数:{} 纯买单数:{} 数据:{} ,量比:{} ", compute_index, threshold_money, |
| | | if new_buy_exec_index is not None: |
| | | l2_log.debug(code, "获取到买入执行位置:{} m值:{} 纯买手数:{} 纯买单数:{} 数据:{} ,量比:{} ", new_buy_exec_index, threshold_money, |
| | | buy_nums, |
| | | buy_count, total_datas[compute_index], cls.volume_rate_info[code]) |
| | | cls.__save_order_begin_data(code, buy_single_index, compute_index, compute_index, |
| | | buy_count, total_datas[new_buy_exec_index], cls.volume_rate_info[code]) |
| | | cls.__save_order_begin_data(code, buy_single_index, new_buy_exec_index, new_buy_exec_index, |
| | | buy_nums, buy_count, max_num_set_new, |
| | | cls.volume_rate_info[code][0]) |
| | | cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[compute_index]["val"]["time"]) |
| | | cls.__LimitUpTimeManager.save_limit_up_time(code, total_datas[new_buy_exec_index]["val"]["time"]) |
| | | cls.__TradePointManager.delete_buy_cancel_point(code) |
| | | l2_log.debug(code, "delete_buy_cancel_point") |
| | | # 直接下单 |
| | | ordered = cls.__buy(code, capture_time, total_datas[compute_index], compute_index, is_first_code) |
| | | ordered = cls.__buy(code, capture_time, total_datas[new_buy_exec_index], new_buy_exec_index, is_first_code) |
| | | |
| | | # 数据是否处理完毕 |
| | | if compute_index < compute_end_index: |
| | | if new_buy_exec_index < compute_end_index: |
| | | if ordered: |
| | | cls.__process_order(code, compute_index + 1, compute_end_index, capture_time, is_first_code, False) |
| | | cls.__process_order(code, new_buy_exec_index + 1, compute_end_index, capture_time, is_first_code, False) |
| | | else: |
| | | cls.__start_compute_buy(code, compute_index + 1, compute_end_index, threshold_money, capture_time, |
| | | cls.__start_compute_buy(code, new_buy_exec_index + 1, compute_end_index, threshold_money, capture_time, |
| | | is_first_code, False) |
| | | else: |
| | | # 未达到下单条件,保存纯买额,设置纯买额 |
| | |
| | | buy_nums, threshold_num) |
| | | |
| | | max_buy_num_set_count = 0 |
| | | for i in max_buy_num_set: |
| | | max_buy_num_set_count += total_datas[i]["re"] |
| | | for i1 in max_buy_num_set: |
| | | max_buy_num_set_count += total_datas[i1]["re"] |
| | | # 有撤单信号,且小于阈值 |
| | | if buy_nums >= threshold_num and buy_count >= threshold_count and trigger_buy and max_buy_num_set_count >= big_num_count: |
| | | return i, buy_nums, buy_count, None, max_buy_num_set |
| | |
| | | import json |
| | | import multiprocessing |
| | | import random |
| | | import threading |
| | | import time |
| | | import unittest |
| | | from copy import deepcopy |
| | |
| | | |
| | | from code_attribute import big_money_num_manager, gpcode_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module import log, log_export |
| | | from log_module import log, log_export, async_log_util |
| | | from trade.huaxin import huaxin_trade_api |
| | | from utils import tool |
| | | from db import redis_manager_delegate as redis_manager |
| | |
| | | |
| | | # @unittest.skip("跳过此单元测试") |
| | | def test_trade(self): |
| | | code = "002527" |
| | | threading.Thread(target=async_log_util.run_sync,daemon=True).start() |
| | | |
| | | code = "000678" |
| | | clear_trade_data(code) |
| | | l2.l2_data_util.load_l2_data(code) |
| | | total_datas = deepcopy(l2.l2_data_util.local_today_datas[code]) |
| | |
| | | current_price_process_manager.set_trade_price(code, round(float(gpcode_manager.get_limit_up_price(code)), 2)) |
| | | |
| | | pss_server, pss_strategy = multiprocessing.Pipe() |
| | | huaxin_trade_api.run_pipe_trade(pss_server) |
| | | huaxin_trade_api.run_pipe_trade(pss_server, None) |
| | | |
| | | for indexs in pos_list: |
| | | l2_log.threadIds[code] = mock.Mock( |