示例#1
0
 def handle_data(context, data):
     closes = pipeline_output('test_close')
     volumes = pipeline_output('test_volume')
     date = get_datetime().normalize()
     for asset in self.assets:
         # Assets should appear iff they exist today and yesterday.
         exists_today = self.exists(date, asset)
         existed_yesterday = self.exists(date - self.trading_day, asset)
         if exists_today and existed_yesterday:
             self.assertEqual(closes.loc[asset, 'close'],
                              self.expected_close(date, asset))
             self.assertEqual(volumes.loc[asset, 'volume'],
                              self.expected_volume(date, asset))
         else:
             self.assertNotIn(asset, closes.index)
             self.assertNotIn(asset, volumes.index)
示例#2
0
 def handle_data(context, data):
     results = pipeline_output('test')
     date = get_datetime().normalize()
     for asset in self.assets:
         # Assets should appear iff they exist today and yesterday.
         exists_today = self.exists(date, asset)
         existed_yesterday = self.exists(date - self.trading_day, asset)
         if exists_today and existed_yesterday:
             latest = results.loc[asset, 'close']
             self.assertEqual(latest, self.expected_close(date, asset))
         else:
             self.assertNotIn(asset, results.index)
示例#3
0
        def handle_data(context, data):
            today = normalize_date(get_datetime())
            results = pipeline_output('test')
            expect_over_300 = {
                AAPL: today < self.AAPL_split_date,
                MSFT: False,
                BRK_A: True,
            }
            for asset in assets:
                should_pass_filter = expect_over_300[asset]
                if set_screen and not should_pass_filter:
                    self.assertNotIn(asset, results.index)
                    continue

                asset_results = results.loc[asset]
                self.assertEqual(asset_results['filter'], should_pass_filter)
                for length in vwaps:
                    computed = results.loc[asset, vwap_key(length)]
                    expected = vwaps[length][asset].loc[today]
                    # Only having two places of precision here is a bit
                    # unfortunate.
                    assert_almost_equal(computed, expected, decimal=2)
示例#4
0
def before_trading_start(context, data):
    context.pipeline_data = pipeline_output('my_pipeline')
示例#5
0
 def before_trading_start(context, data):
     context.results = pipeline_output('test')
     self.assertTrue(context.results.empty)
     count[0] += 1
示例#6
0
 def before_trading_start(context, data):
     pipeline_output('not_test')
     raise AssertionError("Shouldn't make it past pipeline_output!")
示例#7
0
 def initialize(context):
     attach_pipeline(Pipeline(), 'test')
     pipeline_output('test')
     raise AssertionError("Shouldn't make it past pipeline_output()")