Beispiel #1
0
 /**
  * @param LotModel $model
  * @param int $status
  * @return bool
  */
 protected function compareRebalancerQueue(LotModel $model, $status)
 {
     $amount = $model->getAmount();
     if (!empty($amount)) {
         $parameters['status'] = $status;
         $parameters['quantity'] = $model->getQuantity();
         $parameters['security_id'] = $model->getSecurityId();
         $status == RebalancerQueueModel::STATUS_SELL && ($parameters['lot_id'] = $model->getInitialLotId());
         if ($rebalancerQueue = $this->rebalancerQueueRepo->findOneBy($parameters)) {
             $percent = abs(($model->getAmount() - $rebalancerQueue->getAmount()) / $model->getAmount() * 100);
             return $percent > 10;
         }
     }
     return false;
 }
 /**
  * Insert lot
  *
  * @param Lot $model
  * @return int|null
  */
 public function insert(Lot $model)
 {
     return $this->fpdo->insertInto($this->table, array('client_system_account_id' => $model->getClientSystemAccountId(), 'security_id' => $model->getSecurityId(), 'initial_lot_id' => $model->getInitialLotId(), 'quantity' => $model->getQuantity(), 'amount' => $model->getAmount(), 'status' => $model->getStatus(), 'cost_basis' => $model->getCostBasis(), 'was_closed' => $model->getWasClosed(), 'realized_gain_loss' => $model->getRealizedGain(), 'date' => $model->getDate(), 'position_id' => $model->getPositionId(), 'is_cost_basis_known' => false, 'is_wash_sale' => false, 'was_rebalancer_diff' => $model->getWasRebalancerDiff()))->execute();
 }