diagonal debug
This commit is contained in:
@@ -4,53 +4,84 @@
|
||||
:get-model-value="getModelValue" :set-model-value="setModelValue"
|
||||
:set-values="setLines" :set-weights="setWeights"
|
||||
:std-width="stdWidth" :build-tranches="buildTranches">
|
||||
<span>{{ endpoints }}</span>
|
||||
<!--
|
||||
<table>
|
||||
<tbody>
|
||||
<template v-if="prices.length>1">
|
||||
<tr>
|
||||
<td rowspan="2" class="label">Line A</td>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="higherPrice" min="0"
|
||||
density="compact" hide-details class="mx-1 my-2" variant="outlined"
|
||||
label="Price"
|
||||
<absolute-time-entry v-model="time1A"/>
|
||||
</td>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="price1A" min="0"
|
||||
density="compact" hide-details variant="outlined"
|
||||
class="mx-1 my-2 price"
|
||||
:color="color" :base-color="color"
|
||||
style="flex: 6em"
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
<td rowspan="2" class="weight">{{ allocationText(weights[weights.length-1]) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<absolute-time-entry v-model="time1B"/>
|
||||
</td>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="price1B" min="0"
|
||||
density="compact" hide-details variant="outlined"
|
||||
class="mx-1 my-2 price"
|
||||
:color="color" :base-color="color"
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
<td class="weight">{{ allocationText(weights[higherIndex]) }}</td>
|
||||
</tr>
|
||||
<tr v-for="i in innerIndexes" class="ml-5">
|
||||
<td class="pl-5">{{ prices[i] }}</td>
|
||||
<td class="text-right"> </td>
|
||||
<td colspan="2" class="text-center"><i>Diagonal</i></td>
|
||||
<td class="weight">{{ allocationText(weights[i]) }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="lowerPrice" min="0"
|
||||
density="compact" hide-details class="mx-1 my-2" variant="outlined"
|
||||
label="Price"
|
||||
:color="color" :base-color="color"
|
||||
style="flex: 6em"
|
||||
/>
|
||||
</td>
|
||||
<td class="weight">{{ weights.length ? allocationText(weights[lowerIndex]) : '' }}</td>
|
||||
</tr>
|
||||
<tr v-if="weights.length>1">
|
||||
<td rowspan="2" class="label">Line B</td>
|
||||
<td>
|
||||
<absolute-time-entry v-model="time2A"/>
|
||||
</td>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="price2A" min="0"
|
||||
density="compact" hide-details variant="outlined"
|
||||
class="mx-1 my-2 price"
|
||||
:color="color" :base-color="color"
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
<td rowspan="2" class="weight">{{ allocationText(weights[weights.length-1]) }}</td>
|
||||
</tr>
|
||||
<tr v-if="weights.length>1">
|
||||
<td>
|
||||
<absolute-time-entry v-model="time2B"/>
|
||||
</td>
|
||||
<td>
|
||||
<v-text-field type="number" v-model="price2B" min="0"
|
||||
density="compact" hide-details variant="outlined"
|
||||
class="mx-1 my-2 price"
|
||||
:color="color" :base-color="color"
|
||||
label="Price"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
-->
|
||||
</rung-builder>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {applyLinePoints, builderDefaults, useChartOrderStore} from "@/orderbuild.js";
|
||||
import {allocationText, applyLinePoints, builderDefaults, useChartOrderStore} from "@/orderbuild.js";
|
||||
import {sideColor} from "@/misc.js";
|
||||
import {useOrderStore, useStore} from "@/store/store.js";
|
||||
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
||||
import RungBuilder from "@/components/chart/RungBuilder.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {DLine} from "@/charts/shape.js";
|
||||
import {vectorInterpolate} from "@/vector.js";
|
||||
import {vectorEquals, vectorInterpolate} from "@/vector.js";
|
||||
import AbsoluteTimeEntry from "@/components/AbsoluteTimeEntry.vue";
|
||||
|
||||
const s = useStore()
|
||||
const os = useOrderStore()
|
||||
@@ -65,6 +96,8 @@ function computeDefaultColor() {
|
||||
|
||||
const defaultColor = computeDefaultColor()
|
||||
|
||||
const color = computed(()=>props.builder.color ? props.builder.color : defaultColor)
|
||||
|
||||
// Fields must be defined in order to be reactive
|
||||
builderDefaults(props.builder, {
|
||||
lineA: null, // [{time, price}, {time, price}]
|
||||
@@ -123,11 +156,101 @@ const endpoints = computed({
|
||||
}
|
||||
})
|
||||
|
||||
const time1A = computed({
|
||||
get() { return _endpoints.value[0] === null ? 0 : _endpoints.value[0][0] },
|
||||
set(v) {
|
||||
const flatline0 = _endpoints.value[0];
|
||||
update(
|
||||
[{time:v, price: flatline0[1]}, {time:flatline0[2], price: flatline0[3]}],
|
||||
_endpoints.value[1]
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const price1A = computed({
|
||||
get() { return _endpoints.value[0] === null ? null : _endpoints.value[0][1] },
|
||||
set(v) {
|
||||
const flatline0 = _endpoints.value[0];
|
||||
update(
|
||||
[{time:flatline0[0], price: v}, {time:flatline0[2], price: flatline0[3]}],
|
||||
_endpoints.value[1]
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const time1B = computed({
|
||||
get() { return _endpoints.value[0] === null ? 0 : _endpoints.value[0][2] },
|
||||
set(v) {
|
||||
const flatline0 = _endpoints.value[0];
|
||||
update(
|
||||
[{time:flatline0[0], price: flatline0[1]}, {time:v, price: flatline0[3]}],
|
||||
_endpoints.value[1]
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const price1B = computed({
|
||||
get() { return _endpoints.value[0] === null ? null : _endpoints.value[0][3] },
|
||||
set(v) {
|
||||
const flatline0 = _endpoints.value[0];
|
||||
update(
|
||||
[{time:flatline0[0], price: flatline0[1]}, {time:flatline0[2], price: v}],
|
||||
_endpoints.value[1]
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const time2A = computed({
|
||||
get() { return _endpoints.value[1] === null ? 0 : _endpoints.value[1][0] },
|
||||
set(v) {
|
||||
const flatline = _endpoints.value[1];
|
||||
update(
|
||||
_endpoints.value[0],
|
||||
[{time:v, price: flatline[1]}, {time:flatline[2], price: flatline[3]}],
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const price2A = computed({
|
||||
get() { return _endpoints.value[1] === null ? null : _endpoints.value[1][1] },
|
||||
set(v) {
|
||||
const flatline = _endpoints.value[1];
|
||||
update(
|
||||
_endpoints.value[0],
|
||||
[{time:flatline[0], price: v}, {time:flatline[2], price: flatline[3]}],
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const time2B = computed({
|
||||
get() { return _endpoints.value[1] === null ? 0 : _endpoints.value[1][2] },
|
||||
set(v) {
|
||||
const flatline = _endpoints.value[1];
|
||||
update(
|
||||
_endpoints.value[0],
|
||||
[{time:flatline[0], price: flatline[1]}, {time:v, price: flatline[3]}],
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const price2B = computed({
|
||||
get() { return _endpoints.value[1] === null ? null : _endpoints.value[1][3] },
|
||||
set(v) {
|
||||
const flatline = _endpoints.value[1];
|
||||
update(
|
||||
_endpoints.value[0],
|
||||
[{time:flatline[0], price: flatline[1]}, {time:flatline[2], price: v}],
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
function update(a, b) { // a and b are lines of two points
|
||||
const newBuilder = {...props.builder}
|
||||
newBuilder.lineA = a
|
||||
newBuilder.lineB = b
|
||||
emit('update:builder', newBuilder)
|
||||
if (!vectorEquals(props.builder.lineA, a) || !vectorEquals(props.builder.lineB, b)) {
|
||||
const newBuilder = {...props.builder}
|
||||
newBuilder.lineA = a
|
||||
newBuilder.lineB = b
|
||||
emit('update:builder', newBuilder)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,9 +321,24 @@ function dirtyLine(a, b) {
|
||||
|
||||
<style scoped lang="scss">
|
||||
td.weight {
|
||||
width: 11em;
|
||||
width: 5em;
|
||||
max-width: 8em;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
text-align: right;
|
||||
}
|
||||
td.label {
|
||||
$w: 4em;
|
||||
width: $w;
|
||||
min-width: $w;
|
||||
max-width: $w;
|
||||
text-align: right;
|
||||
padding-right: .5em;
|
||||
}
|
||||
.price {
|
||||
$w: 6em;
|
||||
//width: $w;
|
||||
min-width: $w;
|
||||
max-width: 10em;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user