updated SwapOrderStatus with Andrew's changes

This commit is contained in:
tim
2024-08-26 17:27:58 -04:00
parent e0f42f80e7
commit 55397c2b1c
5 changed files with 15 additions and 12 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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 = []

View File

@@ -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;
}

View File

@@ -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)