示例#1
0
        void Main(bool useDemoServer)
        {
            SqliteExtension.UseSqlite("test.sqlite");
            if (useDemoServer == false)
            {
                Console.WriteLine("이 코드는 데모 서버로만 매수 주문을 하는 예제입니다.");
                return;
            }

            LoginInfo user = GetUserInfo(useDemoServer);

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

                string tradeAccount = xing.GetFirstAccount();
                if (string.IsNullOrEmpty(tradeAccount) == true)
                {
                    Console.WriteLine("추정순자산(sunamt) 또는 예수금(sunamt1)을 가진 계정이 없습니다.");
                    return;
                }

                string inptpwd = null;
                if (useDemoServer == true)
                {
                    inptpwd = "0000";
                }

                if (useDemoServer)
                {
                    using (XQCSPAQ12200 query = new XQCSPAQ12200())
                    {
                        XQCSPAQ12200InBlock1 input = new XQCSPAQ12200InBlock1();
                        input.AcntNo = tradeAccount;
                        //  input.BalCreTp =

                        input.Dump(Console.Out);
                        query.SetBlock(input);

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

                        var block1 = query.GetBlock1();
                        block1.Dump(Console.Out);

                        var block2 = query.GetBlock2();
                        block2.Dump(Console.Out, DumpOutputType.Inline);
                    }
                }
            }
        }
示例#2
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var items = XQt1533.ReadFromDB();
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var items = XQt1533.Get(XQt1533Gubun.상승율상위);
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    items.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt1533())
                    {
                        query.SetFieldData(XQt1533InBlock.BlockName, XQt1533InBlock.F.gubun, 0, "2"); // 2 == XQt1533Gubun.하락율상위

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

                        XQt1533OutBlock[] outBlocks = query.GetBlocks();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                            }
                        }
                    }
                }
            }
        }
示例#3
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var items = XQt8425.ReadFromDB();
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }
                }
                else if (useDemoServer)
                {
                    var items = XQt8425.Get();
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    items.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt8425())
                    {
                        if (query.Request() < 0)
                        {
                            Console.WriteLine("Failed to send request");
                        }

                        XQt8425OutBlock[] outBlocks = query.GetBlocks();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline);
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    XQt0167OutBlock outBlock = XQt0167.ReadFromDB();
                    outBlock?.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                }
                else if (useDemoServer)
                {
                    XQt0167OutBlock outBlock = XQt0167.Get();
                    Console.WriteLine(XQt0167OutBlock.F.dt + " == " + outBlock.dt);
                    Console.WriteLine(XQt0167OutBlock.F.time + " == " + outBlock.time);

                    outBlock.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt0167 query = new XQt0167())
                    {
                        query.SetFieldData(XQt0167InBlock.BlockName, XQt0167InBlock.F.id, 0, "");
                        if (query.Request() < 0)
                        {
                            Console.WriteLine("Failed to send request");
                        }

                        XQt0167OutBlock outBlock = query.GetBlock();
                        if (outBlock.IsValidData == true)
                        {
                            outBlock.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                        }
                        else
                        {
                            Console.WriteLine($"Invalid: {outBlock.InvalidReason}");
                        }
                    }
                }
            }
        }
示例#5
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                XQt8430.Get(XQt8430Gubun.전체).WriteToDB();
                XQt8425.Get().WriteToDB();
            }
        }
示例#6
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer)
        {
            SqliteExtension.UseSqlite("test.sqlite");
            if (useDemoServer == false)
            {
                Console.WriteLine("이 코드는 데모 서버로만 매수 주문을 하는 예제입니다.");
                return;
            }

            LoginInfo user = GetUserInfo(useDemoServer);

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

                string tradeAccount = xing.GetFirstAccount();
                if (string.IsNullOrEmpty(tradeAccount) == true)
                {
                    Console.WriteLine("추정순자산(sunamt) 또는 예수금(sunamt1)을 가진 계정이 없습니다.");
                    return;
                }

                string inptpwd = null;
                if (useDemoServer == true)
                {
                    inptpwd = "0000";
                }

                string shcode       = Stock.SHCODE.KOSPI.현대건설;
                string isuNo        = xing.GetExpCode(shcode);
                long   currentPrice = xing.GetCurrentPrice(shcode);

                if (useDemoServer)
                {
                    using (XQCSPAT00600 query = new XQCSPAT00600())
                    {
                        XQCSPAT00600InBlock1 input = new XQCSPAT00600InBlock1();
                        input.AcntNo  = tradeAccount;
                        input.InptPwd = inptpwd;
                        input.IsuNo   = isuNo;
                        input.OrdQty  = 1;

                        // input.OrdPrc = currentPrice - (currentPrice * 0.10); // 10% 낮은 가격으로 매수 주문
                        input.OrdPrc = currentPrice; // 현재가로 매수 주문

                        input.BnsTpCode = XQCSPAT00600.BnsTpCode.매수;

                        // input.OrdprcPtnCode = XQCSPAT00600.OrdprcPtnCode.시장가; // 테스트를 위해 OrdPrc에 상관 없이 시장가로.
                        input.OrdprcPtnCode = XQCSPAT00600.OrdprcPtnCode.지정가;

                        input.MgntrnCode    = XQCSPAT00600.MgntrnCode.보통;
                        input.LoanDt        = null;
                        input.OrdCndiTpCode = XQCSPAT00600.OrdCndiTpCode.없음;

                        Console.WriteLine("[매수 주문]");
                        input.Dump(Console.Out);

                        query.SetBlock(input);

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

                        var block1 = query.GetBlock1();
                        block1.Dump(Console.Out);

                        var block2 = query.GetBlock2();
                        block2.Dump(Console.Out, DumpOutputType.Inline);

                        Console.WriteLine($"===========> 매수 주문 번호: {block2.OrdNo}");
                    }
                }
            }
        }
示例#7
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1301.ReadFromDB();

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1301.Get(Stock.SHCODE.KOSPI.현대건설,
                                                 starttime: "0900", endtime: "1530");

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt1301 query = new XQt1301())
                    {
                        var inBlock = new XQt1301InBlock
                        {
                            shcode    = Stock.SHCODE.KOSPI.현대건설,
                            starttime = "0900",
                            endtime   = "1530",
                        };

                        while (true)
                        {
                            query.SetBlock(inBlock);
                            if (query.Request() < 0)
                            {
                                Console.WriteLine("Failed to send request");
                                break;
                            }

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

                            foreach (var item in query.GetBlock1s())
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                            }

                            inBlock.CopyValueFromBlock(outBlock);
                            if (string.IsNullOrEmpty(outBlock.cts_time) == true)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#8
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                int totalSize = 30;

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1702.ReadFromDB();

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1702.Get(Stock.SHCODE.KOSPI.현대건설,
                                                 volvalgb: XQt1702.VolvalgbCode.금액,
                                                 msmdgb: XQt1702.MsmdgbCode.순매수);

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt1702 query = new XQt1702())
                    {
                        var inBlock = new XQt1702InBlock
                        {
                            shcode   = Stock.SHCODE.KOSPI.현대건설,
                            volvalgb = XQt1702.VolvalgbCode.금액,
                            msmdgb   = XQt1702.MsmdgbCode.순매수
                        };

                        while (totalSize > 0)
                        {
                            query.SetBlock(inBlock);

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

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

                            foreach (var item in query.GetBlock1s())
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                                totalSize--;
                            }

                            inBlock.CopyValueFromBlock(outBlock);
                        }
                    }
                }
            }
        }
示例#9
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1537.ReadFromDB();

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1537.Get(Stock.TMCODE.테마파크);

                    if (multiBlock.OutBlock?.IsValidData != true)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt1537())
                    {
                        query.SetFieldData(XQt1537InBlock.BlockName, XQt1537InBlock.F.tmcode, 0, Stock.TMCODE.테마파크);

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

                        XQt1537OutBlock1[] outBlocks = query.GetBlock1s();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline);
                            }
                        }
                    }
                }
            }
        }
示例#10
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1305.ReadFromDB();

                    if (multiBlock.OutBlock?.IsValidData != true)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1305.Get(Stock.SHCODE.KOSPI.SK하이닉스,
                                                 dwmcode: XQt1305.DWMCode.일,
                                                 cnt: 10);

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt1305())
                    {
                        XQt1305InBlock inBlock = new XQt1305InBlock()
                        {
                            shcode  = Stock.SHCODE.KOSPI.SK하이닉스,
                            dwmcode = XQt1305.DWMCode.일,
                            cnt     = 10,
                        };

                        if (query.SetBlock(inBlock) == false)
                        {
                            Console.WriteLine($"Failed to set block");
                            return;
                        }

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

                        XQt1305OutBlock1[] outBlocks = query.GetBlock1s();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                            }
                        }
                    }
                }
            }
        }
示例#11
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var multiBlock = XQt8419.ReadFromDB();

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    Console.WriteLine($"[{XQt8419OutBlock1.BlockName}]");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt8419.Get("001", '2', 0, "20190101", "201905030", null, 'N');

                    if (multiBlock.OutBlock?.IsValidData != true)
                    {
                        return;
                    }

                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"[{XQt8419OutBlock1.BlockName}]");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt8419 query = new XQt8419())
                    {
                        var inBlock = new XQt8419InBlock
                        {
                            shcode = "001",
                            gubun  = '2',
                            sdate  = "20170101",
                            edate  = "20180424",
                            /* qrycnt = pageSize, // not work */
                            comp_yn = 'N',
                        };

                        query.SetBlock(inBlock);

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

                        var outBlock = query.GetBlock();
                        if (outBlock.IsValidData == true)
                        {
                            Console.WriteLine($"[{outBlock.GetBlockName()}]");
                            outBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                        }
                        else
                        {
                            Console.WriteLine($"Invalid: {outBlock.InvalidReason}");
                        }

                        Console.WriteLine($"[{XQt8419OutBlock1.BlockName}]");
                        foreach (var item in query.GetBlock1s())
                        {
                            item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                        }
                    }
                }
            }
        }
示例#12
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var items = XQt1717.ReadFromDB();
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }
                }
                else if (useDemoServer)
                {
                    var items = XQt1717.Get(Stock.SHCODE.KOSPI.현대건설,
                                            gubun: XQt1717.Gubun.일별,
                                            fromdt: "20170101",
                                            todt: "20172131");
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    items.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt1717())
                    {
                        query.SetFieldData(XQt1717InBlock.BlockName, XQt1717InBlock.F.shcode, 0, Stock.SHCODE.KOSPI.현대건설);
                        query.SetFieldData(XQt1717InBlock.BlockName, XQt1717InBlock.F.gubun, 0, XQt1717.Gubun.일별.ToString());
                        query.SetFieldData(XQt1717InBlock.BlockName, XQt1717InBlock.F.fromdt, 0, "20170101");
                        query.SetFieldData(XQt1717InBlock.BlockName, XQt1717InBlock.F.todt, 0, "20172131");

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

                        XQt1717OutBlock[] outBlocks = query.GetBlocks();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline);
                            }
                        }
                    }
                }
            }
        }
示例#13
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1310.ReadFromDB(Stock.SHCODE.KOSPI.현대건설);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1310.Get(shcode: Stock.SHCODE.KOSPI.현대건설,
                                                 daygb: XQt1310.DayGB.당일,
                                                 timegb: XQt1310.TimeGB.틱);

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt1310 query = new XQt1310())
                    {
                        var inBlock = new XQt1310InBlock
                        {
                            shcode = Stock.SHCODE.KOSPI.현대건설,
                            daygb  = XQt1310.DayGB.당일,
                            timegb = XQt1310.TimeGB.틱,
                        };

                        bool createFirst = true;
                        while (true)
                        {
                            query.SetBlock(inBlock);
                            if (query.Request() < 0)
                            {
                                Console.WriteLine("Failed to send request");
                                break;
                            }

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

                            var blocks = query.GetBlock1s();

                            foreach (var item in blocks)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                            }

                            blocks.WriteToDB(createFirst, inBlock.shcode);
                            createFirst = false;

                            inBlock.CopyValueFromBlock(outBlock);
                            if (string.IsNullOrEmpty(outBlock.cts_time) == true)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#14
0
文件: Program.cs 项目: tdoobw/XingAPI
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                int pageSize  = 10;
                int totalSize = 30;

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1475.ReadFromDB();

                    if (multiBlock.OutBlock?.IsValidData != true)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1475.Get(Stock.SHCODE.KOSDAQ.이베스트투자증권, datacnt: totalSize);

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt1475 query = new XQt1475())
                    {
                        XQt1475InBlock inBlock = new XQt1475InBlock
                        {
                            shcode  = Stock.SHCODE.KOSDAQ.이베스트투자증권,
                            datacnt = pageSize,
                        };

                        while (totalSize > 0)
                        {
                            query.SetBlock(inBlock);
                            if (query.Request() < 0)
                            {
                                Console.WriteLine("Failed to send request");
                                break;
                            }

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

                            foreach (var item in query.GetBlock1s())
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                                totalSize--;
                            }

                            inBlock.CopyValueFromBlock(outBlock);
                        }
                    }
                }
            }
        }
示例#15
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                if (loadFromDB == true)
                {
                    foreach (string account in xing.GetAccounts())
                    {
                        Console.WriteLine($"[Account = {account}]");
                        var multiBlock = XQt0424.ReadFromDB();

                        multiBlock.OutBlock?.Dump(Console.Out, DumpOutputType.FormattedKeyValue);

                        Console.WriteLine($"# of items: {multiBlock.OutBlock1?.Length}");
                        foreach (var item in multiBlock.OutBlock1 ?? Enumerable.Empty <XQt0424OutBlock1>())
                        {
                            item.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                        }
                    }
                }
                else if (useDemoServer)
                {
                    foreach (string account in xing.GetAccounts())
                    {
                        Console.WriteLine($"[Account = {account}]");
                        var multiBlock = XQt0424.Get(account);

                        multiBlock.OutBlock?.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                        multiBlock.OutBlock?.WriteToDB(replace: true);

                        Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                        foreach (var item in multiBlock.OutBlock1)
                        {
                            item.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                        }

                        multiBlock.OutBlock1.WriteToDB(replace: true);
                    }
                }
                else
                {
                    using (var query = new XQt0424())
                    {
                        foreach (string account in xing.GetAccounts())
                        {
                            Console.WriteLine($"[Account = {account}]");
                            XQt0424InBlock inBlock = new XQt0424InBlock()
                            {
                                accno = account,
                            };

                            if (query.SetBlock(inBlock) == false)
                            {
                                Console.WriteLine($"Failed to set block");
                                return;
                            }

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

                            XQt0424OutBlock outBlock = query.GetBlock();
                            {
                                outBlock?.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                            }

                            XQt0424OutBlock1[] outBlocks = query.GetBlock1s();
                            foreach (var item in outBlocks)
                            {
                                item.Dump(Console.Out, DumpOutputType.FormattedKeyValue);
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        void Main(bool useDemoServer, bool loadFromDB)
        {
            SqliteExtension.UseSqlite("test.sqlite");

            LoginInfo user = GetUserInfo(useDemoServer);

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

                int pageSize  = 10;
                int totalSize = 30;

                if (loadFromDB == true)
                {
                    var multiBlock = XQt1514.ReadFromDB();

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var multiBlock = XQt1514.Get("301", gubun2: XQt1514.Gubun2.일, cnt: totalSize);

                    if (multiBlock.OutBlock.IsValidData == false)
                    {
                        return;
                    }

                    multiBlock.OutBlock.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    multiBlock.OutBlock.WriteToDB(replace: true);

                    Console.WriteLine($"# of items: {multiBlock.OutBlock1.Length}");
                    foreach (var item in multiBlock.OutBlock1)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    multiBlock.OutBlock1.WriteToDB(replace: true);
                }
                else
                {
                    using (XQt1514 query = new XQt1514())
                    {
                        var inBlock = new XQt1514InBlock
                        {
                            upcode = "301",
                            cnt    = pageSize,
                            gubun2 = XQt1514.Gubun2.월,
                        };

                        while (totalSize > 0)
                        {
                            query.SetBlock(inBlock);

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

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

                            foreach (var item in query.GetBlock1s())
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                                totalSize--;
                            }

                            inBlock.CopyValueFromBlock(outBlock);
                        }
                    }
                }
            }
        }