예제 #1
0
 /** Write initial cash balance. * */
 public void initialized(Date date, TradingAccount account) {
   writer.println(
       DATE_FORMAT.format(date)
           + ": "
           + "cash="
           + DOLLAR_FORMAT.format(account.getCurrentCashBalance()));
   this.lastTraceDate = date;
 }
예제 #2
0
 /**
  * If writing every day, or shares traded on date,<br>
  * Write [DATE]: cash=[CASHVALUE], stocks=[STOCKVALUE], total=[TOTALVALUE]*
  */
 public void ordersCompleted(Date date, TradingAccount account) {
   // report new balances only if they changed (buy or sell occurred on date)
   if (!this.daysTradedOnly || this.lastTraceDate.equals(date)) {
     double cashBalance = account.getCurrentCashBalance();
     double stockValue = account.getCurrentStockValue();
     double total = cashBalance + stockValue;
     this.writer.println(
         DATE_FORMAT.format(date)
             + ": "
             + "cash="
             + DOLLAR_FORMAT.format(cashBalance)
             + ", "
             + "stocks="
             + DOLLAR_FORMAT.format(stockValue)
             + ", "
             + "total="
             + DOLLAR_FORMAT.format(total));
   }
 }