Esempio n. 1
0
        public async Task Execute(IJobExecutionContext context)
        {
            RunManager.Logger.LogDebug("ConnectionManagerJob");

            RunManager.Clock = await RunManager.AlpacaTradingClient.GetClockAsync();

            RunManager.Logger.LogDebug($"Market IsOpen: {RunManager.Clock.IsOpen}");

            if (RunManager.Clock.IsOpen)
            {
                // Market should be open.  We need to ensure we are connected and subscribed.
                await RunManager.Connect();
            }
            else
            {
                // Market should be closed.  We need to ensure we are disconnected and unsubscribed.
                await RunManager.Disconnect();
            }
        }