# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings

from . import common_pb2 as common__pb2
from . import trading_pb2 as trading__pb2

GRPC_GENERATED_VERSION = '1.70.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + f' but the generated code in trading_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class TradingServiceStub(object):
    """交易服务
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.PlaceOrder = channel.unary_unary(
                '/ctplite.TradingService/PlaceOrder',
                request_serializer=trading__pb2.OrderRequest.SerializeToString,
                response_deserializer=trading__pb2.OrderResponse.FromString,
                _registered_method=True)
        self.CancelOrder = channel.unary_unary(
                '/ctplite.TradingService/CancelOrder',
                request_serializer=trading__pb2.CancelRequest.SerializeToString,
                response_deserializer=trading__pb2.OrderResponse.FromString,
                _registered_method=True)
        self.QueryPosition = channel.unary_unary(
                '/ctplite.TradingService/QueryPosition',
                request_serializer=trading__pb2.PositionQuery.SerializeToString,
                response_deserializer=trading__pb2.PositionResponse.FromString,
                _registered_method=True)
        self.StreamOrderStatus = channel.unary_stream(
                '/ctplite.TradingService/StreamOrderStatus',
                request_serializer=common__pb2.AuthRequest.SerializeToString,
                response_deserializer=trading__pb2.OrderStatusUpdate.FromString,
                _registered_method=True)
        self.QueryTradingAccount = channel.unary_unary(
                '/ctplite.TradingService/QueryTradingAccount',
                request_serializer=trading__pb2.TradingAccountQuery.SerializeToString,
                response_deserializer=trading__pb2.TradingAccountResponse.FromString,
                _registered_method=True)
        self.QueryOrder = channel.unary_unary(
                '/ctplite.TradingService/QueryOrder',
                request_serializer=trading__pb2.OrderQuery.SerializeToString,
                response_deserializer=trading__pb2.OrderQueryResponse.FromString,
                _registered_method=True)
        self.QueryTrade = channel.unary_unary(
                '/ctplite.TradingService/QueryTrade',
                request_serializer=trading__pb2.TradeQuery.SerializeToString,
                response_deserializer=trading__pb2.TradeQueryResponse.FromString,
                _registered_method=True)
        self.ConfirmSettlementInfo = channel.unary_unary(
                '/ctplite.TradingService/ConfirmSettlementInfo',
                request_serializer=trading__pb2.SettlementConfirmRequest.SerializeToString,
                response_deserializer=trading__pb2.SettlementConfirmResponse.FromString,
                _registered_method=True)
        self.QueryInstrument = channel.unary_unary(
                '/ctplite.TradingService/QueryInstrument',
                request_serializer=trading__pb2.InstrumentQuery.SerializeToString,
                response_deserializer=trading__pb2.InstrumentQueryResponse.FromString,
                _registered_method=True)
        self.QueryInstrumentMarginRate = channel.unary_unary(
                '/ctplite.TradingService/QueryInstrumentMarginRate',
                request_serializer=trading__pb2.InstrumentMarginRateQuery.SerializeToString,
                response_deserializer=trading__pb2.InstrumentMarginRateResponse.FromString,
                _registered_method=True)
        self.QueryInstrumentCommissionRate = channel.unary_unary(
                '/ctplite.TradingService/QueryInstrumentCommissionRate',
                request_serializer=trading__pb2.InstrumentCommissionRateQuery.SerializeToString,
                response_deserializer=trading__pb2.InstrumentCommissionRateResponse.FromString,
                _registered_method=True)
        self.QuerySettlementInfo = channel.unary_unary(
                '/ctplite.TradingService/QuerySettlementInfo',
                request_serializer=trading__pb2.SettlementInfoQuery.SerializeToString,
                response_deserializer=trading__pb2.SettlementInfoResponse.FromString,
                _registered_method=True)
        self.TradingLogout = channel.unary_unary(
                '/ctplite.TradingService/TradingLogout',
                request_serializer=trading__pb2.TradingLogoutRequest.SerializeToString,
                response_deserializer=trading__pb2.TradingLogoutResponse.FromString,
                _registered_method=True)
        self.QueryMaxOrderVolume = channel.unary_unary(
                '/ctplite.TradingService/QueryMaxOrderVolume',
                request_serializer=trading__pb2.MaxOrderVolumeQuery.SerializeToString,
                response_deserializer=trading__pb2.MaxOrderVolumeResponse.FromString,
                _registered_method=True)
        self.QueryExchange = channel.unary_unary(
                '/ctplite.TradingService/QueryExchange',
                request_serializer=trading__pb2.ExchangeQuery.SerializeToString,
                response_deserializer=trading__pb2.ExchangeResponse.FromString,
                _registered_method=True)
        self.QueryInvestor = channel.unary_unary(
                '/ctplite.TradingService/QueryInvestor',
                request_serializer=trading__pb2.InvestorQuery.SerializeToString,
                response_deserializer=trading__pb2.InvestorResponse.FromString,
                _registered_method=True)


class TradingServiceServicer(object):
    """交易服务
    """

    def PlaceOrder(self, request, context):
        """下单（异步）
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def CancelOrder(self, request, context):
        """撤单（异步）
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryPosition(self, request, context):
        """查询持仓（异步）
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def StreamOrderStatus(self, request, context):
        """流式订单状态推送
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryTradingAccount(self, request, context):
        """查询资金账户
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryOrder(self, request, context):
        """查询订单
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryTrade(self, request, context):
        """查询成交
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ConfirmSettlementInfo(self, request, context):
        """结算确认
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryInstrument(self, request, context):
        """查询合约信息
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryInstrumentMarginRate(self, request, context):
        """查询合约保证金率
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryInstrumentCommissionRate(self, request, context):
        """查询合约手续费率
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QuerySettlementInfo(self, request, context):
        """查询结算信息
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def TradingLogout(self, request, context):
        """用户登出（CTP交易登出）
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryMaxOrderVolume(self, request, context):
        """查询最大报单量
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryExchange(self, request, context):
        """查询交易所
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def QueryInvestor(self, request, context):
        """查询投资者
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_TradingServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'PlaceOrder': grpc.unary_unary_rpc_method_handler(
                    servicer.PlaceOrder,
                    request_deserializer=trading__pb2.OrderRequest.FromString,
                    response_serializer=trading__pb2.OrderResponse.SerializeToString,
            ),
            'CancelOrder': grpc.unary_unary_rpc_method_handler(
                    servicer.CancelOrder,
                    request_deserializer=trading__pb2.CancelRequest.FromString,
                    response_serializer=trading__pb2.OrderResponse.SerializeToString,
            ),
            'QueryPosition': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryPosition,
                    request_deserializer=trading__pb2.PositionQuery.FromString,
                    response_serializer=trading__pb2.PositionResponse.SerializeToString,
            ),
            'StreamOrderStatus': grpc.unary_stream_rpc_method_handler(
                    servicer.StreamOrderStatus,
                    request_deserializer=common__pb2.AuthRequest.FromString,
                    response_serializer=trading__pb2.OrderStatusUpdate.SerializeToString,
            ),
            'QueryTradingAccount': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryTradingAccount,
                    request_deserializer=trading__pb2.TradingAccountQuery.FromString,
                    response_serializer=trading__pb2.TradingAccountResponse.SerializeToString,
            ),
            'QueryOrder': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryOrder,
                    request_deserializer=trading__pb2.OrderQuery.FromString,
                    response_serializer=trading__pb2.OrderQueryResponse.SerializeToString,
            ),
            'QueryTrade': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryTrade,
                    request_deserializer=trading__pb2.TradeQuery.FromString,
                    response_serializer=trading__pb2.TradeQueryResponse.SerializeToString,
            ),
            'ConfirmSettlementInfo': grpc.unary_unary_rpc_method_handler(
                    servicer.ConfirmSettlementInfo,
                    request_deserializer=trading__pb2.SettlementConfirmRequest.FromString,
                    response_serializer=trading__pb2.SettlementConfirmResponse.SerializeToString,
            ),
            'QueryInstrument': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryInstrument,
                    request_deserializer=trading__pb2.InstrumentQuery.FromString,
                    response_serializer=trading__pb2.InstrumentQueryResponse.SerializeToString,
            ),
            'QueryInstrumentMarginRate': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryInstrumentMarginRate,
                    request_deserializer=trading__pb2.InstrumentMarginRateQuery.FromString,
                    response_serializer=trading__pb2.InstrumentMarginRateResponse.SerializeToString,
            ),
            'QueryInstrumentCommissionRate': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryInstrumentCommissionRate,
                    request_deserializer=trading__pb2.InstrumentCommissionRateQuery.FromString,
                    response_serializer=trading__pb2.InstrumentCommissionRateResponse.SerializeToString,
            ),
            'QuerySettlementInfo': grpc.unary_unary_rpc_method_handler(
                    servicer.QuerySettlementInfo,
                    request_deserializer=trading__pb2.SettlementInfoQuery.FromString,
                    response_serializer=trading__pb2.SettlementInfoResponse.SerializeToString,
            ),
            'TradingLogout': grpc.unary_unary_rpc_method_handler(
                    servicer.TradingLogout,
                    request_deserializer=trading__pb2.TradingLogoutRequest.FromString,
                    response_serializer=trading__pb2.TradingLogoutResponse.SerializeToString,
            ),
            'QueryMaxOrderVolume': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryMaxOrderVolume,
                    request_deserializer=trading__pb2.MaxOrderVolumeQuery.FromString,
                    response_serializer=trading__pb2.MaxOrderVolumeResponse.SerializeToString,
            ),
            'QueryExchange': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryExchange,
                    request_deserializer=trading__pb2.ExchangeQuery.FromString,
                    response_serializer=trading__pb2.ExchangeResponse.SerializeToString,
            ),
            'QueryInvestor': grpc.unary_unary_rpc_method_handler(
                    servicer.QueryInvestor,
                    request_deserializer=trading__pb2.InvestorQuery.FromString,
                    response_serializer=trading__pb2.InvestorResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ctplite.TradingService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ctplite.TradingService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class TradingService(object):
    """交易服务
    """

    @staticmethod
    def PlaceOrder(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/PlaceOrder',
            trading__pb2.OrderRequest.SerializeToString,
            trading__pb2.OrderResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def CancelOrder(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/CancelOrder',
            trading__pb2.CancelRequest.SerializeToString,
            trading__pb2.OrderResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryPosition(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryPosition',
            trading__pb2.PositionQuery.SerializeToString,
            trading__pb2.PositionResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def StreamOrderStatus(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_stream(
            request,
            target,
            '/ctplite.TradingService/StreamOrderStatus',
            common__pb2.AuthRequest.SerializeToString,
            trading__pb2.OrderStatusUpdate.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryTradingAccount(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryTradingAccount',
            trading__pb2.TradingAccountQuery.SerializeToString,
            trading__pb2.TradingAccountResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryOrder(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryOrder',
            trading__pb2.OrderQuery.SerializeToString,
            trading__pb2.OrderQueryResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryTrade(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryTrade',
            trading__pb2.TradeQuery.SerializeToString,
            trading__pb2.TradeQueryResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ConfirmSettlementInfo(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/ConfirmSettlementInfo',
            trading__pb2.SettlementConfirmRequest.SerializeToString,
            trading__pb2.SettlementConfirmResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryInstrument(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryInstrument',
            trading__pb2.InstrumentQuery.SerializeToString,
            trading__pb2.InstrumentQueryResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryInstrumentMarginRate(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryInstrumentMarginRate',
            trading__pb2.InstrumentMarginRateQuery.SerializeToString,
            trading__pb2.InstrumentMarginRateResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryInstrumentCommissionRate(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryInstrumentCommissionRate',
            trading__pb2.InstrumentCommissionRateQuery.SerializeToString,
            trading__pb2.InstrumentCommissionRateResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QuerySettlementInfo(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QuerySettlementInfo',
            trading__pb2.SettlementInfoQuery.SerializeToString,
            trading__pb2.SettlementInfoResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def TradingLogout(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/TradingLogout',
            trading__pb2.TradingLogoutRequest.SerializeToString,
            trading__pb2.TradingLogoutResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryMaxOrderVolume(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryMaxOrderVolume',
            trading__pb2.MaxOrderVolumeQuery.SerializeToString,
            trading__pb2.MaxOrderVolumeResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryExchange(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryExchange',
            trading__pb2.ExchangeQuery.SerializeToString,
            trading__pb2.ExchangeResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def QueryInvestor(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ctplite.TradingService/QueryInvestor',
            trading__pb2.InvestorQuery.SerializeToString,
            trading__pb2.InvestorResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
