bugfixes
This commit is contained in:
@@ -144,7 +144,8 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
let baseUrl
|
||||
let latest = null // latest time, price
|
||||
|
||||
function fill(end, period) {
|
||||
function fill(end) {
|
||||
const period = res.seconds
|
||||
if (latest===null) return
|
||||
const [latestTime, price] = latest
|
||||
end = ohlcStart(end, period)
|
||||
@@ -206,6 +207,8 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
const rows = responses[ri].split('\n')
|
||||
for( let rj=0; rj<rows.length; rj++) {
|
||||
const line = rows[rj];
|
||||
if (line.trim().length === 0)
|
||||
continue
|
||||
const row = line.split(',')
|
||||
let time, open, high, low, close=null
|
||||
switch (row.length) {
|
||||
@@ -262,18 +265,20 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
||||
finished = true
|
||||
break
|
||||
}
|
||||
if (time >= from) {
|
||||
fill(time, res.seconds)
|
||||
if ( time >= from ) {
|
||||
if ( latest !== null && time > latest[0] + res.seconds) {
|
||||
fill(time)
|
||||
}
|
||||
const bar = {time: time * 1000, open, high, low, close};
|
||||
bars.push(bar)
|
||||
latest = [time, close]
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`processed ${lineNum} lines`)
|
||||
// console.log(`processed ${lineNum} lines`)
|
||||
}
|
||||
// console.log('loadOHLC prefill bars', bars)
|
||||
fill(to, res.seconds)
|
||||
fill(to)
|
||||
// console.log('loadOHLC bars', bars)
|
||||
return bars
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user