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

@@ -0,0 +1,4 @@
Roth 55040747
Individual 58291665
IRA 80319442
Regular 89036276

View File

@@ -97,9 +97,9 @@ fi
./getNewAccessToken.sh
curl -s -X POST \
'https://api.schwabapi.com/trader/v1/accounts/CEF970366D4CC9553B5E8846E35FD92A1867F3E73C1082A52647256F42E4746B/orders' \
-H "Authorization: Bearer $(<access_token.dat)" \
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh IRA)/orders" \
-H "Authorization: Bearer $(<access_token.dat)" \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d "${orderJson}"
-d "${orderJson}"

View File

@@ -105,9 +105,9 @@ fi
./getNewAccessToken.sh
curl -s -X POST \
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
-H "Authorization: Bearer $(<access_token.dat)" \
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
-H "Authorization: Bearer $(<access_token.dat)" \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d "${orderJson}"
-d "${orderJson}"

View File

@@ -197,9 +197,9 @@ fi
curl -s -X POST \
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
-H "Authorization: Bearer $(<access_token.dat)" \
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
-H "Authorization: Bearer $(<access_token.dat)" \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d "${orderJson}"
-d "${orderJson}"

View File

@@ -9,7 +9,7 @@ if [[ ${marketOpen} == false ]]; then
errMsg="The market is closed, exiting."
systemd-cat -t "`basename $0` $1" -p info <<< ${errMsg}
>&2 echo "${errMsg}"
# exit 2
exit 2
fi
inputFile="$1"
@@ -152,9 +152,9 @@ fi
curl -s -X POST \
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
-H "Authorization: Bearer $(<access_token.dat)" \
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
-H "Authorization: Bearer $(<access_token.dat)" \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d "${orderJson}"
-d "${orderJson}"

View File

@@ -3,7 +3,7 @@ set -x
IFS=$'\0'
daysOutMin=90
daysOutMax=91
daysOutMax=95
deltaMin=0.35
deltaMax=0.40
@@ -104,10 +104,10 @@ fi
./getNewAccessToken.sh
curl -s -X POST \
'https://api.schwabapi.com/trader/v1/accounts/5A5B921917D97B89FDA53E1E1D13D2EB11E488ADA20A20B3C787477DE59A770E/orders' \
-H "Authorization: Bearer $(<access_token.dat)" \
echo curl -s -X POST \
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Roth)/orders" \
-H "Authorization: Bearer $(<access_token.dat)" \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d "${orderJson}"
-d "${orderJson}"

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

10
getPositions.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
#set -x
mkdir -p temp
./getNewAccessToken.sh
tempFile=temp/accountPositions.tmp.$$.json
curl -s -X GET "https://api.schwabapi.com/trader/v1/accounts/?fields=positions" -H "Authorization: Bearer $(<access_token.dat)" > ${tempFile}
jq -e '{ accountNumber:.[].securitiesAccount.accountNumber, positions:.[].securitiesAccount.positions}' < ${tempFile}