- Fix SPX auto trading by differntiation of SPX and SPWX

- Prevent destruciton of the refresh token when things go wrong
- add auto trading wip code for order getting, and long trading
- add recording of 90 days out expiration tracking
- Add TSLA
This commit is contained in:
2024-07-17 14:08:55 -05:00
parent d242be4d5e
commit e9a651f92e
9 changed files with 255 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
#!/bin/bash
#set -x
set -e
IFS=$'\0'
inputFile="$1"
@@ -19,16 +20,18 @@ fi
dateKey=$(jq -r '.putExpDateMap | keys | .[]' "${inputFile}" | head -n 1)
systemd-cat -t "`basename $0` $1" -p debug <<< "Date-Key: _${dateKey}_"
jq '.putExpDateMap."'${dateKey}'"[]|map({symbol, delta, strikePrice,bid,ask}) |.[] | select(.delta >= -0.30 and .delta <= -0.25) ' "${inputFile}" | tail -n 7 > temp/shortLeg.json
jq '.putExpDateMap."'${dateKey}'"[]|map({symbol,delta,strikePrice,bid,ask,optionRoot}) |.[] | select(.delta >= -0.30 and .delta <= -0.25) ' "${inputFile}" | tail -n 8 > temp/shortLeg.json
shortStrike=$(jq -r '.strikePrice' < temp/shortLeg.json)
shortBid=$(jq -r '.bid' < temp/shortLeg.json)
shortAsk=$(jq -r '.ask' < temp/shortLeg.json)
shortSymbol=$(jq -r '.symbol' < temp/shortLeg.json)
shortOptionRoot=$(jq -r '.optionRoot' < temp/shortLeg.json)
msg="Short Symbol: _${shortSymbol}_ Strike: _${shortStrike}_ Bid: _${shortBid}_ Ask: _${shortAsk}_"
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}) | .[] | 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)
longAsk=$(jq -r '.ask' < temp/longLeg.json)