line inversion fixes
This commit is contained in:
@@ -117,13 +117,23 @@ function buildTranches() {
|
||||
const la = _endpoints.value[0] // use the flatline format which is a vector of length 4, useful for vectorInterpolate()
|
||||
const lb = _endpoints.value[1]
|
||||
const ws = weights.value
|
||||
const symbol = co.selectedSymbol
|
||||
const inverted = symbol.inverted
|
||||
const scale = 10 ** -symbol.decimals
|
||||
const isMinimum = inverted === order.buy
|
||||
for (let i = 0; i < ws.length; i++) {
|
||||
const w = ws[i]
|
||||
const line = ws.length === 1 ? la : vectorInterpolate(la, lb, i/(ws.length-1))
|
||||
if (inverted) {
|
||||
// invert prices
|
||||
line[1] = 1/line[1]
|
||||
line[3] = 1/line[3]
|
||||
}
|
||||
// scale to pool decimals
|
||||
line[1] *= scale
|
||||
line[3] *= scale
|
||||
const t = newTranche({fraction: w * MAX_FRACTION})
|
||||
const symbol = co.selectedSymbol
|
||||
console.log('symbol', symbol)
|
||||
applyLinePoints(t, order.buy, ...line, symbol.decimals, symbol.inverted)
|
||||
applyLinePoints(t, isMinimum, ...line)
|
||||
tranches.push(t)
|
||||
}
|
||||
return tranches
|
||||
|
||||
@@ -81,16 +81,23 @@ function buildTranches() {
|
||||
console.log('buildTranches', builder, order, tranches)
|
||||
const ps = prices.value
|
||||
const ws = weights.value
|
||||
const symbol = co.selectedSymbol
|
||||
const scale = 10 ** -symbol.decimals
|
||||
const inverted = symbol.inverted
|
||||
const isMinimum = inverted === order.buy
|
||||
for(let i=0; i<ps.length; i++) {
|
||||
const p = ps[i]
|
||||
let p = ps[i]
|
||||
if (inverted)
|
||||
p = 1/p
|
||||
p *= scale
|
||||
const w = ws[i]
|
||||
const t = newTranche({
|
||||
// todo start/end
|
||||
fraction: w * MAX_FRACTION,
|
||||
})
|
||||
const symbol = co.selectedSymbol
|
||||
console.log('symbol', symbol)
|
||||
applyLine(t, order.buy, p, 0, symbol.decimals, symbol.inverted)
|
||||
console.log('symbol', symbol, isMinimum, p)
|
||||
applyLine(t, isMinimum, p, 0)
|
||||
tranches.push(t)
|
||||
}
|
||||
return tranches
|
||||
|
||||
Reference in New Issue
Block a user