def calc_profit(order, bid: float, ask: float, leverage: float=100):
    """Compute the profit of a given order, return closing price and profit."""
    isbuy = order.type == 'buy'
    closep = bid if isbuy else ask
    diff = closep - order.price if isbuy else order.price - closep
    profit = diff * leverage * order.volume * 1000 * (1 / closep)
    return closep, round(profit, 2)
