Added script to pull historical stock data and resulting data files (1 per company). Added code to generate average price change per 1, 2 and 3-gram. Added code to output average price change per headline for VALIDATION dataset.

This commit is contained in:
Woody Folsom
2012-04-20 21:22:54 -04:00
parent eec32b19c1
commit 6e3680426e
65 changed files with 360216 additions and 102 deletions

68
data/getStockHistory Normal file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
# NAME
# getStockHistory -- Downloads historic stock prices for a given company stock.
#
# SYNOPSIS
# getStockHistory symbol [optional saveLocation]
# getStockHistory -f file [optional saveLocation]
#
# DESCRIPTION
# The getSockHistory command attempts to download complete stock history for a given company or
# for list of companies in a file.
#
# OPTIONS
# -f Use a file to have a list of stock symbols to download. Each stock symbol should be on a
# differnt line in the file.
#
#
# EXAMPLES
# The following downloads Apple's stock history.
# getStockHistory AAPL
#
# BUGS
#
# Written by: Rowland O'Flaherty (rowland.oflaherty@gmail.com)
# Created on: 02/08/10/
function getHistory() {
stockSymbol=$1
if [[ -z $stockSymbol ]]
then
echo "Invalid stock symbol"
exit 1
fi
stockSymbol=$(echo $stockSymbol | tr '[:lower:]' '[:upper:]')
saveLocation=$2
wget -q -O ${stockSymbol}.csv "http://ichart.finance.yahoo.com/table.csv?s=${stockSymbol}&ignore=.csv"
sed '1s/\ /_/g' ${stockSymbol}.csv > ${stockSymbol}.tmp
mv ${stockSymbol}.tmp ${stockSymbol}.csv
mv ${stockSymbol}.csv ${saveLocation}
}
fOpition=false
while getopts :f OPTION
do
case $OPTION in
f)
fOpition=true
;;
'?')
echo "Invalid option $OPTARG"
;;
esac
done
if [[ "$fOpition" = "true" ]]
then
fileLocation=$2
saveLocation=$3
saveLocation=${saveLocation:=$HOME/Downloads}
for aSym in $(cat $fileLocation)
do
eval "getHistory $aSym $saveLocation"
done
else
saveLocation=$2
saveLocation=${saveLocation:=$HOME/Downloads}
eval "getHistory $1 $saveLocation"
fi