2024-05-28 15:25:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
#set -x
|
|
|
|
|
mkdir -p temp
|
|
|
|
|
|
|
|
|
|
tempFile=temp/accountNumbers.tmp.$$.json
|
2024-08-26 21:44:43 -05:00
|
|
|
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}
|
2024-08-26 21:44:43 -05:00
|
|
|
(jq -r '.[] | [.accountNumber, .hashValue ] | @tsv' < ${tempFile} | while read accNo accHash; do
|
|
|
|
|
read accInfo <<< $(grep ${accNo} accountNumberNameMapping.dat; echo ${accNo})
|
|
|
|
|
echo ${accInfo} ${accHash}
|
|
|
|
|
done) >> ${tempFlatFile}
|
2024-05-28 15:25:56 -05:00
|
|
|
|
2024-08-26 21:44:43 -05:00
|
|
|
if [[ "$1" != "" ]]; then
|
|
|
|
|
read accName accNum accHash <<< $(grep $1 ${tempFlatFile}); echo -n ${accHash}
|
|
|
|
|
else
|
|
|
|
|
cat ${tempFlatFile}
|
|
|
|
|
fi
|