def test_datasource_exception(self):
        self.zipline_test_config['trade_source'] = ExceptionSource()
        zipline = simfactory.create_test_zipline(
            **self.zipline_test_config
        )

        with self.assertRaises(ZeroDivisionError):
            output, _ = drain_zipline(self, zipline)
Exemple #2
0
    def test_zerodivision_exception_in_handle_data(self):

        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            DivByZeroAlgorithm(
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(**self.zipline_test_config)

        with self.assertRaises(ZeroDivisionError):
            output, _ = drain_zipline(self, zipline)
    def test_zerodivision_exception_in_handle_data(self):

        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            DivByZeroAlgorithm(
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(
            **self.zipline_test_config
        )

        with self.assertRaises(ZeroDivisionError):
            output, _ = drain_zipline(self, zipline)
Exemple #4
0
    def test_exception_in_handle_data(self):
        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            ExceptionAlgorithm(
                'handle_data',
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(**self.zipline_test_config)

        with self.assertRaises(Exception) as ctx:
            output, _ = drain_zipline(self, zipline)

        self.assertEqual(str(ctx.exception), 'Algo exception in handle_data')
Exemple #5
0
    def test_set_portfolio(self):
        """
        Are we protected against overwriting an algo's portfolio?
        """

        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            SetPortfolioAlgorithm(
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(**self.zipline_test_config)

        with self.assertRaises(AttributeError):
            output, _ = drain_zipline(self, zipline)
    def test_exception_in_handle_data(self):
        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            ExceptionAlgorithm(
                'handle_data',
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(
            **self.zipline_test_config
        )

        with self.assertRaises(Exception) as ctx:
            output, _ = drain_zipline(self, zipline)

        self.assertEqual(str(ctx.exception), 'Algo exception in handle_data')
    def test_set_portfolio(self):
        """
        Are we protected against overwriting an algo's portfolio?
        """

        # Simulation
        # ----------
        self.zipline_test_config['algorithm'] = \
            SetPortfolioAlgorithm(
                self.zipline_test_config['sid'],
                sim_params=factory.create_simulation_parameters(),
                env=self.env
        )

        zipline = simfactory.create_test_zipline(
            **self.zipline_test_config
        )

        with self.assertRaises(AttributeError):
            output, _ = drain_zipline(self, zipline)
Exemple #8
0
    def test_datasource_exception(self):
        self.zipline_test_config['trade_source'] = ExceptionSource()
        zipline = simfactory.create_test_zipline(**self.zipline_test_config)

        with self.assertRaises(ZeroDivisionError):
            output, _ = drain_zipline(self, zipline)