diff --git a/src/blockchain/orderlib.js b/src/blockchain/orderlib.js index 3126467..fdc9ed1 100644 --- a/src/blockchain/orderlib.js +++ b/src/blockchain/orderlib.js @@ -82,8 +82,14 @@ export function newTranche({ } = {}) { if( minIntercept === 0 && minSlope === 0 && maxIntercept === 0 && maxSlope === 0 ) marketOrder = true - if( marketOrder ) + if( marketOrder ) { + if (minIntercept !== 0 || minSlope !== 0 || maxIntercept !== 0 || maxSlope !== 0) + console.warn('Ignoring line information in a market order') minIntercept = encodeIEE754(slippage) // this is the slippage field for market orders + minSlope = 0 + maxIntercept = 0 + maxSlope = 0 + } else { minIntercept = encodeIEE754(minIntercept) minSlope = encodeIEE754(minSlope) diff --git a/src/charts/chart.js b/src/charts/chart.js index 04592a7..c056d7d 100644 --- a/src/charts/chart.js +++ b/src/charts/chart.js @@ -387,7 +387,7 @@ function chartMeanRange() { for (let barIndex = bars.size() - 1; barIndex >= final; barIndex--) { count++ const [_time, _open, high, low, _close, _volume, _ms] = bars.valueAt(barIndex) - range += (high - low) + range += Math.abs(high - low) } if (count > 0) range /= count diff --git a/src/components/Status.vue b/src/components/Status.vue index 0ea5d44..7f9ae4d 100644 --- a/src/components/Status.vue +++ b/src/components/Status.vue @@ -201,8 +201,6 @@ const orders = computed(()=>{ // [730643660, 0], [min intercept, slope] // [0, 0], [max intercept, slope] // ], - // [...], - // [...], // ] // ], // 4, state @@ -210,8 +208,7 @@ const orders = computed(()=>{ // null, oco group // "0", filled in // "0", filled out - // ["0", "0", "0"], tranche filled in - // ["0", "0", "0"] tranche filled out + // [...], trancheStatus // ] const result = [] diff --git a/src/orderbuild.js b/src/orderbuild.js index 534373e..b62b2cf 100644 --- a/src/orderbuild.js +++ b/src/orderbuild.js @@ -178,11 +178,11 @@ export function applyLine(tranche, isMinimum, intercept, slope) { m = encodeIEE754(m) b = encodeIEE754(b) if (isMinimum) { - tranche.minIntercept = b; - tranche.minSlope = m; + tranche.minLine.intercept = b; + tranche.minLine.slope = m; } else { - tranche.maxIntercept = b; - tranche.maxSlope = m; + tranche.maxLine.intercept = b; + tranche.maxLine.slope = m; } tranche.marketOrder = false; } diff --git a/src/socket.js b/src/socket.js index 8379d87..dd73dc3 100644 --- a/src/socket.js +++ b/src/socket.js @@ -97,8 +97,8 @@ socket.on( 'of', (chainId, vault, orderIndex, filled)=>{ status.filledOut = BigInt(filled[0][1]) for( const i in filled[1] ) { const [filledIn, filledOut] = filled[1][i] - status.trancheFilledIn[i] = BigInt(filledIn) - status.trancheFilledOut[i] = BigInt(filledOut) + status.trancheStatus[i].filledIn = BigInt(filledIn) + status.trancheStatus[i].filledOut = BigInt(filledOut) } // s.orders[vault][orderIndex] = status console.log('applied fills', status)