Class ExposureReservationService

java.lang.Object
edu.yu.marketmaker.exposurereservation.ExposureReservationService

public class ExposureReservationService extends Object
Service responsible for managing exposure limits and reservations. Handles the logic for creating reservations against available capacity, applying fills to reduce open exposure, and releasing unused reservations.
  • Constructor Details

  • Method Details

    • createReservation

      public ReservationResponse createReservation(Quote quote)
      Creates a new exposure reservation. Checks current usage against limits and grants full, partial, or no capacity.
      Parameters:
      quote - The requested quote.
      Returns:
      The response containing the reservation ID and the actual granted quantity.
    • applyFill

      public int applyFill(UUID id, int filledQty)
      Applies a fill to an active reservation. When a trade executes, the reserved exposure is converted to actual position (not tracked here), so we free up the reserved capacity corresponding to the fill.
      Parameters:
      id - The UUID of the reservation.
      filledQty - The quantity that was filled.
      Returns:
      The amount of capacity freed by this operation.
      Throws:
      RuntimeException - if the reservation is not found.
    • release

      public int release(UUID id)
      Releases all remaining capacity for a specific reservation. This is typically called when a quote is cancelled.
      Parameters:
      id - The UUID of the reservation.
      Returns:
      The total capacity freed.
      Throws:
      RuntimeException - if the reservation is not found.
    • getExposureState

      public ExposureState getExposureState()
      Calculates the current system-wide exposure state.
      Returns:
      Snapshot of usage, capacity, and active count.