Fix operation of inverted for history

This commit is contained in:
7400
2024-03-18 11:06:48 -07:00
parent e364942c78
commit dabcbd2b4c

View File

@@ -14,7 +14,7 @@ export function tvResolutionToPeriodString(res) {
} }
export async function jBars (symbol, contract, from, to, 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 toDate = new Date(to*1000);
const fromDate = new Date(from*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; const is_monthly_res = !is_single_res && !is_daily_res;
let bars = []; let bars = [];
let inverted;
for ( // Once around for each sample in from-to range for ( // Once around for each sample in from-to range
let iDate = fromDate, let iDate = fromDate,
@@ -91,7 +92,7 @@ export async function jBars (symbol, contract, from, to, res) {
// return [bars, {noData:true}] // return [bars, {noData:true}]
// } // }
// console.log('metadata', contract, metadataMap, meta) // console.log('metadata', contract, metadataMap, meta)
let inverted = symbol.inverted inverted = symbol.inverted
if (symbol.x?.data) { if (symbol.x?.data) {
baseURL = symbol.x.data.uri baseURL = symbol.x.data.uri
chainId = symbol.x.data.chain chainId = symbol.x.data.chain
@@ -172,7 +173,16 @@ export async function jBars (symbol, contract, from, to, res) {
iohlc++; 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 // Increment loop variable