Skip to content

Instantly share code, notes, and snippets.

@mattjj
Last active December 10, 2015 10:38
Show Gist options
  • Save mattjj/4421916 to your computer and use it in GitHub Desktop.
Save mattjj/4421916 to your computer and use it in GitHub Desktop.
get TIPS prices
#!/bin/bash
curl -s "http://online.wsj.com/mdc/public/page/2_3020-tips-${1}.html?mod=mdc_pastcalendar" \
| tr '^M' '\n' \
| grep -E '<td class="(([pn]?num)|(text))">' \
| sed -E 's/<[^>]*>([^<]*)<.*/\1/' \
| awk '(NR%6==0){print p; p=""; next}{p=p "\t" $0;}' \
| sed "s/^/${1}/"
@mattjj
Copy link
Author

mattjj commented Dec 31, 2012

$ get_TIPS_prices.sh 20110726
20110726 2012 Jan 15 3.375 101.28 101.28 - 1
20110726 2012 Apr 15 2.000 102.03 102.03 - 1
20110726 2012 Jul 15 3.000 104.06 104.06 - 2
20110726 2013 Apr 15 0.625 103.11 103.12 - 1
20110726 2013 Jul 15 1.875 106.19 106.20 unch.
20110726 2014 Jan 15 2.000 108.11 108.12 - 1
20110726 2014 Apr 15 1.250 106.23 106.24 unch.
20110726 2014 Jul 15 2.000 109.23 109.25 unch.
20110726 2015 Jan 15 1.625 109.14 109.16 - 2
20110726 2015 Apr 15 0.500 105.12 105.13 - 1
20110726 2015 Jul 15 1.875 111.09 111.11 - 1
20110726 2016 Jan 15 2.000 112.10 112.12 - 1
20110726 2016 Apr 15 0.125 103.18 103.21 - 1
20110726 2016 Jul 15 2.500 115.24 115.27 - 1
20110726 2017 Jan 15 2.375 115.16 115.19 - 1
20110726 2017 Jul 15 2.625 117.31 118.02 unch.
20110726 2018 Jan 15 1.625 111.21 111.24 + 1
20110726 2018 Jul 15 1.375 110.11 110.14 + 2
20110726 2019 Jan 15 2.125 115.15 115.18 + 1
20110726 2019 Jul 15 1.875 113.24 113.28 + 3
20110726 2020 Jan 15 1.375 109.08 109.12 + 3
20110726 2020 Jul 15 1.250 107.28 108.00 + 4
20110726 2021 Jan 15 1.125 106.01 106.05 + 2
20110726 2021 Jul 15 0.625 100.21 100.25 + 6
20110726 2025 Jan 15 2.375 118.05 118.11 + 11
20110726 2026 Jan 15 2.000 112.20 112.26 + 11
20110726 2027 Jan 15 2.375 117.25 118.00 + 16
20110726 2028 Jan 15 1.750 108.11 108.18 + 13
20110726 2028 Apr 15 3.625 135.18 135.26 + 20
20110726 2029 Jan 15 2.500 119.27 120.03 + 16
20110726 2029 Apr 15 3.875 141.04 141.13 + 19
20110726 2032 Apr 15 3.375 136.24 137.02 + 21
20110726 2040 Feb 15 2.125 112.17 112.29 + 22
20110726 2041 Feb 15 2.125 112.17 112.29 + 20

@mattjj
Copy link
Author

mattjj commented Dec 31, 2012

(for start in {11,18,25}; do for offset in {0..4}; do get_TIPS_prices.sh "201107$(printf %02d $((start+offset)))"; done; done;) \
| tee cachefile \
| grep -E '^[0-9]+\s+2041 Feb 15' \
| awk '{print $1 "\t" $6}' \
| sed -E 's/^([0-9]{4})([0-9]{2})([0-9]{2})/\1 \2 \3/' \
| dateplotter.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment