Skip to navigation

Contract Ledger

Contract Ledger: 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.*;

listPerpetualLedger

Request model: PerpetualLedgerRequest.

import com.sixmm.agent.model.PerpetualLedgerRequest;
import com.sixmm.agent.model.PerpetualResponse;
import java.util.Collections;
PerpetualLedgerRequest request = new PerpetualLedgerRequest();
request.platformUserIds = Collections.singletonList("1188041528");
request.limit = 100;
request.endTime = System.currentTimeMillis();
request.startTime = request.endTime - 3_600_000L;
PerpetualResponse response = client.listPerpetualLedger(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.
assetTypeStringNoAsset classification as returned by the ledger; do not assume USDT.
changeTypeStringNoLedger business-change type, preserving source values.
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.

Contract ledger records

Interface: account/ledger. The returned data only contains the following 11 business fields and does not carry the order boolean flags.

data fieldtypemeaning
ledgerIdstringThe source ledger records to the transaction ID; the same transaction may be split into multiple details
symbolstringRelated trading pair, may be omitted if not related
assetTypestringAsset type, saved by source value; used for asset classification, not inferred by default USDT
changeTypestringAccount change business type, saved according to source value, such as handling fee, profit and loss, transfer; can be filtered by the same field
amountstringThe change amount of this detail, a positive number indicates an increase, a negative number indicates a decrease; precision is retained
walletBalanceBeforestringThe wallet balance before the account change recorded in this detail
walletBalanceAfterstringThe wallet balance after the account change recorded in this detail
frozenBalanceBeforestringThe frozen balance recorded before the account change is recorded in this detail
frozenBalanceAfterstringThe frozen balance recorded in this detail after the account change
referenceIdstringAssociated business number; interpreted as changeType and cannot be uniformly regarded as order orderId; “0” indicates that the source does not have a valid associated number
createdAtintegerCreation time of account change details, milliseconds; this field is used for time filtering in this interface

Use the balance before and after the account change returned by the interface. Different changeType have different semantics, and it cannot be assumed that each amount is equal to walletBalanceAfter − walletBalanceBefore. The display/summary of ledger records should retain the type and detail identity.

Here’s an example of the format, using a fictitious ID and amount:

{
"code": 0,
"message": "success",
"data": {
"items": [
{
"platformUserId": "1188041528",
"entityType": "ACCOUNT_LEDGER",
"entityId": "900001",
"data": {
"ledgerId": "ledger-example-001",
"symbol": "BTCUSDT",
"assetType": "USDT",
"changeType": "HANDLING_FEE",
"amount": "-0.10000000",
"walletBalanceBefore": "100.00000000",
"walletBalanceAfter": "99.90000000",
"frozenBalanceBefore": "0.00000000",
"frozenBalanceAfter": "0.00000000",
"referenceId": "800001",
"createdAt": 1791590400000
}
}
],
"nextCursor": "",
"hasMore": false
}
}

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