Skip to content

Commit

Permalink
Akmal / feat: enable barriers overlapping logic for absolute values (#…
Browse files Browse the repository at this point in the history
…1582)

* feat: enable barriers overlapping logic logic for absolute values

* fix: add condition for ended contracts
  • Loading branch information
akmal-deriv authored May 3, 2024
1 parent ac0e440 commit 5337403
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/store/PriceLineStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ export default class PriceLineStore {
return realPrice.toString();
}

get currentClosePrice(): number {
return this.mainStore.chart.currentCloseQuote()?.Close || 0;
}

get priceLineWidth() {
return window.flutterChart?.app.getCurrentTickWidth() || 60;
}
Expand All @@ -204,6 +208,10 @@ export default class PriceLineStore {
return 16;
}

get isContractOngoing(): boolean {
return this.mainStore.chart.isLive;
}

_getPrice(quote: number) {
const price = this.isDragging ? this.dragPrice : this.price;
return this.relative ? quote + Number(price) : Number(price);
Expand Down Expand Up @@ -264,7 +272,9 @@ export default class PriceLineStore {
_distanceFromCurrentPrice() {
return Math.abs(
this._locationFromPrice(+this.realPrice) -
this._locationFromPrice(+this.realPrice - (this.isDragging ? +this._dragPrice : +this._price))
(this.relative
? this._locationFromPrice(+this.realPrice - (this.isDragging ? +this._dragPrice : +this._price))
: this._locationFromPrice(this.currentClosePrice))
);
}

Expand Down Expand Up @@ -311,7 +321,7 @@ export default class PriceLineStore {
this.isOverlapping = this.overlapCheck(top);
}

this.isOverlappingWithPriceLine = this._distanceFromCurrentPrice() < 25;
this.isOverlappingWithPriceLine = this.isContractOngoing && this._distanceFromCurrentPrice() < 25;

return Math.round(top) | 0;
};
Expand Down

0 comments on commit 5337403

Please sign in to comment.