'Size the order to reflect the dollar-weighting of the
current equity account size based on pre-specified
ticker weights.'

def size_order(self, portfolio, initial_order):

    ticker = initial_order.ticker
    if (initial_order.action == 'EXIT'):
        cur_quantity = portfolio.positions[ticker].quantity
        if (cur_quantity > 0):
            initial_order.action = 'SLD'
            initial_order.quantity = cur_quantity
        else:
            initial_order.action = 'BOT'
            initial_order.quantity = cur_quantity
    else:
        weight = self.ticker_weights[ticker]
        price = portfolio.price_handler.tickers[ticker]['adj_close']
        price = PriceParser.display(price)
        equity = PriceParser.display(portfolio.equity)
        dollar_weight = (weight * equity)
        weighted_quantity = int(floor((dollar_weight / price)))
        initial_order.quantity = weighted_quantity
    return initial_order
