public void LocalDiskShortableProviderDefaultsToZeroForMissingData(string ticker, string brokerage) { var provider = new LocalDiskShortableProvider(SecurityType.Equity, brokerage, QuantConnect.Market.USA); var date = new DateTime(2020, 12, 21); var symbol = new Symbol(SecurityIdentifier.GenerateEquity(ticker, QuantConnect.Market.USA, mappingResolveDate: date), ticker); Assert.AreEqual(0, provider.ShortableQuantity(symbol, date).Value); }
public void LocalDiskShortableProviderGetsDataBySymbol() { var shortableProvider = new LocalDiskShortableProvider(SecurityType.Equity, "testbrokerage", QuantConnect.Market.USA); var symbols = new[] { new Symbol(SecurityIdentifier.GenerateEquity("AAPL", QuantConnect.Market.USA, mappingResolveDate: new DateTime(2021, 1, 4)), "AAPL"), new Symbol(SecurityIdentifier.GenerateEquity("GOOG", QuantConnect.Market.USA, mappingResolveDate: new DateTime(2021, 1, 4)), "GOOG"), new Symbol(SecurityIdentifier.GenerateEquity("BAC", QuantConnect.Market.USA, mappingResolveDate: new DateTime(2021, 1, 4)), "BAC") }; var results = new[] { new Dictionary <Symbol, long?> { { symbols[0], 2000 }, { symbols[1], 5000 }, { symbols[2], 0 } }, new Dictionary <Symbol, long?> { { symbols[0], 4000 }, { symbols[1], 10000 }, { symbols[2], 0 } } }; var dates = new[] { new DateTime(2020, 12, 21), new DateTime(2020, 12, 22) }; foreach (var symbol in symbols) { for (var i = 0; i < dates.Length; i++) { var date = dates[i]; var shortableQuantity = shortableProvider.ShortableQuantity(symbol, date); Assert.AreEqual(results[i][symbol], shortableQuantity); } } }
public void LocalDiskShortableProviderReturnsEmptyDictionaryForMissingDataUsingDate() { var provider = new LocalDiskShortableProvider(SecurityType.Equity, "testbrokerage", QuantConnect.Market.USA); Assert.AreEqual(0, provider.AllShortableSymbols(new DateTime(2020, 12, 31)).Count); }
public void LocalDiskShortableProviderReturnsPopulatedDictionaryUsingLookback() { var provider = new LocalDiskShortableProvider(SecurityType.Equity, "testbrokerage", QuantConnect.Market.USA); Assert.AreEqual(3, provider.AllShortableSymbols(new DateTime(2020, 12, 23)).Count); }