Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package co.nilin.opex.api.core.inout

data class AdminOrdersHistoryRequest(
val uuid: String?,
val symbol: String?,
val ouid: String?,
val startTime: Long?,
val endTime: Long?,
val orderType: MatchingOrderType?,
val direction: OrderDirection?,
val limit: Int? = 10,
val offset: Int? = 0,
val ascendingByTime: Boolean? = false,
val includeNames: Boolean? = false
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package co.nilin.opex.api.core.inout

data class AdminTradesHistoryRequest(
val symbol: String?,
val baseAsset: String?,
val quoteAsset: String?,
val ouid: String?,
val makerOuid: String?,
val takerOuid: String?,
val uuid: String?,
val makerUuid: String?,
val takerUuid: String?,
val fromDate: Long?,
val toDate: Long?,
val ascendingByTime: Boolean? = false,
val excludeSelfTrade: Boolean? = true,
val limit: Int?=10,
val offset: Int?=0,
val includeNames: Boolean? = false,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package co.nilin.opex.api.core.inout

import java.math.BigDecimal
import java.time.LocalDateTime


data class OrderAdminItem(
val symbol: String,
val ouid: String,
val orderType: MatchingOrderType?,
val side: OrderDirection,
val price: BigDecimal,
val quantity: BigDecimal,
val quoteQuantity: BigDecimal?,
val executedQuantity: BigDecimal?,
val takerFee: BigDecimal?,
val makerFee: BigDecimal?,
val status: OrderStatus?,
val appearance: Int?,
val createDate: LocalDateTime,
val updateDate: LocalDateTime,
val uuid: String?,
val ownerName: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class OrderData(
val executedQuantity: BigDecimal,
val takerFee: BigDecimal,
val makerFee: BigDecimal,
val status: Int,
val status: OrderStatus,
val appearance: Int,
val createDate: LocalDateTime,
val updateDate: LocalDateTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package co.nilin.opex.api.core.inout

data class ResolveUsersRequest(
val uuids: List<String>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package co.nilin.opex.api.core.inout

import java.math.BigDecimal
import java.time.LocalDateTime


data class TradeAdminItem(
val tradeId: Long,
val symbol: String,
val baseAsset: String?,
val quoteAsset: String?,
val matchedPrice: BigDecimal,
val matchedQuantity: BigDecimal,
val takerPrice: BigDecimal,
val makerPrice: BigDecimal,
val tradeDate: LocalDateTime,
val makerUuid: String,
val takerUuid: String,
val makerOuid: String?,
val takerOuid: String?,
val makerCommission: BigDecimal?,
val takerCommission: BigDecimal?,
val makerCommissionAsset: String?,
val takerCommissionAsset: String?,
// Enriched in API when includeNames=true
val makerOwnerName: String? = null,
val takerOwnerName: String? = null,
)


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package co.nilin.opex.api.core.inout

import java.math.BigDecimal
import java.time.LocalDateTime

@Deprecated("Use TradeResponseItem")
data class TradeAdminResponse(
val id: Long,
val currency: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ interface MarketDataProxy {

suspend fun recentTrades(symbol: String, limit: Int): List<MarketTrade>

suspend fun recentTrades(token: String, request: AdminTradesHistoryRequest): List<TradeAdminItem>

suspend fun recentOrders(token: String, request: AdminOrdersHistoryRequest): List<OrderAdminItem>

suspend fun lastPrice(symbol: String?): List<PriceTicker>

suspend fun getBestPriceForSymbols(symbols: List<String>): List<BestPrice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import java.util.*

interface MarketUserDataProxy {

suspend fun queryOrder(principal: Principal, symbol: String, orderId: Long?, origClientOrderId: String?): Order?
suspend fun queryOrder(token: String, symbol: String, orderId: Long?, origClientOrderId: String?): Order?

suspend fun openOrders(principal: Principal, symbol: String?, limit: Int?): List<Order>
suspend fun openOrders(token: String, symbol: String?, limit: Int?): List<Order>

suspend fun allOrders(
principal: Principal,
token: String,
symbol: String?,
startTime: Date?,
endTime: Date?,
limit: Int?
): List<Order>

suspend fun allTrades(
principal: Principal,
token: String,
symbol: String?,
fromTrade: Long?,
startTime: Date?,
Expand All @@ -32,7 +32,7 @@ interface MarketUserDataProxy {
): List<Trade>

suspend fun getOrderHistory(
uuid: String,
token: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
Expand All @@ -43,7 +43,7 @@ interface MarketUserDataProxy {
): List<OrderData>

suspend fun getOrderHistoryCount(
uuid: String,
token: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
Expand All @@ -52,7 +52,7 @@ interface MarketUserDataProxy {
): Long

suspend fun getTradeHistory(
uuid: String,
token: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
Expand All @@ -62,7 +62,7 @@ interface MarketUserDataProxy {
): List<Trade>

suspend fun getTradeHistoryCount(
uuid: String,
token: String,
symbol: String?,
startTime: Long?,
endTime: Long?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface ProfileProxy {
request: UpdateApprovalRequestBody
): ProfileApprovalAdminResponse

suspend fun resolveUsers(token: String, request: ResolveUsersRequest): Map<String, String?>

// Address Book
suspend fun addAddressBook(token: String, request: AddAddressBookItemRequest): AddressBookResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AccountController(
if (orderId == null && origClientOrderId == null)
throw OpexError.BadRequest.exception("'orderId' or 'origClientOrderId' must be sent")

val order = queryHandler.queryOrder(principal, localSymbol, orderId, origClientOrderId)
val order = queryHandler.queryOrder(securityContext.jwtAuthentication().tokenValue(), localSymbol, orderId, origClientOrderId)
?: throw OpexError.OrderNotFound.exception()

val response = CancelOrderResponse(
Expand Down Expand Up @@ -220,10 +220,11 @@ class AccountController(
@RequestParam(required = false)
recvWindow: Long?, //The value cannot be greater than 60000
@RequestParam
timestamp: Long
): QueryOrderResponse {
timestamp: Long,
@CurrentSecurityContext securityContext: SecurityContext,
): QueryOrderResponse {
val internalSymbol = symbolMapper.toInternalSymbol(symbol) ?: throw OpexError.SymbolNotFound.exception()
return queryHandler.queryOrder(principal, internalSymbol, orderId, origClientOrderId)
return queryHandler.queryOrder(securityContext.jwtAuthentication().tokenValue(), internalSymbol, orderId, origClientOrderId)
?.asQueryOrderResponse()
?.apply { this.symbol = symbol }
?: throw OpexError.OrderNotFound.exception()
Expand Down Expand Up @@ -261,10 +262,11 @@ class AccountController(
@RequestParam
timestamp: Long,
@RequestParam(required = false)
limit: Int?
): List<QueryOrderResponse> {
limit: Int?,
@CurrentSecurityContext securityContext: SecurityContext,
): List<QueryOrderResponse> {
val internalSymbol = symbolMapper.toInternalSymbol(symbol) ?: throw OpexError.SymbolNotFound.exception()
return queryHandler.openOrders(principal, internalSymbol, limit).map {
return queryHandler.openOrders(securityContext.jwtAuthentication().tokenValue(), internalSymbol, limit).map {
it.asQueryOrderResponse().apply { symbol?.let { s -> this.symbol = s } }
}
}
Expand Down Expand Up @@ -304,10 +306,13 @@ class AccountController(
@RequestParam(required = false)
recvWindow: Long?, //The value cannot be greater than 60000
@RequestParam
timestamp: Long
): List<QueryOrderResponse> {
timestamp: Long,
@CurrentSecurityContext securityContext: SecurityContext,


): List<QueryOrderResponse> {
val internalSymbol = symbolMapper.toInternalSymbol(symbol) ?: throw OpexError.SymbolNotFound.exception()
return queryHandler.allOrders(principal, internalSymbol, startTime, endTime, limit).map {
return queryHandler.allOrders(securityContext.jwtAuthentication().tokenValue(), internalSymbol, startTime, endTime, limit).map {
it.asQueryOrderResponse().apply { symbol?.let { s -> this.symbol = s } }
}
}
Expand Down Expand Up @@ -351,11 +356,12 @@ class AccountController(
@RequestParam(required = false)
recvWindow: Long?, //The value cannot be greater than 60000
@RequestParam
timestamp: Long
timestamp: Long,
@CurrentSecurityContext securityContext: SecurityContext,
): List<TradeResponse> {
val internalSymbol = symbolMapper.toInternalSymbol(symbol) ?: throw OpexError.SymbolNotFound.exception()

return queryHandler.allTrades(principal, internalSymbol, fromId, startTime, endTime, limit)
return queryHandler.allTrades(securityContext.jwtAuthentication().tokenValue(), internalSymbol, fromId, startTime, endTime, limit)
.map {
TradeResponse(
symbol ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Response body:
@CurrentSecurityContext securityContext: SecurityContext
): CancelOrderResponse {
if (orderId == null && origClientOrderId == null) throw OpexError.BadRequest.exception("'orderId' or 'origClientOrderId' must be sent")
val order = queryHandler.queryOrder(principal, symbol, orderId, origClientOrderId)
val order = queryHandler.queryOrder(securityContext.jwtAuthentication().tokenValue(), symbol, orderId, origClientOrderId)
?: throw OpexError.OrderNotFound.exception()
val response = CancelOrderResponse(
symbol,
Expand Down Expand Up @@ -323,8 +323,9 @@ Response body:
]
)
suspend fun queryOrder(

@Parameter(hidden = true)
principal: Principal,
@CurrentSecurityContext securityContext: SecurityContext,

@Parameter(
name = "symbol",
Expand Down Expand Up @@ -353,7 +354,7 @@ Response body:
)
@RequestParam(required = false) origClientOrderId: String?,
): QueryOrderResponse {
return queryHandler.queryOrder(principal, symbol, orderId, origClientOrderId)
return queryHandler.queryOrder(securityContext.jwtAuthentication().tokenValue(), symbol, orderId, origClientOrderId)
?.asQueryOrderResponse()
?.apply { this.symbol = symbol }
?: throw OpexError.OrderNotFound.exception()
Expand Down Expand Up @@ -394,7 +395,7 @@ Response body:
)
suspend fun fetchOpenOrders(
@Parameter(hidden = true)
principal: Principal,
@CurrentSecurityContext securityContext: SecurityContext,

@Parameter(
name = "symbol",
Expand All @@ -414,7 +415,7 @@ Response body:
)
@RequestParam(required = false) limit: Int?
): List<QueryOrderResponse> {
return queryHandler.openOrders(principal, symbol, limit).map {
return queryHandler.openOrders(securityContext.jwtAuthentication().tokenValue(), symbol, limit).map {
it.asQueryOrderResponse().apply { symbol?.let { s -> this.symbol = s } }
}
}
Expand Down
Loading
Loading