Skip to navigation

Perpetual Positions

Perpetual Positions: 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.*;

listCurrentPerpetualPositions

Request model: CurrentPerpetualPositionsRequest.

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

Request fields

FieldJava typeRequiredMeaning
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.

listPerpetualPositionHistory

Request model: PerpetualPositionHistoryRequest.

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

Request fields

FieldJava typeRequiredMeaning
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.
positionSideStringNoFilter using the source position-side enum.
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.

Positions: Current and Historical

data fieldtypeCurrent positionHistorical positionsmeaning
positionIdstringsupplysupplyPosition ID, corresponding to entityId
symbolstringsupplysupplytrading pair
positionSidestringsupplysupplyLONG / SHORT / BOTH and other position directions
statusstringsupplysupplyString with the numerical status of the position, see the query overview
leverageintegersupplysupplyLeverage multiple
marginModestringsupplysupplyNumeric enumeration string “1” for full position, “2” for isolated position
quantitystringsupplyNot availableCurrent position quantity
entryPricestringsupplysupplyAverage opening price of stored positions
marginstringsupplyNot availableThe current position margin amount, not the user’s entire contract wallet balance
maxQuantitystringNot availablesupplyThe maximum number of positions recorded in this historical position
closeQuantitystringNot availablesupplyThe cumulative number of positions closed during the historical position life cycle
closePricestringNot availablesupplyStored average closing price
pnlstringNot availablesupplyHistorical position profit and loss; do not combine it with the transaction realizedPnl to simply repeat and accumulate
roestringNot availablesupplyThe proportional value of historical position return, not multiplied by 100; for example, "0.043" represents 4.3%, "-0.05" represents -5%
fundingFeeAccumstringsupplysupplyAccumulated funding fee, retaining source symbol and accuracy
openedAtintegersupplysupplyPosition opening time, milliseconds
updatedAtintegersupplyNot availableCurrent position update time, milliseconds
closedAtintegerNot availablesupplyClosing time, milliseconds; use this field to filter historical position time

The calculation caliber of history roe is pnl / (entryPrice × maxQuantity / leverage), and the interface directly returns the saved proportion value. When displaying the percentage, use decimal operation and multiply by 100, then add %; the denominator uses the nominal margin of the historical position record, not the account wallet balance. When the opening price or maximum position quantity is 0, the leverage is invalid, etc. and cannot be calculated, the source is saved as 0. Therefore, it cannot be inferred that the profit or loss is 0 just based on roe=0.

The current position does not have real-time mark price, real-time floating profit and loss, real-time ROE or real-time liquidation price. It reflects the stored position status and cannot use the update time and margin fields to claim the current real-time risk control results.

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}}