Fix operation of inverted for history
This commit is contained in:
@@ -14,7 +14,7 @@ export function tvResolutionToPeriodString(res) {
|
||||
}
|
||||
|
||||
export async function jBars (symbol, contract, from, to, res) {
|
||||
console.log('[jBars]: Method call', res, from, to);
|
||||
console.log('[jBars]: Method call', res, from, to, symbol, contract);
|
||||
|
||||
const toDate = new Date(to*1000);
|
||||
const fromDate = new Date(from*1000);
|
||||
@@ -56,6 +56,7 @@ export async function jBars (symbol, contract, from, to, res) {
|
||||
const is_monthly_res = !is_single_res && !is_daily_res;
|
||||
|
||||
let bars = [];
|
||||
let inverted;
|
||||
|
||||
for ( // Once around for each sample in from-to range
|
||||
let iDate = fromDate,
|
||||
@@ -91,7 +92,7 @@ export async function jBars (symbol, contract, from, to, res) {
|
||||
// return [bars, {noData:true}]
|
||||
// }
|
||||
// console.log('metadata', contract, metadataMap, meta)
|
||||
let inverted = symbol.inverted
|
||||
inverted = symbol.inverted
|
||||
if (symbol.x?.data) {
|
||||
baseURL = symbol.x.data.uri
|
||||
chainId = symbol.x.data.chain
|
||||
@@ -172,7 +173,16 @@ export async function jBars (symbol, contract, from, to, res) {
|
||||
iohlc++;
|
||||
}
|
||||
|
||||
if (bar !== undefined) bars.push(bar);
|
||||
if (bar !== undefined) {
|
||||
if (inverted) {
|
||||
bar.open = 1/bar.open
|
||||
let high = bar.high
|
||||
bar.high = 1/bar.low
|
||||
bar.low = 1/high
|
||||
bar.close = 1/bar.close
|
||||
}
|
||||
bars.push(bar);
|
||||
}
|
||||
|
||||
// Increment loop variable
|
||||
|
||||
|
||||
Reference in New Issue
Block a user