ordershapes
This commit is contained in:
@@ -139,21 +139,22 @@ export function linePointsValue(time0, price0, time1, price1, unixTime = null) {
|
||||
|
||||
|
||||
export function applyLinePoint(tranche, symbol, buy, price0) {
|
||||
price0 *= 10 ** symbol.decimals
|
||||
console.log('applyLinePoint', buy?'BUY':'SELL', symbol, price0)
|
||||
if (symbol.inverted)
|
||||
price0 = 1/price0
|
||||
price0 *= 10 ** -symbol.decimals
|
||||
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 scale = 10 ** -symbol.decimals
|
||||
price0 *= scale
|
||||
price1 *= scale
|
||||
const [intercept, slope] = computeInterceptSlope(time0, price0, time1, price1);
|
||||
applyLine(tranche, symbol, buy, intercept, slope)
|
||||
}
|
||||
@@ -162,10 +163,10 @@ export function applyLinePoints(tranche, symbol, buy, time0, price0, time1, pric
|
||||
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))
|
||||
const isMinimum = !buy;
|
||||
console.log('applyLine current line value', isMinimum?'min':'max', m*timestamp()+b, 1./(m*timestamp()+b))
|
||||
m = encodeIEE754(m)
|
||||
b = encodeIEE754(b)
|
||||
const isMinimum = symbol.inverted===buy;
|
||||
if (isMinimum) {
|
||||
tranche.minLine.intercept = b;
|
||||
tranche.minLine.slope = m;
|
||||
@@ -250,13 +251,15 @@ export function weightColors(weights, color) {
|
||||
}
|
||||
|
||||
export function allocationText(weight, amount, symbol) {
|
||||
amount = Number(amount)
|
||||
weight = Number(weight)
|
||||
let text = ''
|
||||
const hasAmount = amount!==null && amount!==undefined && amount > 0
|
||||
if (hasAmount)
|
||||
amount = Number(amount)
|
||||
const hasWeight = weight!==null && weight!==undefined
|
||||
if (hasWeight)
|
||||
weight = Number(weight)
|
||||
let text = ''
|
||||
if (hasWeight)
|
||||
text += `${(weight * 100).toFixed(1)}%`
|
||||
const hasAmount = amount!==null && amount!==undefined && amount > 0
|
||||
const hasSymbol = symbol!==null && symbol!==undefined
|
||||
if (hasAmount && hasSymbol) {
|
||||
if (hasWeight)
|
||||
|
||||
Reference in New Issue
Block a user