mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
Can now enter company name
It will grab ticker automatically by using most relevant result from yahoo finance.
This commit is contained in:
parent
2bdef55435
commit
b273d23d77
@ -13,8 +13,8 @@ checkInternet()
|
|||||||
|
|
||||||
getStockInformation()
|
getStockInformation()
|
||||||
{
|
{
|
||||||
symbol=$1
|
symb=$1
|
||||||
stockInfo=$(curl -s "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=$symbol&apikey=KPCCCRJVMOGN9L6T") > /dev/null
|
stockInfo=$(curl -s "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=$symb&apikey=KPCCCRJVMOGN9L6T") > /dev/null
|
||||||
export PYTHONIOENCODING=utf8
|
export PYTHONIOENCODING=utf8
|
||||||
echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']" > /dev/null 2>&1 || { echo "Not a valid stock symbol" ; exit 1; }
|
echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']" > /dev/null 2>&1 || { echo "Not a valid stock symbol" ; exit 1; }
|
||||||
exchangeName=$(echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']")
|
exchangeName=$(echo $stockInfo | python -c "import sys, json; print json.load(sys.stdin)['Realtime Global Securities Quote']['02. Exchange Name']")
|
||||||
@ -47,6 +47,14 @@ printStockInformation()
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTicker()
|
||||||
|
{
|
||||||
|
response=$(curl -s "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=$1®ion=1&lang=en%22") > /dev/null
|
||||||
|
symbol=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['ResultSet']['Result'][0]['symbol']")
|
||||||
|
unset response
|
||||||
|
}
|
||||||
|
|
||||||
checkInternet || exit 1
|
checkInternet || exit 1
|
||||||
getStockInformation $1
|
getTicker $1
|
||||||
|
getStockInformation $symbol
|
||||||
printStockInformation
|
printStockInformation
|
||||||
|
Loading…
Reference in New Issue
Block a user