Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Last active October 22, 2018 14:30
Show Gist options
  • Save RandyMcMillan/cb9a90c2cbe7c8deaae0a5c6ef3147b6 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/cb9a90c2cbe7c8deaae0a5c6ef3147b6 to your computer and use it in GitHub Desktop.
Get the Bitcoin Futures Contract dates from the command line. Then convert to a .csv file and print to terminal.
#!/usr/bin/env bash
getBTCfutures() {
#depends on curl AND csvkit
#both are installable using Homebrew on macOS
#not sure if productID is static
curl "https://www.cmegroup.com/trading/equity-index/us-index/CmeWS/mvc/ProductCalendar/Download.xls?productId=8478" >> $PWD/cmeBTCfuturesCAL.xls && in2csv $PWD/cmeBTCfuturesCAL.xls > $PWD/cmeBTCfuturesCAL.csv
csvclean -K 4 $PWD/cmeBTCfuturesCAL.csv;
clear
echo $PWD/cmeBTCfuturesCAL_out.csv
csvlook $PWD/cmeBTCfuturesCAL_out.csv
}
Install Homebrew:
https://brew.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install curl
brew install csvkit
cd ~/
In your home directory
git clone https://gist.github.com/cb9a90c2cbe7c8deaae0a5c6ef3147b6.git
cd cb9a90c2cbe7c8deaae0a5c6ef3147b6
source .functions
getBTCfutures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment