or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

account.mdcore.mdindex.mdinstruments.mdorders.mdpositions.mdpricing.mdtrades.mdtransactions.mdusers.md
tile.json

transactions.mddocs/

Transaction History

Transaction history and audit trail. List, get, stream transactions with pagination and filtering.

API Methods

list

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

Get specific transaction details.

get(accountID: string, transactionID: string, responseHandler: (response: Response) => void): void;

Response: { transaction: Transaction, lastTransactionID: string }

range

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 }

since

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

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

Transaction Types

Account Lifecycle

  • CREATE - Account creation
  • CLOSE - Account closure
  • REOPEN - Account reopening
  • CLIENT_CONFIGURE - Configuration change
  • CLIENT_CONFIGURE_REJECT - Configuration rejection
  • TRANSFER_FUNDS - Funds deposit/withdrawal
  • TRANSFER_FUNDS_REJECT - Transfer rejection

Order Transactions

  • MARKET_ORDER / MARKET_ORDER_REJECT
  • FIXED_PRICE_ORDER
  • LIMIT_ORDER / LIMIT_ORDER_REJECT
  • STOP_ORDER / STOP_ORDER_REJECT
  • MARKET_IF_TOUCHED_ORDER / MARKET_IF_TOUCHED_ORDER_REJECT
  • TAKE_PROFIT_ORDER / TAKE_PROFIT_ORDER_REJECT
  • STOP_LOSS_ORDER / STOP_LOSS_ORDER_REJECT
  • TRAILING_STOP_LOSS_ORDER / TRAILING_STOP_LOSS_ORDER_REJECT

Order Management

  • ORDER_FILL - Order filled
  • ORDER_CANCEL - Order cancelled
  • ORDER_CANCEL_REJECT - Cancellation rejected
  • ORDER_CLIENT_EXTENSIONS_MODIFY / ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT

Trade Management

  • TRADE_CLIENT_EXTENSIONS_MODIFY / TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT

Risk Management

  • MARGIN_CALL_ENTER - Entered margin call
  • MARGIN_CALL_EXTEND - Margin call extended
  • MARGIN_CALL_EXIT - Exited margin call
  • DELAYED_TRADE_CLOSURE - Trade closure delayed

Accounting

  • DAILY_FINANCING - Daily financing charge/credit
  • RESET_RESETTABLE_PL - P/L reset

Common Transaction Interfaces

Base Transaction

All transactions extend:

interface Transaction {
  id: string;
  time: string;
  userID: number;
  accountID: string;
  batchID: string;
  requestID: string;
  type: string;
}

OrderFillTransaction

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

MarketOrderTransaction

interface MarketOrderTransaction extends Transaction {
  type: 'MARKET_ORDER';
  instrument: string;
  units: string;
  timeInForce: string;
  priceBound?: string;
  positionFill: string;
  reason: string;
  // ... order details
}

DailyFinancingTransaction

interface DailyFinancingTransaction extends Transaction {
  type: 'DAILY_FINANCING';
  financing: string;
  accountBalance: string;
  accountFinancingMode: string;
  positionFinancings?: PositionFinancing[];
}

TransactionHeartbeat

interface TransactionHeartbeat {
  type: 'HEARTBEAT';
  time: string;
}

Supporting Types

ClientExtensions

interface ClientExtensions {
  id?: string;
  tag?: string;
  comment?: string;
}

TradeOpen

interface TradeOpen {
  tradeID: string;
  units: string;
  price: string;
  guaranteedExecutionFee: string;
  clientExtensions?: ClientExtensions;
  halfSpreadCost: string;
  initialMarginRequired: string;
}

TradeReduce

interface TradeReduce {
  tradeID: string;
  units: string;
  price: string;
  realizedPL: string;
  financing: string;
  guaranteedExecutionFee: string;
  halfSpreadCost: string;
}

PositionFinancing

interface PositionFinancing {
  instrument: string;
  financing: string;
  openTradeFinancings?: OpenTradeFinancing[];
}

Error Handling

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