improve output format of get orders, add check if trade has been executed to auto trader scripts

This commit is contained in:
2024-08-15 11:30:27 -05:00
parent fd90883e79
commit ef28aa59e5
4 changed files with 39 additions and 10 deletions

View File

@@ -30,7 +30,6 @@ msg="Short Symbol: _${shortSymbol}_ Strike: _${shortStrike}_ Bid: _${shortBid}_
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
echo "${msg}"
#jq '.putExpDateMap."'${dateKey}'"[]|map({symbol, delta, strikePrice,bid,ask}) | .[] | select(.strikePrice >= '${shortStrike}'-50 and .strikePrice < '${shortStrike}')' temp/orderInputFile.json | head -n 7 > temp/longLeg.json
jq '.putExpDateMap."'${dateKey}'"[]|map({symbol,delta,strikePrice,bid,ask,optionRoot}) | .[] | select(.optionRoot == "'${shortOptionRoot}'" and .strikePrice >= '${shortStrike}'-50 and .strikePrice < '${shortStrike}')' temp/orderInputFile.json | head -n 8 > temp/longLeg.json
longStrike=$(jq -r '.strikePrice' < temp/longLeg.json)
longBid=$(jq -r '.bid' < temp/longLeg.json)
@@ -40,6 +39,17 @@ msg="Long Symbol: _${longSymbol}_ Strike: _${longStrike}_ Bid: _${longBid}_ Ask:
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
msg="Not Yet traded, continuing"
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
else
msg="Already traded, exiting"
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
exit 0
fi
priceOffset=0.1 # try to get $10 more in premium...
price=$(echo "scale=2; ((${shortBid}+${shortAsk})/2 - (${longBid}+${longAsk})/2) + ${priceOffset}" | bc)
@@ -73,7 +83,6 @@ orderJson=$(jq -c <<-EOM
EOM
)
systemd-cat -t "`basename $0` $1" -p debug <<< "Order: _${orderJson}_"
#echo Enter to continue, Ctrl+C to cancel