Example #1
0
        static void Main(string[] args)
        {
            IBDTaskHandler taskHandler;

            if (args.Length < 3 || args[2] != "--noib")
            {
                var controller = new IBController();
                controller.Connect();

                taskHandler = new IBDTaskHandler(controller);
            }
            else
            {
                taskHandler = new IBDTaskHandler();
            }

            BaseDataStorage storage;

            string commandArg = (args.Length > 0) ? args[0] : "default";

            switch (commandArg)
            {
            case "runtaskfile":
                storage = RunTaskFile(taskHandler, args[1]);
                break;

            case "optionwithstock":
                storage = AddStockToOptions(taskHandler, args[1]);
                break;

            case "optiontasks":
                storage = BuildOptionDownloadTasks(taskHandler, args[1], args[2]);
                break;

            case "importcsv":
                storage = ImportCsv(taskHandler, args[1]);
                break;

            case "downloadoptions":
                string secType = (args.Length > 2) ? args[3] : "STK";
                storage = DownloadOptions(taskHandler, args[1], secType);
                break;

            case "cronfile":
                storage = CronFile(taskHandler, args[1]);
                break;

            default:
                throw new Exception("No commands specified! Try runtaskfile, optionwithstock, optiontasks, importcsv, downloadoptions, cronfile");
            }

            taskHandler.BeginAsync().Wait();
            storage.FlushAsync().Wait();

            Framework.Log("Processing complete.");
#if DEBUG
            Console.ReadLine();
#endif
        }
 public IBDTaskHandler(IBController Controller = null)
 {
     this.Controller = Controller;
 }