- Separate getting option chains from recording
- Add checking for market open - Remove SPX from recording - Hopefully precent the refresh token from being overwritten sometimes
This commit is contained in:
44
getOptionChain.sh
Executable file
44
getOptionChain.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
mkdir -p temp
|
||||
|
||||
ErrorLogLevel=err
|
||||
#Handle additional commandline parameters
|
||||
if [[ $1 == -* ]]; then
|
||||
if [[ $1 == "-ErrorAsWarning" ]]; then
|
||||
ErrorLogLevel=warning
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
|
||||
symbol=$1
|
||||
shift
|
||||
|
||||
queryString="?symbol=${symbol}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
queryString="${queryString}&$1=$2"
|
||||
shift; shift
|
||||
done
|
||||
|
||||
msg="Querying for Symbol: _${symbol}_ query string: _${queryString}_"
|
||||
systemd-cat -t "`basename $0` $1" -p debug <<< ${msg}
|
||||
|
||||
curl -s -X GET "https://api.schwabapi.com/marketdata/v1/chains${queryString}" \
|
||||
-H "Authorization: Bearer $(<access_token.dat)" > temp/optionChain.${symbol}.tmp.$$.json
|
||||
|
||||
jqQuery=".symbol"
|
||||
symbolCheck=$(jq -r ${jqQuery} < temp/optionChain.${symbol}.tmp.$$.json)
|
||||
if [[ "${symbol}" != "${symbolCheck}" ]]; then
|
||||
errMsg="ERROR: THE RESPONSE IS INCORRECT! Symbol: _${symbol}_ Check: _${symbolCheck}_ check file _temp/optionChain.${symbol}.tmp.$$.json_"
|
||||
systemd-cat -t "`basename $0` $1" -p ${ErrorLogLevel} <<< ${errMsg}
|
||||
if [[ "${ErrorLogLevel}" == "err" ]]; then
|
||||
>&2 echo "${errMsg}"
|
||||
fi
|
||||
exit 2
|
||||
else
|
||||
jq < temp/optionChain.${symbol}.tmp.$$.json
|
||||
rm temp/optionChain.${symbol}.tmp.$$.json
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user