Administrator
2024-01-25 6d827382d8a5989abf8e813f5e34d1fbb97c929a
卖票修复
3个文件已修改
36 ■■■■■ 已修改文件
code_attribute/code_nature_analyse.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_sell_util.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
code_attribute/code_nature_analyse.py
@@ -400,7 +400,7 @@
    #     return False
    rate = (float(limit_up_price) - min_price) / min_price
    # print(rate)
    if rate >= 0.28:
    if rate >= 0.319:
        return True
    return False
trade/huaxin/huaxin_sell_util.py
@@ -27,12 +27,13 @@
# 开始撤单
def start_sell(code, volume, price_type, limit_up_price, limit_down_price, current_price, blocking=False,
               request_id=None):
               request_id=None,order_ref=None):
    price = sell_util.get_sell_price(price_type, limit_up_price, limit_down_price, current_price)
    if not price:
        raise Exception("价格获取出错")
    async_log_util.info(logger_trade, f"API卖:  单价-{price}")
    order_ref = huaxin_util.create_order_ref()
    if not order_ref:
        order_ref = huaxin_util.create_order_ref()
    result = huaxin_trade_api.order(2, code, volume, price, order_ref=order_ref,
                                    blocking=blocking, request_id=request_id)
    # 如果是在正常交易时间提交的2s之内还未成交的需要撤单
trade/huaxin/huaxin_trade_server.py
@@ -332,8 +332,8 @@
                                    limit_down_price = gpcode_manager.get_limit_down_price(code)
                                    limit_up_price = gpcode_manager.get_limit_up_price(code)
                                    huaxin_sell_util.start_sell(code, r.sell_volume, r.sell_price_type, limit_up_price,
                                                            limit_down_price,
                                                            buy1_price)
                                                                limit_down_price,
                                                                buy1_price)
                                    SellRuleManager().excute_sell(r.id_)
                                except:
                                    pass
@@ -511,7 +511,7 @@
class OutsideApiCommandCallback(outside_api_command_manager.ActionCallback):
    __cancel_sell_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=8)
    __DealRecordManager = DealRecordManager()
    __code_sell_way_dict={}
    __code_sell_way_dict = {}
    @classmethod
    def __send_response(cls, data_bytes):
@@ -555,10 +555,18 @@
                    current_price = TradeServerProcessor.get_l1_current_price(code)
                    limit_down_price = gpcode_manager.get_limit_down_price(code)
                    limit_up_price = gpcode_manager.get_limit_up_price(code)
                    result = huaxin_sell_util.start_sell(code, volume, price_type, limit_up_price, limit_down_price,
                                                     current_price, blocking=True, request_id=request_id)
                    async_log_util.info(logger_trade, f"API卖结果: {result}")
                    self.send_response(result, client_id, request_id)
                    order_ref = huaxin_util.create_order_ref()
                    try:
                        result = huaxin_sell_util.start_sell(code, volume, price_type, limit_up_price, limit_down_price,
                                                             current_price, blocking=True, request_id=request_id,
                                                             order_ref=order_ref)
                        async_log_util.info(logger_trade, f"API卖结果: {result}")
                        self.send_response(result, client_id, request_id)
                    except Exception as e:
                        if str(e).find("超时") >= 0:
                            self.send_response({"code": 0, "data": {"orderRef": order_ref}}, client_id, request_id)
                        else:
                            raise e
                else:
                    result = huaxin_trade_api.order(direction, code, volume, price, price_type=price_type, sinfo=sinfo,
                                                    blocking=True, request_id=request_id)
@@ -1217,7 +1225,7 @@
                    dealing_info = HuaXinTransactionDataManager.get_dealing_order_info(code)
                    if dealing_info:
                        if str(total_datas[trade_index]["val"]["orderNo"]) == str(dealing_info[0]):
                            total_left_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1]//100)
                            total_left_num += (total_datas[trade_index]["val"]["num"] - dealing_info[1] // 100)
                    limit_up_price = gpcode_manager.get_limit_up_price(code)
                    buy1_money = Buy1PriceManager().get_latest_buy1_money(code)
                    if buy1_money is None:
@@ -1271,7 +1279,7 @@
            elif ctype == "get_positions":
                # 获取所有持仓信息
                positions = PositionManager.latest_positions
                fdatas=[]
                fdatas = []
                if positions:
                    for d in positions:
                        code_ = d["securityID"]
@@ -1284,7 +1292,8 @@
                                                                            results[code_])).start()
                        if d["prePosition"] <= 0:
                            continue
                        fdatas.append({"code":code_,"code_name":code_name,"total":d["prePosition"],"available": d["availablePosition"]})
                        fdatas.append({"code": code_, "code_name": code_name, "total": d["prePosition"],
                                       "available": d["availablePosition"]})
                result = {"code": 0, "data": fdatas}
                self.send_response(result, client_id, request_id)
            elif ctype == "set_code_sell_way":