'Clear out any assets that have expired before starting a new sim day.
Performs two functions:
1. Finds all assets for which we have open orders and clears any
orders whose assets are on or after their auto_close_date.
2. Finds all assets for which we have positions and generates
close_position events for any assets that have reached their
auto_close_date.'

def _cleanup_expired_assets(self, dt, position_assets):

    algo = self.algo
    def past_auto_close_date(asset):
        acd = asset.auto_close_date
        return ((acd is not None) and (acd <= dt))
    assets_to_clear = [asset for asset in position_assets if past_auto_close_date(asset)]
    perf_tracker = algo.perf_tracker
    data_portal = self.data_portal
    for asset in assets_to_clear:
        perf_tracker.process_close_position(asset, dt, data_portal)
    blotter = algo.blotter
    assets_to_cancel = [asset for asset in blotter.open_orders if past_auto_close_date(asset)]
    for asset in assets_to_cancel:
        blotter.cancel_all_orders_for_asset(asset)
    for order in copy(blotter.new_orders):
        if (order.status == ORDER_STATUS.CANCELLED):
            perf_tracker.process_order(order)
            blotter.new_orders.remove(order)
