historical bars fill fix
This commit is contained in:
@@ -121,10 +121,10 @@ export async function loadOHLC (symbol, contract, from, to, tvRes) {
|
|||||||
|
|
||||||
function fill(end, period) {
|
function fill(end, period) {
|
||||||
if (latest===null) return
|
if (latest===null) return
|
||||||
const [start, price] = latest
|
const [latestTime, price] = latest
|
||||||
const periodSecs = period * 60
|
end = ohlcStart(end, period)
|
||||||
end = ohlcStart(end, periodSecs)
|
const start = ohlcStart(latestTime+period, period);
|
||||||
for (let now=ohlcStart(start+periodSecs, periodSecs); now < end; now += periodSecs ) {
|
for (let now= start; now < end; now += period ) {
|
||||||
bars.push({time:now * 1000, open:price, high:price, low:price, close:price})
|
bars.push({time:now * 1000, open:price, high:price, low:price, close:price})
|
||||||
latest = [now, price]
|
latest = [now, price]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,11 +226,14 @@ export function linspace(a, b, n) {
|
|||||||
export function intervalToSeconds(interval) {
|
export function intervalToSeconds(interval) {
|
||||||
if (interval.endsWith('T'))
|
if (interval.endsWith('T'))
|
||||||
throw Error('Tick intervals not supported')
|
throw Error('Tick intervals not supported')
|
||||||
return interval.endsWith('M') ? 30 * 24 * 60 * 60
|
const unit = interval.endsWith('M') ? 30 * 24 * 60 * 60
|
||||||
: interval.endsWith('W') ? 7 * 24 * 60 * 60
|
: interval.endsWith('W') ? 7 * 24 * 60 * 60
|
||||||
: interval.endsWith('D') ? 24 * 60 * 60
|
: interval.endsWith('D') ? 24 * 60 * 60
|
||||||
: interval.endsWith('S') ? 1
|
: interval.endsWith('S') ? 1
|
||||||
: 60 // if no unit char, then it's minutes
|
: 60 // if no unit char, then it's minutes
|
||||||
|
const result = parseInt(/\d+/.exec(interval)[0]) * unit
|
||||||
|
console.log('intervalToSeconds', interval, result)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
theme.js
2
theme.js
@@ -5,7 +5,7 @@ import Color from "color";
|
|||||||
// export const red = '#DD1A10';
|
// export const red = '#DD1A10';
|
||||||
// export const green = '#009f49'
|
// export const green = '#009f49'
|
||||||
// export const red = '#BD0D26'
|
// export const red = '#BD0D26'
|
||||||
export const green = '#1e9a57'
|
export const green = '#20A55D'
|
||||||
export const red = '#B22235'
|
export const red = '#B22235'
|
||||||
export const yellow = '#FFDE00'
|
export const yellow = '#FFDE00'
|
||||||
export const orange = '#F58A00'
|
export const orange = '#F58A00'
|
||||||
|
|||||||
Reference in New Issue
Block a user