Skip to content

Commit

Permalink
clear values when set to null
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-onthelawn committed Apr 9, 2024
1 parent 0183df8 commit 8267411
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
else -> null
},
)
} else {
modified.safeSet(
"usdcDiff",
null,
)
modified.safeSet(
"percentDiff",
null,
)
}
}
"takeProfitOrder.price.triggerPrice" -> {
Expand All @@ -143,6 +152,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
else -> null
},
)
} else {
modified.safeSet(
"usdcDiff",
null,
)
modified.safeSet(
"percentDiff",
null,
)
}
}
"stopLossOrder.price.usdcDiff" -> {
Expand All @@ -159,6 +177,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
"percentDiff",
leverage.times(usdcDiff).div(size.times(notionalTotal)).times(100),
)
} else {
modified.safeSet(
"triggerPrice",
null,
)
modified.safeSet(
"percentDiff",
null,
)
}
}
"takeProfitOrder.price.usdcDiff" -> {
Expand All @@ -175,6 +202,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
"percentDiff",
leverage.times(usdcDiff).div(size.times(notionalTotal)).times(100),
)
} else {
modified.safeSet(
"triggerPrice",
null,
)
modified.safeSet(
"percentDiff",
null,
)
}
}
"stopLossOrder.price.percentDiff" -> {
Expand All @@ -191,6 +227,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
"usdcDiff",
size.times(percentDiff.times(notionalTotal)).div(leverage),
)
} else {
modified.safeSet(
"triggerPrice",
null,
)
modified.safeSet(
"usdcDiff",
null,
)
}
}
"takeProfitOrder.price.percentDiff" -> {
Expand All @@ -207,6 +252,15 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
"usdcDiff",
size.times(percentDiff.times(notionalTotal)).div(leverage),
)
} else {
modified.safeSet(
"triggerPrice",
null,
)
modified.safeSet(
"usdcDiff",
null,
)
}
}
else -> {}
Expand Down

0 comments on commit 8267411

Please sign in to comment.