示例#1
0
        private async Task <Dictionary <Symbol, Security?> > GetSecuritiesyAsync(HashSet <Symbol> symbols, HistoryFlags historyFlags, Symbol historyBase, CancellationToken ct)
        {
            HashSet <Symbol> stockAndCurrencyRateSymbols = symbols.Where(s => s.IsStock || s.IsCurrencyRate).ToHashSet();

            if (historyBase.IsStock)
            {
                stockAndCurrencyRateSymbols.Add(historyBase);
            }
            Dictionary <Symbol, Security?> securities = await Snapshot.GetAsync(stockAndCurrencyRateSymbols, ct).ConfigureAwait(false);

            if (historyFlags == HistoryFlags.None)
            {
                return(securities);
            }

            if (!historyBase.IsEmpty)
            {
                await AddCurrencies(symbols, historyBase, securities, ct).ConfigureAwait(false);
            }

            await AddHistoryToSecurities(securities, historyFlags, ct).ConfigureAwait(false);

            if (!historyBase.IsEmpty)
            {
                HistoryBaseComposer.Compose(symbols, historyBase, securities);
            }

            return(securities);
        }
示例#2
0
 public YahooHistory(ILogger <YahooHistory>?logger = null)
 {
     Logger        = logger ?? NullLogger <YahooHistory> .Instance;
     YahooSnapshot = new YahooSnapshot(); // take Logger
     HistoryCache  = new AsyncLazyCache <string, List <object>?>(Producer);
     SnapshotCache = new AsyncLazyCache <string, Security?>
                         (async(s, c) => await YahooSnapshot.GetAsync(s, c).ConfigureAwait(false));
 }