Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            settings       = new RegistrySettings("Software\\StockStopAlerts");
            positionsTable = new SQLitePositionsTable();

            if (args.Length < 1)
            {
                MessageBox.Show("The Alpha Vantage API key is required as a command-line argument.\n" +
                                "Get your free API key at https://www.alphavantage.co", "Stock Stop Alerts");
                return;
            }
            ApiKey = args[0];
            bool disableUpdate = args.Length == 2 && args[1] == "-du";

            // Show the system tray icon.
            using (ProcessIcon pi = new ProcessIcon())
            {
                pi.Display(disableUpdate);

                // Make sure the application runs!
                Application.Run();
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            RegistryKey baseKey = Registry.CurrentUser;
            settings = new RegistrySettings("Software\\StockStopAlerts");
            positionsTable = new SQLitePositionsTable();

            // Show the system tray icon.
            using (ProcessIcon pi = new ProcessIcon())
            {
                pi.Display();

                // Make sure the application runs!
                Application.Run();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called every 30 minutes to check the time of day.
        /// After 10:00 PM UTC on a week day it will call a function
        /// to get the closing prices of all the positions in the PositionsTable.
        /// </summary>
        private static void TimerEventProcessor(ProcessIcon pi)
        {
            bool updateNow = false;

            if (pi.initialUpdate)
            {
                timer.Interval   = 1000 * 60 * 30;  // 30 minutes
                pi.initialUpdate = false;
                updateNow        = true;
            }
            DateTime now            = DateTime.UtcNow;
            DateTime previousUpdate = Program.settings.GetDateTimeValue("Last Update");

            if (!updateNow && now.Date == previousUpdate.Date)
            {
                Logger.Log("TimerEventProcessor(): already updated for today");
                return;
            }
            DayOfWeek dow = now.DayOfWeek;

            if (!updateNow && (dow == DayOfWeek.Sunday || dow == DayOfWeek.Saturday))
            {
                return;
            }
            if (updateNow || now.Hour == 22)
            {
                timer.Stop();
                Logger.Log("TimerEventProcessor(): calling CheckClosingPrices()");
                pi.CheckClosingPrices();
                Logger.Log("TimerEventProcessor(): returned from CheckClosingPrices()");
                timer.Start();
            }
            else
            {
                Logger.Log("TimerEventProcessor(): waiting for 10 PM GMT");
            }
        }