Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
add roundStep functionality, to help with stepSize
Browse files Browse the repository at this point in the history
```php
    function roundStep($value, $stepSize = 0.1) {
        $precision = strlen(substr(strrchr(rtrim($value,'0'), '.'), 1));
        return round((($value / $stepSize) | 0) * $stepSize, $precision);
    }
```
  • Loading branch information
Jon Eyrick authored Sep 7, 2018
1 parent b64e1cd commit 9752109
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions php-binance-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,18 @@ private function depthData(string $symbol, array $json)
"asks" => $asks,
];
}

/**
* roundStep rounds number with given step
* @param $value price
* @param $stepSize parameter from exchangeInfo
* @return rounded value. example: roundStep(1.2345, 0.1) = 1.2
*
*/
public function roundStep($value, $stepSize = 0.1) {
$precision = strlen(substr(strrchr(rtrim($value,'0'), '.'), 1));
return round((($value / $stepSize) | 0) * $stepSize, $precision);
}

/**
* getTransfered gets the total transfered in b,Kb,Mb,Gb
Expand Down

0 comments on commit 9752109

Please sign in to comment.