Exemple #1
0
 @Override
 public void updatePortfolio(
     Contract contract,
     int qty,
     double marketPrice,
     double marketValue,
     double averageCost,
     double unrealizedPNL,
     double realizedPNL,
     String accountName) {
   try {
     if (logger.isDebugEnabled())
       logger.debug(
           "updatePortfolio: {} {} {} {} {} {} {} {}",
           new Object[] {
             Util.toString(contract),
             qty,
             marketPrice,
             marketValue,
             averageCost,
             unrealizedPNL,
             realizedPNL,
             accountName
           });
     if (qty != 0) {
       Symbol symbol = toSymbol(contract);
       double costBasis =
           averageCost
               / (contract.m_multiplier != null ? Integer.parseInt(contract.m_multiplier) : 1);
       Position position = new Position(symbol, qty, costBasis, 0.0);
       portfolio.setPosition(symbol, position);
       logger.info(
           "Updated {}, last: {}, unrealized pnl: {}",
           new Object[] {position, marketPrice, position.getProfitLoss(marketPrice)});
     }
   } catch (Throwable t) {
     logger.error(t.getMessage(), t);
   }
 }