Beispiel #1
0
        static void test_CTP_Main(string[] args)
        {
            //api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86\QuantBox_CTP_Quote.dll");

            //api.Server.BrokerID = "1017";
            //api.Server.Address = "tcp://ctpmn1-front1.citicsf.com:51213";
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86\QuantBox_CTP_Trade.dll");

            api.Server.BrokerID = "1017";
            api.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51205";
            api.Server.PrivateTopicResumeType = ResumeType.Undefined;

            api.User.UserID   = "00000015";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;
            api.OnRspQryInstrument   = OnRspQryInstrument;

            api.Connect();
            Thread.Sleep(10 * 1000);
            //api.Subscribe("IF1502", "");
            ReqQueryField query = default(ReqQueryField);

            api.ReqQuery(QueryType.ReqQryInstrument, ref query);

            Thread.Sleep(300 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
Beispiel #2
0
        static void test_Tdx_Main(string[] args)
        {
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\Tdx\x86\QuantBox_Tdx_Trade.dll");

            api.Server.BrokerID       = "";
            api.Server.Address        = @"D:\new_hbzq_qq\Login.lua";
            api.Server.ExtInfoChar128 = @"D:\new_hbzq_qq\";

            api.User.UserID   = "05000000000";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api.Connect();

            Console.ReadKey();

            Console.ReadKey();

            api.Dispose();

            Console.ReadKey();

            Console.ReadKey();
        }
Beispiel #3
0
 //
 public override void Login()
 {
     if (mTdApi == null)
     {
         mTdApi = new XApi(mdPath);
         mTdApi.Server.AppID    = ConfigUtil.AppId;
         mTdApi.Server.AuthCode = ConfigUtil.AuthCode;
         mTdApi.Server.Address  = ConfigUtil.TdServer;
         mTdApi.Server.BrokerID = ConfigUtil.TdBroker;
         mTdApi.User.UserID     = ConfigUtil.TdInvestor;
         mTdApi.User.Password   = ConfigUtil.TdPassword;
         //
         mTdApi.Server.PrivateTopicResumeType = ResumeType.Quick;
         mTdApi.OnRspQryInstrument            = _onRspQryInstrument;
         mTdApi.OnRspQryInvestorPosition      = _OnRspQryInvestorPosition;
         mTdApi.OnRtnOrder             = _onRtnOrder;
         mTdApi.OnRtnTrade             = _onRtnTrade;
         mTdApi.OnRspQrySettlementInfo =
             (object sender, ref SettlementInfoClass settlementInfo, int size1, bool bIsLast) => {
             LogUtil.SysLog("结算确认:" + settlementInfo.Content);
         };
         mTdApi.OnConnectionStatus = _onConnectionStatus;
     }
     else if (mTdApi.IsConnected)
     {
         return;
     }
     mTdApi.ReconnectInterval = 60;
     mTdApi.Connect();
 }
Beispiel #4
0
        static void test_KingstarGold_Main(string[] args)
        {
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\KingstarGold\QuantBox_KingstarGold.dll");

            api.Server.BrokerID = "";
            api.Server.Address  = "tcp://124.74.239.38:18961";

            api.User.UserID   = "9843010200773696";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api.Connect();

            Console.ReadKey();
            api.Subscribe("IF1411", "");

            Console.ReadKey();

            api.Dispose();

            Console.ReadKey();

            Console.ReadKey();
        }
Beispiel #5
0
        public void Connect()
        {
            // 查看有多少种连接
            int j = 0;

            foreach (var cc in ConnectionConfigList)
            {
                // 建立多个连接
                for (int i = 0; i < cc.SessionLimit; ++i)
                {
                    XApi api = new XApi(cc.LibPath);
                    api.Server = cc.Server;
                    api.User   = cc.User;
                    api.Log    = LogManager.GetLogger(string.Format("{0}.{1}.{2}.{3}", api.Server.BrokerID, api.User.UserID, j, i));

                    api.MaxSubscribedInstrumentsCount = cc.SubscribePerSession;

                    api.OnConnectionStatus   = OnConnectionStatus;
                    api.OnRtnDepthMarketData = OnRtnDepthMarketData;

                    api.Connect();

                    XApiList.Add(api);
                }
                ++j;
            }
        }
        public void Connect(ConnectionInfo connectionInfo)
        {
            Console.WriteLine(connectionInfo);
            api_Quote.Server.BrokerID = ObjectUtils.ToString(connectionInfo.GetValue("BrokerId"));
            api_Quote.Server.Address  = ObjectUtils.ToString(connectionInfo.GetValue("DataServer"));
            api_Quote.User.UserID     = ObjectUtils.ToString(connectionInfo.GetValue("UserID"));
            api_Quote.User.Password   = ObjectUtils.ToString(connectionInfo.GetValue("Passwd"));

            api_Quote.OnConnectionStatus   = XApi_OnConnectionStatus;
            api_Quote.OnRtnDepthMarketData = XApi_OnRtnDepthMarketData;

            api_Quote.Connect();
        }
Beispiel #7
0
        static void test_Linux_Main(string[] args)
        {
            //Queue queue = new Queue(@"libQuantBox_Queue.so");
            //Queue queue2 = new Queue(@"libQuantBox_Queue.so");

            //ApiManager.QueuePath = @"/home/hetao/works/QuantBox_XAPI/bin/Debug/libQuantBox_Queue.so";
            //XApi api = ApiManager.CreateApi(@"/home/hetao/works/QuantBox_XAPI/bin/Debug/libQuantBox_CTP_Quote.so");
            //XApi api2 = ApiManager.CreateApi(@"/home/hetao/works/QuantBox_XAPI/bin/Debug/libQuantBox_CTP_Trade.so");

            //ApiManager.QueuePath = @"libQuantBox_Queue.so";
            XApi api  = new XApi(@"libQuantBox_CTP_Quote.so");
            XApi api2 = new XApi(@"libQuantBox_CTP_Trade.so");

            api.Server.BrokerID = "1017";
            api.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51213";

            api.User.UserID   = "00000015";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api2.Server.BrokerID = "1017";
            api2.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51205";
            api2.Server.PrivateTopicResumeType = ResumeType.Quick;

            api2.User.UserID   = "00000015";
            api2.User.Password = "******";


            api2.OnConnectionStatus     = OnConnectionStatus2;
            api2.OnRspQryInstrument     = OnRspQryInstrument;
            api2.OnRspQryTradingAccount = OnRspQryTradingAccount;
            api2.OnRspQrySettlementInfo = OnRspQrySettlementInfo;
            api2.OnRtnOrder             = OnRtnOrder;
            api2.OnRtnError             = OnRtnError;
            api2.OnRtnTrade             = OnRtnTrade;

            api.Connect();
            api2.Connect();

            api.Subscribe("IF1412", "");

            Console.ReadKey();

            Thread.Sleep(10000);
            Console.WriteLine(123);
            api.Dispose();
            api2.Dispose();
        }
Beispiel #8
0
        public void Connect()
        {
            XApi api = new XApi(ConnectionConfig.LibPath);

            api.Server = ConnectionConfig.Server;
            api.User   = ConnectionConfig.User;

            api.Log = LogManager.GetLogger(string.Format("{0}.{1}", api.Server.BrokerID, api.User.UserID));
            api.MaxSubscribedInstrumentsCount = ConnectionConfig.SubscribePerSession;

            api.OnConnectionStatus = OnConnectionStatus;
            api.OnRspQryInstrument = OnRspQryInstrument;

            api.Connect();

            XApiList.Add(api);
        }
Beispiel #9
0
        /// <summary>
        /// 连接市场服务器
        /// </summary>
        public void Connect(ConnectionInfo connectionInfo)
        {
            api_Trade.Server.BrokerID = ObjectUtils.ToString(connectionInfo.GetValue("BrokerId"));
            api_Trade.Server.Address  = ObjectUtils.ToString(connectionInfo.GetValue("TradeServer"));
            api_Trade.User.UserID     = ObjectUtils.ToString(connectionInfo.GetValue("UserID"));
            api_Trade.User.Password   = ObjectUtils.ToString(connectionInfo.GetValue("Passwd"));

            api_Trade.OnConnectionStatus = XApi_OnConnectionStatus;
            api_Trade.OnRspQryInstrument = XApi_OnRspQryInstrument;

            api_Trade.OnRspQryTradingAccount   = XApi_OnRspQryTradingAccount;
            api_Trade.OnRspQryInvestorPosition = XApi_OnRspQryInvestorPosition;
            api_Trade.OnRspQrySettlementInfo   = Xapi_OnRspQrySettlementInfo;
            api_Trade.OnRtnOrder = XApi_OnRtnOrder;
            api_Trade.OnRtnError = XApi_OnRtnError;
            api_Trade.OnRtnTrade = XApi_OnRtnTrade;
            api_Trade.Connect();
        }
Beispiel #10
0
        static void test_LTS_Main(string[] args)
        {
            XApi api  = new XApi("QuantBox_LTS_Quote.dll");
            XApi api2 = new XApi("QuantBox_C2LTS_Trade.dll");

            api.Server.BrokerID = "2010";
            api.Server.Address  = "tcp://211.144.195.163:44513";

            api.User.UserID   = "00000015";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api2.Server.BrokerID = "2010";
            api2.Server.Address  = "tcp://211.144.195.163:44505";

            api2.User.UserID   = "0020090001134";
            api2.User.Password = "******";

            api2.OnConnectionStatus     = OnConnectionStatus2;
            api2.OnRspQryInstrument     = OnRspQryInstrument;
            api2.OnRspQryTradingAccount = OnRspQryTradingAccount;
            api2.OnRspQrySettlementInfo = OnRspQrySettlementInfo;
            api2.OnRtnOrder             = OnRtnOrder;
            api2.OnRtnError             = OnRtnError;
            api2.OnRtnTrade             = OnRtnTrade;

            api.Connect();
            api2.Connect();

            Console.ReadKey();

            ReqQueryField query = new ReqQueryField();

            api2.ReqQuery(QueryType.ReqQryInstrument, query);

            Console.ReadKey();

            api.Dispose();
            api2.Dispose();
            //queue.Dispose();
        }
Beispiel #11
0
        static void Test_Linux_Main(string[] args)
        {
            XApi api  = new XApi(@"libQuantBox_CTP_Quote.so");
            XApi api2 = new XApi(@"libQuantBox_CTP_Trade.so");

            api.Server.BrokerID = "1017";
            api.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51213";

            api.User.UserID   = "00000015";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api2.Server.BrokerID = "1017";
            api2.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51205";
            api2.Server.PrivateTopicResumeType = ResumeType.Quick;

            api2.User.UserID   = "00000015";
            api2.User.Password = "******";


            api2.OnConnectionStatus     = OnConnectionStatus2;
            api2.OnRspQryInstrument     = OnRspQryInstrument;
            api2.OnRspQryTradingAccount = OnRspQryTradingAccount;
            api2.OnRspQrySettlementInfo = OnRspQrySettlementInfo;
            api2.OnRtnOrder             = OnRtnOrder;
            api2.OnRtnError             = OnRtnError;
            api2.OnRtnTrade             = OnRtnTrade;

            api.Connect();
            api2.Connect();

            api.Subscribe("IF1502;IF1503", "");

            Console.ReadKey();

            Thread.Sleep(10000);
            Console.WriteLine(123);
            api.Dispose();
            api2.Dispose();
        }
Beispiel #12
0
        static void test_CTP_Main(string[] args)
        {
            //ApiManager.QueuePath = @"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\QuantBox_Queue.dll";
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\QuantBox_CTP_Trade.dll");

            api.Server.BrokerID = "1017";
            api.Server.Address  = "tcp://ctpmn1-front1.citicsf.com:51205";

            api.User.UserID   = "00000015";
            api.User.Password = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api.Connect();

            Thread.Sleep(5 * 1000);

            api.Dispose();
        }
Beispiel #13
0
        static void test_TongShi_Main(string[] args)
        {
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\TongShi\x86\QuantBox_TongShi_Quote.dll");

            api.Server.Address = "D:\\Scengine\\Stock.dll";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;
            api.OnFilterSubscribe    = OnFilterSubscribe;

            api.Connect();
            Thread.Sleep(10 * 1000);
            api.ReqQryInstrument("", "");

            Thread.Sleep(300 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
Beispiel #14
0
        /// <summary>
        /// 连接行情前置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void connectBt_Click(object sender, EventArgs e)
        {
            showInfo("begin");
            showInfo("Initialize api");
            api = new XApi(@"C:\Users\jht\Documents\Visual Studio 2013\Projects\DataApp\DataApp\dll\QuantBox_CTP_Quote.dll");
            showInfo("Initialize server info");
            api.Server.BrokerID = "66666";
            api.Server.Address  = "tcp://ctp1-md9.citicsf.com:41213";

            showInfo("set 回调函数");
            api.OnConnectionStatus   += OnConnectionStatus;
            api.OnRtnDepthMarketData += OnRtnDepthMarketData;

            showInfo("begin connecting");
            api.Connect();


            //Thread.Sleep(3000);
            //showInfo("begin dispose");
            //api.Dispose();

            //Thread.Sleep(5 * 1000);
        }
Beispiel #15
0
 //
 public override void Login()
 {
     if (mMdApi == null)
     {
         mMdApi = new XApi(mdPath);
         mMdApi.Server.AppID    = ConfigUtil.AppId;
         mMdApi.Server.AuthCode = ConfigUtil.AuthCode;
         mMdApi.Server.Address  = ConfigUtil.MdServer;
         mMdApi.Server.BrokerID = ConfigUtil.MdBroker;
         mMdApi.User.UserID     = ConfigUtil.MdInvestor;
         mMdApi.User.Password   = ConfigUtil.MdPassword;
         //
         mMdApi.OnConnectionStatus   = _onConnectionStatus;
         mMdApi.OnRtnError           = _onRtnError;
         mMdApi.OnRtnDepthMarketData = _onRtnDepthMarketData;
     }
     else if (mMdApi.IsConnected)
     {
         return;
     }
     mMdApi.ReconnectInterval = 60;
     mMdApi.Connect();
 }
Beispiel #16
0
        static void test_Tdx_Main(string[] args)
        {
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\x86\Tdx\Tdx_Trade_x86.dll");


            api.Server.Address        = @"D:\tc_yhzq_v6\Login.lua";
            api.Server.ExtInfoChar128 = @"D:\tc_yhzq_v6\";
            api.User.UserID           = "16206";
            api.User.Password         = "******";

            api.Server.Address        = @"D:\new_gjzq_v6\Login.lua";
            api.Server.ExtInfoChar128 = @"D:\new_gjzq_v6\";
            api.User.UserID           = "31244679";
            api.User.Password         = "******";

            api.OnConnectionStatus   = OnConnectionStatus;
            api.OnRtnDepthMarketData = OnRtnDepthMarketData;

            api.Connect();

            Console.ReadKey();
            Console.WriteLine("回车后开始查持仓");
            Console.ReadKey();

            ReqQueryField query = new ReqQueryField();

            query.Int32ID = -1;
            api.ReqQuery(QueryType.ReqQryInvestorPosition, ref query);

            // api.Dispose();

            Console.ReadKey();

            Console.WriteLine("回车后退出");
            Console.ReadKey();
        }
Beispiel #17
0
 public void Connect()
 {
     api.Server = _Server;
     api.User   = _User;
     api.Connect();
 }
Beispiel #18
0
 public void Connect(string szServerPath, string szUserPath, string szPath = "")
 {
     api.Connect(szServerPath, szUserPath, szPath);
 }