applyLine() refactor/fix
This commit is contained in:
@@ -5,7 +5,6 @@ import {encodeIEE754} from "@/common.js";
|
||||
import {defineStore} from "pinia";
|
||||
import {computed, ref} from "vue";
|
||||
import Color from "color";
|
||||
import {chartMeanRange} from "@/charts/chart.js";
|
||||
|
||||
|
||||
export const MIN_EXECUTION_TIME = 60 // give at least one full minute for each tranche to trigger
|
||||
@@ -147,16 +146,16 @@ export function applyLinePoints(tranche, buy, time0, price0, time1, price1, pool
|
||||
|
||||
|
||||
export function applyLine(tranche, buy, intercept, slope, poolDecimals, inverted) {
|
||||
console.log('intercept, slope', intercept, slope)
|
||||
// intercept and slope are still in "human" units of decimal-adjusted prices
|
||||
const scale = 10 ** -poolDecimals
|
||||
let m = slope === 0 ? 0 : inverted ? -scale / slope : scale * slope
|
||||
let b = inverted ? scale / intercept : scale * intercept
|
||||
const cur = b + timestamp() * m
|
||||
console.log('inverted b, m, cur', inverted, b, m, cur)
|
||||
// const cur = b + timestamp() * m
|
||||
// console.log('inverted b, m, cur', inverted, b, m, cur)
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
let isMinimum = !(buy ^ inverted)
|
||||
const isMinimum = !(buy ^ inverted)
|
||||
console.log('applyLine', buy, intercept, slope, poolDecimals, inverted, isMinimum)
|
||||
if (isMinimum) {
|
||||
tranche.minIntercept = b;
|
||||
tranche.minSlope = m;
|
||||
|
||||
Reference in New Issue
Block a user