Skip to content

Commit

Permalink
fix candle parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
frosty00 committed Mar 14, 2022
1 parent 90c5cd1 commit 2264ab0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/bitopro.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,13 @@ module.exports = class bitopro extends Exchange {
limit = 500;
}
const timeframeInSeconds = this.parseTimeframe (timeframe);
let alignedSince = undefined;
if (since === undefined) {
request['to'] = this.seconds ();
request['from'] = request['to'] - (limit * timeframeInSeconds);
} else {
const timeframeInMilliseconds = timeframeInSeconds * 1000;
alignedSince = Math.floor (since / timeframeInMilliseconds) * timeframeInMilliseconds;
request['from'] = Math.floor (since / 1000);
request['to'] = this.sum (request['from'], limit * timeframeInSeconds);
}
Expand All @@ -690,17 +693,24 @@ module.exports = class bitopro extends Exchange {
// }
//
const sparse = this.parseOHLCVs (data, market, timeframe, since, limit);
const timeframeInMilliseconds = timeframeInSeconds * 1000;
const alignedSince = Math.floor (since / timeframeInMilliseconds) * timeframeInMilliseconds;
return this.insertMissingCandles (sparse, timeframeInSeconds, alignedSince, limit);
}

insertMissingCandles (candles, distance, since, limit) {
// the exchange doesn't send zero volume candles so we emulate them instead
// otherwise sending a limit arg leads to unexpected results
const length = candles.length;
if (length === 0) {
return candles;
}
const result = [];
let copyFrom = candles[0];
let timestamp = since;
let timestamp = undefined;
if (since === undefined) {
timestamp = copyFrom[0];
} else {
timestamp = since;
}
let i = 0;
const candleLength = candles.length;
let resultLength = 0;
Expand Down

0 comments on commit 2264ab0

Please sign in to comment.