Пример #1
0
 public int Init(Initiator init)
 {
     if (init != null)
     {
         FrontServers = init.Server.ConnString;
         return(clrXspeedMdApi.Init(FrontServers, clrXspeedMdSpi));
     }
     else
     {
         return(-2);
     }
 }
Пример #2
0
 public int Init(Initiator init)
 {
     if (null != init)
     {
         this.FrontServers = init.Server.ConnString;
         return(clrXspeedTradeApi.Init(FrontServers, clrXspeedTradeSpi));
     }
     else
     {
         return(-2);
     }
 }
Пример #3
0
        /// <summary>
        /// 前置服务器连接事件的响应处理
        /// </summary>
        /// <param name="sender">前置服务器连接事件的发送者:TradeApi/MarketApi</param>
        /// <param name="e">前置服务器连接事件的返回参数</param>

        /*private void FrontServerConnectedHandler(object sender, RspEventArgs e)
         * {
         *  if (sender is QTradeSpi && 0 == e.ErrorID)
         *  {
         *      IsConnected = true;
         *      if(IsLogin)
         *      {
         *          UserLogin(new CLRCQdpFtdcReqUserLoginField { UserID = this.UserID, Password = this.UserPwd, BrokerID = this.BrokerID });
         *      }
         *  }
         * }*/

        /// <summary>
        /// 用户登录事件的响应处理
        /// </summary>
        /// <param name="sender">用户登录事件的发送者:TradeApi/MarketApi</param>
        /// <param name="e">用户登录事件的返回参数</param>

        /*private void UserLoginHandler(object sender, RspUserLoginEventArgs e)
         * {
         #if DEBUG
         *  Debug.WriteLine("Current ThreadID:{0},Thread Called by TradeApi->SetUserInfo", Thread.CurrentThread.ManagedThreadId);
         #endif
         *  if (sender is QTradeSpi && 0 == e.RspInfo.ErrorID)
         *  {
         *      UserID = e.RspUserLoin.UserID;
         *      BrokerID = e.RspUserLoin.BrokerID;
         *      DataCenterID = e.RspUserLoin.DataCenterID;
         *      TradingDay = e.RspUserLoin.TradingDay;
         *      int i;
         *      if(int.TryParse(e.RspUserLoin.MaxOrderLocalID, out i))
         *      {
         *          MaxLocalOrderID = i;
         *      }
         *
         *      IsLogin = true;
         *      clrQdpTradeApi.ReqQryUserInvestor(new CLRCQdpFtdcQryUserInvestorField { BrokerID = BrokerID, UserID = UserID }, RequestID);
         *  }
         * }*/

        /// <summary>
        /// FrontServerDisconnectedHandler 前置服务器连接断开事件的响应处理
        /// </summary>
        /// <param name="sender">前置服务器连接断开事件的发送者:TradeApi/MarketApi</param>
        /// <param name="e">前置服务器连接断开事件的返回参数</param>

        /*private void FrontServerDisconnectedHandler(object sender, RspEventArgs e)
         * {
         *  if (sender is QTradeSpi)
         *  {
         *      if((int)CLRQDP_FTFAIL_REASON.NORMAL_DISCONN == e.ErrorID)
         #if DEBUG
         *          Debug.WriteLine("Disconnect Front Server Normally.\r\nCurrent ThreadID:{0},Thread Called By TradeApi->DisconnectFront", Thread.CurrentThread.ManagedThreadId);
         #endif
         *  }
         * }*/

        /*private void QryUserInvestorHandler(object sender, RspQryUserInvestorEventArgs e)
         * {
         *  if (sender is QTradeApi && 0 == e.RspInfo.ErrorID)
         *  {
         *      InvestorID = e.RspUserInvestor.InvestorID;
         *  }
         * }
         *
         * private void UserLogoutHandler(object sender,RspUserLogoutEventArgs e)
         * {
         *  if (sender is QTradeApi && 0 == e.RspInfo.ErrorID)
         *  {
         *      IsLogin = false;
         *  }
         * }*/
        #endregion

        public int Init(Initiator init)
        {
            if (init.ReqLogging)
            {
                clrQdpTradeApi.OpenRequestLog(@"Logs\TradeReq.log");
            }
            if (init.RspLogging)
            {
                clrQdpTradeApi.OpenResponseLog(@"Logs\TradeRsp.log");
            }
            clrQdpTradeApi.SubscribePrivateTopic(CLRQDP_TE_RESUME_TYPE.QDP_TERT_QUICK);
            clrQdpTradeApi.SubscribePublicTopic(CLRQDP_TE_RESUME_TYPE.QDP_TERT_QUICK);
            clrQdpTradeApi.SubscribeUserTopic(CLRQDP_TE_RESUME_TYPE.QDP_TERT_QUICK);
            clrQdpTradeApi.RegisterFront(init.Server.ConnString);
            clrQdpTradeApi.Init();
            return(0);
        }