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

v1.7.83: Update order status enum strings #454

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
}

group = "exchange.dydx.abacus"
version = "1.7.82"
version = "1.7.83"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class AccountCalculator(val parser: ParserProtocol, private val useParentSubacco
}

val orderStatus = parser.asString(parser.value(order, "status"))

if (!listOf("OPEN", "PENDING", "UNTRIGGERED", "PARTIALLY_FILLED").contains(orderStatus)) {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import exchange.dydx.abacus.utils.GoodTil
import exchange.dydx.abacus.utils.IList
import exchange.dydx.abacus.utils.IMap
import exchange.dydx.abacus.utils.IMutableList
import exchange.dydx.abacus.utils.Logger
import exchange.dydx.abacus.utils.MAX_SUBACCOUNT_NUMBER
import exchange.dydx.abacus.utils.NUM_PARENT_SUBACCOUNTS
import exchange.dydx.abacus.utils.ParsingHelper
Expand Down Expand Up @@ -556,7 +557,13 @@ internal class SubaccountSupervisor(
val openPositions = subaccount.openPositions
val openOrders = subaccount.orders?.filter { order ->
val status = helper.parser.asString(order.status)
status == "open" || status == "pending" || status == "untriggered" || status == "partiallyFilled"

iListOf(
OrderStatus.Open.name,
OrderStatus.Pending.name,
OrderStatus.Untriggered.name,
OrderStatus.PartiallyFilled.name,
).contains(status)
}

val positionMarketIds = openPositions?.map { position ->
Expand Down Expand Up @@ -1476,12 +1483,18 @@ internal class SubaccountSupervisor(
return@mapValues 0.0
}

val quoteBalance = subaccount.value.quoteBalance?.current ?: 0.0
val openPositions = subaccount.value.openPositions

val openOrders = subaccount.value.orders?.filter { order ->
val status = helper.parser.asString(order.status)
iListOf("open", "pending", "untriggered", "partiallyFilled").contains(status)
iListOf(
OrderStatus.Open.name,
OrderStatus.Pending.name,
OrderStatus.Untriggered.name,
OrderStatus.PartiallyFilled.name,
).contains(status)
}
val quoteBalance = subaccount.value.quoteBalance?.current ?: 0.0

// Only return a quoteBalance if the subaccount has no open positions or orders
if (openPositions.isNullOrEmpty() && openOrders.isNullOrEmpty() && quoteBalance > 0.0) {
Expand All @@ -1496,8 +1509,13 @@ internal class SubaccountSupervisor(
val transferPayloadStrings = iMutableListOf<String>()

subaccountQuoteBalanceMap.forEach {
val childSubaccountNumber = it.key.toInt()
val amountToTransfer = it.value.toString()
val childSubaccountNumber = helper.parser.asInt(it.key)
val amountToTransfer = helper.parser.asString(it.value)

if (childSubaccountNumber == null || amountToTransfer == null) {
Logger.e { "Child Subaccount Number or Amount to Transfer is null" }
return@forEach
}

val transferPayload = HumanReadableSubaccountTransferPayload(
childSubaccountNumber,
Expand Down
Loading