예제 #1
0
        //建立交易
        private void Connect_TD()
        {
            lock (_lockTd)
            {
                if (_bWantTdConnect &&
                    (null == m_pTdApi || IntPtr.Zero == m_pTdApi))
                {
                    m_pTdApi = TraderApi.TD_CreateTdApi();
                    TraderApi.XSpeed_RegOnRspCancelOrder(m_pMsgQueue, _fnOnRspCancelOrder_Holder);
                    TraderApi.XSpeed_RegOnRspInsertOrder(m_pMsgQueue, _fnOnRspInsertOrder_Holder);
                    TraderApi.XSpeed_RegOnRspArbitrageInstrument(m_pMsgQueue, _fnOnRspArbitrageInstrument_Holder);
                    TraderApi.XSpeed_RegOnRspQryExchangeInstrument(m_pMsgQueue, _fnOnRspQryExchangeInstrument_Holder);
                    TraderApi.XSpeed_RegOnRtnCancelOrder(m_pMsgQueue, _fnOnRtnCancelOrder_Holder);
                    TraderApi.XSpeed_RegOnRtnInstrumentStatus(m_pMsgQueue, _fnOnRtnInstrumentStatus_Holder);
                    TraderApi.XSpeed_RegOnRtnMatchedInfo(m_pMsgQueue, _fnOnRtnMatchedInfo_Holder);
                    TraderApi.XSpeed_RegOnRtnOrder(m_pMsgQueue, _fnOnRtnOrder_Holder);
                    TraderApi.XSpeed_RegOnRspQuoteSubscribe(m_pMsgQueue, _fnOnRspQuoteSubscribe_Holder);
                    TraderApi.XSpeed_RegOnRtnQuoteSubscribe(m_pMsgQueue, _fnOnRtnQuoteSubscribe_Holder);
                    TraderApi.TD_RegMsgQueue2TdApi(m_pTdApi, m_pMsgQueue);
                    TraderApi.TD_Connect(m_pTdApi, string.Join(";", server.Trading.ToArray()), account.InvestorId, account.Password, 0);

                    //向单例对象中注入操作用句柄
                    XSpeedAPI.GetInstance().__RegTdApi(m_pTdApi);
                }
            }
        }
        private void OnRtnQuoteSubscribe(IntPtr pTraderApi, ref DFITCQuoteSubscribeRtnField pRtnQuoteSubscribeData)
        {
            tdlog.Info("报价通知订阅回报:{0},{1},{2},{3},{4}",
                       pRtnQuoteSubscribeData.quoteID,
                       pRtnQuoteSubscribeData.ExchangeID,
                       pRtnQuoteSubscribeData.InstrumentID,
                       pRtnQuoteSubscribeData.buySellType,
                       pRtnQuoteSubscribeData.source);

            XSpeedAPI.GetInstance().FireOnRtnQuoteSubscribe(pRtnQuoteSubscribeData);
        }
예제 #3
0
        private void Disconnect_TD()
        {
            lock (_lockTd)
            {
                if (null != m_pTdApi && IntPtr.Zero != m_pTdApi)
                {
                    TraderApi.TD_RegMsgQueue2TdApi(m_pTdApi, IntPtr.Zero);
                    TraderApi.TD_ReleaseTdApi(m_pTdApi);
                    m_pTdApi = IntPtr.Zero;

                    XSpeedAPI.GetInstance().__RegTdApi(m_pTdApi);
                }
                _bTdConnected = false;
            }
        }
예제 #4
0
        private void Disconnect_MD()
        {
            lock (_lockMd)
            {
                if (null != m_pMdApi && IntPtr.Zero != m_pMdApi)
                {
                    MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, IntPtr.Zero);
                    MdApi.MD_ReleaseMdApi(m_pMdApi);
                    m_pMdApi = IntPtr.Zero;

                    XSpeedAPI.GetInstance().__RegMdApi(m_pMdApi);
                }
                _bMdConnected = false;
            }
        }
예제 #5
0
        //建立行情
        private void Connect_MD()
        {
            lock (_lockMd)
            {
                if (_bWantMdConnect &&
                    (null == m_pMdApi || IntPtr.Zero == m_pMdApi))
                {
                    m_pMdApi = MdApi.MD_CreateMdApi();
                    MdApi.XSpeed_RegOnMarketData(m_pMsgQueue, _fnOnMarketData_Holder);
                    MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, m_pMsgQueue);
                    MdApi.MD_Connect(m_pMdApi, string.Join(";", server.MarketData.ToArray()), account.InvestorId, account.Password, 0);

                    //向单例对象中注入操作用句柄
                    XSpeedAPI.GetInstance().__RegMdApi(m_pMdApi);
                }
            }
        }