Tangency is a full-stack, institutional-grade Robo-Advisor and Portfolio Optimization platform. It implements Modern Portfolio Theory (MPT) to calculate the Markowitz Mean-Variance optimal weights (the Tangency Portfolio), simulate the Efficient Frontier, and perform chronological historical backtesting against real-world market data.
The system is built with a Java/Spring Boot mathematical backend powered by ojAlgo for linear algebra optimizations, paired with a React/Vite frontend featuring a strict, minimalist institutional UI design.
- Markowitz Mean-Variance Optimization: Calculates the exact Tangency Portfolio (Maximum Sharpe Ratio) for any given universe of equities based on 5-year historical covariance mapping.
- Efficient Frontier Generation: Executes a numerical bounds-sweep solver to calculate and topologically plot the complete Efficient Frontier curve natively.
- On-Demand Data Ingestion: Pure Java asynchronous fetching mechanism utilizing the Yahoo Finance v8 JSON API (
query2.finance.yahoo.com) to bypass rigid401 Unauthorizedweb blocks. No Python required. - Historical Backtesting Simulation: Synchronizes asset time-series arrays and calculates chronological daily compounding (assuming a $10,000 principal) against the mathematically optimal weights.
- Institutional-Grade UI: A strict, lightning-fast React frontend built with Tailwind CSS v4, utilizing sharp corners, high-contrast layouts, and Recharts for precise SVG topological rendering.
Backend:
- Java 21
- Spring Boot 3.2.4
- Spring Data JPA / H2 (In-Memory Database)
ojAlgo(v53.0.0) - High-performance mathematics and linear algebra solver- Jackson - JSON Parsing for native market data API consumption
Frontend:
- React 18 / TypeScript
- Vite - Build tooling
- Tailwind CSS (v4.0 Alpha) - Utility-first styling
- Recharts - Composable charting library
shadcn/ui(Headless UI architecture)
d:\stocks\
├── frontend/ # React / Vite SPA
│ ├── src/components/ # Primary UI (Dashboard.tsx)
│ ├── src/types/ # TypeScript DTO mappings
│ └── vite.config.ts # Vite config
├── src/main/java/.../roboadvisor/# Spring Boot Backend
│ ├── controller/ # REST Endpoints (/api/v1/portfolio)
│ ├── controller/dto/ # PortfolioAllocationResponse
│ ├── domain/ # JPA Entities (HistoricalPrice)
│ ├── repository/ # Spring Data JPA Repositories
│ └── service/ # Core Business Logic
│ ├── FinancialMathService.java # Covariance & Returns matrices
│ ├── MarketDataFetchingService.java # Yahoo Finance JSON ingest
│ └── PortfolioOptimizationService.java # ojAlgo solver & Backtesting
└── start.ps1 # Windows initialization script
Prerequisites:
- Java 21+
- Maven 3.8+
- Node.js 18+
A single execution script is provided for Windows environments. This script cleanly kills lingering processes on Port 8080 and Port 5173, compiles the Java application, starts the Spring Boot server, installs npm dependencies, and launches the Vite dev server asynchronously.
.\start.ps1The application will be accessible at http://localhost:5173.
1. Start the Backend:
mvn clean spring-boot:run(Runs on http://localhost:8080)
2. Start the Frontend:
cd frontend
npm install
npm run dev(Runs on http://localhost:5173)
- The optimization engine strictly enforces a No-Shorting constraint (
optimizer.setShortingAllowed(false);). - Expected returns are annualized utilizing a standard 252 trading-day calendar (
Mean Daily Return * 252). - The covariance matrix is structured linearly as
(X^T * X) / (N-1)over centered return vectors, then scaled by 252 to represent annualized volatility. - Market Data is scraped natively without authentication boundaries using the Yahoo Finance v8 JSON charting endpoint, ensuring reliable data ingestion without third-party API keys.
