Finance Monitor


This is part of my suit of Financial Investments tools.

In this monorepo, everything related to ETL of the required data is handled.

  • Portfolio status from a spreadsheet with my transactions.
  • Stock, bonds, ETF, etc daily and backfill ingestions.
    • Alpha Vantage for US market
    • IOL for Argentina.
  • Argentina fixed rate income from IAMC.
  • ARS / USD from BCRA.

The project is run on Google Cloud Platform.

Design

financemonitor/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml
β”œβ”€β”€ data_pipelines/
β”‚   β”œβ”€β”€ stocks/
β”‚   β”‚   β”œβ”€β”€ orchestrator/
β”‚   β”‚   β”‚   └── stocks_dag.py
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ alphavantage_extractor/    # Service 1: API -> GCS
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚   β”‚   └── tests/
β”‚   β”‚   β”‚   β”‚       └── test_main.py
β”‚   β”‚   β”‚   β”œβ”€β”€ iol_extractor/             # Service 2: API -> GCS
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚   β”‚   └── tests/
β”‚   β”‚   β”‚   β”‚       └── test_main.py
β”‚   β”‚   β”‚   └── stock_loader/              # Service 3: GCS -> BQ
β”‚   β”‚   β”‚       β”œβ”€β”€ main.py
β”‚   β”‚   β”‚       β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚       └── tests/
β”‚   β”‚   β”‚           └── test_main.py
β”‚   β”‚   └── bq_schemas/
β”‚   β”‚       └── stocks.json
β”‚   β”œβ”€β”€ bonds/
β”‚   β”‚   β”œβ”€β”€ orchestrator/
β”‚   β”‚   β”‚   └── bonds_dag.py
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ lecaps_extractor/          # Service 1: Scrape -> GCS
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚   β”‚   └── tests/
β”‚   β”‚   β”‚   β”‚       └── test_main.py
β”‚   β”‚   β”‚   └── bond_loader/               # Service 2: GCS -> BQ
β”‚   β”‚   β”‚       β”œβ”€β”€ main.py
β”‚   β”‚   β”‚       β”œβ”€β”€ Dockerfile
β”‚   β”‚   β”‚       └── tests/
β”‚   β”‚   β”‚           └── test_main.py
β”‚   β”‚   └── bq_schemas/
β”‚   β”‚       └── lecaps.json
β”‚   └── ... (and so on for other data domains)
β”œβ”€β”€ packages/                              # Shared, reusable code
β”‚   └── financemonitor_helpers/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ bigquery_client.py           # BQ helper functions
β”‚       └── gcs_client.py                # GCS helper functions (new!)
└── terraform/                  
    β”œβ”€β”€ gcp_project/
    β”‚   β”œβ”€β”€ main.tf
    β”‚   └── variables.tf
    └── services/
        β”œβ”€β”€ cloud_run.tf
        └── bq.tf
        β”œβ”€β”€ main.tf
        └── modules/
            └── main.tf

Backlog

  • Migrate the AlphaVantage client.
    1. It should be separated in two, the client code and the runner. The runner should be on the cloud run job and call the client (a package).
    2. ~~The runner should also write into GCS the output. ~~
    3. Call BQ from the runner, to retrieve the list of stocks to use.
    4. Read from GCS and write into BQ.
    5. Write tests for this job.
    6. Add the DAG into orchestrator/stocks_dag.py and try it on Cloud Composer.
  • Add transactions into the porfolio.
    1. Use the new BQ schemas.
    2. Read the transactions log from google sheets.
    3. Populate assets not in dim_asset using the transaction’s data.
    4. Create a new LookerStudio dashboard.
  • Migrate the LECAP’ scraper.
    • Lecap scraper should skip corrupted rows, not fail the whole process.
  • Add/migrate the IOL code.
  • Expose endpoints for the Portfolio API to query on demand values. This could be a Cloud Function.
  • Consider integrating yfinance to work aroung the AV daily limit.
  • Configure the timezone with an ENV var.

Technologies

  • Google Cloud Platform (GCP)
  • Python
  • Flask
  • Cloud Run
  • Terraform
  • Cloud Workflows
  • Bigquery
  • Cloud Storage
  • Airflow 3