Introduce mnemonic account name resolution in getAccountNumbers
This commit is contained in:
4
accountNumberNameMapping.dat
Normal file
4
accountNumberNameMapping.dat
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Roth 55040747
|
||||||
|
Individual 58291665
|
||||||
|
IRA 80319442
|
||||||
|
Regular 89036276
|
||||||
@@ -97,7 +97,7 @@ fi
|
|||||||
./getNewAccessToken.sh
|
./getNewAccessToken.sh
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
'https://api.schwabapi.com/trader/v1/accounts/CEF970366D4CC9553B5E8846E35FD92A1867F3E73C1082A52647256F42E4746B/orders' \
|
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh IRA)/orders" \
|
||||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ fi
|
|||||||
./getNewAccessToken.sh
|
./getNewAccessToken.sh
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
|
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
|
||||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
|
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
|
||||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ if [[ ${marketOpen} == false ]]; then
|
|||||||
errMsg="The market is closed, exiting."
|
errMsg="The market is closed, exiting."
|
||||||
systemd-cat -t "`basename $0` $1" -p info <<< ${errMsg}
|
systemd-cat -t "`basename $0` $1" -p info <<< ${errMsg}
|
||||||
>&2 echo "${errMsg}"
|
>&2 echo "${errMsg}"
|
||||||
# exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
inputFile="$1"
|
inputFile="$1"
|
||||||
@@ -152,7 +152,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
|
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Regular)/orders" \
|
||||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ set -x
|
|||||||
IFS=$'\0'
|
IFS=$'\0'
|
||||||
|
|
||||||
daysOutMin=90
|
daysOutMin=90
|
||||||
daysOutMax=91
|
daysOutMax=95
|
||||||
deltaMin=0.35
|
deltaMin=0.35
|
||||||
deltaMax=0.40
|
deltaMax=0.40
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ fi
|
|||||||
|
|
||||||
./getNewAccessToken.sh
|
./getNewAccessToken.sh
|
||||||
|
|
||||||
curl -s -X POST \
|
echo curl -s -X POST \
|
||||||
'https://api.schwabapi.com/trader/v1/accounts/5A5B921917D97B89FDA53E1E1D13D2EB11E488ADA20A20B3C787477DE59A770E/orders' \
|
"https://api.schwabapi.com/trader/v1/accounts/$(./getAccountNumbers.sh Roth)/orders" \
|
||||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
|
|||||||
@@ -2,9 +2,16 @@
|
|||||||
#set -x
|
#set -x
|
||||||
mkdir -p temp
|
mkdir -p temp
|
||||||
|
|
||||||
./getNewAccessToken.sh
|
|
||||||
|
|
||||||
tempFile=temp/accountNumbers.tmp.$$.json
|
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}
|
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
10
getPositions.sh
Executable 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}
|
||||||
|
|
||||||
Reference in New Issue
Block a user