Karl Hudgell f971708c5e refactor(price): enhance currency handling with FX conversion and cache support
- Add `get_fx_rate()` function with caching to fetch foreign exchange rates from open.er-api.com
- Introduce `get_currency()` helper to map market codes to currency identifiers
- Update price parsing regex to support multiple currency symbols (£, $, €)
- Convert shares to float to accommodate fractional holdings
- Add currency, fx_rate, and total_value_gbp fields to output JSON
- Support fractional share counts (e.g., 3.6185 AAPL shares)
2026-04-20 11:48:15 +01:00

Freetrade Portfolio Tracker

Fetches live stock prices from Freetrade and calculates portfolio holdings values.

Setup

python -m venv venv
venv\Scripts\activate        # Windows
source venv/bin/activate     # Linux/Mac

pip install requests beautifulsoup4

Usage

Copy the sample file and add your own positions:

cp holdings.sample.csv holdings.csv

Format (ticker,market,shares):

GGP,GB,100
PAF,GB,200
SVM,US,50

Markets: GB for UK stocks, US for US-listed stocks.

Run:

python price.py                  # uses holdings.csv by default
python price.py my_portfolio.csv # custom file

Output (JSON):

[
  {
    "ticker": "GGP",
    "market": "GB",
    "shares": 100,
    "price": 7.67,
    "total_value": 767.0
  }
]
Description
No description provided
Readme 30 KiB
Languages
Python 100%