Package agents.markets.meritOrder.books
Class OrderBook
- java.lang.Object
-
- agents.markets.meritOrder.books.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 energyDayAheadMarket
for a single time frame of trading- Author:
- Martin Klein, Christoph Schimeczek, A. Achraf El Ghazi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OrderBook.DistributionMethod
Method of how to award energy across multiple price-setting bids
-
Field Summary
Fields Modifier and Type Field Description protected double
awardedCumulativePower
total power awarded to both supply and demandprotected double
awardedPrice
market clearing priceprotected boolean
isSorted
tells if thisOrderBook
has been yet finalised and sortedprotected ArrayList<OrderBookItem>
orderBookItems
list of all items in thisOrderBook
-
Constructor Summary
Constructors Constructor Description OrderBook()
required forPortable
s
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addBid(Bid bid, long traderUuid)
void
addBids(List<Bid> bids, long traderUuid)
void
addComponentsTo(de.dlr.gitlab.fame.communication.transfer.ComponentCollector collector)
required forPortable
svoid
clear()
Removes all storedOrderBookItems
-- sets status to "unsorted" -- setsawardedPrice
andawardedCumulativePower
toDouble.NaN
protected void
ensureNotYetSortedOrThrow(String exceptionMessage)
protected void
ensurePositiveBidPower()
Ensures theOrderBook
's items have non-negative block power.protected void
ensureSortedOrThrow(String exceptionMessage)
ArrayList<OrderBookItem>
filterForBidsByTrader(long traderID)
Returns list ofOrderBookItem
s that belong to the specified traderdouble
getCumulatePowerOfItems()
protected abstract Bid
getLastBid()
ArrayList<OrderBookItem>
getOrderBookItems()
protected abstract Comparator<OrderBookItem>
getSortComparator()
double
getTradersSumOfPower(long traderUuid)
Return sum of power across all bids in this OrderBook for given traderboolean
hasNoValidBids()
Checks if thisOrderBook
contains no bids with power; this closes the order book - no further calls toaddBid(Bid, long)
oraddBids(List, long)
are allowed afterwardsvoid
populate(de.dlr.gitlab.fame.communication.transfer.ComponentProvider provider)
required forPortable
sString
toString()
void
updateAwardedPowerInBids(double totalAwardedPower, double awardedPrice, OrderBook.DistributionMethod method)
Updates awarded powers of all containedOrderBookItem
s, based on the given parameters
-
-
-
Field Detail
-
awardedPrice
protected double awardedPrice
market clearing price
-
awardedCumulativePower
protected double awardedCumulativePower
total power awarded to both supply and demand
-
orderBookItems
protected ArrayList<OrderBookItem> orderBookItems
list of all items in thisOrderBook
-
isSorted
protected boolean isSorted
tells if thisOrderBook
has been yet finalised and sorted
-
-
Method Detail
-
addBid
public void addBid(Bid bid, long traderUuid)
- Parameters:
bid
- to be added to the unsorted OrderBooktraderUuid
- id of the trader associated with the bids
-
ensureNotYetSortedOrThrow
protected void ensureNotYetSortedOrThrow(String exceptionMessage)
- Parameters:
exceptionMessage
- message of the thrown exception (if any)- Throws:
RuntimeException
- if items are already sorted
-
ensureSortedOrThrow
protected void ensureSortedOrThrow(String exceptionMessage)
- Parameters:
exceptionMessage
- message of the thrown exception (if any)- Throws:
RuntimeException
- if items are not yet sorted
-
ensurePositiveBidPower
protected void ensurePositiveBidPower()
Ensures theOrderBook
's items have non-negative block power.- Throws:
RuntimeException
- if bid's block power is negative
-
addBids
public void addBids(List<Bid> bids, long traderUuid)
- Parameters:
bids
- to add to this unsorted OrderBooktraderUuid
- id of the trader associated with the bids
-
clear
public void clear()
Removes all storedOrderBookItems
-- sets status to "unsorted" -- setsawardedPrice
andawardedCumulativePower
toDouble.NaN
-
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
-
getSortComparator
protected abstract Comparator<OrderBookItem> getSortComparator()
- Returns:
Comparator
to sortorderBookItems
with
-
updateAwardedPowerInBids
public void updateAwardedPowerInBids(double totalAwardedPower, double awardedPrice, OrderBook.DistributionMethod method)
Updates awarded powers of all containedOrderBookItem
s, based on the given parameters- Parameters:
totalAwardedPower
- obtained at market clearing - after this call: equals to sum of all OrderBookItem's awarded powerawardedPrice
- uniform market clearing pricemethod
- determines, how power is distributed among multiple price-setting bids
-
filterForBidsByTrader
public ArrayList<OrderBookItem> filterForBidsByTrader(long traderID)
Returns list ofOrderBookItem
s 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 forPortable
s- Specified by:
addComponentsTo
in interfacede.dlr.gitlab.fame.communication.transfer.Portable
-
populate
public void populate(de.dlr.gitlab.fame.communication.transfer.ComponentProvider provider)
required forPortable
s- Specified by:
populate
in interfacede.dlr.gitlab.fame.communication.transfer.Portable
-
getTradersSumOfPower
public double getTradersSumOfPower(long traderUuid)
Return sum of power across all bids in this OrderBook for given trader- Parameters:
traderUuid
- UUID of trader to sum up awarded power- Returns:
- awarded power of given trader
-
getCumulatePowerOfItems
public double getCumulatePowerOfItems()
- Returns:
- sum of power value of
orderBookItems
-
hasNoValidBids
public boolean hasNoValidBids()
Checks if thisOrderBook
contains no bids with power; this closes the order book - no further calls toaddBid(Bid, long)
oraddBids(List, long)
are allowed afterwards- Returns:
- true if no bids with power are contained
-
-