diff --git a/accountNumberNameMapping.dat b/accountNumberNameMapping.dat new file mode 100644 index 0000000..b8bc9d4 --- /dev/null +++ b/accountNumberNameMapping.dat @@ -0,0 +1,4 @@ +Roth 55040747 +Individual 58291665 +IRA 80319442 +Regular 89036276 diff --git a/autoTradeQQQLongCall.sh b/autoTradeQQQLongCall.sh index 6a32ebf..cb3ffac 100755 --- a/autoTradeQQQLongCall.sh +++ b/autoTradeQQQLongCall.sh @@ -97,9 +97,9 @@ fi ./getNewAccessToken.sh curl -s -X POST \ - 'https://api.schwabapi.com/trader/v1/accounts/CEF970366D4CC9553B5E8846E35FD92A1867F3E73C1082A52647256F42E4746B/orders' \ - -H "Authorization: Bearer $(&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 $( ${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 diff --git a/getPositions.sh b/getPositions.sh new file mode 100755 index 0000000..fb3d746 --- /dev/null +++ b/getPositions.sh @@ -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 $( ${tempFile} +jq -e '{ accountNumber:.[].securitiesAccount.accountNumber, positions:.[].securitiesAccount.positions}' < ${tempFile} +