historical bars fill fix

This commit is contained in:
tim
2024-10-26 19:58:54 -04:00
parent ffdb60afa2
commit cf7eb637bc
3 changed files with 13 additions and 10 deletions

View File

@@ -121,10 +121,10 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
function fill(end, period) {
if (latest===null) return
const [start, price] = latest
const periodSecs = period * 60
end = ohlcStart(end, periodSecs)
for (let now=ohlcStart(start+periodSecs, periodSecs); now < end; now += periodSecs ) {
const [latestTime, price] = latest
end = ohlcStart(end, period)
const start = ohlcStart(latestTime+period, period);
for (let now= start; now < end; now += period ) {
bars.push({time:now * 1000, open:price, high:price, low:price, close:price})
latest = [now, price]
}