Skip to content

Commit

Permalink
Fixed futures prices calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Aug 22, 2024
1 parent 87cfa68 commit 0dbd102
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Services/Deals/DealData.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function getBuyPrice(): string
{
// Futures price
if ($this->deal['futureName']) {
if($this->deal['deal']->getBuyPrice() > $this->deal['futureLotSize']) {
return bcmul($this->deal['deal']->getBuyPrice(), $this->deal['futureStepPrice'], 4);
}

return bcmul(bcmul($this->deal['deal']->getBuyPrice(), $this->deal['futureStepPrice'], 4), $this->deal['futureLotSize'], 4);
}

Expand All @@ -97,6 +101,9 @@ public function getSellPrice(): string
{
// Futures price
if ($this->deal['futureName']) {
if($this->deal['deal']->getSellPrice() > $this->deal['futureLotSize']) {
return bcmul($this->deal['deal']->getSellPrice(), $this->deal['futureLotSize'], 4);
}
return bcmul(bcmul($this->deal['deal']->getSellPrice(), $this->deal['futureStepPrice'], 4), $this->deal['futureLotSize'], 4);
}

Expand All @@ -116,6 +123,9 @@ public function getFullSellPrice(): string
public function getCurrentPrice(): string
{
if ($this->deal['futurePrice']) {
if ($this->deal['futurePrice'] > $this->deal['futureLotSize']) {
return bcmul($this->deal['futurePrice'], $this->deal['futureStepPrice'], 4);
}
return bcmul(bcmul($this->deal['futurePrice'], $this->deal['futureStepPrice'], 4), $this->deal['futureLotSize'], 4);
}

Expand All @@ -129,6 +139,10 @@ public function getCurrentPrice(): string
public function getPrevPrice(): string
{
if ($this->deal['futurePrevPrice']) {
if ($this->deal['futurePrevPrice'] > $this->deal['futureLotSize']) {
return bcmul($this->deal['futurePrevPrice'], $this->deal['futureStepPrice'], 4);
}

return bcmul(bcmul($this->deal['futurePrevPrice'], $this->deal['futureStepPrice'], 4), $this->deal['futureLotSize'], 4);
}

Expand Down

0 comments on commit 0dbd102

Please sign in to comment.