QFcli is a professional-grade, open-source command-line tool designed for quantitative stock analysis. It bridges the gap between complex financial data and accessible, readable insights. By leveraging real-time data and standard financial models, QFcli provides a comprehensive snapshot of any asset's performance, risk profile, and technical trends.
- Real-time Data: Fetches the latest OHLCV (Open, High, Low, Close, Volume) data via
yfinance. - Returns Analysis: Computes Cumulative Return, Average Daily Return, and Annualized Volatility.
- Risk-Adjusted Metrics: Calculates the Sharpe Ratio to evaluate return per unit of risk.
- Daily Performance Stats: Identifying Best Day, Worst Day, and Win Ratio (consistency metric).
- Moving Averages:
- SMA (Simple Moving Average): 20-day (Short-term), 50-day (Medium-term), 200-day (Long-term).
- Trend Signals: Automatically detects Golden Crosses or Death Crosses logic (Price > SMA = BULLISH).
- Momentum & Volatility:
- RSI (Relative Strength Index): 14-period momentum oscillator to spot overbought (>70) or oversold (<30) conditions.
- MACD (Moving Average Convergence Divergence): 12, 26, 9 standard setting. Used for trend-following and momentum.
- Bollinger Bands: 20-period SMA ยฑ 2 standard deviations. Measures volatility squeeze and breakouts.
- Head-to-Head: Compare any two assets (e.g., AAPL vs MSFT, BTC-USD vs ETH-USD).
- Winner Determination: Algorithmic scoring system that evaluates which asset wins on each metric.
- Smart Recommendations: Generates a final investment suggestion based on your risk profile (Growth vs. Stability).
- Rich UI: Beautiful terminal output with color-coded panels, tables, and progress bars.
- Risk Scoring: Auto-classifies assets as
HIGH RISK,MODERATE, orSTABLEbased on annualized volatility.
- Python 3.8+: Ensure you have Python installed (
python --version). - pip: Python package manager.
-
Clone the Repository
git clone https://github.com/MRX-72/QFcli.git cd QFcli -
Create a Virtual Environment (Highly Recommended) A virtual environment keeps your dependencies isolated.
- Windows:
python -m venv venv .\venv\Scripts\activate
- macOS / Linux:
python3 -m venv venv source venv/bin/activate
- Windows:
-
Install Dependencies
pip install -r requirements.txt
Get a deep-dive report on a single asset.
Syntax: python main.py [TICKER]
Example:
python main.py NVDACustomization Options:
--period: Change the lookback period. Default is1y.- Valid Options:
1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max. - Example:
python main.py NVDA --period 5y
- Valid Options:
--rf: Set a Risk-Free Rate for Sharpe Ratio (e.g., 10-year Treasury yield). Default is0.0.- Example:
python main.py SPY --rf 0.045(implies 4.5% risk-free rate)
- Example:
Compare two assets to decide which fits your portfolio.
Syntax: python main.py --compare [TICKER1] [TICKER2]
Example:
python main.py --compare GOOGL METABelow is an actual output of the tool analyzing Apple Inc. (AAPL):
(The screenshot above demonstrates the clean, tabulated view of Returns, Daily Stats, Moving Averages, Technicals, and Risk Metrics)
For the developers and quants, here is exactly how the metrics are calculated:
| Metric | Formula | Python Implementation |
|---|---|---|
| Cumulative Return | (prices[-1] - prices[0]) / prices[0] |
|
| Daily Returns | prices.pct_change() |
|
| Annualized Volatility | returns.std() * np.sqrt(252) |
|
| Sharpe Ratio | (returns.mean() - daily_rf) / returns.std() * np.sqrt(252) |
|
| Max Drawdown |
min(drawdown) where drawdown is calculated per peak |
| Indicator | Parameters | Formula / Logic |
|---|---|---|
| SMA | 20, 50, 200 | Simple average of the last |
| RSI | Period: 14 |
|
| MACD | 12, 26, 9 |
MACD Line: Signal Line: Histogram: MACD - Signal |
| Bollinger Bands | 20, 2 |
Middle: Upper: Lower: |
The Risk Score is determined by Annualized Volatility:
- ๐ข STABLE: Volatility < 15%
- ๐ก MODERATE: Volatility 15% - 30%
- ๐ด HIGH RISK: Volatility > 30%
QFcli/
โโโ main.py # ๐ Entry Point: Handles args and CLI flow
โโโ requirements.txt # ๐ฆ Dependencies list
โโโ README.md # ๐ This documentation
โโโ quant_finance/ # ๐ง Core Package
โโโ __init__.py # - Init file
โโโ data_fetcher.py # - yfinance wrapper
โโโ metrics.py # - Math: Sharpe, Volatility, Returns
โโโ indicators.py # - Technicals: RSI, MACD, SMA, BB
โโโ output.py # - UI: Rich tables and panels
โโโ comparison.py # - Logic: Comparing two stocks
We welcome contributions! Whether you're fixing a bug, adding a new indicator (e.g., Stochastic Oscillator, ATR), or improving documentation:
- Fork the repo.
- Create a new branch (
git checkout -b feature/amazing-feature). - Commit your changes.
- Push to the branch.
- Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ for quantitative finance enthusiasts
