Ejemplo n.º 1
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 = XQt8430.ReadFromDB();
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }
                }
                else if (useDemoServer)
                {
                    var items = XQt8430.Get(XQt8430Gubun.코스닥);
                    foreach (var item in items)
                    {
                        item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                    }

                    items.WriteToDB(replace: true);
                }
                else
                {
                    using (var query = new XQt8430())
                    {
                        query.SetFieldData(XQt8430InBlock.BlockName, XQt8430InBlock.F.gubun, 0, "1"); // 코스피 == '1'
                        if (query.Request() < 0)
                        {
                            Console.WriteLine("Failed to send request");
                        }

                        XQt8430OutBlock[] outBlocks = query.GetBlocks();
                        foreach (var item in outBlocks)
                        {
                            if (item.IsValidData == true)
                            {
                                item.Dump(Console.Out, DumpOutputType.Inline80Cols);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private string GetSHCode(string tab)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"{tab}public partial class SHCODE");
            sb.AppendLine($"{tab}{{");

            int totalCode = 0;

            {
                sb.AppendLine($"{tab}\tpublic partial class KOSDAQ");
                sb.AppendLine($"{tab}\t{{");

                var items = XQt8430.GetKOSDAQ(true);
                Dictionary <string, int> names = new Dictionary <string, int>();

                foreach (var item in items)
                {
                    sb.AppendLine($"{tab}\t\tpublic const string {ToVariableName(item.Name, names)} = \"{item.SHCode}\"; // {item.Name} {item.ExpCode}");
                    totalCode++;
                }
                sb.AppendLine($"{tab}\t}}");
            }
            sb.AppendLine($"{tab}\tpublic static int NumberOfKOSDAQ = {totalCode};");
            totalCode = 0;

            {
                sb.AppendLine($"{tab}\tpublic partial class KOSPI");
                sb.AppendLine($"{tab}\t{{");

                var items = XQt8430.GetKOSPI(true);
                Dictionary <string, int> names = new Dictionary <string, int>();

                foreach (var item in items)
                {
                    sb.AppendLine($"{tab}\t\tpublic const string {ToVariableName(item.Name, names)} = \"{item.SHCode}\"; // {item.Name} {item.ExpCode}");
                    totalCode++;
                }
                sb.AppendLine($"{tab}\t}}");
            }
            sb.AppendLine($"{tab}\tpublic static int NumberOfKOSPI = {totalCode};");
            totalCode = 0;

            sb.AppendLine($"{tab}}}");

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        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();
            }
        }