diagonals working except for start/end times
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
<td rowspan="2" class="weight">{{ allocationTexts[weights.length-1] }}</td>
|
||||
<td rowspan="2" class="weight" style="vertical-align: bottom">{{ allocationTexts[weights.length-1] }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@@ -36,7 +36,7 @@
|
||||
</tr>
|
||||
<tr v-for="i in innerIndexes" class="ml-5">
|
||||
<td class="text-right"> </td>
|
||||
<td colspan="2" class="text-center"><i>Diagonal</i></td>
|
||||
<td colspan="2" class="text-center">— Interior Line —</td>
|
||||
<td class="weight">{{ allocationTexts[i] }}</td>
|
||||
</tr>
|
||||
<tr v-if="weights.length>1">
|
||||
@@ -52,7 +52,7 @@
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
<td rowspan="2" class="weight">{{ allocationTexts[0] }}</td>
|
||||
<td rowspan="2" class="weight" style="vertical-align: top">{{ allocationTexts[0] }}</td>
|
||||
</tr>
|
||||
<tr v-if="weights.length>1">
|
||||
<td>
|
||||
@@ -109,18 +109,17 @@ builderDefaults(props.builder, {
|
||||
|
||||
|
||||
function buildTranches() {
|
||||
throw Error('unimplemented') // todo
|
||||
const order = props.order
|
||||
const builder = props.builder
|
||||
const tranches = []
|
||||
|
||||
console.log('buildTranches', builder, order, tranches)
|
||||
const la = buildLine(_endpoints[0])
|
||||
const lb = buildLine(_endpoints[1])
|
||||
console.log('buildTranches', builder, order, _endpoints.value)
|
||||
const la = _endpoints.value[0] // use the flatline format which is a vector of length 4, useful for vectorInterpolate()
|
||||
const lb = _endpoints.value[1]
|
||||
const ws = weights.value
|
||||
for (let i = 0; i < ws.length; i++) {
|
||||
const w = ws[i]
|
||||
const line = vectorInterpolate(la, lb, i/(ws.length-1))
|
||||
const line = ws.length === 1 ? la : vectorInterpolate(la, lb, i/(ws.length-1))
|
||||
const t = newTranche({fraction: w * MAX_FRACTION})
|
||||
const symbol = co.selectedSymbol
|
||||
console.log('symbol', symbol)
|
||||
@@ -137,7 +136,7 @@ function flattenLine(l) {
|
||||
|
||||
|
||||
function buildLine(f) {
|
||||
console.log('buildLine', f)
|
||||
// console.log('buildLine', f)
|
||||
return f === null ? null : [{time: f[0], price: f[1]}, {time: f[2], price: f[3]}]
|
||||
}
|
||||
|
||||
@@ -243,17 +242,13 @@ const price2B = computed({
|
||||
})
|
||||
|
||||
function update(a, b) { // a and b are lines of two points
|
||||
console.log('update', a, b)
|
||||
if (!vectorEquals(props.builder.lineA, a) || !vectorEquals(props.builder.lineB, b)) {
|
||||
console.log('update was dirty')
|
||||
_endpoints.value = [flattenLine(a), flattenLine(b)]
|
||||
const newBuilder = {...props.builder}
|
||||
newBuilder.lineA = a
|
||||
newBuilder.lineB = b
|
||||
emit('update:builder', newBuilder)
|
||||
}
|
||||
else
|
||||
console.log('update was not dirty')
|
||||
}
|
||||
|
||||
|
||||
@@ -290,14 +285,14 @@ function getModelValue(model) {
|
||||
if (!model.pointA || !model.pointB)
|
||||
return null
|
||||
const result = flattenLine([model.pointA, model.pointB]);
|
||||
console.log('getModelValue', {...model}, result)
|
||||
// console.log('getModelValue', {...model}, result)
|
||||
return result // this is the vector the RungBuilder will interpolate
|
||||
}
|
||||
|
||||
|
||||
function setModelValue(model, value) {
|
||||
const oldModel = {...model};
|
||||
console.log('setModelValue', oldModel, value)
|
||||
// console.log('setModelValue', oldModel, value)
|
||||
const oldLine = !model.pointA || !model.pointB ? null : [model.pointA, model.pointB]
|
||||
const line = buildLine(value)
|
||||
if (dirtyLine(oldLine, line)) {
|
||||
@@ -310,7 +305,7 @@ function setModelValue(model, value) {
|
||||
model.pointB = line[1]
|
||||
}
|
||||
}
|
||||
console.log('setModelValue end', oldModel, value, model)
|
||||
// console.log('setModelValue end', oldModel, value, model)
|
||||
}
|
||||
|
||||
|
||||
@@ -318,7 +313,7 @@ function dirtyLine(a, b) {
|
||||
const result = a === b ? false :
|
||||
a === null && b !== null || a !== null && b === null ||
|
||||
a[0].time !== b[0].time || a[0].price !== b[0].price || a[1].time !== b[1].time || a[1].price !== b[1].price
|
||||
console.log('dirtyLine', result, a, b)
|
||||
// console.log('dirtyLine', result, a, b)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ watchEffect(()=>{
|
||||
|
||||
|
||||
function setEndpoints(a, b) {
|
||||
console.log('rb setting endpoints', devectorize(a), devectorize(b))
|
||||
// console.log('rb setting endpoints', devectorize(a), devectorize(b))
|
||||
endpoints.value = [devectorize(a), devectorize(b)]
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ const rungs = computed({
|
||||
r = Number(r)
|
||||
const prevR = Number(props.builder.rungs)
|
||||
props.builder.rungs = r
|
||||
console.log('set rungs', prevR, r, a, b)
|
||||
// console.log('set rungs', prevR, r, a, b)
|
||||
if ( r > 0 && vectorIsNull(b) ) {
|
||||
// convert single shape to a range
|
||||
if (props.mode===0) {
|
||||
const width = vectorize(props.stdWidth)
|
||||
const mid = vectorize(a)
|
||||
console.log('stdWidth', width)
|
||||
// console.log('stdWidth', width)
|
||||
const halfWidth = vectorDiv(width,2);
|
||||
a = vectorAdd(mid, vectorNeg(halfWidth) )
|
||||
b = vectorAdd(mid, halfWidth)
|
||||
@@ -149,7 +149,6 @@ const values = computed(()=>{
|
||||
let [a, b] = endpoints.value
|
||||
a = vectorize(a)
|
||||
b = vectorize(b)
|
||||
console.log('computing values', a, b)
|
||||
const r = props.builder.rungs
|
||||
let result
|
||||
if ( !r || vectorIsNull(a) )
|
||||
@@ -170,14 +169,20 @@ const values = computed(()=>{
|
||||
}
|
||||
}
|
||||
props.setValues(result)
|
||||
console.log('values', result)
|
||||
// console.log('values', result)
|
||||
return result;
|
||||
})
|
||||
|
||||
|
||||
const weights = computed(() => {
|
||||
// const skew = props.flip ? -props.builder.skew : props.builder.skew
|
||||
const ws = linearWeights(props.builder.rungs, -props.builder.skew)
|
||||
const most = 0.998
|
||||
let skew = -props.builder.skew
|
||||
if (skew <= -1)
|
||||
skew = -most
|
||||
else if (skew >= 1)
|
||||
skew = most
|
||||
const ws = linearWeights(props.builder.rungs, skew)
|
||||
if (props.setWeights)
|
||||
props.setWeights(ws)
|
||||
return ws
|
||||
@@ -239,7 +244,7 @@ function translateOnModel(shape) {
|
||||
const prev = getModelValue(oldModel)
|
||||
const cur = vectorize(getModelValue(this.model))
|
||||
const delta = vectorSub(cur, prev)
|
||||
console.log('delta', shape.id, prev, cur, delta)
|
||||
// console.log('delta', shape.id, prev, cur, delta)
|
||||
let [a, b] = endpoints.value
|
||||
a = vectorize(a)
|
||||
if (!vectorIsZero(delta)) {
|
||||
@@ -252,7 +257,6 @@ function translateOnModel(shape) {
|
||||
}
|
||||
|
||||
function setModelColor(model) {
|
||||
console.log('setmc', color.value, model.color)
|
||||
if (model.color !== undefined && model.color !== color.value)
|
||||
color.value = model.color
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user