diff --git a/php-binance-api.php b/php-binance-api.php index fcb845db..8ef3b562 100755 --- a/php-binance-api.php +++ b/php-binance-api.php @@ -1498,17 +1498,29 @@ private function depthData(string $symbol, array $json) } /** - * roundStep rounds number with given step - * @param $value price + * roundStep rounds quantity with stepSize + * @param $qty quantity * @param $stepSize parameter from exchangeInfo * @return rounded value. example: roundStep(1.2345, 0.1) = 1.2 * */ - public function roundStep($value, $stepSize = 0.1) { + public function roundStep($qty, $stepSize = 0.1) { $precision = strlen(substr(strrchr(rtrim($stepSize,'0'), '.'), 1)); - return round((($value / $stepSize) | 0) * $stepSize, $precision); + return round((($qty / $stepSize) | 0) * $stepSize, $precision); } - + + /** + * roundTicks rounds price with tickSize + * @param $value price + * @param $tickSize parameter from exchangeInfo + * @return rounded value. example: roundStep(1.2345, 0.1) = 1.2 + * + */ + public function roundTicks($price, $tickSize) { + $precision = strlen(rtrim(substr($tickSize,strpos($tickSize, '.', 1) + 1), '0')); + return number_format($price, $precision, '.', ''); + } + /** * getTransfered gets the total transfered in b,Kb,Mb,Gb *