price handling fixes affecting orderbuild, pairprice, ordershapes, etc

This commit is contained in:
tim
2024-10-13 18:28:01 -04:00
parent 4b5626094a
commit fe8dd3ef6c
8 changed files with 16 additions and 17 deletions

View File

@@ -139,11 +139,11 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
export function applyLinePoint(tranche, symbol, buy, price0) {
console.log('applyLinePoint', buy?'BUY':'SELL', symbol, price0)
const orig = price0
price0 *= 10 ** -symbol.decimals
const inverted = buy === symbol.inverted
if (inverted)
if (buy)
price0 = 1/price0
console.log('applyLinePoint', buy?'BUY':'SELL', symbol, orig, price0)
applyLine(tranche, symbol, buy, price0, 0)
}
@@ -152,8 +152,7 @@ export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, pric
const scale = 10 ** -symbol.decimals
price0 *= scale
price1 *= scale
const inverted = buy === symbol.inverted
if (inverted) {
if (buy) {
price0 = 1/price0
price1 = 1/price1
}
@@ -165,7 +164,7 @@ export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, pric
function applyLine(tranche, symbol, buy, intercept, slope, isMaximum=false) {
let m = slope
let b = intercept
console.log('applyLine current line value', isMaximum?'min':'max', m*timestamp()+b, 1./(m*timestamp()+b))
console.log('applyLine current line value', isMaximum?'max':'min', m*timestamp()+b, 1./(m*timestamp()+b))
m = encodeIEE754(m)
b = encodeIEE754(b)
if (isMaximum) {