def pack_req(cls, trd_side, order_type, price, qty,
                 code, adjust_limit, trd_env, sec_mkt_str, acc_id, trd_mkt, conn_id):
        """Convert from user request for place order to PLS request"""
        from futuquant.common.pb.Trd_PlaceOrder_pb2 import Request
        req = Request()
        serial_no = get_unique_id32()
        req.c2s.packetID.serialNo = serial_no
        req.c2s.packetID.connID = conn_id

        req.c2s.header.trdEnv = TRD_ENV_MAP[trd_env]
        req.c2s.header.accID = acc_id
        req.c2s.header.trdMarket = TRD_MKT_MAP[trd_mkt]

        req.c2s.trdSide = TRD_SIDE_MAP[trd_side]
        req.c2s.orderType = ORDER_TYPE_MAP[order_type]
        req.c2s.code = code
        req.c2s.qty = qty
        req.c2s.price = price
        req.c2s.adjustPrice = adjust_limit != 0
        req.c2s.adjustSideAndLimit = adjust_limit
        proto_qot_mkt = MKT_MAP.get(sec_mkt_str, Qot_Common_pb2.QotMarket_Unknown)
        proto_trd_sec_mkt = QOT_MARKET_TO_TRD_SEC_MARKET_MAP.get(proto_qot_mkt,
                                                                 Trd_Common_pb2.TrdSecMarket_Unknown)
        req.c2s.secMarket = proto_trd_sec_mkt

        return pack_pb_req(req, ProtoId.Trd_PlaceOrder, conn_id, serial_no)
def pack_req ( cls , trd_side , order_type , price , qty , code , adjust_limit , trd_env , sec_mkt_str , acc_id , trd_mkt , conn_id ) : from futuquant . common . pb . Trd_PlaceOrder_pb2 import Request req = Request ( ) serial_no = get_unique_id32 ( ) req . c2s . packetID . serialNo = serial_no req . c2s . packetID . connID = conn_id req . c2s . header . trdEnv = TRD_ENV_MAP [ trd_env ] req . c2s . header . accID = acc_id req . c2s . header . trdMarket = TRD_MKT_MAP [ trd_mkt ] req . c2s . trdSide = TRD_SIDE_MAP [ trd_side ] req . c2s . orderType = ORDER_TYPE_MAP [ order_type ] req . c2s . code = code req . c2s . qty = qty req . c2s . price = price req . c2s . adjustPrice = adjust_limit != 0 req . c2s . adjustSideAndLimit = adjust_limit proto_qot_mkt = MKT_MAP . get ( sec_mkt_str , Qot_Common_pb2 . QotMarket_Unknown ) proto_trd_sec_mkt = QOT_MARKET_TO_TRD_SEC_MARKET_MAP . get ( proto_qot_mkt , Trd_Common_pb2 . TrdSecMarket_Unknown ) req . c2s . secMarket = proto_trd_sec_mkt return pack_pb_req ( req , ProtoId . Trd_PlaceOrder , conn_id , serial_no )
Convert from user request for place order to PLS request