'Test that EOD order cancel works in minute mode for both shorts and
longs, and both daily emission and minute emission'

@parameter_space(direction=[1, (-1)], minute_emission=[True, False])
def test_eod_order_cancel_minute(self, direction, minute_emission):

    algo = self.prep_algo('set_cancel_policy(cancel_policy.EODCancel())', amount=np.copysign(1000, direction), minute_emission=minute_emission)
    log_catcher = TestHandler()
    with log_catcher:
        results = algo.run(self.data_portal)
        for daily_positions in results.positions:
            self.assertEqual(1, len(daily_positions))
            self.assertEqual(np.copysign(389, direction), daily_positions[0]['amount'])
            self.assertEqual(1, results.positions[0][0]['sid'])
        np.testing.assert_array_equal([1, 0, 0], list(map(len, results.orders)))
        np.testing.assert_array_equal([389, 0, 0], list(map(len, results.transactions)))
        the_order = results.orders[0][0]
        self.assertEqual(ORDER_STATUS.CANCELLED, the_order['status'])
        self.assertEqual(np.copysign(389, direction), the_order['filled'])
        warnings = [record for record in log_catcher.records if (record.level == WARNING)]
        self.assertEqual(1, len(warnings))
        if (direction == 1):
            self.assertEqual('Your    order    for    1000    shares    of    ASSET1    has    been    partially    filled.    389    shares    were    successfully    purchased.    611    shares    were    not    filled    by    the    end    of    day    and    were    canceled.', str(warnings[0].message))
        elif (direction == (-1)):
            self.assertEqual('Your    order    for    -1000    shares    of    ASSET1    has    been    partially    filled.    389    shares    were    successfully    sold.    611    shares    were    not    filled    by    the    end    of    day    and    were    canceled.', str(warnings[0].message))
