16 package emlab.gen.role.market;
18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.transaction.annotation.Transactional;
21 import agentspring.role.Role;
22 import agentspring.role.RoleComponent;
46 public class ProcessAcceptedBidsRole extends AbstractMarketRole<DecarbonizationMarket> implements Role<DecarbonizationMarket> {
52 public Reps getReps() {
60 logger.info(
"Process accepted bids to cash flow now");
62 boolean isCO2Traded =
false;
64 cashFlowType = CashFlow.CO2AUCTION;
67 cashFlowType = CashFlow.COMMODITY;
69 cashFlowType = CashFlow.UNCLASSIFIED;
73 Iterable<Bid> acceptedSupplyBids = reps.bidRepository.findAllAcceptedOffersForMarketForTime(market, getCurrentTick());
74 Iterable<Bid> acceptedDemandBids = reps.bidRepository.findAllAcceptedDemandBidsForMarketForTime(market, getCurrentTick());
78 ClearingPoint clearingPoint = reps.clearingPointRepositoryOld.findClearingPointForMarketAndTime(market,
79 getCurrentTick(),
false);
81 for (
Bid bid : acceptedSupplyBids) {
83 reps.nonTransactionalCreateRepository.createCashFlow(market, bid.getBidder(),
84 bid.getAcceptedAmount() * clearingPoint.getPrice(), cashFlowType, getCurrentTick(), null);
86 bid.getBidder().setCo2Allowances(bid.getBidder().getCo2Allowances() - bid.getAcceptedAmount());
90 for (
Bid bid : acceptedDemandBids) {
92 reps.nonTransactionalCreateRepository.createCashFlow(bid.getBidder(), market,
93 bid.getAcceptedAmount() * clearingPoint.getPrice(), cashFlowType, getCurrentTick(), null);
95 bid.getBidder().setCo2Allowances(bid.getBidder().getCo2Allowances() + bid.getAcceptedAmount());