Files
OptionRecorderSchwab/getAccountNumbers.sh

18 lines
635 B
Bash
Raw Normal View History

#!/bin/bash
#set -x
mkdir -p temp
tempFile=temp/accountNumbers.tmp.$$.json
tempFlatFile=temp/accountNumbers.flat.$$.tsv
2024-09-03 10:32:56 -05:00
curl -s -X GET "https://api.schwabapi.com/trader/v1/accounts/accountNumbers" -H "Authorization: Bearer $(./getNewAccessToken.sh)" > ${tempFile}
(jq -r '.[] | [.accountNumber, .hashValue ] | @tsv' < ${tempFile} | while read accNo accHash; do
read accInfo <<< $(grep ${accNo} accountNumberNameMapping.dat; echo ${accNo})
echo ${accInfo} ${accHash}
done) >> ${tempFlatFile}
if [[ "$1" != "" ]]; then
read accName accNum accHash <<< $(grep $1 ${tempFlatFile}); echo -n ${accHash}
else
cat ${tempFlatFile}
fi