Add number of days to look back to the getting of the orders; use in 1DTE trade

This commit is contained in:
2024-08-29 15:50:22 -05:00
parent d9c479af18
commit 51b4d17cd7
2 changed files with 16 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ longSymbolC=$(jq -r '.symbol' < temp/longLegC.json)
log "Long Symbol: _${longSymbolC}_ Strike: _${longStrikeC}_ Bid: _${longBidC}_ Ask: _${longAskC}_" info
#Check if this order has already been submitted.
./getOrders.sh | (grep '\(WORKING\|FILLED\),'${longSymbolC:0:12} || true) > temp/existingOrders.${myPID}
./getOrders.sh -daysBack 1 | (grep '\(WORKING\|FILLED\),'${longSymbolC:0:12} || true) > temp/existingOrders.${myPID}
if [[ $(wc -l < temp/existingOrders.${myPID}) -eq 0 ]];then
log "Not Yet traded, continuing" info

View File

@@ -2,11 +2,24 @@
#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")
while [[ $# -gt 0 ]]
do
case "$1" in
-daysBack) fromEnteredTime=$(date -u "+%Y-%m-%dT%H:%M:%S.000Z" -d "-$2 days");
shift;shift
;;
-*|--*|*) echo "Invalid option: -$1"; exit 1;;
esac
done
echo $fromEnteredTime
./getNewAccessToken.sh
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}