rate limit DCA

This commit is contained in:
tim
2025-03-19 21:04:24 -04:00
parent 8750951de5
commit 5a4a67e726
3 changed files with 10 additions and 6 deletions

View File

@@ -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 = allocationText(buy, weight, amount, amountSymbol, amountIsBase ? null : this.symbol.base.s, '\n') const text = allocationText(buy, weight, amount, amountSymbol, amountIsBase ? null : this.symbol.base.s, 1, '\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)

View File

@@ -40,7 +40,7 @@ export const ShapeType = {
} }
export function allocationText(buy, weight, amount, baseSymbol, amountSymbol = null, separator = ' ') { export function allocationText(buy, weight, amount, baseSymbol, amountSymbol = null, parts = 1, separator = ' ') {
const hasAmount = amount !== null && amount !== undefined && amount > 0 const hasAmount = amount !== null && amount !== undefined && amount > 0
if (hasAmount) if (hasAmount)
amount = Number(amount) amount = Number(amount)
@@ -59,9 +59,12 @@ export function allocationText(buy, weight, amount, baseSymbol, amountSymbol = n
else else
text += `${toPrecision(amount,3)} ${baseSymbol}` text += `${toPrecision(amount,3)} ${baseSymbol}`
} }
if (parts > 1)
text += separator + `in ${Math.round(parts)} parts`
return text return text
} }
export class Shape { export class Shape {
constructor(type, onModel=null, onDelete=null, props=null, readonly=false, overrides={}) { constructor(type, onModel=null, onDelete=null, props=null, readonly=false, overrides={}) {

View File

@@ -44,7 +44,7 @@
<script setup> <script setup>
import {builderDefaults, DEFAULT_SLIPPAGE, useChartOrderStore} from "@/orderbuild.js"; import {builderDefaults, DEFAULT_SLIPPAGE, useChartOrderStore} from "@/orderbuild.js";
import {ShapeType} from "@/charts/shape.js"; import {allocationText, ShapeType} from "@/charts/shape.js";
import {sideColor, vAutoSelect} from "@/misc.js"; import {sideColor, vAutoSelect} from "@/misc.js";
import {useStore} from "@/store/store.js"; import {useStore} from "@/store/store.js";
import {computed, ref, watchEffect} from "vue"; import {computed, ref, watchEffect} from "vue";
@@ -233,9 +233,10 @@ function emitUpdate(changes) {
} }
const text = computed(()=>{ const text = computed(()=>{
let msg = props.order.buy ? 'Buy ' : 'Sell ' const o = props.order
msg += props.builder.tranches + ' parts' console.log('check text', o.buy, o.amountIsTokenA)
return msg return allocationText(o.buy, 1, o.amount, co.selectedSymbol.base.s,
o.amountIsTokenA ? null : co.selectedSymbol.quote.s, parts.value, '\n')
}) })
let shapeId = createShape(ShapeType.DateRange, [{time:barStart.value}, {time:barEnd.value}], {}, callbacks) let shapeId = createShape(ShapeType.DateRange, [{time:barStart.value}, {time:barEnd.value}], {}, callbacks)