breakout orders

This commit is contained in:
tim
2024-10-31 16:54:57 -04:00
parent 4eb15355a6
commit a65bc94dac
9 changed files with 87 additions and 28 deletions

View File

@@ -98,13 +98,13 @@ class TrancheShapes {
const amountSymbol = buy ? this.symbol.base.s : this.symbol.quote.s
const color = buy ? 'green' : 'red'
if (intercept !== 0 || slope !== 0) {
console.log('tranche line', intercept, slope)
// console.log('tranche line', intercept, slope)
// line active
if (slope === 0) {
let price = intercept
price *= scale
// horizontal line
console.log('hline', price)
// console.log('hline', price)
const model = {price, color, maxAllocation: status.order.amount, amount, amountSymbol};
const s = new HLine(model, null, null, null, true)
this.shapes.push(s)
@@ -120,7 +120,7 @@ class TrancheShapes {
let endPrice = (intercept + slope * endTime);
startPrice *= scale
endPrice *= scale
console.log('dline', startTime, endTime, DISTANT_FUTURE, startPrice, endPrice)
// console.log('dline', startTime, endTime, DISTANT_FUTURE, startPrice, endPrice)
// noinspection EqualityComparisonWithCoercionJS
const model = {
pointA: {time: startTime, price: startPrice},

View File

@@ -108,6 +108,8 @@ export class Shape {
// both amount and amountSymbol must be set in order to display amount text
this.model.amount = null
this.model.amountSymbol = null
this.model.extraText = null
this.model.textLocation = 'above'
// LEAF SUBCLASSES MUST CALL setModel(model) AFTER ALL CONSTRUCTION.
}
@@ -127,6 +129,10 @@ export class Shape {
this.model.amount = model.amount
if (model.amountSymbol)
this.model.amountSymbol = model.amountSymbol
if (model.extraText)
this.model.extraText = model.extraText
if (model.textLocation)
this.model.textLocation = model.textLocation
const newProps = {}
@@ -152,12 +158,18 @@ export class Shape {
// text label
let text = allocationText(this.model.allocation, this.model.amount, this.model.amountSymbol)
if (this.model.extraText)
text += ' '+this.model.extraText
if (this.debug) text = `${this.id} ` + text
if (!text.length)
newProps.showLabel = false
else {
newProps.text = text
newProps.showLabel = true
newProps.textLocation = this.model.textLocation
newProps.vertLabelsAlign =
this.model.textLocation === 'above' ? 'bottom' :
this.model.textLocation === 'below' ? 'top' : null;
}
if (this.debug && this.id)
@@ -612,7 +624,7 @@ export class DLine extends Line {
}
/*
/* todo tim
pointsToTvOhlcStart(points, periodSeconds = null) {
if (points === null) return null
const [v,w] = points