def __test(self, strategyClass, finalValue): feed = yahoofeed.Feed() feed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2001-yahoofinance.csv")) myStrategy = strategyClass(feed, 10, 25) myStrategy.run() myStrategy.printDebug("Final result:", round(myStrategy.getFinalValue(), 2)) self.assertTrue(round(myStrategy.getFinalValue(), 2) == finalValue)
def __testIGE_BrokerImpl(self, quantity): initialCash = 42.09*quantity # This testcase is based on an example from Ernie Chan's book: # 'Quantitative Trading: How to Build Your Own Algorithmic Trading Business' barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV("ige", common.get_data_file_path("sharpe-ratio-test-ige.csv")) strat = strategy_test.BaseStrategy(barFeed, initialCash) strat.setUseAdjustedValues(True) strat.setBrokerOrdersGTC(True) stratAnalyzer = drawdown.DrawDown() strat.attachAnalyzer(stratAnalyzer) # Disable volume checks to match book results. strat.getBroker().getFillStrategy().setVolumeLimit(None) # Manually place the order to get it filled on the first bar. order = strat.getBroker().createMarketOrder(broker.Order.Action.BUY, "ige", quantity, True) # Adj. Close: 42.09 order.setGoodTillCanceled(True) strat.getBroker().submitOrder(order) strat.addOrder(datetime.datetime(2007, 11, 13), strat.getBroker().createMarketOrder, broker.Order.Action.SELL, "ige", quantity, True) # Adj. Close: 127.64 strat.run() self.assertTrue(round(strat.getBroker().getCash(), 2) == initialCash + (127.64 - 42.09) * quantity) self.assertEqual(strat.orderUpdatedCalls, 6) self.assertTrue(round(stratAnalyzer.getMaxDrawDown(), 5) == 0.31178) self.assertTrue(stratAnalyzer.getLongestDrawDownDuration() == datetime.timedelta(days=623))
def __testIGE_BrokerImpl(self, quantity): initialCash = 42.09 * quantity # This testcase is based on an example from Ernie Chan's book: # 'Quantitative Trading: How to Build Your Own Algorithmic Trading Business' barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( "ige", common.get_data_file_path("sharpe-ratio-test-ige.csv")) strat = strategy_test.BaseStrategy(barFeed, initialCash) strat.setUseAdjustedValues(True) strat.setBrokerOrdersGTC(True) stratAnalyzer = sharpe.SharpeRatio() strat.attachAnalyzer(stratAnalyzer) # Disable volume checks to match book results. strat.getBroker().getFillStrategy().setVolumeLimit(None) # Manually place the order to get it filled on the first bar. order = strat.getBroker().createMarketOrder(broker.Order.Action.BUY, "ige", quantity, True) # Adj. Close: 42.09 order.setGoodTillCanceled(True) strat.getBroker().submitOrder(order) strat.addOrder(datetime.datetime(2007, 11, 13), strat.getBroker().createMarketOrder, broker.Order.Action.SELL, "ige", quantity, True) # Adj. Close: 127.64 strat.run() self.assertEqual(round(strat.getBroker().getCash(), 2), initialCash + (127.64 - 42.09) * quantity) self.assertEqual(strat.orderUpdatedCalls, 6) # The results are slightly different only because I'm taking into account the first bar as well. self.assertEqual(round(stratAnalyzer.getSharpeRatio(0.04, True), 4), 0.7889) self.assertEqual(round(stratAnalyzer.getSharpeRatio(0.04, False), 4), 0.0497)
def testBounded(self): tmpFeed = TemporarySQLiteFeed(SQLiteFeedTestCase.dbName, bar.Frequency.DAY, maxLen=2) with tmpFeed: # Load bars using a Yahoo! feed. yahooFeed = yahoofeed.Feed(maxLen=1) yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.timezone) yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2001-yahoofinance.csv"), marketsession.USEquities.timezone) # Fill the database using the bars from the Yahoo! feed. sqliteFeed = tmpFeed.getFeed() sqliteFeed.getDatabase().addBarsFromFeed(yahooFeed) # Load the SQLite feed and process all bars. sqliteFeed.loadBars("orcl") for bars in sqliteFeed: pass barDS = sqliteFeed["orcl"] self.assertEqual(len(barDS), 2) self.assertEqual(len(barDS.getDateTimes()), 2) self.assertEqual(len(barDS.getCloseDataSeries()), 2) self.assertEqual(len(barDS.getCloseDataSeries().getDateTimes()), 2) self.assertEqual(len(barDS.getOpenDataSeries()), 2) self.assertEqual(len(barDS.getHighDataSeries()), 2) self.assertEqual(len(barDS.getLowDataSeries()), 2) self.assertEqual(len(barDS.getAdjCloseDataSeries()), 2)
def main(plot): instruments = ["gld", "gdx"] windowSize = 50 # Load the bars. These files were manually downloaded from Yahoo Finance. feed = yahoofeed.Feed() for year in range(2006, 2012 + 1): for instrument in instruments: fileName = "%s-%d-yahoofinance.csv" % (instrument, year) print("Loading bars from %s" % fileName) feed.addBarsFromCSV(instrument, fileName) strat = StatArb(feed, instruments[0], instruments[1], windowSize) sharpeRatioAnalyzer = sharpe.SharpeRatio() strat.attachAnalyzer(sharpeRatioAnalyzer) if plot: plt = plotter.StrategyPlotter(strat, False, False, True) plt.getOrCreateSubplot("hedge").addDataSeries("Hedge Ratio", strat.getHedgeRatioDS()) plt.getOrCreateSubplot("spread").addDataSeries("Spread", strat.getSpreadDS()) strat.run() print("Sharpe ratio: %.2f" % sharpeRatioAnalyzer.getSharpeRatio(0.05)) if plot: plt.plot()
def testOneBarReturn(self): initialCash = 1000 barFeed = yahoofeed.Feed() barFeed.setBarFilter( csvfeed.DateRangeFilter(datetime.datetime(2001, 12, 7), datetime.datetime(2001, 12, 7))) barFeed.addBarsFromCSV( AnalyzerTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) strat = strategy_test.BaseStrategy(barFeed, initialCash) # 2001-12-07,15.74,15.95,15.55,15.91,42463200,15.56 # Manually place the orders to get them filled on the first (and only) bar. order = strat.getBroker().createMarketOrder( broker.Order.Action.BUY, AnalyzerTestCase.TestInstrument, 1, False) # Open: 15.74 strat.getBroker().submitOrder(order) order = strat.getBroker().createMarketOrder( broker.Order.Action.SELL, AnalyzerTestCase.TestInstrument, 1, True) # Close: 15.91 strat.getBroker().submitOrder(order) stratAnalyzer = returns.Returns() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertTrue(strat.getBroker().getCash() == initialCash + (15.91 - 15.74)) finalValue = 1000 - 15.74 + 15.91 rets = (finalValue - initialCash) / float(initialCash) self.assertEqual(stratAnalyzer.getReturns()[-1], rets)
def testLoadDailyBars(self): tmpFeed = TemporarySQLiteFeed(SQLiteFeedTestCase.dbName, bar.Frequency.DAY) with tmpFeed: # Load bars using a Yahoo! feed. yahooFeed = yahoofeed.Feed() yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.timezone) yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2001-yahoofinance.csv"), marketsession.USEquities.timezone) # Fill the database using the bars from the Yahoo! feed. sqliteFeed = tmpFeed.getFeed() sqliteFeed.getDatabase().addBarsFromFeed(yahooFeed) # Load the SQLite feed and process all bars. sqliteFeed.loadBars("orcl") for bars in sqliteFeed: pass # Check that both dataseries have the same bars. yahooDS = yahooFeed["orcl"] sqliteDS = sqliteFeed["orcl"] self.assertEqual(len(yahooDS), len(sqliteDS)) for i in xrange(len(yahooDS)): self.assertEqual(yahooDS[i].getDateTime(), sqliteDS[i].getDateTime()) self.assertEqual(yahooDS[i].getOpen(), sqliteDS[i].getOpen()) self.assertEqual(yahooDS[i].getHigh(), sqliteDS[i].getHigh()) self.assertEqual(yahooDS[i].getLow(), sqliteDS[i].getLow()) self.assertEqual(yahooDS[i].getClose(), sqliteDS[i].getClose()) self.assertEqual(yahooDS[i].getAdjClose(), sqliteDS[i].getAdjClose())
def testCumulativeReturn(self): initialCash = 33.06 barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( AnalyzerTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) strat = position_test.BaseTestStrategy(barFeed, AnalyzerTestCase.TestInstrument, initialCash) strat.addPosEntry(datetime.datetime(2001, 1, 12), strat.enterLong, AnalyzerTestCase.TestInstrument, 1) # 33.06 strat.addPosExitMarket(datetime.datetime(2001, 11, 27)) # 14.32 stratAnalyzer = returns.Returns(maxLen=10) strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertTrue( round(strat.getBroker().getCash(), 2) == round( initialCash + (14.32 - 33.06), 2)) self.assertTrue( round(33.06 * (1 + stratAnalyzer.getCumulativeReturns()[-1]), 2) == 14.32) self.assertEqual(len(stratAnalyzer.getCumulativeReturns()), 10) self.assertEqual(len(stratAnalyzer.getReturns()), 10)
def testTwoBarReturns_CloseClose(self): initialCash = 15.90 barFeed = yahoofeed.Feed() barFeed.setBarFilter( csvfeed.DateRangeFilter(datetime.datetime(2001, 12, 6), datetime.datetime(2001, 12, 7))) barFeed.addBarsFromCSV( AnalyzerTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) strat = strategy_test.BaseStrategy(barFeed, initialCash) # 2001-12-06,15.61,16.03,15.50,15.90,66944900,15.55 # 2001-12-07,15.74,15.95,15.55,15.91,42463200,15.56 # Manually place the entry order, to get it filled on the first bar. order = strat.getBroker().createMarketOrder( broker.Order.Action.BUY, AnalyzerTestCase.TestInstrument, 1, True) # Close: 15.90 strat.getBroker().submitOrder(order) strat.addOrder(datetime.datetime(2001, 12, 6), strat.getBroker().createMarketOrder, broker.Order.Action.SELL, AnalyzerTestCase.TestInstrument, 1, True) # Close: 15.91 stratAnalyzer = returns.Returns() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertTrue(strat.getBroker().getCash() == initialCash + (15.91 - 15.90)) # First day returns: 0 self.assertTrue(stratAnalyzer.getReturns()[0] == 0) # Second day returns: Open vs Prev. day's close self.assertTrue(stratAnalyzer.getReturns()[1] == (15.91 - 15.90) / 15.90)
def testFirstBar(self): initialCash = 1000 barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( AnalyzerTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) strat = strategy_test.BaseStrategy(barFeed, initialCash) strat.addOrder(datetime.datetime(2001, 1, 2), strat.getBroker().createMarketOrder, broker.Order.Action.BUY, AnalyzerTestCase.TestInstrument, 1, False) # 2001-01-03 Open: 25.25 Close: 32.00 stratAnalyzer = returns.Returns() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertEqual(stratAnalyzer.getReturns()[0], 0) self.assertEqual(stratAnalyzer.getReturns()[1], (32.00 - 25.25) / 1000) # Check date times. datetimes = barFeed[AnalyzerTestCase.TestInstrument].getDateTimes() for i in [0, -1]: self.assertEqual(stratAnalyzer.getReturns().getDateTimes()[i], datetimes[i]) self.assertEqual( stratAnalyzer.getCumulativeReturns().getDateTimes()[i], datetimes[i])
def testBaseBarFeed(self): barFeed = yahoofeed.Feed() barFeed.sanitizeBars(True) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barfeed_test.check_base_barfeed(self, barFeed, True)
def __getFeed(self): # Load the feed and process all bars. barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( VWAPTestCase.Instrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) return barFeed
def testSetSharesWithNoStartingCash(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( AnalyzerTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) strat = test_strategy.BacktestingStrategy(barFeed, 0) initialShares = 2 initialPrice = 16.25 strat.getBroker().setShares(AnalyzerTestCase.TestInstrument, initialShares, initialPrice) # Close initial position closingPrice = 32.50 strat.scheduleCall( datetime.datetime(2001, 1, 4), lambda: strat.marketOrder( AnalyzerTestCase.TestInstrument, -initialShares)) stratAnalyzer = returns.Returns() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertEqual( strat.getBroker().getShares(AnalyzerTestCase.TestInstrument), 0) self.assertEqual(strat.getBroker().getCash(), closingPrice * initialShares) # Check period returns. expectedPeriodReturns = [ (26.37 - initialPrice) / initialPrice, (32.00 - 26.37) / 26.37, (32.56 - 32.00) / 32.00, (32.50 - 32.56) / 32.56, 0, # Nothing should change moving forward 0, 0, ] for i, expectedReturn in enumerate(expectedPeriodReturns): self.assertEqual(stratAnalyzer.getReturns()[i], expectedReturn) self.assertEqual(stratAnalyzer.getReturns()[-1], expectedPeriodReturns[-1]) # Check cumulative returns. expectedCumulativeReturns = [ (26.37 - initialPrice) / initialPrice, (32.00 - initialPrice) / initialPrice, (32.56 - initialPrice) / initialPrice, (32.50 - initialPrice) / initialPrice, # Nothing should change moving forward (32.50 - initialPrice) / initialPrice, (32.50 - initialPrice) / initialPrice, ] for i, expectedReturn in enumerate(expectedCumulativeReturns): self.assertEqual(round(stratAnalyzer.getCumulativeReturns()[i], 4), round(expectedReturn, 4)) self.assertEqual(round(stratAnalyzer.getCumulativeReturns()[-1], 4), round(expectedCumulativeReturns[-1], 4))
def testDefaultInstrument(self): barFeed = yahoofeed.Feed() self.assertEqual(barFeed.getDefaultInstrument(), None) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) self.assertEqual(barFeed.getDefaultInstrument(), FeedTestCase.TestInstrument)
def testNoEvents(self): feed = yahoofeed.Feed() feed.addBarsFromCSV( "orcl", common.get_data_file_path("orcl-2000-yahoofinance.csv")) predicate = Predicate([]) eventProfiler = eventprofiler.Profiler(predicate, 5, 5) eventProfiler.run(feed, True) self.assertEqual(eventProfiler.getResults().getEventCount(), 0)
def testDuplicateBars(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) with self.assertRaisesRegex(Exception, "Duplicate bars found for.*"): barFeed.loadAll()
def testWithoutTimezone(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) for dateTime, bars in barFeed: bar = bars.getBar(FeedTestCase.TestInstrument) self.assertTrue(dt.datetime_is_naive(bar.getDateTime()))
def testFailingStrategy(self): barFeed = yahoofeed.Feed() instrument = "orcl" barFeed.addBarsFromCSV( instrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) res = local.run(FailingStrategy, barFeed, parameters_generator(instrument, 5, 100), logLevel=logging.DEBUG) self.assertIsNone(res)
def testWithDefaultTimezone(self): barFeed = yahoofeed.Feed( timezone=marketsession.USEquities.getTimezone()) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) for dateTime, bars in barFeed: bar = bars.getBar(FeedTestCase.TestInstrument) self.assertFalse(dt.datetime_is_naive(bar.getDateTime()))
def testWithIntegerTimezone(self): try: barFeed = yahoofeed.Feed(timezone=-5) self.assertTrue(False, "Exception expected") except Exception as e: self.assertTrue( str(e).find( "timezone as an int parameter is not supported anymore") == 0) try: barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"), -3) self.assertTrue(False, "Exception expected") except Exception as e: self.assertTrue( str(e).find( "timezone as an int parameter is not supported anymore") == 0)
def testMapTypeOperations(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.getTimezone()) for dateTime, bars in barFeed: self.assertTrue(FeedTestCase.TestInstrument in bars) self.assertFalse(FeedTestCase.TestInstrument not in bars) bars[FeedTestCase.TestInstrument] with self.assertRaises(KeyError): bars["pirulo"]
def testOneEvent(self): feed = yahoofeed.Feed() feed.addBarsFromCSV( "orcl", common.get_data_file_path("orcl-2000-yahoofinance.csv")) predicate = Predicate([datetime.date(2000, 1, 11)]) eventProfiler = eventprofiler.Profiler(predicate, 5, 5) eventProfiler.run(feed, True) self.assertEqual(eventProfiler.getResults().getEventCount(), 1) self.assertEqual(eventProfiler.getResults().getValues(0)[0], 1.0) self.assertEqual(round(eventProfiler.getResults().getValues(5)[0], 5), round(1.016745541, 5))
def testLocal(self): barFeed = yahoofeed.Feed() instrument = "orcl" barFeed.addBarsFromCSV( instrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) res = local.run(sma_crossover.SMACrossOver, barFeed, parameters_generator(instrument, 5, 100), logLevel=logging.DEBUG, batchSize=50) self.assertEqual(round(res.getResult(), 2), 1295462.6) self.assertEqual(res.getParameters()[1], 20)
def testNoTrades(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( "ige", common.get_data_file_path("sharpe-ratio-test-ige.csv")) strat = strategy_test.BaseStrategy(barFeed, 1000) stratAnalyzer = sharpe.SharpeRatio() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertTrue(strat.getBroker().getCash() == 1000) self.assertTrue(stratAnalyzer.getSharpeRatio(0.04, True) == 0) self.assertTrue(stratAnalyzer.getSharpeRatio(0) == 0) self.assertTrue(stratAnalyzer.getSharpeRatio(0, True) == 0)
def testNoTrades(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV("ige", common.get_data_file_path("sharpe-ratio-test-ige.csv")) barFeed.addBarsFromCSV("spy", common.get_data_file_path("sharpe-ratio-test-spy.csv")) strat = strategy_test.BaseStrategy(barFeed, 1000) strat.setBrokerOrdersGTC(True) strat.setUseAdjustedValues(True) stratAnalyzer = drawdown.DrawDown() strat.attachAnalyzer(stratAnalyzer) strat.run() self.assertTrue(strat.getBroker().getCash() == 1000) self.assertEqual(strat.orderUpdatedCalls, 0) self.assertTrue(stratAnalyzer.getMaxDrawDown() == 0) self.assertTrue(stratAnalyzer.getLongestDrawDownDuration() == datetime.timedelta())
def testBaseFeedInterface(self): tmpFeed = TemporarySQLiteFeed(SQLiteFeedTestCase.dbName, bar.Frequency.DAY) with tmpFeed: # Load bars using a Yahoo! feed. yahooFeed = yahoofeed.Feed() yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.timezone) yahooFeed.addBarsFromCSV("orcl", common.get_data_file_path("orcl-2001-yahoofinance.csv"), marketsession.USEquities.timezone) # Fill the database using the bars from the Yahoo! feed. sqliteFeed = tmpFeed.getFeed() sqliteFeed.getDatabase().addBarsFromFeed(yahooFeed) # Load the SQLite feed and process all bars. sqliteFeed.loadBars("orcl") feed_test.tstBaseFeedInterface(self, sqliteFeed)
def testCSVFeedLoadOrder(self): barFeed = yahoofeed.Feed() barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) # Dispatch and handle events. handler = BarFeedEventHandler_TestLoadOrder( self, barFeed, FeedTestCase.TestInstrument) barFeed.getNewValuesEvent().subscribe(handler.onBars) while not barFeed.eof(): barFeed.dispatch() self.assertTrue(handler.getEventCount() > 0)
def testDifferentTimezones(self): # Market times in UTC: # - TSE: 0hs ~ 6hs # - US: 14:30hs ~ 21hs feed = yahoofeed.Feed() for year in [2010, 2011]: feed.addBarsFromCSV( "^n225", common.get_data_file_path("nikkei-%d-yahoofinance.csv" % year), marketsession.TSE.getTimezone()) feed.addBarsFromCSV( "spy", common.get_data_file_path("spy-%d-yahoofinance.csv" % year), marketsession.USEquities.getTimezone()) self.__testDifferentTimezonesImpl(feed)
def __testFilteredRangeImpl(self, fromDate, toDate): barFeed = yahoofeed.Feed() barFeed.setBarFilter(csvfeed.DateRangeFilter(fromDate, toDate)) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv")) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2001-yahoofinance.csv")) # Dispatch and handle events. handler = BarFeedEventHandler_TestFilterRange( self, FeedTestCase.TestInstrument, fromDate, toDate) barFeed.getNewValuesEvent().subscribe(handler.onBars) while not barFeed.eof(): barFeed.dispatch() self.assertTrue(handler.getEventCount() > 0)
def testBounded(self): barFeed = yahoofeed.Feed(maxLen=2) barFeed.addBarsFromCSV( FeedTestCase.TestInstrument, common.get_data_file_path("orcl-2000-yahoofinance.csv"), marketsession.USEquities.getTimezone()) for dateTime, bars in barFeed: pass barDS = barFeed[FeedTestCase.TestInstrument] self.assertEqual(len(barDS), 2) self.assertEqual(len(barDS.getDateTimes()), 2) self.assertEqual(len(barDS.getCloseDataSeries()), 2) self.assertEqual(len(barDS.getCloseDataSeries().getDateTimes()), 2) self.assertEqual(len(barDS.getOpenDataSeries()), 2) self.assertEqual(len(barDS.getHighDataSeries()), 2) self.assertEqual(len(barDS.getLowDataSeries()), 2) self.assertEqual(len(barDS.getAdjCloseDataSeries()), 2)