Beispiel #1
0
    def __enter__(self):
        # Use the given context module to grab configuration
        Loader = utils.intuition_module(self._ctx_module)
        log.info('building context',
                 driver=self._ctx_module, data=self._ctx_infos)
        config, strategy = Loader(self._ctx_infos).build()

        # TODO Validate strategy as well
        self._validate(config)

        # From a human input (forex,4), setup a complete market structure
        market = universe.Market()
        market.parse_universe_description(config.pop('universe'))
        # Remove holidays and other market closed periods
        config['index'] = market.filter_open_days(config['index'])

        return {'config': config, 'strategy': strategy, 'market': market}
Beispiel #2
0
 def test_parse_universe(self):
     market = universe.Market()
     market.parse_universe_description(
         self.good_universe_description + ',4')
     self.assertIsInstance(market.sids, list)
     eq_(len(market.sids), 4)
Beispiel #3
0
 def test__lookup_sids_wrong_market(self):
     market = universe.Market()
     market._lookup_sids(self.bad_universe_description)
Beispiel #4
0
 def test__lookup_sids_with_limit(self):
     limit = 4
     market = universe.Market()
     sids = market._lookup_sids(self.good_universe_description, limit)
     self.assertIsInstance(sids, list)
     eq_(len(sids), limit)
Beispiel #5
0
 def test__lookup_sids_no_limit(self):
     market = universe.Market()
     sids = market._lookup_sids(self.good_universe_description)
     self.assertIsInstance(sids, list)
     self.assertGreater(len(sids), 0)
Beispiel #6
0
 def test__extract_cac40(self):
     market = universe.Market()
     sids = market._extract_cac40(['stocks', 'paris', 'cac40'])
     self.assertGreater(len(sids), 0)
     self.assertGreater(sids[0].find('.pa'), 0)
Beispiel #7
0
 def test__extract_forex(self):
     market = universe.Market()
     sids = market._extract_forex()
     self.assertGreater(len(sids), 0)
     self.assertGreater(sids[0].find('/'), 0)
Beispiel #8
0
 def test_initialize_market(self):
     market = universe.Market()
     self.assertIsInstance(market.scheme, dict)
     eq_(market.benchmark, self.default_benchmark)
     eq_(market.timezone, self.default_timezone)