Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / ust-bonds-interest
549 bytesRaw
1 | |
2 | # ust-bonds-interest - get interest on treasury bonds |
3 | |
4 | get_value() { |
5 | wget -qO- \ |
6 | "http://www.treasurydirect.gov/BC/SBCPrice?$query&RedemptionDate=$1" |\ |
7 | sed -n '/colspan="6"/!d; n; n; n; n |
8 | s/.*<td>//; s/<\/td.*//; s/[$,]//g; p' |
9 | } |
10 | |
11 | get_diff() { |
12 | query="${BONDS_QUERY?BONDS_QUERY env var must be set}" |
13 | amt1=$(get_value $1) |
14 | amt2=$(get_value $2) |
15 | echo \$$(echo $amt2 - $amt1 | bc -l) |
16 | } |
17 | |
18 | usage() { |
19 | echo Usage: $0 start_date end_date |
20 | echo Date format: mm/yyyy |
21 | } |
22 | |
23 | case $# in |
24 | 0) usage;; |
25 | 2) get_diff $@;; |
26 | *) usage >&2; exit 1;; |
27 | esac |
28 |
Built with git-ssb-web