orderbuild fixes; tranche table work; ordershapes still broken

This commit is contained in:
tim
2024-09-20 04:12:23 -04:00
parent ce54b943ea
commit e5d5c9c0d8
10 changed files with 111 additions and 48 deletions

View File

@@ -8,7 +8,6 @@ export let widget = null
export let chart = null
export let crosshairPoint = null
let symbolChangedCbs = [] // callbacks for TV's chart.onSymbolChanged()
let lastSymbolChangedArgs = null
const s = useStore()
@@ -23,17 +22,22 @@ export function removeSymbolChangedCallback(cb) {
}
function changeSymbol(symbol) {
console.log('change symbol', symbol)
if (symbol===null)
co.selectedSymbol = null
else {
const info = lookupSymbol(symbol.full_name)
lastSymbolChangedArgs = info
const info = lookupSymbol(symbol.ticker)
symbolChangedCbs.forEach((cb) => cb(info))
co.selectedSymbol = info
}
}
export function setSymbol(symbol) {
widget.activeChart().setSymbol(symbol.ticker)
}
function changeInterval(interval, _timeframe) {
co.intervalSecs = intervalToSeconds(interval)
DataFeed.intervalChanged(co.intervalSecs)
@@ -100,7 +104,14 @@ function initChart() {
s.timeZone = tzapi.getTimezone().id
// chart.onHoveredSourceChanged().subscribe(null, ()=>console.log('hovered source changed', arguments))
// chart.selection().onChanged().subscribe(null, s => console.log('selection', chart.selection().allSources()));
changeSymbol(chart.symbolExt())
const symbolExt = chart.symbolExt();
console.log('symbolExt', symbolExt);
if(symbolExt) {
changeSymbol(symbolExt)
}
else {
changeSymbol(null)
}
changeInterval(widget.symbolInterval().interval)
co.chartReady = true
console.log('chart ready')

View File

@@ -222,7 +222,17 @@ function getAllSymbols() {
}
export function lookupSymbol(key) { // lookup by ticker which is "0xbaseAddress/0xquoteAddress"
return getAllSymbols()[key]
const symbols = getAllSymbols();
if (!(key in symbols)) {
// check the inverted symbol
const [base,quote] = key.split('/')
key = quote+'/'+base
if (!(key in symbols)) {
console.error('no symbol found for key', key, symbols)
return null
}
}
return symbols[key]
}
function checkBar(bar, msg) {

View File

@@ -70,7 +70,7 @@ class TrancheShapes {
// console.log('price', price)
const channel = buy?'low':'high';
const text = (buy ? 'Buy ' : 'Sell ') + allocationText(null, f.filled, '')
const s = createShape(buy?'arrow_up':'arrow_down', {time, price}, {channel,text})
const s = createShape(buy?'arrow_up':'arrow_down', {time, price}, {channel,text,lock:true})
console.log('created fill shape at', time, price)
this.fills.push(s)
}
@@ -90,7 +90,7 @@ class TrancheShapes {
price: intercept * scale,
color,
// todo allocation maxAllocation amount amountSymbol
})
}, null, null, null, true)
this.shapes.push(s)
} else {
// diagonal line
@@ -103,7 +103,7 @@ class TrancheShapes {
extendRight: t.endTime === DISTANT_FUTURE,
color,
// todo allocation maxAllocation amount amountSymbol
})
}, null, null, null, true)
this.shapes.push(s)
}
}

View File

@@ -41,7 +41,7 @@ export const ShapeType = {
export class Shape {
constructor(type, onModel=null, onDelete=null, props=null) {
constructor(type, onModel=null, onDelete=null, props=null, readonly=false, overrides={}) {
// the Shape object manages synchronizing internal data with a corresponding TradingView shape
// each shape in the class hierarchy overrides setModel() to cause effects in TradingView
@@ -64,7 +64,10 @@ export class Shape {
this.tvCallbacks = null
this.ourPoints = null
this.tvPoints = null
this.creationOptions = {disableSave:true, disableUndo:true, disableSelection:false}
this.creationOptions = readonly ?
{disableSave:true, disableUndo:true, disableSelection:true, lock:true} :
{disableSave:true, disableUndo:true, disableSelection:false}
this.creationOptions.overrides = overrides
this.ourProps = {}
if (props !== null)
this.ourProps = mixin(props, this.ourProps)
@@ -437,8 +440,13 @@ export class Line extends Shape {
export class HLine extends Line {
constructor(model, onModel=null, onDelete=null, props=null) {
super(ShapeType.HLine, onModel, onDelete, props)
constructor(model, onModel=null, onDelete=null, props=null, readonly=false) {
super(ShapeType.HLine, onModel, onDelete, props, readonly, {
// todo this isnt working
linestyle: 0,
linewidth: 2,
italic: false,
})
// Model
this.model.price = null
@@ -513,8 +521,10 @@ export class VLine extends Line {
export class DLine extends Line {
constructor(model, onModel=null, onDelete=null, props=null) {
super(ShapeType.Ray, onModel, onDelete, props)
constructor(model, onModel=null, onDelete=null, props=null, readonly=false) {
super(ShapeType.Ray, onModel, onDelete, props, readonly,{
// todo style overrides
})
// Model
this.model.pointA = null // {time:..., price:...}