/** * @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; }
/** * Set position for lots * * @param Lot $model * @return bool */ public function updatePositionBy(Lot $model) { return $this->fpdo->update($this->table)->set('position_id', $model->getPositionId())->where('security_id', $model->getSecurityId())->where('date = DATE(?)', $model->getDate())->where('client_system_account_id', $model->getClientSystemAccountId())->execute(); }