Savings bond calculator for treasury direct using playwright.
Create a .csv file in the format of: Series, Denomination, Issue Date (MMYYYY), Serial Number (optional)
Series | Denomination | Issue Date | Serial Number |
---|---|---|---|
EE | 50 | 011976 | XXXXXXXXXXXX |
E | 25 | 052011 |
File contents savings-bond.csv
EE,50,011976,XXXXXXXXXXXX
E,25,052011,
Assumption is that python3 is installed and working.
- Install Poetry
cd python/calculator
poetry install
poetry run python3 playwright install
poetry run python3 calculator.py savings-bond.csv
(or whatever your saved file is)
Assumption is that node and yarn are installed and working
cd javascript
yarn install
yarn run calc savings-bond.csv
(or whatever your saved file is)
The output of the bonds entered will be saved. You will receive a saved file called saved-bonds.html once all the bonds are input into the calculator. This file can be opened or double clicked. Once it is open, if you click on return to calculator, it will return back to the calculator with today's calculation.
The chosen browser is Firefox because per Treasury Direct guidance, Chrome doesn't work with saving the output of the calculation.
I have a bunch of savings bonds (>50), some fully matured, and some not. I wanted to verify their estimated price before cashing them in. It's so much easier to enter in details to a csv than to the website.
There were a few fully featured calculators already, including one that used selenium. I didn't really need to write this, but I did want to develop a Playwright version. This didn't turn out to be the best example of Playwright though. I'm using both python and javascript versions as libraries, so not using full capabilities. And my locator strategy is not ideal. I prefer to use accessibility selectors, but this was quick, easy, and the page is pretty static.