Esempio n. 1
0
        public static PositionDetail CreateDetail(CLRDFITCPositionInfoRtnField pos)
        {
            PositionDetail result = new PositionDetail();

            switch (pos.exchangeID)
            {
            case "DCE":
                result.ExchangeID = ExchangeID.DCE;
                break;

            case "CZCE":
                result.ExchangeID = ExchangeID.CZCE;
                break;

            case "SHFE":
                result.ExchangeID = ExchangeID.SHFE;
                break;

            case "CFFEX":
                result.ExchangeID = ExchangeID.CFFEX;
                break;

            case "INE":
                result.ExchangeID = ExchangeID.INE;
                break;
            }
            result.InstrumentID = pos.instrumentID;
            switch (pos.buySellType)
            {
            case (short)CLRDFITCBuySellType.SPD_BUY:
                result.Direction = Direction.Buy;
                break;

            case (short)CLRDFITCBuySellType.SPD_SELL:
                result.Direction = Direction.Sell;
                break;
            }
            result.PositionPrice = pos.positionAvgPrice;
            result.VolumeAll     = pos.positionAmount;
            switch (pos.speculator)
            {
            case (int)CLRDFITCSpeculatorType.SPD_SPECULATOR:
                result.Flag = Flag.Speculator;
                break;

            case (int)CLRDFITCSpeculatorType.SPD_HEDGE:
                result.Flag = Flag.Hedge;
                break;

            case (int)CLRDFITCSpeculatorType.SPD_ARBITRAGE:
                result.Flag = Flag.Arbitrage;
                break;
            }
            return(result);
        }
Esempio n. 2
0
 protected override void OnRspQryPosition(CLRDFITCPositionInfoRtnField PositionInfo, CLRDFITCErrorRtnField ErrorInfo, bool bIsLast)
 {
     if (ProgramTradeEvents.RspEventHandler.ContainsKey(RspSpiModules.QryPosition) && null != ProgramTradeEvents.RspEventHandler[RspSpiModules.QryPosition])
     {
         TypedRspEventArgs <CLRDFITCPositionInfoRtnField, CLRDFITCErrorRtnField> evt = new TypedRspEventArgs <CLRDFITCPositionInfoRtnField, CLRDFITCErrorRtnField> {
             RequestID = PositionInfo.lRequestID, ErrorID = ErrorInfo.nErrorID, Message = ErrorInfo.errorMsg, Data = PositionInfo, Error = ErrorInfo, IsLast = bIsLast
         };
         Parallel.ForEach(ProgramTradeEvents.RspEventHandler[RspSpiModules.QryPosition].GetInvocationList(), handler =>
         {
             (handler as EventHandler <RspEventArgs>).BeginInvoke(this, evt, null, null);
         });
     }
 }