/**
  * Return aggregated data for portfolio history
  * Prices of all stocks from the portfolio are summed for each day
  *
  * @param PersistentCollection $portfolio
  * @return array
  */
 public function getPortfolioHistory(PersistentCollection $portfolio)
 {
     return $this->getEntityManager()->createQueryBuilder()->select('h.date', 'sum(h.closePrice) AS total')->from('AppBundle:StockHistory', 'h')->where('h.stock in (:portfolio)')->setParameter('portfolio', $portfolio->getValues())->addGroupBy('h.date')->orderBy('h.date')->getQuery()->getArrayResult();
 }
Beispiel #2
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Checks if current position is valid
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  *       Returns true on success or false on failure.
  */
 public function valid()
 {
     $children = $this->children->getValues();
     return isset($children[$this->childrenPosition]);
 }