应用成交，并计算交易产生的现金变动。

        开仓：
        delta_cash
        = -1 * margin
        = -1 * quantity * contract_multiplier * price * margin_rate

        平仓：
        delta_cash
        = old_margin - margin + delta_realized_pnl
        = (sum of (cost_price * quantity) of closed trade) * contract_multiplier * margin_rate + delta_realized_pnl

        :param trade: rqalpha.model.trade.Trade
        :return: float

def apply_trade(self, trade):
        """
        应用成交，并计算交易产生的现金变动。

        开仓：
        delta_cash
        = -1 * margin
        = -1 * quantity * contract_multiplier * price * margin_rate

        平仓：
        delta_cash
        = old_margin - margin + delta_realized_pnl
        = (sum of (cost_price * quantity) of closed trade) * contract_multiplier * margin_rate + delta_realized_pnl

        :param trade: rqalpha.model.trade.Trade
        :return: float
        """
        # close_trade: delta_cash = old_margin - margin + delta_realized_pnl
        trade_quantity = trade.last_quantity
        if trade.side == SIDE.BUY:
            if trade.position_effect == POSITION_EFFECT.OPEN:
                self._buy_avg_open_price = (self._buy_avg_open_price * self.buy_quantity +
                                            trade_quantity * trade.last_price) / (self.buy_quantity + trade_quantity)
                self._buy_transaction_cost += trade.transaction_cost
                self._buy_today_holding_list.insert(0, (trade.last_price, trade_quantity))
                return -1 * self._margin_of(trade_quantity, trade.last_price)
            else:
                old_margin = self.margin
                self._sell_transaction_cost += trade.transaction_cost
                delta_realized_pnl = self._close_holding(trade)
                self._sell_realized_pnl += delta_realized_pnl
                return old_margin - self.margin + delta_realized_pnl
        else:
            if trade.position_effect == POSITION_EFFECT.OPEN:
                self._sell_avg_open_price = (self._sell_avg_open_price * self.sell_quantity +
                                             trade_quantity * trade.last_price) / (self.sell_quantity + trade_quantity)
                self._sell_transaction_cost += trade.transaction_cost
                self._sell_today_holding_list.insert(0, (trade.last_price, trade_quantity))
                return -1 * self._margin_of(trade_quantity, trade.last_price)
            else:
                old_margin = self.margin
                self._buy_transaction_cost += trade.transaction_cost
                delta_realized_pnl = self._close_holding(trade)
                self._buy_realized_pnl += delta_realized_pnl
                return old_margin - self.margin + delta_realized_pnl