Initial checkin

This commit is contained in:
Joe Tretter
2024-05-09 15:29:45 -05:00
commit 3addfb992e
9 changed files with 368 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#!/bin/bash
#set -x
symbol=$1
outDir=data/$(date +%Y-%m-%d)
mkdir -p "${outDir}"
mkdir -p temp
curl -s -X GET "https://api.schwabapi.com/marketdata/v1/${symbol}/quotes?fields=quote%2Creference" \
-H "Authorization: Bearer $(<access_token.dat)" > temp/quote.${symbol}.tmp.$$.json
jqQuery=".\"${symbol}\".symbol"
symbolCheck=$(jq -r ${jqQuery} < temp/quote.${symbol}.tmp.$$.json)
if [[ "${symbol}" != "${symbolCheck}" ]]; then
errMsg="ERROR: THE RESPONSE IS INCORRECT! Symbol: _${symbol}_ Check: _${symbolCheck}_ check file _temp/quote.${symbol}.tmp.$$.json_"
systemd-cat -t "$0 $1" -p err <<< ${errMsg}
>&2 echo "${errMsg}"
exit 2
else
quoteFileName=$(date "+%Y-%m-%d %H_%M_%S")_quote.${symbol}.json
#echo writing to file "${outDir}/${quoteFileName}"
pbzip2 -9 -c < temp/quote.${symbol}.tmp.$$.json > "${outDir}/${quoteFileName}.bz2"
rm temp/quote.${symbol}.tmp.$$.json
fi