def derivative_pnl(long: list, short: list):
    # It is assumed that the amount and leverage for both open and close orders are thesame.
    """
    Calculates PnL for a close position
    :param long: a list containing pairs of open and closed long position orders
    :param short: a list containing pairs of open and closed short position orders
    :return: A list containing PnL for each closed positions
    """
    pnls = []
    for lg in long:
        pnls.append((lg[1].price - lg[0].price) * lg[1].amount)
    for st in short:
        pnls.append((st[0].price - st[1].price) * st[1].amount)
    return pnls