Beispiel #1
0
 public double remove(String omxId) throws ParserConfigurationException {
   if (stockmap.containsKey(omxId)) {
     events.addEvent("Stock removed from portfolio", omxId, invest.getShortName(omxId));
     updateLatestBuy();
     updateLatestSell();
     return stockmap.remove(omxId);
   }
   return 0;
 }
Beispiel #2
0
 public boolean sell(String omxId, int nbrOfStocks, double price)
     throws ParserConfigurationException {
   if (stockmap.containsKey(omxId) && nbrOfStocks > 0) {
     stockmap.put(omxId, stockmap.get(omxId) - nbrOfStocks);
     liquidAsset += nbrOfStocks * price;
     events.addEvent("shares sold", -1 * nbrOfStocks, nbrOfStocks * price);
     return true;
   }
   return false;
 }
Beispiel #3
0
 public boolean add(String omxId) throws ParserConfigurationException {
   if (stockmap.containsKey(omxId)) {
     return false;
   }
   stockmap.put(omxId, 0);
   updateLatestBuy();
   updateLatestSell();
   events.addEvent("Stock added to portfolio", omxId, invest.getShortName(omxId));
   return true;
 }
Beispiel #4
0
 public void setLiquidAsset(double liquidAsset) throws ParserConfigurationException {
   double old = this.liquidAsset;
   this.liquidAsset = liquidAsset;
   events.addEvent("set liquid asset", old - liquidAsset, liquidAsset);
 }