How fabioavelino/money-printer works
Main Components
• Backtesting Core:
• Files: backtest.js, backtest_v1.js, and the backtest/ directory (with backtest_helper.js and market_data_configs.js) form the core of the backtesting logic.
• Data Input / Market Data Services:
• Directory: services/ – Contains subdirectories for data providers (alphavantage, binance, polygon, tiingo) with their corresponding data handlers and helper modules.
• Data flows from these modules into the backtesting engine.
• Strategy Evaluation:
• Directory: strategies/ – Contains individual trading strategies (e.g., strategies/arima, strategies/hma_kahlman_strategy.js) that implement specific buy/sell logic.
• Signal Generation:
• Directory: signals/ – Contains various signal generation modules (adaptive_zlema_signal.js, macd_signal.js, rsi_signal.js, etc.) that compute indicators and criteria used by the strategies.
• Utility and Helper Functions:
• Directory: helpers/ – Provides utility functions (data manipulation, statistical calculations, ARIMA helper, TensorFlow-related helpers, etc.) that support both strategies and signal processing.
• Portfolio Management:
• Directory: portfolio/ – Implements portfolio evaluation and performance comparison tools, vital for gauging trading strategy outcomes.
• Visualization:
• Files: index.html, htmls/visualizeCharts/ – Although not the primary focus for strategy evaluation, these present the results and analytics in a user-friendly way.
Component Relationships and Data Flow
• Data Collection: Market data is fetched from external providers through the services modules. Each service has data handler modules that “generate” or process the data, which is then passed to the backtesting engine.
• Backtesting Engine: The backtest.js file orchestrates the process by:
• Loading historical market data.
• Invoking the chosen strategy from the strategies/ directory.
• Using signals modules to decide on “buy” or “sell” actions.
• Employing helper utilities to process technical indicators and metrics.
• Strategy Execution: Each strategy (located in strategies/) uses algorithm logic, frequently calling on the signals and helpers to evaluate market conditions.
• Portfolio and Performance: The portfolio/ directory takes the outcomes from backtesting. It computes metrics like Sharpe Ratio and Maximum Drawdown and may work with visualization components to display the performance.
• Visualization/UI: After computation, the output data can be sent to the HTML/JS visualization modules for rendering interactive charts.
Architectural Patterns and Design Principles
• Modular Separation: The project follows a modular design where each component (data services, backtesting logic, strategy implementation, signal generation, etc.) is separated into its own directory.
• Loose Coupling: Strategies, signals, and helper utilities are designed to operate independently, allowing for easy extension or swapping of individual modules.
• Plug-and-Play: New strategies or data sources can be added without major changes to the core system, thanks to the standardized folder structure and conventions.
• Clear Data Flow: There is a clear flow from external market data through processing to strategy decision-making and finally portfolio evaluation.
Technologies, Frameworks, and Libraries
• Node.js: The project is a Node.js application that leverages JavaScript for server-side logic.
• External APIs: Utilizes APIs from providers such as Binance, Tiingo, AlphaVantage, and Polygon.
• Built-in/Custom Libraries: Uses custom helper functions and modules (possibly some TensorFlow utilities) for analysis and numerical calculations.