Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.7.18: fix: update sl/tp percentage diff calculation to use max(leverage, 1) #354

Merged
merged 10 commits into from
May 15, 2024

Conversation

moo-onthelawn
Copy link
Contributor

@moo-onthelawn moo-onthelawn commented May 14, 2024

leverage of < 1 made our percentage calculations really funky. After chatting, it made sense to take max(leverage, 1) since <1 leverage is effectively trading with 1 leverage. See vid of update in action:

modifiedPercentageDIff.mov

Copy link

linear bot commented May 14, 2024

@moo-onthelawn moo-onthelawn force-pushed the mulan/ct-836-update-percentage-diff-calculation branch from 6de153e to 3784b8a Compare May 14, 2024 14:52
@moo-onthelawn moo-onthelawn changed the title fix: update sl/tp percentage diff calculation to use max(leverage, 1) 1.7.14: fix: update sl/tp percentage diff calculation to use max(leverage, 1) May 14, 2024
@moo-onthelawn moo-onthelawn requested a review from mike-dydx May 14, 2024 14:58
@moo-onthelawn moo-onthelawn marked this pull request as ready for review May 14, 2024 14:58
@prashanDYDX
Copy link
Contributor

tests please

@@ -89,13 +90,14 @@ internal class TriggerOrdersInputCalculator(val parser: ParserProtocol) {
val positionSide = parser.asString(parser.value(position, "resources.indicator.current"))
val positionSize = parser.asDouble(parser.value(position, "size.current"))?.abs() ?: return modified
val notionalTotal = parser.asDouble(parser.value(position, "notionalTotal.current")) ?: return modified
val leverage = parser.asDouble(parser.value(position, "leverage.current"))?.abs() ?: return modified
val leverage = requireNotNull(parser.asDouble(parser.value(position, "leverage.current"))) { "leverage was null" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chatted w @prashanDYDX let's revert requireNotNull

it's not with 100% certainty that leverage.current is non-null and requireNotNull throws an error which would break in semi-valid cases.

@moo-onthelawn moo-onthelawn changed the title 1.7.14: fix: update sl/tp percentage diff calculation to use max(leverage, 1) 1.7.17: fix: update sl/tp percentage diff calculation to use max(leverage, 1) May 15, 2024
null,
)

val leverage = 1.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be less than 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh but for the calculations, they should be 1 (and I'm just using this variable for calculations)

}

@Test
fun testLessThanZeroLeverageInputs() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean less than one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahahaaaaaaa yes i do

@moo-onthelawn moo-onthelawn merged commit 5eaad16 into main May 15, 2024
3 checks passed
@moo-onthelawn moo-onthelawn deleted the mulan/ct-836-update-percentage-diff-calculation branch May 15, 2024 21:09
@moo-onthelawn moo-onthelawn changed the title 1.7.17: fix: update sl/tp percentage diff calculation to use max(leverage, 1) 1.7.18: fix: update sl/tp percentage diff calculation to use max(leverage, 1) May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants