- Scripts that automatically download and upload consolidated financial statments for companies listed on CVM and save them in a postgres database
- additional scripts to interact with the database and return statments in the usual form
- Download zip files from CVM website
- Unzips and unifies file under unified_csv_files folder
- Creates and saves in the dir CSV for statment balnce_sheet, Income Statement and cash_flow_statement (DFC metodo direto). All from consolidado statements 3.1 The statements are in the form of GRUPO_DFP | CD_CVM | DENOM_CIA | CD_CONTA | DS_CONTA | ST_CONTA_FIXA | DT_FIM_EXERC | VL_CONTA
Should run under 3 minutes total maximum.
- Connects do postgres database
- Creates a table for each statement type
- Inserts the data from the csv files into the database
- Commits the transaction
- execute_query returns a given staetment pivoted to the usual format of financial statements
- get_companies_list returns a list of companies from the database
- get_distinct_cd_cvm returns a list of distinct cd_cvm from the database
- get_company_name_by_cd_cvm returns the company name given cd_cvm from the database
- Create a .env file with the database connection string by renaming .env.example and adding string. Suggested to use Neon DB.
- Run poetry shell (make sure poetry is installed - in MacOS brew install poetry)
- Run the script cvm_downloader.py
- Run the script database_uploader.py
- Use db_interaction.py to interact with the database