Example #1
0
    def test_security_list(self):
        # set the knowledge date to the first day of the
        # leveraged etf knowledge date.
        def get_datetime():
            return self.start

        rl = SecurityListSet(get_datetime, self.env.asset_finder)
        # assert that a sample from the leveraged list are in restricted
        should_exist = [
            asset.sid for asset in [
                self.env.asset_finder.lookup_symbol(
                    symbol, as_of_date=self.extra_knowledge_date)
                for symbol in ["BZQ", "URTY", "JFT"]
            ]
        ]
        for sid in should_exist:
            self.assertIn(
                sid, rl.leveraged_etf_list.current_securities(get_datetime()))

        # assert that a sample of allowed stocks are not in restricted
        shouldnt_exist = [
            asset.sid for asset in [
                self.env.asset_finder.lookup_symbol(
                    symbol, as_of_date=self.extra_knowledge_date)
                for symbol in ["AAPL", "GOOG"]
            ]
        ]
        for sid in shouldnt_exist:
            self.assertNotIn(
                sid, rl.leveraged_etf_list.current_securities(get_datetime()))
Example #2
0
    def test_security_add_delete(self):
        with security_list_copy():

            def get_datetime():
                return pd.Timestamp("2015-01-27", tz='UTC')

            rl = SecurityListSet(get_datetime, self.env.asset_finder)
            self.assertNotIn(
                "BZQ",
                rl.leveraged_etf_list.current_securities(get_datetime()))
            self.assertNotIn(
                "URTY",
                rl.leveraged_etf_list.current_securities(get_datetime()))
Example #3
0
    def test_security_add(self):
        def get_datetime():
            return pd.Timestamp("2015-01-27", tz='UTC')

        with security_list_copy():
            add_security_data(['AAPL', 'GOOG'], [])
            rl = SecurityListSet(get_datetime, self.env.asset_finder)
            should_exist = [
                asset.sid for asset in [
                    self.env.asset_finder.lookup_symbol(
                        symbol, as_of_date=self.extra_knowledge_date)
                    for symbol in ["AAPL", "GOOG", "BZQ", "URTY"]
                ]
            ]
            for sid in should_exist:
                self.assertIn(
                    sid,
                    rl.leveraged_etf_list.current_securities(get_datetime()))
Example #4
0
 def initialize(self, symbol):
     self.rl = SecurityListSet(self.get_datetime, self.asset_finder)
     self.set_asset_restrictions(self.rl.restrict_leveraged_etfs)
     self.order_count = 0
     self.sid = self.symbol(symbol)
     self.found = False
Example #5
0
 def initialize(self, symbol):
     self.rl = SecurityListSet(self.get_datetime, self.asset_finder)
     self.set_do_not_order_list(self.rl.leveraged_etf_list)
     self.order_count = 0
     self.sid = self.symbol(symbol)