def _OnRspQryPositionDetail(self, pInvestorPositionDetail: CThostFtdcInvestorPositionDetailField, pRspInfo: CThostFtdcRspInfoField, nRequestID: int, bIsLast: bool):
        """持仓明细"""
        if pInvestorPositionDetail.getInstrumentID() == '':
            return
        detail = PositionDetail()
        detail.Instrument = pInvestorPositionDetail.getInstrumentID()
        detail.CloseProfit = pInvestorPositionDetail.getCloseProfitByTrade()
        detail.Direction = DirectType.Buy if pInvestorPositionDetail.getDirection() == TThostFtdcDirectionType.THOST_FTDC_D_Buy else DirectType.Sell
        detail.HedgeFlag = HedgeType(list(TThostFtdcHedgeFlagType).index(pInvestorPositionDetail.getHedgeFlag()))
        detail.OpenDate = pInvestorPositionDetail.getOpenDate()
        detail.PositionProfit = pInvestorPositionDetail.getPositionProfitByTrade()
        detail.OpenPrice = pInvestorPositionDetail.getOpenPrice()
        detail.TradeType = TradeTypeType(list(TThostFtdcTradeTypeType).index(pInvestorPositionDetail.getTradeType()))
        detail.Volume = pInvestorPositionDetail.getVolume()
        self.position_details[pInvestorPositionDetail.getTradeID()] = detail
def _OnRspQryPositionDetail ( self , pInvestorPositionDetail : CThostFtdcInvestorPositionDetailField , pRspInfo : CThostFtdcRspInfoField , nRequestID : int , bIsLast : bool ) : if pInvestorPositionDetail . getInstrumentID ( ) == '' : return detail = PositionDetail ( ) detail . Instrument = pInvestorPositionDetail . getInstrumentID ( ) detail . CloseProfit = pInvestorPositionDetail . getCloseProfitByTrade ( ) detail . Direction = DirectType . Buy if pInvestorPositionDetail . getDirection ( ) == TThostFtdcDirectionType . THOST_FTDC_D_Buy else DirectType . Sell detail . HedgeFlag = HedgeType ( list ( TThostFtdcHedgeFlagType ) . index ( pInvestorPositionDetail . getHedgeFlag ( ) ) ) detail . OpenDate = pInvestorPositionDetail . getOpenDate ( ) detail . PositionProfit = pInvestorPositionDetail . getPositionProfitByTrade ( ) detail . OpenPrice = pInvestorPositionDetail . getOpenPrice ( ) detail . TradeType = TradeTypeType ( list ( TThostFtdcTradeTypeType ) . index ( pInvestorPositionDetail . getTradeType ( ) ) ) detail . Volume = pInvestorPositionDetail . getVolume ( ) self . position_details [ pInvestorPositionDetail . getTradeID ( ) ] = detail
持仓明细