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

Compute liquidation price correctly after direction change #2423

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mobile/native/src/trade/position/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ impl Position {
let updated_liquidation_price = calculate_liquidation_price(
f32_from_decimal(updated_average_execution_price),
f32_from_decimal(starting_leverage),
self.direction,
order.direction,
maintenance_margin_rate,
);

Expand Down Expand Up @@ -887,7 +887,7 @@ mod tests {
assert_eq!(updated_position.contract_symbol, position.contract_symbol);
assert_eq!(updated_position.direction, order.direction);
assert_eq!(updated_position.average_entry_price, 36_401.5);
assert_eq!(updated_position.liquidation_price, 26001.072);
assert_eq!(updated_position.liquidation_price, 60669.168);
assert_eq!(updated_position.position_state, PositionState::Open);
assert_eq!(updated_position.collateral, 13_736);
assert!(!updated_position.stable);
Expand Down
Loading