bar inconsistent messages
This commit is contained in:
@@ -191,20 +191,7 @@ export function lookupBaseQuote(baseAddr, quoteAddr) {
|
||||
}
|
||||
|
||||
function poolIsInverted(pool) {
|
||||
const chainId = useStore().chainId.value
|
||||
let p
|
||||
for (p of metadata[chainId].p) {
|
||||
if (p.a===pool.substr(0,42)) {
|
||||
let fullname = `${p.q}${p.b}`
|
||||
let symbol = lookupSymbol(fullname)
|
||||
if (symbol in [undefined, null]) {
|
||||
throw Error(`poolIsInverted: pool fullname not found: ${fullname}`)
|
||||
}
|
||||
return symbol.inverted
|
||||
// return p.x.data.inverted ^ symbol.inverted
|
||||
}
|
||||
}
|
||||
throw Error(`poolIsInverted: pool not found in metadata.json: ${pool}`)
|
||||
return useChartOrderStore().selectedSymbol.inverted
|
||||
}
|
||||
|
||||
export function maybeInvertBar (pool, bar) {
|
||||
@@ -214,16 +201,32 @@ export function maybeInvertBar (pool, bar) {
|
||||
bar.high = 1/bar.low
|
||||
bar.low = 1/high
|
||||
bar.close = 1/bar.close
|
||||
console.log("bar inverted")
|
||||
} else {
|
||||
console.log("bar NOT inverted")
|
||||
}
|
||||
return bar
|
||||
}
|
||||
|
||||
function checkBar(bar, msg) {
|
||||
if (bar.high<bar.open||bar.high<bar.low||bar.high<bar.close ||
|
||||
bar.low>bar.open||bar.low>bar.high||bar.low>bar.close) {
|
||||
// throw error("poolCallback: bar.high/low inconsistent.")
|
||||
console.log(msg, "bar.high/low inconsistent:", bar)
|
||||
}
|
||||
|
||||
// Everything should be positive
|
||||
|
||||
let o_l = bar.open - bar.low
|
||||
let c_l = bar.close - bar.low
|
||||
let h_o = bar.high - bar.open
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
export const DataFeed = {
|
||||
@@ -335,15 +338,6 @@ export const DataFeed = {
|
||||
subscriptions[subscriberUID] = [chainId, poolAddr, period]
|
||||
DataFeed.subscribeBarsOnRealtimeCallback = onRealtimeCallback;
|
||||
subOHLC(chainId, poolAddr, period)
|
||||
// return; // disable
|
||||
// subscribeOnStream(
|
||||
// symbolInfo,
|
||||
// resolution,
|
||||
// onRealtimeCallback,
|
||||
// subscriberUID,
|
||||
// onResetCacheNeededCallback,
|
||||
// lastBarsCache.get(symbolInfo.full_name),
|
||||
// );
|
||||
},
|
||||
|
||||
unsubscribeBars: (subscriberUID) => {
|
||||
@@ -351,13 +345,12 @@ export const DataFeed = {
|
||||
const [chainId, poolAddr, period] = subscriptions[subscriberUID]
|
||||
delete subscriptions[subscriberUID]
|
||||
unsubOHLC(chainId, poolAddr, period)
|
||||
// return; // disable
|
||||
// unsubscribeFromStream(subscriberUID);
|
||||
},
|
||||
|
||||
poolCallbackState : {lastBar: null},
|
||||
|
||||
poolCallback(chainId, pool, ohlcs) {
|
||||
console.log("poolCallback: chainId, pool:", chainId, pool)
|
||||
let ohlc = ohlcs.at(-1);
|
||||
// for (const ohlc of ohlcs) {
|
||||
let date = new Date(ohlc[0]*1000)
|
||||
@@ -386,6 +379,7 @@ export const DataFeed = {
|
||||
}
|
||||
// new bar, then render and replace last bar
|
||||
else {
|
||||
console.log('DataFeed.poolCallback, open=', bar.open, "inverted", poolIsInverted(pool), "pool", pool)
|
||||
DataFeed.subscribeBarsOnRealtimeCallback(bar)
|
||||
DataFeed.poolCallbackState.lastBar = bar
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user