Skip to content

Commit 9752109

Browse files
author
Jon Eyrick
authored
add roundStep functionality, to help with stepSize
```php function roundStep($value, $stepSize = 0.1) { $precision = strlen(substr(strrchr(rtrim($value,'0'), '.'), 1)); return round((($value / $stepSize) | 0) * $stepSize, $precision); } ```
1 parent b64e1cd commit 9752109

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

php-binance-api.php

+12
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,18 @@ private function depthData(string $symbol, array $json)
14961496
"asks" => $asks,
14971497
];
14981498
}
1499+
1500+
/**
1501+
* roundStep rounds number with given step
1502+
* @param $value price
1503+
* @param $stepSize parameter from exchangeInfo
1504+
* @return rounded value. example: roundStep(1.2345, 0.1) = 1.2
1505+
*
1506+
*/
1507+
public function roundStep($value, $stepSize = 0.1) {
1508+
$precision = strlen(substr(strrchr(rtrim($value,'0'), '.'), 1));
1509+
return round((($value / $stepSize) | 0) * $stepSize, $precision);
1510+
}
14991511

15001512
/**
15011513
* getTransfered gets the total transfered in b,Kb,Mb,Gb

0 commit comments

Comments
 (0)