Class AuctionService

  • All Implemented Interfaces:
    InitializationService

    @Service
    public class AuctionService
    extends TimeslotPhaseProcessor
    implements InitializationService
    This is the wholesale day-ahead market. Energy is traded in future timeslots by submitting MarketOrders representing bids and asks. Each specifies a price (minimum price for asks, maximum (negative) price for bids) and a quantity in mWh. A bid is defined as an Order with a positive value for mWh; an ask is an Order with a negative mWh value. Once during each timeslot, the market is cleared by matching bids with asks such that the bid price is no lower than the ask price, and allocating quantities, until no matching bids or asks are available. In general, the last matched bid will have a higher price than the last matched ask. All trades are cleared at a price determined by splitting the difference between the last bid and the last ask according to the value of sellerSurplusRatio, which is a parameter set in the initialization process.

    Orders may be market orders (no specified price) as well as limit orders (the normal case). Market orders are considered to have a "more attractive" price than any limit order, so they are sorted first in the clearing process. In case the clearing process needs to set a price by matching a market order with a limit order, the clearing price is set by applying a "default margin" to the limit order. If there are no limit orders in the match, then the market clears at a fixed default clearing price. It's probably best if brokers do not allow this to happen.

    Author:
    John Collins
    • Constructor Detail

      • AuctionService

        public AuctionService()
    • Method Detail

      • initialize

        public String initialize​(Competition competition,
                                 List<String> completedInits)
        Description copied from interface: InitializationService
        Initializes a plugin prior to the beginning of a game. The completedInits parameter is the list of plugin role names that have been successfully initialized. If sequence dependencies are satisfied (or if there are no sequence dependencies), then an implementation must complete its pre-game initialization process and return its role name. If sequence dependencies are not satisfied, then an implementation must return null. It will be called again after additional successful initializations have been completed. If initialization is not possible, then returning the string 'fail' will cause the server to log an error and shut down. This will be helpful just in case the implementation also logs a detailed error message.
        Specified by:
        initialize in interface InitializationService
      • getSellerSurplusRatio

        public double getSellerSurplusRatio()
      • getDefaultMargin

        public double getDefaultMargin()
      • getDefaultClearingPrice

        public double getDefaultClearingPrice()
      • handleMessage

        public void handleMessage​(Order msg)
        Receives, validates, and queues an incoming Order message. Processing the incoming marketOrders happens during Phase 2 in each timeslot.
      • validateOrder

        public boolean validateOrder​(Order order)
      • activate

        public void activate​(org.joda.time.Instant time,
                             int phaseNumber)
        Processes incoming Order instances for each timeslot, generating the appropriate MarketTransactions, Orderbooks, and ClearedTrade instances.
        Specified by:
        activate in class TimeslotPhaseProcessor