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 ConfigLoader

From Leeroopedia


Knowledge Sources
Domains Frontend, Configuration, YAML
Last Updated 2026-02-09 14:00 GMT

Overview

Frontend JavaScript class that loads and provides access to the YAML-based dashboard configuration, including market definitions, agent lists, and display settings.

Description

The ConfigLoader class is a singleton configuration manager for the AI Trader web dashboard. It loads config.yaml via HTTP fetch and the js-yaml library, then exposes typed accessor methods for market configs, agent lists, benchmark settings, chart parameters, UI settings, and cache settings. It supports multi-market configurations with per-market agent lists and display options. The global instance is created as window.configLoader and must be loaded before other frontend modules.

Usage

Include this script first among the dashboard JavaScript files. Other modules (DataLoader, AssetChart, PortfolioPage, TransactionLoader) access it via window.configLoader.

Code Reference

Source Location

Signature

class ConfigLoader {
    constructor()
    async loadConfig()                           // Fetch and parse config.yaml
    getEnabledAgents(marketId = null)            // Get enabled agent list for market
    getAgentFolders(marketId = null)             // Get agent folder names
    getAgentConfig(folderName, marketId = null)  // Get single agent config
    getDisplayName(folderName, marketId = null)  // Get agent display name
    getIcon(folderName, marketId = null)         // Get agent icon path
    getColor(folderName, marketId = null)        // Get agent theme color
    getBenchmarkConfig()                         // Get benchmark display settings
    getDataPath()                                // Get base data directory path
    getPriceFilePrefix()                         // Get price file naming prefix
    getBenchmarkFile()                           // Get benchmark data filename
    getChartConfig()                             // Get Chart.js display settings
    getUIConfig()                                // Get UI settings (initial value, date formats)
    getCacheConfig()                             // Get cache settings (enabled, max age)
    isAgentEnabled(folderName)                   // Check if agent is enabled
    getAllAgents()                                // Get all agents including disabled
    getMarketConfig(marketId)                    // Get full config for a market
    getEnabledMarkets()                          // Get all enabled market configs
}

// Global instance
window.configLoader = new ConfigLoader();

Import

<script src="https://cdn.jsdelivr.net/npm/js-yaml/dist/js-yaml.min.js"></script>
<script src="assets/js/config-loader.js"></script>

I/O Contract

Inputs

Name Type Required Description
config.yaml YAML file Yes Dashboard configuration served via HTTP
js-yaml Library Yes YAML parser loaded in global scope

Outputs

Name Type Description
config Object Parsed YAML configuration tree
window.configLoader ConfigLoader Global singleton instance for other modules

Usage Examples

// Wait for config to load
const config = await window.configLoader.loadConfig();

// Get US market agents
const usAgents = window.configLoader.getEnabledAgents("us");
console.log("US agents:", usAgents.map(a => a.display_name));

// Get chart settings
const chartConfig = window.configLoader.getChartConfig();
console.log("Default scale:", chartConfig.default_scale);

// Get market config
const cnMarket = window.configLoader.getMarketConfig("cn");
console.log("CN benchmark:", cnMarket.benchmark_display_name);

Related Pages

Page Connections

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