orderbuild fixes; tranche table work; ordershapes still broken
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user