diff --git a/src/charts/ohlc.js b/src/charts/ohlc.js index beb39d8..9368065 100644 --- a/src/charts/ohlc.js +++ b/src/charts/ohlc.js @@ -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] } diff --git a/src/misc.js b/src/misc.js index 46f206e..363046b 100644 --- a/src/misc.js +++ b/src/misc.js @@ -226,11 +226,14 @@ export function linspace(a, b, n) { export function intervalToSeconds(interval) { if (interval.endsWith('T')) throw Error('Tick intervals not supported') - return interval.endsWith('M') ? 30 * 24 * 60 * 60 - : interval.endsWith('W') ? 7 * 24 * 60 * 60 - : interval.endsWith('D') ? 24 * 60 * 60 - : interval.endsWith('S') ? 1 - : 60 // if no unit char, then it's minutes + const unit = interval.endsWith('M') ? 30 * 24 * 60 * 60 + : interval.endsWith('W') ? 7 * 24 * 60 * 60 + : interval.endsWith('D') ? 24 * 60 * 60 + : interval.endsWith('S') ? 1 + : 60 // if no unit char, then it's minutes + const result = parseInt(/\d+/.exec(interval)[0]) * unit + console.log('intervalToSeconds', interval, result) + return result } diff --git a/theme.js b/theme.js index b001804..d381a82 100644 --- a/theme.js +++ b/theme.js @@ -5,7 +5,7 @@ import Color from "color"; // export const red = '#DD1A10'; // export const green = '#009f49' // export const red = '#BD0D26' -export const green = '#1e9a57' +export const green = '#20A55D' export const red = '#B22235' export const yellow = '#FFDE00' export const orange = '#F58A00'