How joshhheo/s-p500_risk works
This repository’s implemented workflow builds an S&P 500 debt-to-assets dataset: it obtains company and sector metadata, pulls SEC financials, records liability availability and calculation methods, computes ratios, then loads company and financial records into a database and refreshes a sector-leverage view. The README also names interest coverage and current ratios, but the sampled implementation shows only debt-to-assets. Edges follow the visible orchestrator and sampled calls; unsampled merge behavior is left unspecified.
Main entry points: main.py Pipeline runner · sec_pull.py SEC financial pull · calculate_debt_to_assets_ratio.py Debt-assets calculation · companies_table_info.py Company records
Components 17
Company and SEC Data
- Company universe
src/wiki_pull.py - SEC identity setup
src/setup_sec.py - SEC financial pull
src/sec_pull.py - Filing status data
data/raw/debt_to_assets_status.csv
Ratio Processing
- Pipeline runner
src/main.py - Debt-assets calculation
src/calculate_debt_to_assets_ratio.py - Ratio results
data/processed/debt_to_assets_ratios.csv - CSV merge
src/merge_csv_info.py
Database and View
- Table creation
src/create_tables.py - Company records
src/companies_table_info.py - Financial records
src/financials_table_info.py - Relational database
- View refresh
src/read_sql.py - Sector leverage SQL
sql/sector_leverage.sql
Other components
- Equity investors
- Wikipedia
- SEC EDGAR
Connections 24
- Equity investors → Pipeline runner: runs pipeline
- Pipeline runner → SEC financial pull: runs pull
src/main.py - SEC financial pull → Company universe: gets tickers
src/sec_pull.py - Company universe → Wikipedia: fetches company table
src/wiki_pull.py - SEC financial pull → SEC identity setup: sets identity
src/sec_pull.py - SEC financial pull → SEC EDGAR: requests financials
src/sec_pull.py - SEC financial pull → Filing status data: writes status
src/sec_pull.py - Pipeline runner → Debt-assets calculation: runs calculation
src/main.py - Debt-assets calculation → SEC identity setup: sets identity
src/calculate_debt_to_assets_ratio.py - Debt-assets calculation → Filing status data: reads status
src/calculate_debt_to_assets_ratio.py - Debt-assets calculation → SEC EDGAR: requests financials
src/calculate_debt_to_assets_ratio.py - Debt-assets calculation → Ratio results: writes ratios
src/calculate_debt_to_assets_ratio.py - Pipeline runner → CSV merge: runs merge
src/main.py - Pipeline runner → Table creation: creates tables
src/main.py - Table creation → Relational database: creates tables
src/create_tables.py - Pipeline runner → Company records: loads companies
src/main.py - Company records → Company universe: gets company data
src/companies_table_info.py - Company records → Relational database: upserts companies
src/companies_table_info.py - Pipeline runner → Financial records: loads financials
src/main.py - Financial records → Ratio results: reads ratios
src/financials_table_info.py - Financial records → Relational database: upserts financials
src/financials_table_info.py - Pipeline runner → View refresh: refreshes view
src/main.py - View refresh → Sector leverage SQL: reads query
src/read_sql.py - View refresh → Relational database: executes query
src/read_sql.py