Skip to content

Commit

Permalink
Merge pull request #20 from oraichain/hotfix/trigger-take-profit
Browse files Browse the repository at this point in the history
fix: check  take profit is gt 0
  • Loading branch information
trung2891 authored Mar 4, 2024
2 parents 6f428f5 + 4594ae8 commit c9d2718
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/tp_sl_lq/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export class EngineHandler {
const slCloseSpread = bigAbs(stopLoss - closePrice);
// if spot_price is ~ take_profit or stop_loss, close position
if (side === "buy") {
if (closePrice > takeProfit || tpCloseSpread <= tpSpread) {
if (
(takeProfit > 0 && closePrice > takeProfit) ||
tpCloseSpread <= tpSpread
) {
msg = "trigger_take_profit";
} else if (stopLoss > closePrice || slCloseSpread <= slSpread) {
msg = "trigger_stop_loss";
Expand Down

0 comments on commit c9d2718

Please sign in to comment.