order amount bugfix
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
<order title="Ladder" subtitle="Multiple price levels" :tranches="buildTranches" :valid="validOrder">
|
||||
<limit-price :required="true" label="start price" :show-price="false"/>
|
||||
<limit-price store-var="limitPrice2" :required="true" label="end price"/>
|
||||
<v-text-field label='Parts' type="number" step="1" aria-valuemin="0" min="1" variant="outlined"
|
||||
v-model="num" />
|
||||
<v-text-field label="Tranches" type="number" variant="outlined" aria-valuemin="1" min="1" max="255"
|
||||
v-model="os.tranches" :rules="[validateRequired,validateTranches]">
|
||||
<template v-slot:append-inner>tranches</template>
|
||||
</v-text-field>
|
||||
<v-text-field label='Skew' type="number" step="10" aria-valuemin="0" min="-100" max="100" variant="outlined"
|
||||
v-model="skew" clearable @click:clear="skew=0" suffix="%"/>
|
||||
<!-- todo deadline -->
|
||||
@@ -27,16 +29,16 @@ import {useOrderStore} from "@/store/store";
|
||||
import LimitPrice from "@/components/LimitPrice.vue";
|
||||
import Order from "@/components/Order.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {newTimeConstraint, TimeMode} from "@/blockchain/orderlib.js";
|
||||
import {limitConstraint, maxFraction} from "@/orderbuild.js";
|
||||
import {validateMax} from "@/validate.js";
|
||||
import {validateRequired, validateTranches} from "@/validate.js";
|
||||
|
||||
const os = useOrderStore()
|
||||
|
||||
const num = ref(3)
|
||||
const skew = ref(0)
|
||||
const rungs = computed(()=>{
|
||||
const n = num.value;
|
||||
if( !os.limitPrice || !os.limitPrice2 )
|
||||
return []
|
||||
const n = os.tranches;
|
||||
const a = parseFloat(os.limitPrice);
|
||||
const b = parseFloat(os.limitPrice2);
|
||||
if( n < 1 || !a || !b ) return []
|
||||
@@ -52,7 +54,7 @@ const rungsFmt = computed(()=>{
|
||||
return rungs.value.map((r)=>r.toPrecision(5)) // todo precisions
|
||||
})
|
||||
const fractions = computed(()=>{
|
||||
const n = num.value
|
||||
const n = os.tranches
|
||||
const s = skew.value / 100
|
||||
const result = []
|
||||
if( s === 1 ) {
|
||||
@@ -72,11 +74,11 @@ const fractions = computed(()=>{
|
||||
}
|
||||
return result
|
||||
})
|
||||
const amounts = computed( ()=>fractions.value.map((f)=>f*os.amount) )
|
||||
const amounts = computed( ()=>fractions.value.map((f)=>f*os.totalAmount) )
|
||||
|
||||
function buildTranches() {
|
||||
const ts = []
|
||||
const n = num.value
|
||||
const n = os.tranches
|
||||
const mf = Number(maxFraction)
|
||||
for( let i=0; i<n; i++ ) {
|
||||
// todo optional deadline
|
||||
|
||||
Reference in New Issue
Block a user