Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:HKUDS AI Trader TransactionLoader

From Leeroopedia


Knowledge Sources
Domains Frontend, Transaction_Display, Leaderboard
Last Updated 2026-02-09 14:00 GMT

Overview

Frontend JavaScript class that loads transaction history and builds agent leaderboard data for the AI Trader web dashboard.

Description

The TransactionLoader class parses position JSONL logs from all enabled agents to extract trade transactions (buy/sell actions with non-zero amounts). It provides sorted transaction feeds, agent thinking/reasoning retrieval from log files, and a leaderboard builder that ranks agents by final portfolio value. The class includes formatting utilities for currency, percentages, and action icons. The global instance is exposed as window.transactionLoader.

Usage

Include this script on dashboard pages that display transaction feeds or agent rankings. It requires window.configLoader and window.dataLoader to be initialized first.

Code Reference

Source Location

Signature

class TransactionLoader {
    constructor()
    async loadAllTransactions()                      // Load transactions from all agents
    async loadAgentTransactions(agentFolder, market)  // Load transactions for one agent
    async loadAgentThinking(agentFolder, date, market) // Load agent reasoning from logs
    async buildLeaderboard(allAgentsData)             // Build ranked agent leaderboard
    getMostRecentTransactions(n = 100)                // Get top N most recent transactions
    formatCurrency(value)                             // Format number as USD currency
    formatPercent(value)                              // Format number as signed percentage
    formatDateTime(dateStr)                           // Format date string for display
    getActionIcon(action)                             // Get emoji icon for buy/sell
    getActionColor(action)                            // Get CSS color for buy/sell
}

// Global instance
window.transactionLoader = new TransactionLoader();

Import

<script src="assets/js/transaction-loader.js"></script>

I/O Contract

Inputs

Name Type Required Description
window.configLoader ConfigLoader Yes Agent list and market configuration
window.dataLoader DataLoader Yes Market state and data paths
position.jsonl JSONL files Yes Agent position logs served via HTTP
log/{date}/log.jsonl JSONL files No Agent reasoning logs (optional)

Outputs

Name Type Description
allTransactions Array Sorted array of trade objects {agentFolder, date, action, symbol, amount, ...}
leaderboardData Array Ranked array of {agentName, displayName, currentValue, gain, gainPercent, rank}

Usage Examples

const txLoader = window.transactionLoader;

// Load all transactions across agents
const transactions = await txLoader.loadAllTransactions();
console.log(`Total trades: ${transactions.length}`);

// Get recent trades
const recent = txLoader.getMostRecentTransactions(10);
recent.forEach(tx => {
    console.log(`${tx.date}: ${tx.action} ${tx.amount} ${tx.symbol} (${tx.agentFolder})`);
});

// Build leaderboard
const leaderboard = await txLoader.buildLeaderboard(allAgentsData);
leaderboard.forEach(entry => {
    console.log(`#${entry.rank} ${entry.displayName}: ${txLoader.formatCurrency(entry.currentValue)}`);
});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment