def test_account_bts(self):
        algo_code = dedent("""
        from zipline.api import order, sid, record

        def initialize(context):
            context.ordered = False
            context.hd_account = context.account

        def before_trading_start(context, data):
            bts_account = context.account

            # Assert that the account in BTS is the same as the last account
            # in handle_data
            assert (context.hd_account == bts_account)
            record(port_value=context.account.equity_with_loan)

        def handle_data(context, data):
            if not context.ordered:
                order(sid(1), 1)
                context.ordered = True
            context.hd_acount = context.account
        """)

        algo = TradingAlgorithm(
            script=algo_code,
            data_frequency="minute",
            sim_params=self.sim_params,
            env=self.env
        )

        results = algo.run(self.data_portal)

        # Starting portfolio value is 10000. Order for the asset fills on the
        # second bar of 1/06, where the price is 391, and costs the default
        # commission of 1. On 1/07, the price is 780, and the increase in
        # portfolio value is 780-392-1
        self.assertEqual(results.port_value.iloc[0], 10000)
        self.assertAlmostEqual(results.port_value.iloc[1],
                               10000 + 780 - 392 - 1)
dataset/ETHPy150Open quantopian/zipline/tests/test_algorithm.py/TestBeforeTradingStart.test_account_bts/original