Beispiel #1
0
        bool ORDER_ACTION_SENT = false; //是否发送了报单

        public void Run()
        {
            api = new CTPTraderAdapter();
            api.OnFrontConnected           += new FrontConnected(OnFrontConnected);
            api.OnFrontDisconnected        += new FrontDisconnected(OnFrontDisconnected);
            api.OnHeartBeatWarning         += new HeartBeatWarning(OnHeartBeatWarning);
            api.OnRspError                 += new RspError(OnRspError);
            api.OnRspUserLogin             += new RspUserLogin(OnRspUserLogin);
            api.OnRspOrderAction           += new RspOrderAction(OnRspOrderAction);
            api.OnRspOrderInsert           += new RspOrderInsert(OnRspOrderInsert);
            api.OnRspQryInstrument         += new RspQryInstrument(OnRspQryInstrument);
            api.OnRspQryInvestorPosition   += new RspQryInvestorPosition(OnRspQryInvestorPosition);
            api.OnRspQryTradingAccount     += new RspQryTradingAccount(OnRspQryTradingAccount);
            api.OnRspSettlementInfoConfirm += new RspSettlementInfoConfirm(OnRspSettlementInfoConfirm);
            api.OnRtnOrder                 += new RtnOrder(OnRtnOrder);
            api.OnRtnTrade                 += new RtnTrade(OnRtnTrade);

            api.SubscribePublicTopic(EnumTeResumeType.THOST_TERT_RESTART);                                      // 注册公有流
            api.SubscribePrivateTopic(EnumTeResumeType.THOST_TERT_RESTART);                                     // 注册私有流

            try
            {
                api.RegisterFront(FRONT_ADDR);
                api.Init();
                api.Join(); // 阻塞直到关闭或者CTRL+C
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                api.Release();
            }
        }
Beispiel #2
0
        bool ORDER_ACTION_SENT = false; //是否发送了报单

        public void Run()
        {
            api = new CTPTraderAdapter();
            api.OnFrontConnected           += new FrontConnected(OnFrontConnected);
            api.OnFrontDisconnected        += new FrontDisconnected(OnFrontDisconnected);
            api.OnHeartBeatWarning         += new HeartBeatWarning(OnHeartBeatWarning);
            api.OnRspError                 += new RspError(OnRspError);
            api.OnRspUserLogin             += new RspUserLogin(OnRspUserLogin);
            api.OnRspOrderAction           += new RspOrderAction(OnRspOrderAction);
            api.OnRspOrderInsert           += new RspOrderInsert(OnRspOrderInsert);
            api.OnRspQryInstrument         += new RspQryInstrument(OnRspQryInstrument);
            api.OnRspQryInvestorPosition   += new RspQryInvestorPosition(OnRspQryInvestorPosition);
            api.OnRspQryTradingAccount     += new RspQryTradingAccount(OnRspQryTradingAccount);
            api.OnRspSettlementInfoConfirm += new RspSettlementInfoConfirm(OnRspSettlementInfoConfirm);
            api.OnRtnOrder                 += new RtnOrder(OnRtnOrder);
            api.OnRtnTrade                 += new RtnTrade(OnRtnTrade);



            api.SubscribePublicTopic(EnumTeResumeType.THOST_TERT_QUICK);                                        // 注册公有流
            api.SubscribePrivateTopic(EnumTeResumeType.THOST_TERT_QUICK);                                       // 注册私有流

            try
            {
                api.RegisterFront(FRONT_ADDR);
                //ThostFtdcUserPasswordUpdateField req = new ThostFtdcUserPasswordUpdateField();
                //req.BrokerID = BROKER_ID;
                //req.UserID = INVESTOR_ID;
                //req.OldPassword = PASSWORD;
                //req.NewPassword = "******";
                //int iResult = api.ReqUserPasswordUpdate(req, iRequestID);
                //Console.WriteLine("--->>> 修改密码: " + ((iResult == 0) ? "修改成功" : "修改失败"));

                api.Init();
                api.Join(); // 阻塞直到关闭或者CTRL+C

                //修改密码
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                api.Release();
            }
        }