Skip to navigation

Perpetual Orders

Perpetual Orders: Agent Java SDK v0.3.0 integration, examples, parameters and response semantics.

View as Markdown

This guide targets Agent Java SDK v0.3.0, Java 8+, and the tagged public contract. Examples run in a partner backend after initializing client in Quick Start.

Example prerequisites

The Java snippets share these imports. Initialize client using Quick Start and obtain platformUserId from the saved binding. Example user/order IDs must be replaced with your own persisted values.

import com.sixmm.agent.*;
import com.sixmm.agent.model.*;
import java.util.*;

listCurrentPerpetualOrders

Request model: CurrentPerpetualOrdersRequest.

import com.sixmm.agent.model.CurrentPerpetualOrdersRequest;
import com.sixmm.agent.model.PerpetualResponse;
import java.util.Collections;
CurrentPerpetualOrdersRequest request = new CurrentPerpetualOrdersRequest();
request.platformUserIds = Collections.singletonList("1188041528");
request.limit = 100;
request.orderCategory = "NORMAL";
request.symbol = "BTCUSDT";
PerpetualResponse response = client.listCurrentPerpetualOrders(request);
System.out.println(response.data.items.size());
System.out.println(response.data.hasMore);
System.out.println(response.data.nextCursor);

Request fields

FieldJava typeRequiredMeaning
orderCategoryStringYesNORMAL or CONDITIONAL; conditional queries require explicit users.
platformUserIdsjava.util.List<String>Conditional1–100 unique public IDs; required for fills and conditional orders. Omit on supported queries for direct-player scope; [] is invalid.
symbolStringNoOptional trading-pair filter.
limitIntegerNoDefault 500; 1–1000.
cursorStringNoUse the returned nextCursor with unchanged filters; stop when hasMore is false.

The example reads one page. For required fields, player scope, filter semantics, limit, cursor and bounded retries, follow Query overview. Keep all filters unchanged while paging; do not interpret an error as an empty result.

listPerpetualOrderHistory

Request model: PerpetualOrderHistoryRequest.

import com.sixmm.agent.model.PerpetualOrderHistoryRequest;
import com.sixmm.agent.model.PerpetualResponse;
import java.util.Collections;
PerpetualOrderHistoryRequest request = new PerpetualOrderHistoryRequest();
request.platformUserIds = Collections.singletonList("1188041528");
request.limit = 100;
request.orderCategory = "NORMAL";
request.symbol = "BTCUSDT";
request.endTime = System.currentTimeMillis();
request.startTime = request.endTime - 3_600_000L;
PerpetualResponse response = client.listPerpetualOrderHistory(request);
System.out.println(response.data.items.size());
System.out.println(response.data.hasMore);
System.out.println(response.data.nextCursor);

Request fields

FieldJava typeRequiredMeaning
orderCategoryStringYesNORMAL or CONDITIONAL; conditional queries require explicit users.
platformUserIdsjava.util.List<String>Conditional1–100 unique public IDs; required for fills and conditional orders. Omit on supported queries for direct-player scope; [] is invalid.
symbolStringNoOptional trading-pair filter.
orderIdStringNoOrdinary order ID; not a partner transfer order number.
conditionIdStringNoConditional order ID; do not mix with orderId.
clientOrderIdStringNoTrading client order reference, not agentOrderNo.
sideStringNoBUY / SELL filter.
statusStringNoResource-specific status; see the status reference.
startTimeLongNoInclusive Unix milliseconds; use a fixed UTC history window.
endTimeLongNoExclusive Unix milliseconds.
limitIntegerNoDefault 500; 1–1000.
cursorStringNoUse the returned nextCursor with unchanged filters; stop when hasMore is false.

The example reads one page. For required fields, player scope, filter semantics, limit, cursor and bounded retries, follow Query overview. Keep all filters unchanged while paging; do not interpret an error as an empty result.

Ordinary orders: current and history

Current: orders/current + orderCategory=NORMAL; History: orders/history + orderCategory=NORMAL.

data fieldtypeMeaning and scope of application
symbolstringTrading pair, such as BTCUSDT
orderIdstringPlatform ordinary order ID
orderCategorystringFixed NORMAL
clientOrderIdstringClient order number provided by the transaction order source; not the same field as merchant fund transfer agentOrderNo
orderTypestringDelegate type, such as LIMIT, MARKET; the actual enumeration value shall prevail
sidestringBuying and selling direction BUY / SELL
statusstringOrdinary order status, see the query overview
timeInForcestringValidity period/deal execution strategy, such as GTC, IOC, FOK; interpreted according to actual values
pricestringEntrusted price; it may be omitted when no price is provided, and the market transaction price will not be supplemented by oneself.
quantitystringOriginal order quantity
filledQuantitystringTransaction quantity
remainingQuantitystringUntransacted quantity; the current query takes quantity − filledQuantity, and the historical query takes the historical record value
avgFilledPricestringThe average transaction price of the completed part; there may be no value when it is not completed
reduceOnlybooleanWhether to only reduce positions
closeOnlybooleanWhether it is only used to close positions
makerOnlybooleanWhether to execute only as Maker
leverageintegerLeverage multiple; Historical ordinary order has a source, and the current ordinary order does not create this value
marginModestringMargin mode; Historical ordinary order currently returns a numerical enumeration string, such as “1”, “2”; current ordinary order is not provided
createdAtintegerOrder creation time, milliseconds; use this field to filter historical order time
updatedAtintegerDelegate record update time, milliseconds

The order history includes terminated ordinary orders. Each record cannot be regarded as fully completed based on the interface name alone. The current order page is a current status query, not a order event stream.

Conditional orders: current and history

Current: orders/current + orderCategory=CONDITIONAL; History: orders/history + orderCategory=CONDITIONAL. Both require explicit platformUserIds.

data fieldtypemeaning
symbolstringtrading pair
conditionIdstringConditional orders ID, independent from ordinary orderId
orderCategorystringFixed CONDITIONAL
generatedOrderIdstringOrdinary order ID generated after triggering; may be omitted if not generated
clientOrderIdstringThe client order number of conditional orders, output when it exists
sidestringBUY / SELL
orderTypestringPost-trigger order type, interpreted according to actual value
triggerTypestringTrigger rule type, explained by actual source enumeration
workingTypestringJob type/price source that triggers price, interpreted as actual enumeration
timeInForcestringValidity period/execution strategy of the order after triggering
pricestringThe order price after triggering, output when the source has value
quantitystringConditional order quantity
triggerPricestringtrigger price
reduceOnlybooleanWhether to only reduce positions
closePositionbooleanWhether to use full position closing semantics, cannot be confused with closeOnly as the same field
leverageintegerLeverage multiple, output when non-zero
marginModestringThis class returns CROSS / ISOLATED, which is a numeric string that is different from ordinary historical orders/positions
statusstringConditional single trigger state, see the query overview
triggerStatusstringThe current implementation uses the same conditional status value as status
createdAtintegerConditional order creation time, milliseconds; historical conditions are filtered by this time
updatedAtintegerUpdate time, output when there is a value, milliseconds
deletedAtintegerDelete mark time, output when there is a value, milliseconds; it is not a unified transaction/cancellation time field

Conditional orders do not provide filledQuantity, remainingQuantity, avgFilledPrice for ordinary orders. If you need the transaction status of ordinary orders after triggering, query ordinary orders/transactions through generatedOrderId, and do not infer the transaction volume from the conditional order status.

Example response envelope

This is an illustrative empty page, not a sample of a completed trade. Resource-specific field tables above describe populated items[].data.

{"code":0,"message":"success","data":{"items":[],"nextCursor":"","hasMore":false}}