Files
OptionRecorderSchwab/getOrders.sh

14 lines
648 B
Bash
Executable File

#!/bin/bash
#set -x
mkdir -p temp
./getNewAccessToken.sh
tempFile=temp/accountOrders.tmp.$$.json
fromEnteredTime=$(date -u "+%Y-%m-%dT%H:%M:%S.000Z" -d "-100 days")
toEnteredTime=$(date -u "+%Y-%m-%dT%H:%M:%S.000Z" -d "-0 minutes")
curl -s -X GET "https://api.schwabapi.com/trader/v1/orders?fromEnteredTime=${fromEnteredTime}&toEnteredTime=${toEnteredTime}" -H "Authorization: Bearer $(<access_token.dat)" > ${tempFile}
#jq -r 'map(.enteredTime)[]' < ${tempFile}
#jq -r '.[].orderLegCollection[].instrument.symbol' < ${tempFile}
jq -r '.[] | [.orderId | tostring][0] + "," + .status + "," + .orderLegCollection[].instrument.symbol' < ${tempFile}