orderbuild fixes; tranche table work; ordershapes still broken

This commit is contained in:
tim
2024-09-20 04:12:23 -04:00
parent ce54b943ea
commit e5d5c9c0d8
10 changed files with 111 additions and 48 deletions

View File

@@ -140,39 +140,40 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
export function applyLinePoint(tranche, symbol, buy, price0) {
console.log('applyLinePoint', buy?'BUY':'SELL', symbol, price0)
if (symbol.inverted)
price0 = 1/price0
price0 *= 10 ** -symbol.decimals
const inverted = buy === symbol.inverted
if (inverted)
price0 = 1/price0
applyLine(tranche, symbol, buy, price0, 0)
}
export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, price1) {
if (symbol.inverted) {
price0 = 1/price0
price1 = 1/price1
}
const scale = 10 ** -symbol.decimals
price0 *= scale
price1 *= scale
const inverted = buy === symbol.inverted
if (inverted) {
price0 = 1/price0
price1 = 1/price1
}
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
applyLine(tranche, symbol, buy, intercept, slope)
}
function applyLine(tranche, symbol, buy, intercept, slope) {
function applyLine(tranche, symbol, buy, intercept, slope, isMaximum=false) {
let m = slope
let b = intercept
const isMinimum = !buy;
console.log('applyLine current line value', isMinimum?'min':'max', m*timestamp()+b, 1./(m*timestamp()+b))
console.log('applyLine current line value', isMaximum?'min':'max', m*timestamp()+b, 1./(m*timestamp()+b))
m = encodeIEE754(m)
b = encodeIEE754(b)
if (isMinimum) {
tranche.minLine.intercept = b;
tranche.minLine.slope = m;
} else {
if (isMaximum) {
tranche.maxLine.intercept = b;
tranche.maxLine.slope = m;
} else {
tranche.minLine.intercept = b;
tranche.minLine.slope = m;
}
tranche.marketOrder = false;
}