More debugging for flat bars

This commit is contained in:
7400
2024-03-19 20:49:22 -07:00
parent 56901584b1
commit a5eccc84a0

View File

@@ -218,15 +218,22 @@ function checkBar(bar, msg) {
let h_c = bar.high - bar.close
let h_l = bar.high - bar.low
if (o_l<0||c_l||h_o<0||h_c<0||h_l<0) {
if (o_l<0||c_l<0||h_o<0||h_c<0||h_l<0) {
console.log(msg, "bar.high/low inconsistent:", bar)
if (o_l<0) console.log("bar inconsistent: open-low: ", o_l)
if (c_l<0) console.log("bar inconsistent: close-low: ", c_l)
if (h_o<0) console.log("bar inconsistent: high-open: ", h_o)
if (h_c<0) console.log("bar inconsistent: high-close:", h_c)
if (h_l<0) console.log("bar inconsistent: high-low: ", h_l)
} else {
console.log(msg, "bar diffs:", bar)
console.log("bar diff: open-low: ", o_l)
console.log("bar diff: close-low: ", c_l)
console.log("bar diff: high-open: ", h_o)
console.log("bar diff: high-close:", h_c)
console.log("bar diff: high-low: ", h_l)
}
if (o_l<0) console.log("bar inconsistent: open-low: ", o_l)
if (c_l<0) console.log("bar inconsistent: close-low: ", c_l)
if (h_o<0) console.log("bar inconsistent: high-open: ", h_o)
if (h_c<0) console.log("bar inconsistent: high-close:", h_c)
if (h_l<0) console.log("bar inconsistent: high-low: ", h_l)
}
export const DataFeed = {
@@ -352,6 +359,8 @@ export const DataFeed = {
poolCallback(chainId, pool, ohlcs) {
console.log("poolCallback: chainId, pool:", chainId, pool)
let ohlc = ohlcs.at(-1);
console.log("poolCallBack ohlc:", ohlc)
for (let i = 0; i<ohlc.length; i++) if (ohlc[i]!=null) ohlc[i] = Number(ohlc[i])
// for (const ohlc of ohlcs) {
let date = new Date(ohlc[0]*1000)
let close = ohlc[4] // close
@@ -370,10 +379,10 @@ export const DataFeed = {
if ( DataFeed.poolCallbackState.lastBar===null) {
DataFeed.poolCallbackState.lastBar = bar
}
// bar is less than last bar then ignore
// bar time is less than last bar then ignore
else if (bar.time<DataFeed.poolCallbackState.lastBar.time ) {
}
// bar equal to last bar then replace last bar
// bar time equal to last bar then replace last bar
else if (bar.time==DataFeed.poolCallbackState.lastBar.time ) {
DataFeed.poolCallbackState.lastBar = bar
}