How amircp/investingpy works
Project Type and Purpose
• This is a lightweight Python package (library) whose sole responsibility is to fetch the last 30 days of historical data from Investing.com for various financial instruments.
• It uses Selenium WebDriver to drive a headless browser, scrape the page, parse the table, and return the result as a pandas DataFrame.
File Structure
• Top-level files:
• datafeed.py – core module exposing get_investing_last30days_data().
• __init__.py – makes the folder a Python package.
• requirements.txt – lists Selenium, pandas, and other dependencies.
• README.md – documents usage.
• No subdirectories—this is a single-module library.
Extract Key Components & Roles
• User Application / Script: the consumer code that imports your package.
• datafeed Module: contains the API function and internal helpers.
• Selenium WebDriver: third-party component (e.g., ChromeDriver/GeckoDriver).
• Investing.com Website: external service providing the data.
• Parser & DataFrame: internal logic to transform raw HTML into a pandas DataFrame.
Interactions & Data Flow
1. Consumer calls get_investing_last30days_data(symbol, category).
2. datafeed module spins up a Selenium WebDriver instance.
3. WebDriver navigates to the correct Investing.com URL.
4. Investing.com responds with HTML (sometimes slow or blocked).
5. datafeed parses the HTML table (e.g., via BeautifulSoup or Selenium APIs).
6. Parsed rows are assembled into a pandas DataFrame.
7. DataFrame is returned to the consumer code.
8. WebDriver is shut down/teardown.
Architectural Patterns
• Single-module library pattern: clear separation between public API (get_investing_last30days_data) and internal helpers (browser setup, parsing).
• Dependency-injection point: ability to pass custom WebDriver instance (future enhancement).
• Error-handling/timeouts around slow or blocked requests to Investing.com.