Skip to content

Commit

Permalink
Added liquidation price
Browse files Browse the repository at this point in the history
  • Loading branch information
johnqh committed May 30, 2024
1 parent f10d067 commit b4e2c06
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -912,45 +912,46 @@ open class TradingStateMachine(
"trade" -> {
val trade = parser.asNativeMap(input["trade"]) ?: return null
val type = parser.asString(trade["type"]) ?: return null
val isolatedMargin = (parser.asString(trade["marginMode"]) == "ISOLATED")
val isolatedMargin = parser.asString(trade["marginMode"]) == "ISOLATED"
return when (type) {
"MARKET", "STOP_MARKET", "TAKE_PROFIT_MARKET", "TRAILING_STOP" -> {
listOfNotNull(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
if (isolatedMargin) {
ReceiptLine.PositionLeverage.rawValue
} else {
null
},
if (isolatedMargin) {
ReceiptLine.PositionMargin.rawValue
} else {
null
},
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
if (isolatedMargin) {
listOf(
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.LiquidationPrice.rawValue,
ReceiptLine.PositionMargin.rawValue,
ReceiptLine.PositionLeverage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
} else {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.ExpectedPrice.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
}
}

else -> {
listOfNotNull(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
if (isolatedMargin) {
ReceiptLine.PositionLeverage.rawValue
} else {
null
},
if (isolatedMargin) {
ReceiptLine.PositionMargin.rawValue
} else {
null
},
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
if (isolatedMargin) {
listOf(
ReceiptLine.LiquidationPrice.rawValue,
ReceiptLine.PositionMargin.rawValue,
ReceiptLine.PositionLeverage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
} else {
listOf(
ReceiptLine.BuyingPower.rawValue,
ReceiptLine.MarginUsage.rawValue,
ReceiptLine.Fee.rawValue,
ReceiptLine.Reward.rawValue,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) {
}
},
"receiptLines": [
"BUYING_POWER",
"MARGIN_USAGE",
"POSITION_LEVERAGE",
"LIQUIDATION_PRICE",
"POSITION_MARGIN",
"POSITION_LEVERAGE",
"FEE",
"REWARD"
]
Expand Down

0 comments on commit b4e2c06

Please sign in to comment.