line building fixes
This commit is contained in:
@@ -138,45 +138,31 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
|
||||
}
|
||||
|
||||
|
||||
export function applyLinePoint(tranche, symbol, buy, price0) {
|
||||
price0 *= 10 ** symbol.decimals
|
||||
if (symbol.inverted)
|
||||
price0 = 1/price0
|
||||
applyLine(tranche, symbol, buy, price0, 0)
|
||||
}
|
||||
|
||||
|
||||
export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, price1) {
|
||||
const scale = 10 ** symbol.decimals
|
||||
price0 *= scale
|
||||
price1 *= scale
|
||||
if (symbol.inverted) {
|
||||
price0 = 1/price0
|
||||
price1 = 1/price1
|
||||
}
|
||||
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
|
||||
applyLine(tranche, symbol, buy, intercept, slope)
|
||||
}
|
||||
|
||||
|
||||
export function applyLineOld(tranche, intercept, slope, isMinimum = null) {
|
||||
console.log('intercept, slope', intercept, slope)
|
||||
// intercept and slope are still in "human" units of decimal-adjusted prices
|
||||
const os = useOrderStore()
|
||||
const route = os.route
|
||||
const inverted = routeInverted(route)
|
||||
const scale = 10 ** (os.tokenA.d - os.tokenB.d)
|
||||
let m = inverted ? -scale / slope : slope / scale
|
||||
let b = inverted ? scale / intercept : intercept / scale
|
||||
const cur = b + timestamp() * m
|
||||
console.log('inverted b, m, cur', inverted, b, m, cur)
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
if (isMinimum === null)
|
||||
isMinimum = os.limitIsMinimum
|
||||
console.log('limit is minimum', isMinimum)
|
||||
if (isMinimum) {
|
||||
tranche.minIntercept = b;
|
||||
tranche.minSlope = m;
|
||||
} else {
|
||||
tranche.maxIntercept = b;
|
||||
tranche.maxSlope = m;
|
||||
}
|
||||
tranche.marketOrder = false;
|
||||
}
|
||||
|
||||
|
||||
export function applyLine(tranche, symbol, buy, intercept, slope) {
|
||||
console.log('applyLine', tranche, symbol, buy, intercept, slope)
|
||||
const scale = 10 ** symbol.decimals
|
||||
const inverted = symbol.inverted
|
||||
let m = inverted ? -scale / slope : slope / scale
|
||||
let b = inverted ? scale / intercept : intercept / scale
|
||||
function applyLine(tranche, symbol, buy, intercept, slope) {
|
||||
let m = slope
|
||||
let b = intercept
|
||||
console.log('applyLine current line value', m*timestamp()+b, 1./(m*timestamp()+b))
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
const isMinimum = symbol.inverted===buy;
|
||||
|
||||
Reference in New Issue
Block a user