SwapOrder.inverted
This commit is contained in:
@@ -138,36 +138,27 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
|
||||
}
|
||||
|
||||
|
||||
export function applyLinePoint(tranche, symbol, buy, price0) {
|
||||
const orig = price0
|
||||
price0 *= 10 ** -symbol.decimals
|
||||
if (buy)
|
||||
price0 = 1/price0
|
||||
console.log('applyLinePoint', buy?'BUY':'SELL', symbol, orig, price0)
|
||||
applyLine(tranche, symbol, buy, price0, 0)
|
||||
export function applyLinePoint(tranche, symbol, buy, price0, breakout=false) {
|
||||
applyLine(tranche, symbol, buy, price0, 0, breakout)
|
||||
}
|
||||
|
||||
|
||||
export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, price1) {
|
||||
const scale = 10 ** -symbol.decimals
|
||||
price0 *= scale
|
||||
price1 *= scale
|
||||
if (buy) {
|
||||
price0 = 1/price0
|
||||
price1 = 1/price1
|
||||
}
|
||||
export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, price1, breakout=false) {
|
||||
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
|
||||
applyLine(tranche, symbol, buy, intercept, slope)
|
||||
applyLine(tranche, symbol, buy, intercept, slope, breakout)
|
||||
}
|
||||
|
||||
|
||||
function applyLine(tranche, symbol, buy, intercept, slope, isMaximum=false) {
|
||||
let m = slope
|
||||
let b = intercept
|
||||
console.log('applyLine current line value', isMaximum?'max':'min', m*timestamp()+b, 1./(m*timestamp()+b))
|
||||
function applyLine(tranche, symbol, buy, intercept, slope=0, breakout=false) {
|
||||
const scale = 10 ** -symbol.decimals
|
||||
let m = slope * scale
|
||||
let b = intercept * scale
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
if (isMaximum) {
|
||||
const isMax = (buy !== symbol.inverted) !== breakout // buy XOR inverted XOR breakout
|
||||
console.log('apply line point isMax?', buy?'buy':'sell', symbol.inverted, breakout, isMax)
|
||||
console.log('applyLine current line value', isMax?'max':'min', m*timestamp()+b, 1./(m*timestamp()+b))
|
||||
if (isMax) {
|
||||
tranche.maxLine.intercept = b;
|
||||
tranche.maxLine.slope = m;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user