Fix auto trading SPX, ends program if order doesn't exist due to grep errorlevel

This commit is contained in:
2024-08-22 11:17:17 -05:00
parent 7f3e1d74bb
commit ea050ab12a
2 changed files with 5 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
#set -x
set -e
IFS=$'\0'
myPID=$$
inputFile="$1"
if [[ "" == "$inputFile" ]]; then
@@ -40,8 +41,9 @@ systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
echo "${msg}"
#Check if this order has already been submitted.
./getOrders.sh | grep '\(WORKING\|FILLED\),\('${longSymbol}'\|'${shortSymbol}'\)' > temp/existingOrders.$$
if [[ $(wc -l < temp/existingOrders.$$) -eq 0 ]];then
./getOrders.sh | (grep '\(WORKING\|FILLED\),\('${longSymbol}'\|'${shortSymbol}'\)' || true) > temp/existingOrders.${myPID}
if [[ $(wc -l < temp/existingOrders.${myPID} -eq 0 ]];then
msg="Not Yet traded, continuing"
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
else