How arvind-narayan/portfolio-returns works
Main Components Identification
• Entry Point:
• app.py – Acts as the main Streamlit application orchestrator.
• UI/Functional Components (located in the “components” folder):
• portfolio_input.py – Handles the manual and CSV entry of transaction data.
• portfolio_view.py – Responsible for displaying the current portfolio, allocation charts, and transaction history.
• portfolio_analysis.py – Computes and displays performance metrics such as XIRR, Total Return, Annualized Return, etc.
• Utility Modules (from the “utils” folder):
• calculations.py – Performs all necessary financial calculations.
• data_manager.py – Manages data storage and retrieval from Streamlit’s session state.
• stock_api.py – Interacts with the Yahoo Finance API (through yfinance) to fetch current stock prices.
• Supporting Files/Configuration:
• requirements.txt – Lists all project dependencies.
• .devcontainer – Contains development environment configuration (useful for consistent containerized development).
• initial_prompt.txt – Potentially used as a starter text or prompt guide for user input or onboarding.
Relationships and Interactions
• User → Streamlit UI (app.py): Interactions (input transactions, view charts, etc.) originate here.
• app.py → Components:
• Calls functions from portfolio_input.py, portfolio_view.py, and portfolio_analysis.py based on the user selection (this could be visualized as different “pages” or “views” within the Streamlit environment).
• Components → Utilities:
• When users input transactions, data_manager.py is called to store session data.
• For calculations such as portfolio performance metrics, components call functions from calculations.py.
• For live stock data, components or utility functions call stock_api.py to fetch information from Yahoo Finance.
• Data Flow:
• Inputs (manual and CSV) pass from the UI components to the backend utility modules.
• Calculated results and fetched data are returned and rendered in the UI.
• External Integration:
• The system interacts with the Yahoo Finance API (internalized in stock_api.py) and uses third-party libraries like Pandas, NumPy, and Plotly for data processing and visualization.
Architectural Patterns and Design Principles
• Separation of Concerns:
• The project isolates core functionality into distinct modules (UI rendering, data processing, API integration), simplifying maintenance and promoting modular development.
• Real-time Processing:
• Data stays transient in session state; every user interaction triggers immediate calculations and data fetching.
• Component-Based Design:
• The “components” folder clearly delineates handling of different aspects of portfolio management—input, view, and analysis.