API Reference
Comprehensive API documentation for FinWorld's seven-layer architecture and core modules.
Architecture Overview
FinWorld follows a seven-layer architecture design, where each layer has clear responsibilities and functional boundaries. All components are registered in the global registry and can be referenced by their type field in configuration files.
1. Configuration Layer
Built on top of mmengine, providing a unified and extensible configuration system based on Python dictionaries.
Registry System
All components are registered under global registries:
DATASET- Dataset registriesENVIRONMENT- Environment registriesMODEL- Model registriesAGENT- Agent registriesLOSS- Loss function registriesMETRIC- Metric registriesOPTIMIZER- Optimizer registriesSCHEDULER- Scheduler registriesTRAINER- Trainer registriesTASK- Task registries
GitHub: finworld/registry.py
Configuration Files
Task-specific configuration files organized by functionality:
Asset Lists- Predefined asset collections (DJ30, SP500, NASDAQ100, HS300, SSE50)Agent Configs- AI agent configurations for financial decision makingDownload Configs- Data download configurations for multiple sourcesFinReasoner Configs- Financial reasoning model configurationsML Portfolio Configs- Machine learning portfolio management configurationsML Trading Configs- Machine learning trading strategy configurationsProcess Configs- Data processing and feature engineering configurationsRL Portfolio Configs- Reinforcement learning portfolio optimization configurationsRL Trading Configs- Reinforcement learning trading agent configurationsRule Portfolio Configs- Rule-based portfolio strategy configurationsRule Trading Configs- Rule-based trading strategy configurationsStorm Configs- Storm framework configurations for financial AITime Series Configs- Time series forecasting model configurationsVAE Configs- Variational autoencoder configurations
GitHub: configs/
2. Data Layer
Comprises multiple functional modules for standardized, extensible, and task-oriented data management.
Downloader Module
Unified interface for heterogeneous financial data providers:
PriceDownloader- Unified market data downloader supporting multiple financial data sources and formatsNewsDownloader- Financial news data downloader with sentiment analysis and text processing capabilitiesSymbolInfoDownloader- Symbol information downloader for fetching comprehensive asset metadataFMPPriceDownloader- Financial Modeling Prep API downloader for comprehensive US market dataFMPNewsDownloader- FMP news data downloader with financial sentiment analysisFMPSymbolInfoDownloader- FMP symbol information downloader for asset metadataAlpacaPriceDownloader- Alpaca API downloader for real-time and historical US market dataAlpacaNewsDownloader- Alpaca news data downloader for financial market informationAkSharePriceDownloader- AkShare downloader for Chinese market data and financial informationAkShareNewsDownloader- AkShare news downloader for Chinese financial news and analysisTuSharePriceDownloader- TuShare downloader for Chinese financial data and research toolsTuShareNewsDownloader- TuShare news downloader for Chinese financial news and market analysis
GitHub: finworld/downloader/
Processor Module
Configurable preprocessing pipelines for numerical and textual data:
Processor- Main processor class with unified interface for multiple data sourcesAggProcessor- Aggregation processor for combining multiple data processing pipelinesLLMProcessor- LLM data processor for natural language processing tasksFMPPriceProcessor- FMP price data processor with financial data preprocessingFMPNewsProcessor- FMP news data processor with text preprocessing and sentiment analysisFMPFeatureProcessor- FMP feature engineering processor for technical indicatorsAlpacaPriceProcessor- Alpaca price data processor for US market dataAlpacaNewsProcessor- Alpaca news data processor for financial news analysisAlpacaFeatureProcessor- Alpaca feature engineering processor for market indicatorsAkSharePriceProcessor- AkShare price data processor for Chinese market dataAkShareNewsProcessor- AkShare news data processor for Chinese financial newsAkShareFeatureProcessor- AkShare feature engineering processor for Chinese market indicatorsTuSharePriceProcessor- TuShare price data processor for Chinese financial dataTuShareNewsProcessor- TuShare news data processor for Chinese financial newsTuShareFeatureProcessor- TuShare feature engineering processor for Chinese market analysis
GitHub: finworld/processor/
Dataset Module
Task-specific datasets for machine learning:
SingleAssetDataset- Single asset datasets with price, feature, and news data integrationMultiAssetDataset- Multi-asset datasets with cross-asset relationships and portfolio managementDataLoader- Custom data loading utilities with batch processing and collationSingleAssetPriceTextCollateFn- Collate function for single asset price and text data batchingMultiAssetPriceTextCollateFn- Collate function for multi-asset price and text data batching
GitHub: finworld/data/
Environment Module
Interactive environments for reinforcement learning:
EnvironmentGeneralTrading- General-purpose trading environment with realistic market simulation and transaction costsEnvironmentGeneralPortfolio- Multi-asset portfolio management environment with risk constraints and rebalancingEnvironmentLLMTrading- LLM-powered trading environment with natural language processing and reasoningEnvironmentAgentTrading- Agent-based trading environment with multi-agent collaboration and coordinationEnvironmentPatchTrading- Patch-based trading environment for transformer models with attention mechanismsEnvironmentSequenceTrading- Sequence-based trading environment for recurrent neural network modelsEnvironmentPatchPortfolio- Patch-based portfolio environment for transformer models with multi-asset attentionEnvironmentAgentTradingWrapper- Wrapper for agent-based trading environment with gym interfaceEnvironmentSequenceTradingWrapper- Wrapper for sequence-based trading environment with gym interfaceEnvironmentPatchTradingWrapper- Wrapper for patch-based trading environment with gym interfaceEnvironmentPatchPortfolioWrapper- Wrapper for patch-based portfolio environment with gym interface
GitHub: finworld/environment/
3. Model Layer
Specialized modules supporting unified definition and management of heterogeneous modeling paradigms.
Embedding Components
Data embedding for financial time series:
PatchEmbed- Converts time series data into patch-based embeddings for transformer modelsDataEmbed- General-purpose data embedding layer for financial time series processingTradingDataEmbed- Specialized embedding for trading data with market-specific featuresPortfolioDataEmbed- Multi-asset portfolio embedding with cross-asset relationshipsAbsPosition1DEmbed- Absolute positional encoding for one-dimensional time series dataAbsPosition2DEmbed- Absolute positional encoding for two-dimensional data structuresSinCosPosition1DEmbed- Sinusoidal positional encoding with sine and cosine functionsSinCosPosition2DEmbed- Two-dimensional sinusoidal positional encoding for complex data structuresDenseLinearEmbed- Linear embedding for dense input data with dropout supportDenseConv1dEmbed- 1D convolutional embedding for sequential data processingSparseEmbed- Sparse embedding for categorical and discrete featuresTimeSparseEmbed- Time-aware sparse embedding for temporal categorical dataTimeDenseEmbed- Time-aware dense embedding for temporal continuous dataAggEmbed- Aggregation embedding for multi-scale feature representationAggDataEmbed- Aggregated data embedding for multi-level feature extractionTimePatchEmbed- Time-aware patch embedding for temporal patch-based modelsTradingPatchEmbed- Trading-specific patch embedding for market data patchesPortfolioPatchEmbed- Portfolio-specific patch embedding for multi-asset patchesFactorVAEEmbed- Factor VAE embedding for disentangled representation learning
GitHub: finworld/models/embed/
Encoder Components
Encoder architectures for financial data:
TransformerEncoder- Standard transformer encoder with self-attention mechanisms for financial dataVAELSTMEncoder- Variational autoencoder with LSTM backbone for time series representation learningAutoformerEncoder- Autoformer encoder with decomposition-based attention for long-term forecastingCrossformerEncoder- Crossformer encoder with two-stage attention for multivariate time seriesEtsformerEncoder- ETSformer encoder with exponential smoothing for trend and seasonal components
GitHub: finworld/models/encoder/
Decoder Components
Decoder architectures for financial predictions:
TransformerDecoder- Standard transformer decoder with cross-attention for financial prediction tasksVAELSTMDecoder- Variational autoencoder decoder with LSTM for time series generation and reconstructionAutoformerDecoder- Autoformer decoder with decomposition-based attention for long-term financial forecastingCrossformerDecoder- Crossformer decoder with two-stage attention for multivariate time series predictionEtsformerDecoder- ETSformer decoder with exponential smoothing for trend and seasonal forecasting
GitHub: finworld/models/decoder/
Model Components
Complete model implementations:
Model- Base model class with common initialization and weight management for all FinWorld modelsTransformerVAE- Transformer-based variational autoencoder for financial time series generation and representationVQVAE- Vector Quantized Variational Autoencoder with discrete latent representations for financial dataDiT- Diffusion Transformer for financial time series generation with denoising diffusion processesClipTextEncoder- CLIP-based text encoder for multimodal financial data processing and understanding
GitHub: finworld/models/
4. Training Layer
Modular scaffold for optimizing all method pipelines for financial applications.
Optimizer
First-order optimization methods:
Adam- Adam optimizer with adaptive learning ratesAdamW- AdamW optimizer with weight decay regularizationSGD- Stochastic gradient descent with momentum
GitHub: finworld/optimizer/
Loss Functions
Objective functions for financial tasks:
MSELoss- Mean squared error loss for regression tasksMAELoss- Mean absolute error loss for robust regressionVAELoss- Variational autoencoder loss for generative modelingVQVAELoss- Vector quantized VAE loss for discrete representationsFactorVAELoss- Factor VAE loss for disentangled representationsPriceLoss- Price prediction loss for financial forecasting
GitHub: finworld/loss/
Scheduler
Learning rate scheduling strategies:
CosineWithWarmupScheduler- Cosine annealing with warmup for stable trainingLinearWithWarmupScheduler- Linear decay with warmup for gradual learning rate reductionConstantWithWarmupScheduler- Constant learning rate with warmup for stable training
GitHub: finworld/scheduler/
Trainer
Training orchestration and control:
BaseTrainer- Base trainer class with common training utilitiesForecastingTrainer- Time series forecasting trainer with specialized metricsVAETrainer- Variational autoencoder trainer for generative modelingVQVAETrainer- Vector quantized VAE trainer for discrete representationsDualVQVAETrainer- Dual VQVAE trainer for multi-modal financial dataFactorVAETrainer- Factor VAE trainer for disentangled representationsSingleVQVAETrainer- Single VQVAE trainer for single-asset modelingDynamicSingleVQVAETrainer- Dynamic single VQVAE trainer with adaptive learningDynamicDualVQVAETrainer- Dynamic dual VQVAE trainer for complex financial dataFinanceAgentTrainer- Financial agent trainer for LLM-based tradingMLTradingTrainer- Machine learning trading trainer for supervised learningMLPortfolioTrainer- Machine learning portfolio trainer for multi-asset optimizationPPOTradingTrainer- PPO reinforcement learning trainer for tradingPPOPortfolioTrainer- PPO reinforcement learning trainer for portfolio managementSACTradingTrainer- SAC reinforcement learning trainer for tradingSACPortfolioTrainer- SAC reinforcement learning trainer for portfolio managementRuleTradingTrainer- Rule-based trading trainer for traditional strategiesRulePortfolioTrainer- Rule-based portfolio trainer for traditional allocation
GitHub: finworld/trainer/
5. Evaluation Layer
Unified, extensible, and highly modular evaluation system for financial AI tasks.
Metrics
Financial-specific evaluation metrics:
ARR- Annualized rate of return for financial performance evaluationSR- Sharpe ratio for risk-adjusted return measurementAccuracy- Classification accuracy for trading signal evaluationF1Score- F1 score for balanced precision and recall evaluationMSE- Mean squared error for regression task evaluationMAE- Mean absolute error for robust regression evaluationPrecision- Precision metric for classification performanceRecall- Recall metric for classification sensitivityAUC- Area under the ROC curve for binary classificationRANKIC- Rank information coefficient for factor analysisRANKICIR- Rank information coefficient information ratioMDD- Maximum drawdown for risk assessmentCR- Calmar ratio for risk-adjusted performanceDD- Drawdown duration for risk analysisSOR- Sortino ratio for downside risk assessmentVOL- Volatility metric for risk measurementHitRatio- Hit ratio for trading signal accuracy
GitHub: finworld/metric/
Plot
Advanced visualization tools:
PlotProKline- Professional candlestick charts for financial data visualizationPlotCurve- Cumulative return curves for performance trackingPlotCompass- Compass plots for multi-dimensional financial metricsPlotStar- Star plots for portfolio performance visualizationPlotSunBurst- Sunburst diagrams for hierarchical financial dataPlotLLMScore- LLM score visualization for language model evaluation
GitHub: finworld/plot/
6. Task Layer
Systematic definition, abstraction, and encapsulation of financial AI task types.
Task Classes
Core task execution framework:
Task- Synchronous task execution with trainer integrationAsyncTask- Asynchronous task execution for concurrent processingTaskType- Enum defining supported task types (forecasting, trading, portfolio, etc.)
GitHub: finworld/task/
7. Presentation Layer
Automated and multi-modal dissemination of experimental results.
Output Formats
Multi-modal result presentation:
HTML- Web page generationLaTeX- Technical report generationPDF- PDF report generationPNG- Figure generationCSV- Table exportJSON- Artifact export
GitHub: finworld/
Other Modules
Additional supporting modules and utilities.
Tools Module
Utility tools and functions:
Tool- Base tool class for all utility toolsDefaultTools- Default set of financial analysis toolsDeepAnalyzer- Deep analysis tool for complex financial dataDeepResearcher- Research tool for financial market investigationPlanningTool- Strategic planning tool for financial decisionsPythonInterpreter- Python code execution tool for financial calculationsWebFetcher- Web data fetching tool for financial informationWebSearcher- Web search tool for financial news and dataFileReader- File reading tool for financial documentsArchiveSearcher- Archive search tool for historical financial dataCustomBrowser- Custom browser tool for web automationAutoBrowser- Automated browser tool for financial data collectionFinalAnswer- Final answer tool for result presentationToolValidation- Tool validation for ensuring correct usageSearchBase- Base search tool for web search functionalityGoogleSearch- Google search tool for financial informationBingSearch- Bing search tool for financial dataDuckDuckGoSearch- DuckDuckGo search tool for privacy-focused searchesBaiduSearch- Baidu search tool for Chinese financial dataLocalPythonExecutor- Local Python code executor for financial calculationsRemoteExecutors- Remote code executor for distributed computingMarkdownConverter- Markdown conversion tool for document formatting
GitHub: finworld/tools/
Memory Module
Memory management for agents:
AgentMemory- Main agent memory class for managing conversation history and stepsMemoryStep- Base class for all memory step types with message conversionActionStep- Memory step for agent actions with tool calls and observationsPlanningStep- Memory step for agent planning and strategy formulationTaskStep- Memory step for task initialization and user prompts
GitHub: finworld/memory/
Getting Started
To get started with FinWorld's API, check out our documentation and task examples.