Transaction history and audit trail. List, get, stream transactions with pagination and filtering.
List transactions with pagination and filtering.
list(
accountID: string,
queryParams: {
from?: string;
to?: string;
pageSize?: number; // default 100, max 1000
type?: string[];
},
responseHandler: (response: Response) => void
): void;Response: { from: string, to: string, pageSize: number, count: number, pages: number, lastTransactionID: string }
Note: Returns pagination info, not actual transactions. Use range() or since() to get transaction objects.
Get specific transaction details.
get(accountID: string, transactionID: string, responseHandler: (response: Response) => void): void;Response: { transaction: Transaction, lastTransactionID: string }
Get transactions within an ID range.
range(
accountID: string,
queryParams: {
from: string;
to: string;
type?: string[];
},
responseHandler: (response: Response) => void
): void;Response: { transactions: Transaction[], lastTransactionID: string }
Get transactions after a specific transaction ID.
since(
accountID: string,
queryParams: {
id: string;
type?: string[];
},
responseHandler: (response: Response) => void
): void;Response: { transactions: Transaction[], lastTransactionID: string }
Example:
ctx.transaction.since(accountID, { id: lastTransactionID }, (response) => {
if (response.isSuccess()) {
response.body.transactions.forEach(tx => {
console.log(tx.type, tx.id);
});
lastTransactionID = response.body.lastTransactionID;
}
});Stream real-time transactions.
stream(
accountID: string,
streamChunkHandler: (chunk: Transaction | TransactionHeartbeat) => void,
responseHandler: (response: Response) => void
): void;Example:
ctx.transaction.stream(accountID, (chunk) => {
if (chunk.type === 'HEARTBEAT') {
console.log('Heartbeat:', chunk.time);
} else {
console.log('Transaction:', chunk.type, chunk.id);
if (chunk.type === 'ORDER_FILL') {
console.log('Fill:', chunk.units, chunk.instrument, chunk.pl);
}
}
}, (response) => {
if (response.isError()) {
console.error('Stream error:', response.statusMessage);
}
});CREATE - Account creationCLOSE - Account closureREOPEN - Account reopeningCLIENT_CONFIGURE - Configuration changeCLIENT_CONFIGURE_REJECT - Configuration rejectionTRANSFER_FUNDS - Funds deposit/withdrawalTRANSFER_FUNDS_REJECT - Transfer rejectionMARKET_ORDER / MARKET_ORDER_REJECTFIXED_PRICE_ORDERLIMIT_ORDER / LIMIT_ORDER_REJECTSTOP_ORDER / STOP_ORDER_REJECTMARKET_IF_TOUCHED_ORDER / MARKET_IF_TOUCHED_ORDER_REJECTTAKE_PROFIT_ORDER / TAKE_PROFIT_ORDER_REJECTSTOP_LOSS_ORDER / STOP_LOSS_ORDER_REJECTTRAILING_STOP_LOSS_ORDER / TRAILING_STOP_LOSS_ORDER_REJECTORDER_FILL - Order filledORDER_CANCEL - Order cancelledORDER_CANCEL_REJECT - Cancellation rejectedORDER_CLIENT_EXTENSIONS_MODIFY / ORDER_CLIENT_EXTENSIONS_MODIFY_REJECTTRADE_CLIENT_EXTENSIONS_MODIFY / TRADE_CLIENT_EXTENSIONS_MODIFY_REJECTMARGIN_CALL_ENTER - Entered margin callMARGIN_CALL_EXTEND - Margin call extendedMARGIN_CALL_EXIT - Exited margin callDELAYED_TRADE_CLOSURE - Trade closure delayedDAILY_FINANCING - Daily financing charge/creditRESET_RESETTABLE_PL - P/L resetAll transactions extend:
interface Transaction {
id: string;
time: string;
userID: number;
accountID: string;
batchID: string;
requestID: string;
type: string;
}interface OrderFillTransaction extends Transaction {
type: 'ORDER_FILL';
orderID: string;
clientOrderID?: string;
instrument: string;
units: string;
price?: string;
fullPrice?: ClientPrice;
reason: string;
pl: string;
financing: string;
commission: string;
guaranteedExecutionFee: string;
accountBalance: string;
tradeOpened?: TradeOpen;
tradesClosed?: TradeReduce[];
tradeReduced?: TradeReduce;
halfSpreadCost: string;
}interface MarketOrderTransaction extends Transaction {
type: 'MARKET_ORDER';
instrument: string;
units: string;
timeInForce: string;
priceBound?: string;
positionFill: string;
reason: string;
// ... order details
}interface DailyFinancingTransaction extends Transaction {
type: 'DAILY_FINANCING';
financing: string;
accountBalance: string;
accountFinancingMode: string;
positionFinancings?: PositionFinancing[];
}interface TransactionHeartbeat {
type: 'HEARTBEAT';
time: string;
}interface ClientExtensions {
id?: string;
tag?: string;
comment?: string;
}interface TradeOpen {
tradeID: string;
units: string;
price: string;
guaranteedExecutionFee: string;
clientExtensions?: ClientExtensions;
halfSpreadCost: string;
initialMarginRequired: string;
}interface TradeReduce {
tradeID: string;
units: string;
price: string;
realizedPL: string;
financing: string;
guaranteedExecutionFee: string;
halfSpreadCost: string;
}interface PositionFinancing {
instrument: string;
financing: string;
openTradeFinancings?: OpenTradeFinancing[];
}ctx.transaction.list(accountID, { pageSize: 100 }, (response) => {
if (response.isSuccess()) {
console.log('Transaction count:', response.body.count);
} else if (response.isClientError()) {
console.error('Client error:', response.body.errorCode);
}
});