/**
  * Receives a new MarketTransaction. We look to see whether an order we have placed has cleared.
  */
 public synchronized void handleMessage(MarketTransaction tx) {
   // reset price escalation when a trade fully clears.
   Order lastTry = lastOrder.get(tx.getTimeslotIndex());
   if (lastTry == null) // should not happen
   log.error("order corresponding to market tx " + tx + " is null");
   else if (tx.getMWh() == lastTry.getMWh()) // fully cleared
   lastOrder.put(tx.getTimeslotIndex(), null);
 }
 @Override
 public void handleNewObject(Object thing) {
   initMaybe();
   MarketTransaction msg = (MarketTransaction) thing;
   // contains MWh and price/MWh
   Broker broker = msg.getBroker();
   if (brokerMkt.keySet().contains(broker)) {
     double amt = -msg.getMWh() * msg.getPrice() * Math.signum(msg.getPrice());
     brokerMkt.put(broker, brokerMkt.get(broker) + amt);
   }
 }
Beispiel #3
0
  public void addMarketTransaction(MarketTransaction transaction) {
    marketTransactions.add(transaction);

    totalPrice += transaction.getPrice();
    totalMWh += transaction.getMWh();
  }