Complete Technical Paper Content โ Ai Robo Advisor
1. Executive Abstract, Problem Formulation & Background
AI-Powered Fintech Robo-Advisor for Personal Portfolio Optimization ๐ Overview This project implements an intelligent Robo-advisor system designed to optimize personal investment portfolios. By leveraging cutting-edge Artificial Intelligence algorithms, it bridges the gap between individual risk tolerance and optimal market performance. The system utilizes a hybrid approach combining two core algorithms: Inverse Portfolio Optimization (IPO) : Infers the investor's implicit risk appetite based on their current asset allocation. Deep Reinforcement Learning (DDPG) : Dynamically optimizes multi-period capital allocation to maximize risk-adjusted returns over time. Designed specifically for the Vietnamese stock market (VN-Index), the current model is trained and evaluated on 30 highly liquid, large-cap stocks. ๐ System Architecture 1. Data Acquisition & Preprocessing Sources : Yahoo Finance and vnstock . Features : Daily Closing Prices, Daily Log Returns, Trading Volumes, and Technical Indicators. Processing : Built-in handling for missing data, outliers, and a rolling window of 126 days (approx. 6 months). 2. Inverse Portfolio Optimization (IPO) Rather than relying on subjective questionnaires, the system learns the investor's risk-aversion coefficient ( $\lambda$ ) and expected returns ( $\mu$ ) directly from their existing portfolio distribution using Mean-Variance Optimization principles. Objective Function: max_w [ w^T * ฮผ_t - ฮป * w^T * ฮฃ_t * w ] s.t. ฮฃ_i w_i = 1, w_i โฅ 0 3. Deep Deterministic Policy Gradient (DDPG) An Actor-Critic reinforcement learning architecture is employed to handle continuous action spaces (portfolio weights). State : Historical prices, technical indicators, market news sentiment, and IPO risk parameters. Action : New weight distribution across the selected assets. Reward : Risk-adjusted return metrics, specifically prioritizing the Sharpe ratio, Sortino ratio, while explicitly penalizing maximum drawdowns. ๐ Installation & Setup Prerequisites Python 3.7 or higher 1. Clone & Install Dependencies git clone https://github.com/your-username/your-repo-name.git cd your-repo-name pip install -r requirements.txt 2. Project Structure . โโโ Train_Model.py # Train entrypoint (compat wrapper) โโโ src/ # Source code โ โโโ app.py # Flask web application โ โโโ main.py # CLI entry point for portfolio analysis โ โโโ train_model.py # Model training script โ โโโ get_data.py # Data ingestion and preprocessing utilities โ โโโ robo_agent.py # Core IPO & DDPG implementations โ โโโ data_source.py # APIs for fetching financial data โ โโโ news_scraper.py # Financial news scraping & sentiment analysis โ โโโ news_features.py # News feature engineering โโโ data/ # Directory for historical datasets โโโ models/ # Directory for serialized, trained models โโโ templates/ # HTML/CSS for the Flask portal ๐ป Usage Instructions โก Quick Start git clone https://github.com/ < your-username > / < your-repo-name > .git cd < your-repo-name > pip install -r requirements.txt # 1) (Optional) Refresh / prepare price data # By default this reads from data/Data_test.csv. # If you set ENABLE_ONLINE_DATA=1 in your environment, # it will first try to fetch newer daily prices from Yahoo Finance # and then fall back to the CSV. python3 src/get_data.py # 2) (Optional) Train the DDPG agent from scratch using the prepared data python3 Train_Model.py # 3) Start the web application python3 src/app.py Then open your browser at http://127.0.0.1:5001 and select 5 VN-Index stocks plus capital amounts to get AI-powered allocation recommendations. Step 1: Training the Agent (Optional) To train the model from scratch using the top 30 VN-Index stocks over the past 2 years: python3 Train_Model.py The trained weights will be saved automatically to models/trained_model.pth . Step 2: Running the Application Option A: Web Application (Recommended) Provides an interactive GUI to input current portfolio holdings and view the AI's recommendations. python3 src/app.py Navigate to http://127.0.0.1:5002 (or the port printed in the console). Option B: Command Line Interface (CLI) For programmatic usage or terminal-based analysis: python3 src/main.py ๐ Evaluation Metrics The agent's performance is heavily monitored using industry-standard financial metrics: Annualized Mean Return Standard Deviation (Volatility) Sharpe Ratio (Assumes a 4.5% risk-free rate based on VN Government Bonds) Portfolio Turnover Rate Cumulative Transaction Costs (Modeled at 0.3% per trade) Maximum Drawdown (MDD) Benchmark Results (VN-Index universe) Using all available data in data/Data_test.csv , we compare the proposed IPOโDRL strategy against simple baselines: Strategy Annual Return (%) Std Dev (%) Sharpe Ratio Max Drawdown (%) Turnover Tx Cost (cum) Buy & Hold 21.35 19.31 0.87 18.09 0.00 0.00 Quarterly MV 21.35 19.31 0.87 18.09 0.00 0.00 IPOโDRL (Ours) 112.67 31.52 3.43 19.79 0.03 0.03 Note: Numbers above are produced from the provided synthetic/backtested dataset and should be interpreted for research/academic purposes only. ๐ References & Literature Wang & Yu (2021) - "Robo-Advisor using Inverse Portfolio Optimization and Deep Reinforcement Learning" Markowitz (1952) - "Portfolio Selection" Lillicrap et. al (2015) - "Continuous control with deep reinforcement learning" ๐ License This project is developed for academic and research purposes. ๐ญ Future Work Extend beyond VN-Index to multi-market / multi-asset universes. Add alternative RL baselines (PPO, SAC) for a more complete comparison. Improve transaction-cost modeling and slippage assumptions. Package the core logic as a reusable Python library and add unit tests.
This project implements an intelligent Robo-advisor system designed to optimize personal investment portfolios. By leveraging cutting-edge Artificial Intelligence algorithms, it bridges the gap between individual risk tolerance and optimal market performance.
Designed specifically for the Vietnamese stock market (VN-Index), the current model is trained and evaluated on 30 highly liquid, large-cap stocks.
2. Related Work, Literature Survey & Algorithmic Foundations
Rather than relying on subjective questionnaires, the system learns the investor's risk-aversion coefficient ( $\lambda$ ) and expected returns ( $\mu$ ) directly from their existing portfolio distribution using Mean-Variance Optimization principles.
An Actor-Critic reinforcement learning architecture is employed to handle continuous action spaces (portfolio weights).
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name pip install -r requirements.txt
3. Dataset Ingestion, Preprocessing & Stochastic Augmentations
. โโโ Train_Model.py # Train entrypoint (compat wrapper) โโโ src/ # Source code โ โโโ app.py # Flask web application โ โโโ main.py # CLI entry point for portfolio analysis โ โโโ train_model.py # Model training script โ โโโ get_data.py # Data ingestion and preprocessing utilities โ โโโ robo_agent.py # Core IPO & DDPG implementations โ โโโ data_source.py # APIs for fetching financial data โ โโโ news_scraper.py # Financial news scraping & sentiment analysis โ โโโ news_features.py # News feature engineering โโโ data/ # Directory for historical datasets โโโ models/ # Directory for serialized, trained models โโโ templates/ # HTML/CSS for the Flask portal
git clone https://github.com/ < your-username > / < your-repo-name > .git cd < your-repo-name > pip install -r requirements.txt # 1) (Optional) Refresh / prepare price data # By default this reads from data/Data_test.csv. # If you set ENABLE_ONLINE_DATA=1 in your environment, # it will first try to fetch newer daily prices from Yahoo Finance # and then fall back to the CSV. python3 src/get_data.py # 2) (Optional) Train the DDPG agent from scratch using the prepared data python3 Train_Model.py # 3) Start the web application python3 src/app.py
Then open your browser at http://127.0.0.1:5001 and select 5 VN-Index stocks plus capital amounts to get AI-powered allocation recommendations.
4. Neural Network Backbone, Layer Specifications & Loss Formulations
To train the model from scratch using the top 30 VN-Index stocks over the past 2 years:
Option A: Web Application (Recommended) Provides an interactive GUI to input current portfolio holdings and view the AI's recommendations.
Option B: Command Line Interface (CLI) For programmatic usage or terminal-based analysis:
5. Training Protocol, Convergence Behavior & Experimental Evaluation
The agent's performance is heavily monitored using industry-standard financial metrics:
Using all available data in data/Data_test.csv , we compare the proposed IPOโDRL strategy against simple baselines:
Note: Numbers above are produced from the provided synthetic/backtested dataset and should be interpreted for research/academic purposes only.
Model Figures & Evaluation Curves (4 Images)
Deep Learning Execution Pipeline
(Preprocessing)
(Feature Extraction)
(Self-Attention)
(Loss Optimization)