示例#1
0
文件: Program.cs 项目: wzugang/XAPI2
        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();
        }
示例#2
0
        static void Test_CTP_Main(string[] args)
        {
            Type type = Type.GetType("XAPI.Callback.XApi, XApi_CSharp");
            var  a    = (IXApi)Activator.CreateInstance(type, @"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\x86\CTP\CTP_Quote_x86.dll");

            api = a;

            api.Server.BrokerID = "9999";
            api.Server.Address  = "tcp://180.168.146.187:10010";
            api.Server.PrivateTopicResumeType = ResumeType.Undefined;

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

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

            api.Connect();
            Thread.Sleep(3 * 1000);
            api.Subscribe("IF000;IF_WI;IF_IH_1803;IF888", "");

            Console.ReadKey();
            Thread.Sleep(1000 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
示例#3
0
        static void test_CTP_Main2(string[] args)
        {
            Type type = Type.GetType("XAPI.Callback.XApi, XAPI_CSharp");
            var  a    = (IXApi)Activator.CreateInstance(type, @"d:\Users\Kan\Documents\GitHub\XAPI3\bin\Debug64\x64\CTP_SE\CTP_SE_Trade_x64.dll");

            api = a;

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

            api.Connect(
                @"d:\Users\Kan\Documents\GitHub\XAPI3\bin\Debug64\x64\CTP_SE\td_1.json",
                @"d:\Users\Kan\Documents\GitHub\XAPI3\bin\Debug64\x64\CTP_SE\td_2.json",
                Path.GetTempPath());
            Thread.Sleep(3 * 1000);

            Console.ReadKey();
            Thread.Sleep(1000 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
        private IXApi ConnectToApi(ApiItem item)
        {
            //lock (this)
            {
                DisconnectToApi(item);

                IXApi api = item.Api;

                if (api == null)
                {
                    api      = XApiHelper.CreateInstance(item.TypeName, item.DllPath);
                    item.Api = api;
                }

                string szServerPath = ServerList[item.Server].Path;
                string szUserPath   = UserList[item.User].Path;
                string szUserLabel  = UserList[item.User].Label;

                // 更新Log名字,这样在日志中可以进行识别
                api.Log = LogManager.GetLogger(string.Format("{0}.{1}.{2}", Name, item.LogPrefix, szUserLabel));

                if (api.IsConnected)
                {
                    return(api);
                }

                api.OnConnectionStatus = OnConnectionStatus_callback;
                api.OnRtnError         = OnRtnError_callback;
                api.OnLog = OnLog_callback;

                api.OnRtnDepthMarketData = OnRtnDepthMarketData_callback;

                api.OnRspQryInstrument       = OnRspQryInstrument_callback;
                api.OnRspQryTradingAccount   = OnRspQryTradingAccount_callback;
                api.OnRspQryInvestor         = OnRspQryInvestor_callback;
                api.OnRspQryInvestorPosition = OnRspQryInvestorPosition_callback;

                api.OnRspQryOrder = OnRspQryOrder_callback;
                api.OnRspQryTrade = OnRspQryTrade_callback;
                api.OnRspQryQuote = OnRspQryQuote_callback;

                api.OnRtnOrder = OnRtnOrder_callback;
                api.OnRtnTrade = OnRtnTrade_callback;
                api.OnRtnQuote = OnRtnQuote_callback;

                api.OnRtnQuoteRequest = OnRtnQuoteRequest_callback;

                api.OnRspQryHistoricalTicks = OnRspQryHistoricalTicks_callback;
                api.OnRspQryHistoricalBars  = OnRspQryHistoricalBars_callback;

                api.OnRspQrySettlementInfo = OnRspQrySettlementInfo_callback;
                api.OnRtnInstrumentStatus  = OnRtnInstrumentStatus_callback;

                api.Connect(szServerPath, szUserPath, Path.GetTempPath());

                return(api);
            }
        }
示例#5
0
文件: Program.cs 项目: wzugang/XAPI2
        static void test_CTP_Main(string[] args)
        {
            Type type = Type.GetType("XAPI.Callback.XApi, XAPI_CSharp");
            var  a    = (IXApi)Activator.CreateInstance(type, @"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\x86\CTP\CTP_Quote_x86.dll");

            //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\x86\CTP\CTP_Trade_x86.dll");
            api = a;

            api.Server.BrokerID = "9999";
            api.Server.Address  = "tcp://180.168.146.187:10010";
            api.Server.PrivateTopicResumeType = ResumeType.Undefined;

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

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

            api.Connect();
            Thread.Sleep(3 * 1000);
            api.Subscribe("IF1802;au1806;au000;IF000", "");

            Console.ReadKey();
            api.Unsubscribe("au1806", "");
            Console.ReadKey();
            api.Unsubscribe("au000", "");
            Console.ReadKey();
            api.Unsubscribe("au1806", "");
            Console.ReadKey();


            api.Subscribe("au1806;au000", "");
            Console.ReadKey();
            api.Unsubscribe("au000", "");
            Console.ReadKey();
            Thread.Sleep(1000 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
示例#6
0
文件: Program.cs 项目: wzugang/XAPI2
        static void test_KingstarStock_Main(string[] args)
        {
            //ApiManager.QueuePath = @"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\QuantBox_CTP_Trade.dll";
            api = new XApi(@"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\KingstarStock\x86\QuantBox_KingstarStock_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.OnRtnError           = OnRtnError;

            api.Connect();

            Thread.Sleep(5 * 1000);

            api.Dispose();
        }
示例#7
0
文件: Program.cs 项目: wzugang/XAPI2
        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.Connect();
            Thread.Sleep(10 * 1000);
            ReqQueryField query = new ReqQueryField();

            api.ReqQuery(QueryType.ReqQryInstrument, query);

            Thread.Sleep(300 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
示例#8
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()
            {
                Int32ID = -1
            };

            api.ReqQuery(QueryType.ReqQryInvestorPosition, query);

            // api.Dispose();

            Console.ReadKey();

            Console.WriteLine("回车后退出");
            Console.ReadKey();
        }
示例#9
0
        static void test_CTP_Main(string[] args)
        {
            Type type = Type.GetType("XAPI.Callback.XApi, XAPI_CSharp");
            var  a    = (IXApi)Activator.CreateInstance(type, @"C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\x86\CTP\CTP_Trade_x86.dll");

            //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\x86\CTP\CTP_Trade_x86.dll");
            api = a;

            api.Server.BrokerID = "9999";
            api.Server.Address  = "tcp://218.202.237.33:10002";
            api.Server.PrivateTopicResumeType = ResumeType.Undefined;

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

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

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

            query.DateStart = 20161124;
            api.ReqQuery(QueryType.ReqQrySettlementInfo, query);

            Thread.Sleep(10 * 1000);

            api.Dispose();

            Thread.Sleep(5 * 1000);
        }
 public void Connect(ServerInfoField server, UserInfoField user)
 {
     _api.Connect(server, user);
 }