A Python tool that tracks and analyses the New Zealand carbon market, correlating NZU carbon spot prices with the Salt (CO2) listed investment trust share price.
Featured in Carbon News.
- Polls live carbon spot prices and Salt share prices every 5 minutes via headless Selenium scraping
- Stores prices and auction events in a MySQL database
- Estimates Salt price movements based on carbon price changes (two models)
- Plots historical relationships between carbon price, Salt share price, NZX50, and auction dates
Scrapers (api/)
├── headless_getters.py — Selenium: carbon spot price, Salt share price, NTA, auction dates
└── web_requests.py — requests/BeautifulSoup: Carbon News RSS feed
main.py — polling loop (5 min interval)
calculations.py — Salt price estimation models
db_connect.py — MySQL stored procedure wrappers
data_helpers.py — date utilities, price parsing
reporting.py — matplotlib charts
Historical backfill
├── historical_carbon_prices.py — loads CSV from theecanmole/nzu
├── historical_salt_prices.py — manual data from Sharesies network tab
├── historical_nzx.py — NZX50 historical prices
└── historical_auctions.py — scrapes ETS auction noticeboard
Prerequisites: Python 3, MySQL, geckodriver
pip install -r requirements.txtCreate a password.py in the project root:
def getPassword():
return "your_mysql_password"Update the geckodriver path in api/headless_getters.py:
gecko_driver = '/path/to/geckodriver'Run the polling loop:
python main.py| Data | Source |
|---|---|
| Carbon spot price (live) | commtrade.co.nz via Selenium |
| Carbon spot price (daily) | carbonnews.co.nz RSS feed |
| Carbon historical | theecanmole/nzu |
| Salt share price | nzx.com/instruments/CO2 via Selenium |
| Salt historical | Sharesies network tab (manual export) |
| Auction dates | etsauctions.govt.nz via Selenium |
The MySQL database and password.py are not included in this repo. The scrapers and historical data files are fully standalone — anyone can run the backfill scripts and wire up their own database.