updated allocationText()
This commit is contained in:
@@ -87,7 +87,7 @@ class TrancheShapes {
|
|||||||
price *= scale
|
price *= scale
|
||||||
// console.log('price', price)
|
// console.log('price', price)
|
||||||
const channel = buy?'low':'high';
|
const channel = buy?'low':'high';
|
||||||
const text = (buy ? 'Buy ' : 'Sell ') + allocationText(weight, amount, amountSymbol, '\n')
|
const text = allocationText(buy, weight, amount, amountSymbol, '\n')
|
||||||
const s = createShape(buy?'arrow_up':'arrow_down', {time, price}, {channel,text,lock:true})
|
const s = createShape(buy?'arrow_up':'arrow_down', {time, price}, {channel,text,lock:true})
|
||||||
// console.log('created fill shape at', time, price)
|
// console.log('created fill shape at', time, price)
|
||||||
this.fills.push(s)
|
this.fills.push(s)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const ShapeType = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function allocationText(weight, amount, symbol, separator = ' ') {
|
export function allocationText(buy, weight, amount, symbol, separator = ' ') {
|
||||||
// set breakout=true for a buy breakout and breakout=false for a sell breakout
|
// set breakout=true for a buy breakout and breakout=false for a sell breakout
|
||||||
const hasAmount = amount !== null && amount !== undefined && amount > 0
|
const hasAmount = amount !== null && amount !== undefined && amount > 0
|
||||||
if (hasAmount)
|
if (hasAmount)
|
||||||
@@ -47,7 +47,9 @@ export function allocationText(weight, amount, symbol, separator = ' ') {
|
|||||||
const hasWeight = weight !== null && weight !== undefined && weight !== 1
|
const hasWeight = weight !== null && weight !== undefined && weight !== 1
|
||||||
if (hasWeight)
|
if (hasWeight)
|
||||||
weight = Number(weight)
|
weight = Number(weight)
|
||||||
let text = ''
|
if (buy===undefined)
|
||||||
|
console.error('allocation text buy', buy)
|
||||||
|
let text = buy === undefined ? '' : buy ? 'Buy ' : 'Sell '
|
||||||
if (hasWeight)
|
if (hasWeight)
|
||||||
text += `${(weight * 100).toFixed(1)}%`
|
text += `${(weight * 100).toFixed(1)}%`
|
||||||
const hasSymbol = symbol !== null && symbol !== undefined
|
const hasSymbol = symbol !== null && symbol !== undefined
|
||||||
@@ -136,6 +138,8 @@ export class Shape {
|
|||||||
this.model.breakout = model.breakout
|
this.model.breakout = model.breakout
|
||||||
if (defined(model.textLocation))
|
if (defined(model.textLocation))
|
||||||
this.model.textLocation = model.textLocation
|
this.model.textLocation = model.textLocation
|
||||||
|
if (defined(model.buy))
|
||||||
|
this.model.buy = model.buy
|
||||||
|
|
||||||
const newProps = {}
|
const newProps = {}
|
||||||
|
|
||||||
@@ -160,7 +164,7 @@ export class Shape {
|
|||||||
newProps.linecolor = color
|
newProps.linecolor = color
|
||||||
|
|
||||||
// text label
|
// text label
|
||||||
let text = allocationText(this.model.allocation, this.model.amount, this.model.amountSymbol)
|
let text = allocationText(this.model.buy, this.model.allocation, this.model.amount, this.model.amountSymbol)
|
||||||
if (this.model.breakout)
|
if (this.model.breakout)
|
||||||
text += ' ' + (this.model.textLocation==='above' ? '▲Breakout▲' : '▼Breakout▼')
|
text += ' ' + (this.model.textLocation==='above' ? '▲Breakout▲' : '▼Breakout▼')
|
||||||
if (this.model.extraText)
|
if (this.model.extraText)
|
||||||
|
|||||||
@@ -75,13 +75,14 @@ builderDefaults(props.builder, {
|
|||||||
rungs: 1,
|
rungs: 1,
|
||||||
skew: 0,
|
skew: 0,
|
||||||
color: defaultColor,
|
color: defaultColor,
|
||||||
|
buy: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const times = ref([])
|
const times = ref([])
|
||||||
const weights = ref([])
|
const weights = ref([])
|
||||||
|
|
||||||
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
||||||
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(w, w*props.order.amount, amountSymbol.value)))
|
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(props.order.buy, w, w*props.order.amount, amountSymbol.value)))
|
||||||
|
|
||||||
const endTimes = computed(()=>{
|
const endTimes = computed(()=>{
|
||||||
if (props.builder.rungs === 1)
|
if (props.builder.rungs === 1)
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ builderDefaults(props.builder, {
|
|||||||
skew: 0,
|
skew: 0,
|
||||||
breakout: false,
|
breakout: false,
|
||||||
color: defaultColor,
|
color: defaultColor,
|
||||||
|
buy: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -348,7 +349,7 @@ function setWeights(ws) {
|
|||||||
|
|
||||||
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
||||||
|
|
||||||
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(w, w*props.order.amount, amountSymbol.value)))
|
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(props.order.buy, w, w*props.order.amount, amountSymbol.value)))
|
||||||
|
|
||||||
const stdWidth = computed(()=>[0, co.meanRange, 0, co.meanRange])
|
const stdWidth = computed(()=>[0, co.meanRange, 0, co.meanRange])
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ builderDefaults(props.builder, {
|
|||||||
skew: 0,
|
skew: 0,
|
||||||
breakout: false,
|
breakout: false,
|
||||||
color: defaultColor,
|
color: defaultColor,
|
||||||
|
buy: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
function buildTranches() {
|
function buildTranches() {
|
||||||
@@ -195,7 +196,7 @@ function setPrices(ps) {prices.value = ps}
|
|||||||
function setWeights(ws) { weights.value = ws }
|
function setWeights(ws) { weights.value = ws }
|
||||||
|
|
||||||
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
|
||||||
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(w, w*props.order.amount, amountSymbol.value)))
|
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(props.order.buy, w, w*props.order.amount, amountSymbol.value)))
|
||||||
const color = computed(()=>props.builder.color ? props.builder.color : defaultColor)
|
const color = computed(()=>props.builder.color ? props.builder.color : defaultColor)
|
||||||
const stdWidth = computed(()=>co.meanRange)
|
const stdWidth = computed(()=>co.meanRange)
|
||||||
const description = computed(()=>{
|
const description = computed(()=>{
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ function makeModel(index) {
|
|||||||
textLocation: above ? 'above' : 'below',
|
textLocation: above ? 'above' : 'below',
|
||||||
breakout: props.builder.breakout,
|
breakout: props.builder.breakout,
|
||||||
extraText: null,
|
extraText: null,
|
||||||
|
buy,
|
||||||
}
|
}
|
||||||
setModelValue(result, values.value[index])
|
setModelValue(result, values.value[index])
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user