Skip to content

Commit

Permalink
Deprecate FOK (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
aforaleka authored Jun 3, 2024
1 parent f432c16 commit 7eb2bd4
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 438 deletions.
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.48"
version = "1.7.49"

repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion docs/Account.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Order status

## timeInForce

Time in force, GTT (Good Til Time), IOC (Immediate or Cancel) or FOK (Fill or Kill)
Time in force, GTT (Good Til Time) or IOC (Immediate or Cancel)

## marketId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ internal class TradeInputCalculator(
executionField(true),
marginModeField(market, account, subaccount),
when (execution) {
"FOK", "IOC" -> reduceOnlyField()
"IOC" -> reduceOnlyField()
else -> null
},
).filterNotNull()
Expand Down Expand Up @@ -1057,7 +1057,6 @@ internal class TradeInputCalculator(
"options" to listOf(
timeInForceOptionGTT,
timeInForceOptionIOC,
timeInForceOptionFOK,
),
)
}
Expand Down Expand Up @@ -1101,13 +1100,11 @@ internal class TradeInputCalculator(
listOf(
executionDefault,
executionIOC,
executionFOK,
executionPostOnly,
)
} else {
listOf(
executionIOC,
executionFOK,
)
},
)
Expand Down Expand Up @@ -1253,9 +1250,9 @@ internal class TradeInputCalculator(
): String? {
return if (featureFlags.reduceOnlySupported) {
when (parser.asString(trade["type"])) {
"LIMIT" -> "GENERAL.TRADE.REDUCE_ONLY_TIMEINFORCE_IOC_FOK"
"LIMIT" -> "GENERAL.TRADE.REDUCE_ONLY_TIMEINFORCE_IOC"

"STOP_LIMIT", "TAKE_PROFIT" -> "GENERAL.TRADE.REDUCE_ONLY_EXECUTION_IOC_FOK"
"STOP_LIMIT", "TAKE_PROFIT" -> "GENERAL.TRADE.REDUCE_ONLY_TIMEINFORCE_IOC"

else -> return null
}
Expand Down Expand Up @@ -1802,8 +1799,6 @@ internal class TradeInputCalculator(

private val timeInForceOptionGTT: Map<String, Any>
get() = mapOf("type" to "GTT", "stringKey" to "APP.TRADE.GOOD_TIL_TIME")
private val timeInForceOptionFOK: Map<String, Any>
get() = mapOf("type" to "FOK", "stringKey" to "APP.TRADE.FILL_OR_KILL")
private val timeInForceOptionIOC: Map<String, Any>
get() = mapOf("type" to "IOC", "stringKey" to "APP.TRADE.IMMEDIATE_OR_CANCEL")

Expand Down Expand Up @@ -1832,11 +1827,8 @@ internal class TradeInputCalculator(
get() = mapOf("type" to "DEFAULT", "stringKey" to "APP.TRADE.GOOD_TIL_DATE")
private val executionPostOnly: Map<String, Any>
get() = mapOf("type" to "POST_ONLY", "stringKey" to "APP.TRADE.POST_ONLY")
private val executionFOK: Map<String, Any>
get() = mapOf("type" to "FOK", "stringKey" to "APP.TRADE.FILL_OR_KILL")
private val executionIOC: Map<String, Any>
get() = mapOf("type" to "IOC", "stringKey" to "APP.TRADE.IMMEDIATE_OR_CANCEL")

private val marginModeCross: Map<String, Any>
get() = mapOf("type" to "CROSS", "stringKey" to "APP.TRADE.CROSS_MARGIN")
private val marginModeIsolated: Map<String, Any>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,7 @@ enum class OrderStatus(val rawValue: String) {
@Serializable
enum class OrderTimeInForce(val rawValue: String) {
GTT("GTT"),
IOC("IOC"),
FOK("FOK");
IOC("IOC");

companion object {
operator fun invoke(rawValue: String) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ open class StateManagerAdaptor(
val reduceOnly = true
val postOnly = false

// TP/SL orders always have a null timeInForce. IOC/FOK/PostOnly/GTD is distinguished by the execution field.
// TP/SL orders always have a null timeInForce. IOC/PostOnly/GTD is distinguished by the execution field.
val timeInForce = null;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ internal class SubaccountSupervisor(
val reduceOnly = true
val postOnly = false

// TP/SL orders always have a null timeInForce. IOC/FOK/PostOnly/GTD is distinguished by the execution field.
// TP/SL orders always have a null timeInForce. IOC/PostOnly/GTD is distinguished by the execution field.
val timeInForce = null;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ internal class TradeInputDataValidator(
return when (parser.asString(trade["type"])) {
"STOP_LIMIT", "TAKE_PROFIT" -> {
val execution = parser.asString(trade["execution"])
if (execution == "IOC" || execution == "FOK") {
if (execution == "IOC") {
parser.asString(parser.value(trade, "side"))?.let { side ->
parser.asDouble(parser.value(trade, "price.limitPrice"))
?.let { limitPrice ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ class TradeInputOptionsTests : V3BaseTests() {
{
"type": "IOC",
"stringKey": "APP.TRADE.IMMEDIATE_OR_CANCEL"
},
{
"type": "FOK",
"stringKey": "APP.TRADE.FILL_OR_KILL"
}
]
}
Expand All @@ -192,32 +188,5 @@ class TradeInputOptionsTests : V3BaseTests() {
}
""".trimIndent(),
)

test(
{
perp.trade("FOK", TradeInputField.timeInForceType, 0)
},
"""
{
"input": {
"trade": {
"options": {
"needsSize": true,
"needsLeverage": false,
"needsTriggerPrice": false,
"needsLimitPrice": true,
"needsTrailingPercent": false,
"needsReduceOnly": true,
"needsPostOnly": false,
"needsBrackets": false,
"needsTimeInForce": true,
"needsGoodUntil": false,
"needsExecution": false
}
}
}
}
""".trimIndent(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class V3PerpTests : V3BaseTests() {
"sideStringKey": "APP.GENERAL.BUY",
"typeStringKey": "APP.TRADE.MARKET_ORDER_SHORT",
"statusStringKey": "APP.TRADE.ORDER_FILLED",
"timeInForceStringKey": "APP.TRADE.FILL_OR_KILL"
"timeInForceStringKey": "APP.TRADE.IMMEDIATE_OR_CANCEL"
}
}
},
Expand Down
Loading

0 comments on commit 7eb2bd4

Please sign in to comment.