private void LoadToken()
 {
     try
     {
         string fileName = Path.Combine(System.AppContext.BaseDirectory, TOKEN_FILE);
         if (File.Exists(fileName))
         {
             using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
             {
                 var formatter = new BinaryFormatter();
                 token = (APIToken)formatter.Deserialize(stream);
                 if (token == null)
                 {
                     Logger.Instance.LogMessage(TracingLevel.ERROR, "Failed to load tokens, deserialized token is null");
                     return;
                 }
                 Logger.Instance.LogMessage(TracingLevel.INFO, $"Token initialized. Last refresh date was: {token.TokenLastRefresh}");
             }
         }
         else
         {
             Logger.Instance.LogMessage(TracingLevel.WARN, $"Failed to load tokens, token file does not exist: {fileName}");
         }
     }
     catch (Exception ex)
     {
         Logger.Instance.LogMessage(TracingLevel.ERROR, $"Exception loading tokens: {ex}");
     }
 }
 internal void InitTokens(string stockToken, DateTime tokenCreateDate)
 {
     Logger.Instance.LogMessage(TracingLevel.INFO, "InitTokens called");
     if (token == null || token.TokenLastRefresh < tokenCreateDate)
     {
         if (String.IsNullOrWhiteSpace(stockToken))
         {
             Logger.Instance.LogMessage(TracingLevel.WARN, "InitTokens: Token revocation!");
         }
         token = new APIToken()
         {
             StockToken = stockToken, TokenLastRefresh = tokenCreateDate
         };
         failedToken = false;
         SaveToken();
         Logger.Instance.LogMessage(TracingLevel.INFO, $"New token saved: {stockToken}");
     }
     TokensChanged?.Invoke(this, new APITokenEventArgs(TokenExists));
 }