Esempio n. 1
0
    def testCSVFeedLoadOrder(self):
        barFeed = CSVFeed()
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120627.csv"))
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120628.csv"))
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120629.csv"))

        handler = BarFeedEventHandler_TestLoadOrder(self, barFeed, IBCSVFeedTestCase.TestInstrument)
        barFeed.getNewBarsEvent().subscribe(handler.onBars)
        while not barFeed.stopDispatching():
            barFeed.dispatch()
        assert handler.getEventCount() > 0
Esempio n. 2
0
    def __testFilteredRangeImpl(self, fromDate, toDate):
        barFeed = CSVFeed()
        barFeed.setBarFilter(csvfeed.DateRangeFilter(fromDate, toDate))
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120627.csv"))
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120628.csv"))
        barFeed.addBarsFromCSV(IBCSVFeedTestCase.TestInstrument, common.get_data_file_path("ib-spy-5min-20120629.csv"))

        # Dispatch and handle events.
        handler = BarFeedEventHandler_TestFilterRange(self, IBCSVFeedTestCase.TestInstrument, fromDate, toDate)
        barFeed.getNewBarsEvent().subscribe(handler.onBars)
        while not barFeed.stopDispatching():
            barFeed.dispatch()
        assert handler.getEventCount() > 0