Class OrderBook

  • All Implemented Interfaces:
    de.dlr.gitlab.fame.communication.transfer.Portable
    Direct Known Subclasses:
    DemandOrderBook, SupplyOrderBook

    public abstract class OrderBook
    extends Object
    implements de.dlr.gitlab.fame.communication.transfer.Portable
    Handles a list of bids or asks at an energy DayAheadMarket for a single time frame of trading
    Author:
    Martin Klein, Christoph Schimeczek
    • Field Detail

      • awardedPrice

        protected double awardedPrice
        market clearing price
      • awardedCumulativePower

        protected double awardedCumulativePower
        total power awarded to both supply and demand
      • isSorted

        protected boolean isSorted
        tells if this OrderBook has been yet finalised and sorted
    • Constructor Detail

      • OrderBook

        public OrderBook()
        required for Portables
    • Method Detail

      • addBid

        public void addBid​(Bid bid)
        Adds given Bid to this OrderBook; the OrderBook must not be sorted yet
        Parameters:
        bid - to be added to the unsorted OrderBook
      • ensureNotYetSortedOrThrow

        protected void ensureNotYetSortedOrThrow​(String exceptionMessage)
        Ensures the OrderBook items are not yet sorted
        Parameters:
        exceptionMessage - message of the thrown exception (if any)
        Throws:
        RuntimeException - if items are already sorted
      • ensureSortedOrThrow

        protected void ensureSortedOrThrow​(String exceptionMessage)
        Ensures the OrderBook items are already sorted
        Parameters:
        exceptionMessage - message of the thrown exception (if any)
        Throws:
        RuntimeException - if items are not yet sorted
      • addBids

        public void addBids​(ArrayList<Bid> bids)
        Adds multiple Bids to this OrderBook; the OrderBook must not be sorted yet
        Parameters:
        bids - to add to this unsorted OrderBook
      • getOrderBookItems

        public ArrayList<OrderBookItem> getOrderBookItems()
        Returns:
        a list of items, which are sorted and have assigned cumulated power values
      • getLastBid

        protected abstract Bid getLastBid()
        Returns:
        the last virtual Bid depending on the type of order book
      • updateAwardedPowerInBids

        public void updateAwardedPowerInBids​(double totalAwardedPower,
                                             double awardedPrice,
                                             OrderBook.DistributionMethod method)
        Updates awarded powers of all contained OrderBookItems, based on the given parameters
        Parameters:
        totalAwardedPower - obtained at market clearing - after this call: equals to sum of all OrderBookItem's awarded power
        awardedPrice - uniform market clearing price
        method - determines, how power is distributed among multiple price-setting bids
      • filterForBidsByTrader

        public ArrayList<OrderBookItem> filterForBidsByTrader​(long traderID)
        Returns list of OrderBookItems that belong to the specified trader
        Parameters:
        traderID - to look for
        Returns:
        list of Items that associated with specified trader
      • addComponentsTo

        public void addComponentsTo​(de.dlr.gitlab.fame.communication.transfer.ComponentCollector collector)
        required for Portables
        Specified by:
        addComponentsTo in interface de.dlr.gitlab.fame.communication.transfer.Portable
      • populate

        public void populate​(de.dlr.gitlab.fame.communication.transfer.ComponentProvider provider)
        required for Portables
        Specified by:
        populate in interface de.dlr.gitlab.fame.communication.transfer.Portable