diagonals working except for start/end times
This commit is contained in:
@@ -378,8 +378,8 @@ function pendOrderAsTransaction(pend) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('placing order', pend.id)
|
console.log('placing order', pend.id, pend.order)
|
||||||
const tx = await contract.placeDexorder(pend.order) // todo update status
|
const tx = await contract.placeDexorder(pend.order)
|
||||||
pend.tx = tx
|
pend.tx = tx
|
||||||
pend.state = PendingOrderState.Sent
|
pend.state = PendingOrderState.Sent
|
||||||
console.log(`order ${pend.id} sent transaction`, tx)
|
console.log(`order ${pend.id} sent transaction`, tx)
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ export const ShapeType = {
|
|||||||
text anchored_text note anchored_note signpost double_curve arc icon emoji sticker arrow_up arrow_down arrow_left arrow_right price_label price_note arrow_marker flag vertical_line horizontal_line cross_line horizontal_ray trend_line info_line trend_angle arrow ray extended parallel_channel disjoint_angle flat_bottom anchored_vwap pitchfork schiff_pitchfork_modified schiff_pitchfork balloon comment inside_pitchfork pitchfan gannbox gannbox_square gannbox_fixed gannbox_fan fib_retracement fib_trend_ext fib_speed_resist_fan fib_timezone fib_trend_time fib_circles fib_spiral fib_speed_resist_arcs fib_channel xabcd_pattern cypher_pattern abcd_pattern callout triangle_pattern 3divers_pattern head_and_shoulders fib_wedge elliott_impulse_wave elliott_triangle_wave elliott_triple_combo elliott_correction elliott_double_combo cyclic_lines time_cycles sine_line long_position short_position forecast date_range price_range date_and_price_range bars_pattern ghost_feed projection rectangle rotated_rectangle circle ellipse triangle polyline path curve cursor dot arrow_cursor eraser measure zoom brush highlighter regression_trend fixed_range_volume_profile
|
text anchored_text note anchored_note signpost double_curve arc icon emoji sticker arrow_up arrow_down arrow_left arrow_right price_label price_note arrow_marker flag vertical_line horizontal_line cross_line horizontal_ray trend_line info_line trend_angle arrow ray extended parallel_channel disjoint_angle flat_bottom anchored_vwap pitchfork schiff_pitchfork_modified schiff_pitchfork balloon comment inside_pitchfork pitchfan gannbox gannbox_square gannbox_fixed gannbox_fan fib_retracement fib_trend_ext fib_speed_resist_fan fib_timezone fib_trend_time fib_circles fib_spiral fib_speed_resist_arcs fib_channel xabcd_pattern cypher_pattern abcd_pattern callout triangle_pattern 3divers_pattern head_and_shoulders fib_wedge elliott_impulse_wave elliott_triangle_wave elliott_triple_combo elliott_correction elliott_double_combo cyclic_lines time_cycles sine_line long_position short_position forecast date_range price_range date_and_price_range bars_pattern ghost_feed projection rectangle rotated_rectangle circle ellipse triangle polyline path curve cursor dot arrow_cursor eraser measure zoom brush highlighter regression_trend fixed_range_volume_profile
|
||||||
*/
|
*/
|
||||||
Segment: {name: 'Trend Line', code: 'trend_line'},
|
Segment: {name: 'Trend Line', code: 'trend_line'},
|
||||||
Ray: {name: 'Ray', code: 'ray'},
|
Ray: {name: 'Ray', code: 'ray', drawingProp: 'linetoolray'},
|
||||||
Line: {name: 'Extended Line', code: 'extended', drawingProp: 'linetoolextended'},
|
Line: {name: 'Extended Line', code: 'extended', drawingProp: 'linetoolray'},
|
||||||
HRay: {name: 'Horizontal Ray', code: 'horizontal_ray'},
|
HRay: {name: 'Horizontal Ray', code: 'horizontal_ray'},
|
||||||
HLine: {name: 'Horizontal Line', code: 'horizontal_line', drawingProp: 'linetoolhorzline'},
|
HLine: {name: 'Horizontal Line', code: 'horizontal_line', drawingProp: 'linetoolhorzline'},
|
||||||
VLine: {name: 'Vertical Line', code: 'vertical_line', drawingProp: 'linetoolvertline'},
|
VLine: {name: 'Vertical Line', code: 'vertical_line', drawingProp: 'linetoolvertline'},
|
||||||
@@ -539,20 +539,20 @@ export class VLine extends Line {
|
|||||||
|
|
||||||
export class DLine extends Line {
|
export class DLine extends Line {
|
||||||
constructor(model, onModel=null, onDelete=null, props=null) {
|
constructor(model, onModel=null, onDelete=null, props=null) {
|
||||||
super(ShapeType.Line, onModel, onDelete, props)
|
super(ShapeType.Ray, onModel, onDelete, props)
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
this.model.pointA = null // {time:..., price:...}
|
this.model.pointA = null // {time:..., price:...}
|
||||||
this.model.pointB = null
|
this.model.pointB = null
|
||||||
|
|
||||||
this.setModel(model) // call setModel at the end
|
this.setModel(model) // call setModel at the end
|
||||||
console.log('initial shape model', {...model})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
drawingOverrides() {
|
drawingOverrides() {
|
||||||
const result = super.drawingOverrides();
|
const result = super.drawingOverrides();
|
||||||
result.linetoolextended = {extendLeft: false, extendRight: false}
|
result.extendLeft = false
|
||||||
|
result.extendRight = false
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +585,6 @@ export class DLine extends Line {
|
|||||||
dirty = true
|
dirty = true
|
||||||
}
|
}
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
console.log('DLine points were dirty', this.tvPoints, points)
|
|
||||||
super.onPoints(points);
|
super.onPoints(points);
|
||||||
this.updateModel({pointA: points[0], pointB: points[1]})
|
this.updateModel({pointA: points[0], pointB: points[1]})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
label="Price"
|
label="Price"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td rowspan="2" class="weight">{{ allocationTexts[weights.length-1] }}</td>
|
<td rowspan="2" class="weight" style="vertical-align: bottom">{{ allocationTexts[weights.length-1] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr v-for="i in innerIndexes" class="ml-5">
|
<tr v-for="i in innerIndexes" class="ml-5">
|
||||||
<td class="text-right"> </td>
|
<td class="text-right"> </td>
|
||||||
<td colspan="2" class="text-center"><i>Diagonal</i></td>
|
<td colspan="2" class="text-center">— Interior Line —</td>
|
||||||
<td class="weight">{{ allocationTexts[i] }}</td>
|
<td class="weight">{{ allocationTexts[i] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="weights.length>1">
|
<tr v-if="weights.length>1">
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
label="Price"
|
label="Price"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td rowspan="2" class="weight">{{ allocationTexts[0] }}</td>
|
<td rowspan="2" class="weight" style="vertical-align: top">{{ allocationTexts[0] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="weights.length>1">
|
<tr v-if="weights.length>1">
|
||||||
<td>
|
<td>
|
||||||
@@ -109,18 +109,17 @@ builderDefaults(props.builder, {
|
|||||||
|
|
||||||
|
|
||||||
function buildTranches() {
|
function buildTranches() {
|
||||||
throw Error('unimplemented') // todo
|
|
||||||
const order = props.order
|
const order = props.order
|
||||||
const builder = props.builder
|
const builder = props.builder
|
||||||
const tranches = []
|
const tranches = []
|
||||||
|
|
||||||
console.log('buildTranches', builder, order, tranches)
|
console.log('buildTranches', builder, order, _endpoints.value)
|
||||||
const la = buildLine(_endpoints[0])
|
const la = _endpoints.value[0] // use the flatline format which is a vector of length 4, useful for vectorInterpolate()
|
||||||
const lb = buildLine(_endpoints[1])
|
const lb = _endpoints.value[1]
|
||||||
const ws = weights.value
|
const ws = weights.value
|
||||||
for (let i = 0; i < ws.length; i++) {
|
for (let i = 0; i < ws.length; i++) {
|
||||||
const w = ws[i]
|
const w = ws[i]
|
||||||
const line = vectorInterpolate(la, lb, i/(ws.length-1))
|
const line = ws.length === 1 ? la : vectorInterpolate(la, lb, i/(ws.length-1))
|
||||||
const t = newTranche({fraction: w * MAX_FRACTION})
|
const t = newTranche({fraction: w * MAX_FRACTION})
|
||||||
const symbol = co.selectedSymbol
|
const symbol = co.selectedSymbol
|
||||||
console.log('symbol', symbol)
|
console.log('symbol', symbol)
|
||||||
@@ -137,7 +136,7 @@ function flattenLine(l) {
|
|||||||
|
|
||||||
|
|
||||||
function buildLine(f) {
|
function buildLine(f) {
|
||||||
console.log('buildLine', f)
|
// console.log('buildLine', f)
|
||||||
return f === null ? null : [{time: f[0], price: f[1]}, {time: f[2], price: f[3]}]
|
return f === null ? null : [{time: f[0], price: f[1]}, {time: f[2], price: f[3]}]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,17 +242,13 @@ const price2B = computed({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function update(a, b) { // a and b are lines of two points
|
function update(a, b) { // a and b are lines of two points
|
||||||
console.log('update', a, b)
|
|
||||||
if (!vectorEquals(props.builder.lineA, a) || !vectorEquals(props.builder.lineB, b)) {
|
if (!vectorEquals(props.builder.lineA, a) || !vectorEquals(props.builder.lineB, b)) {
|
||||||
console.log('update was dirty')
|
|
||||||
_endpoints.value = [flattenLine(a), flattenLine(b)]
|
_endpoints.value = [flattenLine(a), flattenLine(b)]
|
||||||
const newBuilder = {...props.builder}
|
const newBuilder = {...props.builder}
|
||||||
newBuilder.lineA = a
|
newBuilder.lineA = a
|
||||||
newBuilder.lineB = b
|
newBuilder.lineB = b
|
||||||
emit('update:builder', newBuilder)
|
emit('update:builder', newBuilder)
|
||||||
}
|
}
|
||||||
else
|
|
||||||
console.log('update was not dirty')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -290,14 +285,14 @@ function getModelValue(model) {
|
|||||||
if (!model.pointA || !model.pointB)
|
if (!model.pointA || !model.pointB)
|
||||||
return null
|
return null
|
||||||
const result = flattenLine([model.pointA, model.pointB]);
|
const result = flattenLine([model.pointA, model.pointB]);
|
||||||
console.log('getModelValue', {...model}, result)
|
// console.log('getModelValue', {...model}, result)
|
||||||
return result // this is the vector the RungBuilder will interpolate
|
return result // this is the vector the RungBuilder will interpolate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setModelValue(model, value) {
|
function setModelValue(model, value) {
|
||||||
const oldModel = {...model};
|
const oldModel = {...model};
|
||||||
console.log('setModelValue', oldModel, value)
|
// console.log('setModelValue', oldModel, value)
|
||||||
const oldLine = !model.pointA || !model.pointB ? null : [model.pointA, model.pointB]
|
const oldLine = !model.pointA || !model.pointB ? null : [model.pointA, model.pointB]
|
||||||
const line = buildLine(value)
|
const line = buildLine(value)
|
||||||
if (dirtyLine(oldLine, line)) {
|
if (dirtyLine(oldLine, line)) {
|
||||||
@@ -310,7 +305,7 @@ function setModelValue(model, value) {
|
|||||||
model.pointB = line[1]
|
model.pointB = line[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('setModelValue end', oldModel, value, model)
|
// console.log('setModelValue end', oldModel, value, model)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,7 +313,7 @@ function dirtyLine(a, b) {
|
|||||||
const result = a === b ? false :
|
const result = a === b ? false :
|
||||||
a === null && b !== null || a !== null && b === null ||
|
a === null && b !== null || a !== null && b === null ||
|
||||||
a[0].time !== b[0].time || a[0].price !== b[0].price || a[1].time !== b[1].time || a[1].price !== b[1].price
|
a[0].time !== b[0].time || a[0].price !== b[0].price || a[1].time !== b[1].time || a[1].price !== b[1].price
|
||||||
console.log('dirtyLine', result, a, b)
|
// console.log('dirtyLine', result, a, b)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ watchEffect(()=>{
|
|||||||
|
|
||||||
|
|
||||||
function setEndpoints(a, b) {
|
function setEndpoints(a, b) {
|
||||||
console.log('rb setting endpoints', devectorize(a), devectorize(b))
|
// console.log('rb setting endpoints', devectorize(a), devectorize(b))
|
||||||
endpoints.value = [devectorize(a), devectorize(b)]
|
endpoints.value = [devectorize(a), devectorize(b)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +107,13 @@ const rungs = computed({
|
|||||||
r = Number(r)
|
r = Number(r)
|
||||||
const prevR = Number(props.builder.rungs)
|
const prevR = Number(props.builder.rungs)
|
||||||
props.builder.rungs = r
|
props.builder.rungs = r
|
||||||
console.log('set rungs', prevR, r, a, b)
|
// console.log('set rungs', prevR, r, a, b)
|
||||||
if ( r > 0 && vectorIsNull(b) ) {
|
if ( r > 0 && vectorIsNull(b) ) {
|
||||||
// convert single shape to a range
|
// convert single shape to a range
|
||||||
if (props.mode===0) {
|
if (props.mode===0) {
|
||||||
const width = vectorize(props.stdWidth)
|
const width = vectorize(props.stdWidth)
|
||||||
const mid = vectorize(a)
|
const mid = vectorize(a)
|
||||||
console.log('stdWidth', width)
|
// console.log('stdWidth', width)
|
||||||
const halfWidth = vectorDiv(width,2);
|
const halfWidth = vectorDiv(width,2);
|
||||||
a = vectorAdd(mid, vectorNeg(halfWidth) )
|
a = vectorAdd(mid, vectorNeg(halfWidth) )
|
||||||
b = vectorAdd(mid, halfWidth)
|
b = vectorAdd(mid, halfWidth)
|
||||||
@@ -149,7 +149,6 @@ const values = computed(()=>{
|
|||||||
let [a, b] = endpoints.value
|
let [a, b] = endpoints.value
|
||||||
a = vectorize(a)
|
a = vectorize(a)
|
||||||
b = vectorize(b)
|
b = vectorize(b)
|
||||||
console.log('computing values', a, b)
|
|
||||||
const r = props.builder.rungs
|
const r = props.builder.rungs
|
||||||
let result
|
let result
|
||||||
if ( !r || vectorIsNull(a) )
|
if ( !r || vectorIsNull(a) )
|
||||||
@@ -170,14 +169,20 @@ const values = computed(()=>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
props.setValues(result)
|
props.setValues(result)
|
||||||
console.log('values', result)
|
// console.log('values', result)
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const weights = computed(() => {
|
const weights = computed(() => {
|
||||||
// const skew = props.flip ? -props.builder.skew : props.builder.skew
|
// const skew = props.flip ? -props.builder.skew : props.builder.skew
|
||||||
const ws = linearWeights(props.builder.rungs, -props.builder.skew)
|
const most = 0.998
|
||||||
|
let skew = -props.builder.skew
|
||||||
|
if (skew <= -1)
|
||||||
|
skew = -most
|
||||||
|
else if (skew >= 1)
|
||||||
|
skew = most
|
||||||
|
const ws = linearWeights(props.builder.rungs, skew)
|
||||||
if (props.setWeights)
|
if (props.setWeights)
|
||||||
props.setWeights(ws)
|
props.setWeights(ws)
|
||||||
return ws
|
return ws
|
||||||
@@ -239,7 +244,7 @@ function translateOnModel(shape) {
|
|||||||
const prev = getModelValue(oldModel)
|
const prev = getModelValue(oldModel)
|
||||||
const cur = vectorize(getModelValue(this.model))
|
const cur = vectorize(getModelValue(this.model))
|
||||||
const delta = vectorSub(cur, prev)
|
const delta = vectorSub(cur, prev)
|
||||||
console.log('delta', shape.id, prev, cur, delta)
|
// console.log('delta', shape.id, prev, cur, delta)
|
||||||
let [a, b] = endpoints.value
|
let [a, b] = endpoints.value
|
||||||
a = vectorize(a)
|
a = vectorize(a)
|
||||||
if (!vectorIsZero(delta)) {
|
if (!vectorIsZero(delta)) {
|
||||||
@@ -252,7 +257,6 @@ function translateOnModel(shape) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setModelColor(model) {
|
function setModelColor(model) {
|
||||||
console.log('setmc', color.value, model.color)
|
|
||||||
if (model.color !== undefined && model.color !== color.value)
|
if (model.color !== undefined && model.color !== color.value)
|
||||||
color.value = model.color
|
color.value = model.color
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,24 +208,24 @@ export function builderDefaults(builder, defaults) {
|
|||||||
builder[k] = defaults[k] instanceof Function ? defaults[k]() : defaults[k]
|
builder[k] = defaults[k] instanceof Function ? defaults[k]() : defaults[k]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function linearWeights(n, s) {
|
export function linearWeights(num, skew) {
|
||||||
if (n === 1) return [1]
|
if (num === 1) return [1]
|
||||||
const result = []
|
const result = []
|
||||||
if (s === 0) {
|
if (skew === 0) {
|
||||||
// equal weighted
|
// equal weighted
|
||||||
for (let i = 0; i < n; i++)
|
for (let i = 0; i < num; i++)
|
||||||
result.push(1 / n)
|
result.push(1 / num)
|
||||||
} else if (s === 1) {
|
} else if (skew === 1) {
|
||||||
result.push(1)
|
result.push(1)
|
||||||
for (let i = 1; i < n; i++)
|
for (let i = 1; i < num; i++)
|
||||||
result.push(0)
|
result.push(0)
|
||||||
} else if (s === -1) {
|
} else if (skew === -1) {
|
||||||
for (let i = 1; i < n; i++)
|
for (let i = 1; i < num; i++)
|
||||||
result.push(0)
|
result.push(0)
|
||||||
result.push(1)
|
result.push(1)
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < n; i++)
|
for (let i = 0; i < num; i++)
|
||||||
result.push((1 - s * (2 * i / (n - 1) - 1)) / n)
|
result.push((1 - skew * (2 * i / (num - 1) - 1)) / num)
|
||||||
}
|
}
|
||||||
// console.log('weights', result)
|
// console.log('weights', result)
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user