Introduce mnemonic account name resolution in getAccountNumbers

This commit is contained in:
2024-08-26 21:44:43 -05:00
parent 5535bdae7f
commit d8891ec75f
8 changed files with 42 additions and 21 deletions

View File

@@ -2,9 +2,16 @@
#set -x
mkdir -p temp
./getNewAccessToken.sh
tempFile=temp/accountNumbers.tmp.$$.json
tempFlatFile=temp/accountNumbers.flat.$$.tsv
curl -s -X GET "https://api.schwabapi.com/trader/v1/accounts/accountNumbers" -H "Authorization: Bearer $(<access_token.dat)" > ${tempFile}
jq '.' < ${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