A Python-based backend service combining financial valuation models with a proprietary AI engine to provide comprehensive investment analysis and AI-powered trading insights via REST API.
Tech Stack: FastAPI + Python + TradeMe AI Engine
Build an intelligent trading backend that:
- Runs selective financial models (user chooses which models to apply)
- Analyzes stocks using different valuation techniques
- Leverages a AI engine for insights
- Generates trading signals and recommendations
- Serves results via FastAPI REST endpoints
- Evolves iteratively from models → real data → web dashboard → production
Endgame: A production-ready trading intelligence platform that traders and apps can consume
| Framework | Language | Best For |
|---|---|---|
| FastAPI | Python | AI/data backend, high-performance APIs and docs |
| Next.js | JavaScript | Frontend + backend together, SSR support |
| React | JavaScript | Frontend dashboard, interactive UI |
Backend Structure
├── Market Data (price feeds, news, financials)
│ └── Data Provider
│
├── Financial Models (selective analysis)
│ ├── Valuation Models
│ │ ├── DCF
│ │ ├── Reverse DCF
│ │ └── Comparable Analysis
│ │
│ ├── Accounting Models
│ │ └── 3 Statement Model
│ │
│ ├── Deal Models
│ │ ├── LBO
│ │ └── M&A Accretion/Dilution
│ │
│ └── Risk Models
│ ├── Portfolio Risk
│ └── Monte Carlo Simulation
│
├── Logic Layer
│ ├── Trading strategies
│ ├── Signal generation
│ └── Risk rules
│
└── TradeMe AI Engine
├── Analyze model outputs
├── Summarize insights
├── Explain trade decisions
└── Generate trading signals
- Clone the repo
git clone https://github.com/your-username/trademe.git
cd trademe- Create a virtual environment
python3 -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Create your
.envfile
cp .env.example .envThen open .env and fill in your keys:
AI_BASE_URL=
AI_SERVICE_KEY=
AI_MODEL=- Run the platform
python -m uvicorn src.main:app --reload- Open your browser for FastAPI docs
http://localhost:8000/docs
What it does: Values a company based on present value of future free cash flows
Required Data:
- Free Cash Flow (FCF) - Historical or projected annual cash flows
- Terminal Growth Rate - Long-term perpetual growth assumption (typically 2-3%)
- WACC - Weighted Average Cost of Capital (discount rate)
- Forecast Period - Number of years to project (typically 5-10 years)
Data Sources: Cash flow statements, income statements, balance sheets, market risk data
Best For: Long-term valuation, intrinsic value analysis, comparing against market price
What it does: Values a company based on trading multiples of similar peer companies
Required Data:
- Target Company Revenue - Annual revenue
- Target Company Net Income - Net profitability
- Peer Company Data (multiple peers needed):
- Revenue
- Net Income
- Market Capitalization
- (Optional) EBITDA, Book Value
Data Sources: Financial statements, market capitalization data, peer databases, industry reports
Best For: Relative valuation, market benchmarking, identifying over/undervalued stocks
What it does: Projects and analyzes income statement, balance sheet, and cash flow statements together
Required Data:
- Income Statement Components:
- Revenue
- Cost of Goods Sold (COGS)
- Operating Expenses
- Tax Rate
- Balance Sheet Components:
- Total Assets
- Total Liabilities
- Optional: Interest expense, depreciation, capex
Data Sources: Income statements, balance sheets, tax filings, SEC reports
Best For: Financial health assessment, profitability analysis, operational metrics evaluation
What it does: Analyzes leveraged buyout scenarios and projected investment returns
Required Data:
- EBITDA - Earnings Before Interest, Taxes, Depreciation & Amortization
- Purchase Price - Total acquisition cost
- Debt Amount - Financing/leverage amount
- Equity Investment - Equity check size
- Growth Rate - Projected annual growth rate
- Exit Year - Time horizon (typically 5 years)
- Exit Multiple - EBITDA exit multiple assumption (target exit valuation)
Data Sources: Historical financials, transaction databases, comps for multiples
Best For: Private equity analysis, M&A scenarios, leveraged transaction evaluation
What it does: Analyzes impact of mergers/acquisitions on earnings per share
Required Data:
- Acquirer Earnings - Acquirer's annual net income
- Target Earnings - Target company's net income
- Acquisition Price - Total deal consideration
- Acquirer Shares Outstanding - Current share count
- Synergies - Projected cost/revenue synergies from deal
Data Sources: Income statements, share count data, deal structure documents
Best For: Merger impact analysis, deal evaluation, accretion/dilution assessment
What it does: Calculates portfolio risk metrics including Value at Risk (VaR) and Sharpe Ratio
Required Data:
- Portfolio Value - Total portfolio size
- Holdings Data (for each position):
- Weight in portfolio (%)
- Expected Annual Returns
- Volatility/Standard Deviation of returns
- (Optional) Correlations between holdings
- Confidence Level - Risk confidence interval (e.g., 95% or 99%)
- Risk-Free Rate - Current risk-free rate (usually Treasury rate)
Data Sources: Historical price data, volatility calculations, portfolio positions, Treasury rates
Best For: Risk management, portfolio optimization, downside protection analysis
What it does: Simulates asset price paths to estimate probability distributions of future outcomes
Required Data:
- Initial Value - Starting price or portfolio value
- Mean Return - Expected annual return
- Volatility - Standard deviation of returns
- Time Horizon - Analysis period (e.g., 1 year, 5 years)
- Number of Simulations - Simulation iterations for accuracy (more = better, 1000-10000 typical)
Data Sources: Historical prices, volatility metrics, return assumptions
Best For: Scenario analysis, probability of profit, confidence intervals, stress testing