Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            /*
             * Type sessionType = Type.GetTypeFromProgID("XA_Session.XASession");
             * object objSession = Activator.CreateInstance(sessionType);
             * IXASession xingSession = objSession as IXASession;
             */

            bool      useDemoServer = false;
            LoginInfo user          = GetUserInfo(useDemoServer);

            _xingClient = new XingClient(useDemoServer);
            _xingClient.ConnectWithLogin(user);

            Console.WriteLine($"# of account: {_xingClient.NumberOfAccount}");

            foreach (string account in _xingClient.GetAccounts())
            {
                Console.WriteLine("\t" + account);
            }

            if (useDemoServer)
            {
                var outBlock = XQt1101.Get(shcode: Stock.SHCODE.KOSDAQ.이베스트투자증권);
                if (outBlock != null)
                {
                    OutputPrice(outBlock.shcode, outBlock.price);
                }
            }
            else
            {
                using (XQt1101 query = new XQt1101())
                {
                    XQt1101InBlock inBlock = new XQt1101InBlock {
                        shcode = Stock.SHCODE.KOSDAQ.이베스트투자증권
                    };

                    if (query.SetBlock(inBlock) == false)
                    {
                        Console.WriteLine("Failed to verify data: " + XQt1101InBlock.BlockName);
                        return;
                    }

                    Console.WriteLine("GetFields: " + XQt1101InBlock.BlockName);

                    int queryResult = query.Request();
                    if (queryResult < 0)
                    {
                        Console.WriteLine("Failed to send request");
                    }

                    XQt1101OutBlock outBlock = query.GetBlock();
                    OutputPrice(outBlock.shcode, outBlock.price);
                }
            }

            {
                _realS3              = new XRS3_();
                _realS3.DataArrived += _realS3_DataArrived;

                XRS3_InBlock inBlock = new XRS3_InBlock {
                    shcode = Stock.SHCODE.KOSDAQ.이베스트투자증권
                };
                if (_realS3.SetBlock(inBlock) == false)
                {
                    Console.WriteLine("Failed to verify data: " + XRS3_InBlock.BlockName);
                    return;
                }

                _realS3.Advise();
            }
        }
Ejemplo n.º 2
0
        void Main()
        {
            bool      useDemoServer = true;
            LoginInfo user          = GetUserInfo(useDemoServer);

            using (XingClient xing = new XingClient(useDemoServer))
            {
                if (xing.ConnectWithLogin(user) == false)
                {
                    Console.WriteLine(xing.ErrorMessage);
                    return;
                }

                Console.WriteLine($"# of account: {xing.NumberOfAccount}");

                foreach (string account in xing.GetAccounts())
                {
                    Console.WriteLine("\t" + account);
                }

                // 현재가 조회한 후,
                using (XQt1101 query = new XQt1101())
                {
                    XQt1101InBlock inBlock = new XQt1101InBlock {
                        shcode = Stock.SHCODE.KOSDAQ.이베스트투자증권
                    };

                    if (query.SetBlock(inBlock) == false)
                    {
                        Console.WriteLine("Failed to verify data: " + XQt1101InBlock.BlockName);
                        return;
                    }

                    if (query.Request() < 0)
                    {
                        Console.WriteLine("Failed to send request");
                    }

                    XQt1101OutBlock outBlock = query.GetBlock();
                    if (outBlock.IsValidData == true)
                    {
                        outBlock.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                    }
                    else
                    {
                        Console.WriteLine($"Invalid: {outBlock.InvalidReason}");
                    }
                }

                // 실시간 데이터를 조회
                using (XRS2_ real = new XRS2_())
                {
                    //XRS3_InBlock inBlock = new XRS3_InBlock { shcode = shcode };
                    //if (real.SetFields(inBlock) == false)
                    //{
                    //    Console.WriteLine("Failed to verify data: " + inBlock.BlockName);
                    //    return;
                    //}

                    real.SetFieldData(XRS2_InBlock.BlockName, XRS2_InBlock.F.shcode, Stock.SHCODE.KOSDAQ.이베스트투자증권);
                    real.Advise();

                    while (_exitProcess == false)
                    {
                        if (real.WaitForData(1000) == false)
                        {
                            Console.Write(".");
                            continue;
                        }

                        XRS2_OutBlock outBlock = real.GetBlock();
                        if (outBlock.IsValidData == true)
                        {
                            // outBlock.Dump(Console.Out, DumpOutputType.KeyValue);
                            Console.WriteLine(outBlock.bidho);
                        }
                        else
                        {
                            Console.WriteLine($"Invalid: {outBlock.InvalidReason}");
                        }
                    }
                }
            }
        }