Esempio n. 1
0
        static void Main(string[] args)
        {
            DRTickWriter TickWriter = new DRTickWriter(
                ConfigurationManager.AppSettings[KEY_DataPath],
                ConfigurationManager.AppSettings[KEY_OutputFormat]
                );

            DataReceiver dataReceiver = new DataReceiver();

            dataReceiver.TickWriter = TickWriter;

            dataReceiver.ConfigPath = ConfigurationManager.AppSettings[KEY_ConfigPath];
            dataReceiver.DataPath   = ConfigurationManager.AppSettings[KEY_DataPath];
            dataReceiver.ConnectionConfigListFileName = ConfigurationManager.AppSettings[KEY_ConnectionConfigListFileName];
            dataReceiver.InstrumentInfoListFileName   = ConfigurationManager.AppSettings[KEY_InstrumentInfoListFileName];
            dataReceiver.IncludeFilterListFileName    = ConfigurationManager.AppSettings[KEY_IncludeFilterListFileName];
            dataReceiver.ExcludeFilterListFileName    = ConfigurationManager.AppSettings[KEY_ExcludeFilterListFileName];

            dataReceiver.SaveAsFilteredInstrumentInfoListFileName   = ConfigurationManager.AppSettings[KEY_SaveAsFilteredInstrumentInfoListFileName];
            dataReceiver.SaveAsSubscribedInstrumentInfoListFileName = ConfigurationManager.AppSettings[KEY_SaveAsSubscribedInstrumentInfoListFileName];
            dataReceiver.SaveAsTradingDayFileName = ConfigurationManager.AppSettings[KEY_SaveAsTradingDayFileName];

            dataReceiver.ScheduleTasksListFileName = ConfigurationManager.AppSettings[KEY_ScheduleTasksListFileName];

            dataReceiver.LoadConnectionConfig();
            dataReceiver.Connect();

            // 由于会建立多个,所以超时时间可以长一些
            if (dataReceiver.WaitConnectd(30 * 1000))
            {
                dataReceiver.WatcherStrat(dataReceiver.ConfigPath, "*.json");
                // 复制老列表
                dataReceiver.ProcessConfig(null);
                dataReceiver.ProcessScheduleTasks(null);
                Console.WriteLine("开始接收,按Ctrl+Q退出");
            }
            else
            {
                Console.WriteLine("登录超时,按Ctrl+Q退出");
            }

            do
            {
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine(cki);
                if (cki.Key == ConsoleKey.Q && cki.Modifiers == ConsoleModifiers.Control)
                {
                    break;
                }
            }while(true);


            dataReceiver.WatcherStop();
            dataReceiver.Disconnect();

            return;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DRTickWriter TickWriter = new DRTickWriter(ConfigurationManager.AppSettings[KEY_DataPath]);

            DataReceiver dataReceiver = new DataReceiver();
            dataReceiver.TickWriter = TickWriter;

            dataReceiver.ConfigPath = ConfigurationManager.AppSettings[KEY_ConfigPath];
            dataReceiver.DataPath = ConfigurationManager.AppSettings[KEY_DataPath];
            dataReceiver.ConnectionConfigListFileName = ConfigurationManager.AppSettings[KEY_ConnectionConfigListFileName];
            dataReceiver.InstrumentInfoListFileName = ConfigurationManager.AppSettings[KEY_InstrumentInfoListFileName];
            dataReceiver.IncludeFilterListFileName = ConfigurationManager.AppSettings[KEY_IncludeFilterListFileName];
            dataReceiver.ExcludeFilterListFileName = ConfigurationManager.AppSettings[KEY_ExcludeFilterListFileName];

            dataReceiver.SaveAsFilteredInstrumentInfoListFileName = ConfigurationManager.AppSettings[KEY_SaveAsFilteredInstrumentInfoListFileName];
            dataReceiver.SaveAsSubscribedInstrumentInfoListFileName = ConfigurationManager.AppSettings[KEY_SaveAsSubscribedInstrumentInfoListFileName];
            dataReceiver.SaveAsTradingDayFileName = ConfigurationManager.AppSettings[KEY_SaveAsTradingDayFileName];

            dataReceiver.ScheduleTasksListFileName = ConfigurationManager.AppSettings[KEY_ScheduleTasksListFileName];

            dataReceiver.LoadConnectionConfig();
            dataReceiver.Connect();

            // 由于会建立多个,所以超时时间可以长一些
            if (dataReceiver.WaitConnectd(30 * 1000))
            {
                dataReceiver.WatcherStrat(dataReceiver.ConfigPath, "*.json");
                // 复制老列表
                dataReceiver.ProcessConfig(null);
                dataReceiver.ProcessScheduleTasks(null);
                Console.WriteLine("开始接收,按Ctrl+Q退出");
            }
            else
            {
                Console.WriteLine("登录超时,按Ctrl+Q退出");
            }

            do
            {
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine(cki);
                if (cki.Key == ConsoleKey.Q && cki.Modifiers == ConsoleModifiers.Control)
                    break;
            }while(true);


            dataReceiver.WatcherStop();
            dataReceiver.Disconnect();

            return;
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // 禁用控制台的关闭按钮
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);

            DRTickWriter TickWriter = new DRTickWriter(
                ConfigurationManager.AppSettings[KEY_DataPath],
                ConfigurationManager.AppSettings[KEY_OutputFormat]
                );

            Tom.Kdb.KdbWriter KdbWriter = new Tom.Kdb.KdbWriter(
                ConfigurationManager.AppSettings[KEY_Kdb_Host],
                ConfigurationManager.AppSettings[KEY_Kdb_Port],
                ConfigurationManager.AppSettings[KEY_Kdb_UsernameAndPassword],
                ConfigurationManager.AppSettings[KEY_Kdb_DataPath],
                ConfigurationManager.AppSettings[KEY_Kdb_Save_Quote]
                );

            DataReceiver dataReceiver = new DataReceiver();

            dataReceiver.TickWriter = TickWriter;
            if (bool.Parse(ConfigurationManager.AppSettings[KEY_Kdb_Enable]))
            {
                dataReceiver.KdbWriter = KdbWriter;
            }



            dataReceiver.ConfigPath = ConfigurationManager.AppSettings[KEY_ConfigPath];
            dataReceiver.DataPath   = ConfigurationManager.AppSettings[KEY_DataPath];
            dataReceiver.ConnectionConfigListFileName = ConfigurationManager.AppSettings[KEY_ConnectionConfigListFileName];
            dataReceiver.InstrumentInfoListFileName   = ConfigurationManager.AppSettings[KEY_InstrumentInfoListFileName];
            dataReceiver.IncludeFilterListFileName    = ConfigurationManager.AppSettings[KEY_IncludeFilterListFileName];
            dataReceiver.ExcludeFilterListFileName    = ConfigurationManager.AppSettings[KEY_ExcludeFilterListFileName];

            dataReceiver.SaveAsFilteredInstrumentInfoListFileName   = ConfigurationManager.AppSettings[KEY_SaveAsFilteredInstrumentInfoListFileName];
            dataReceiver.SaveAsSubscribedInstrumentInfoListFileName = ConfigurationManager.AppSettings[KEY_SaveAsSubscribedInstrumentInfoListFileName];
            dataReceiver.SaveAsTradingDayFileName = ConfigurationManager.AppSettings[KEY_SaveAsTradingDayFileName];

            dataReceiver.ScheduleTasksListFileName = ConfigurationManager.AppSettings[KEY_ScheduleTasksListFileName];

            dataReceiver.LoadConnectionConfig();
            dataReceiver.Connect();

            // 由于会建立多个,所以超时时间可以长一些
            if (dataReceiver.WaitConnectd(30 * 1000))
            {
                // 可以在这里加入一些订阅前的准备工作
                // 这里已经登录成功了,并获得了交易日时间,所以可以用来做别的工作
                dataReceiver.BeforeSubscribe();

                dataReceiver.WatcherStrat(dataReceiver.ConfigPath, "*.json");
                // 监控配置文件
                dataReceiver.ProcessConfig(null);
                dataReceiver.ProcessScheduleTasks(null);
                Console.WriteLine("开始接收,按Ctrl+Q退出");
            }
            else
            {
                Console.WriteLine("登录超时,按Ctrl+Q退出");
            }

            do
            {
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine(cki);
                if (cki.Key == ConsoleKey.Q && cki.Modifiers == ConsoleModifiers.Control)
                {
                    break;
                }
            }while(true);


            dataReceiver.WatcherStop();
            dataReceiver.Disconnect();
            Console.WriteLine("按任意键退出");
            Console.ReadKey();

            return;
        }