Add caching to market hour and cater for (long) weekends in the 1DTE trade automation

This commit is contained in:
2024-08-30 15:39:18 -05:00
parent 51b4d17cd7
commit e0be7c1889
3 changed files with 14 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ fi
inputFile="$1"
if [[ "" == "$inputFile" ]]; then
inputFile=temp/orderInputFile.$$.json
./getOptionChain.sh '$SPX' fromDate $(date "+%Y-%m-%d" -d "+1 days") toDate $(date "+%Y-%m-%d" -d "+1 days") > "${inputFile}"
./getOptionChain.sh '$SPX' fromDate $(date "+%Y-%m-%d" -d "+1 days") toDate $(date "+%Y-%m-%d" -d "+4 days") > "${inputFile}"
fi
if [[ ! -f "${inputFile}" ]]; then
throw "ERROR: Input file _${inputFile}_ does not exist." err 1
@@ -23,9 +23,9 @@ dateKey=$(jq -r '.putExpDateMap | keys | .[]' "${inputFile}" | head -n 1)
log "Date-Key: _${dateKey}_" debug
underlyingPrice=$(jq ".underlyingPrice" "${inputFile}")
log "Underlying Price: _${underlyingPrice}_" debug
atmStrike=$(jq -r '.callExpDateMap[]|keys[]' "${inputFile}" | sort -n | awk -e '{lastStrike=$1; if ($1 > '${underlyingPrice}') {print $1; exit } }')
optionRoot=SPXW #I only want the PM expiry (SPX without the W is AM expiry)
jq '.putExpDateMap."'${dateKey}'"[]|map({symbol,delta,strikePrice,bid,ask,optionRoot}) |.[] | select(.optionRoot == "'${optionRoot}'" and .strikePrice=='${atmStrike}') ' "${inputFile}" | tail -n 8 > temp/shortLegP.json