fetch_ohlcv should be useable without endTime for this usecase
See original GitHub issueRecent changes made to fetch_ohlcv on binance.php prevent us from using fetch_ohlcv to grab the oldest OHLCVs for a pair, due to an enforced use of endTime parameter. I used to be able to call fetch_ohlcv with 0 startTime in previous versions to grab the oldest OHLCV from Binance, because endTime was not used.
I propose the following change to this code block in binance.php to allow use of startTime without endTime in fetch_ohlcv requests, if called with $since => null.
if ($since !== null) {
$request['startTime'] = $since;
$endTime = $this->sum($since, $limit * $duration * 1000 - 1);
$now = $this->milliseconds();
$request['endTime'] = min ($now, $endTime);
}
to:
if ($since !== null) {
$request['startTime'] = $since;
$endTime = $this->sum($since, $limit * $duration * 1000 - 1);
$now = $this->milliseconds();
$request['endTime'] = min ($now, $endTime);
} elseif($since === null) {
$request['startTime'] = 0;
}
This way, if you call the function with null, it defaults to 0 startTime and no endTime, which brings the oldest candles for that pair from Binance. Then if you’d want to use startTime with endTime, I can always provide 0 to $since parameter.
Eitherway, if you see a better way to do this, please propose it here. I don’t think endTime should be enforced for this specific usecase.
If approved, I’ll submit a PR.
- OS: Ubuntu 20.04
- Programming Language version: PHP 7.4
- CCXT version: 1.4.61
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
@yazeed thx for your feedback!
Thank you, my bad, it works now. Apologies. Have a great day or evening wherever you are!