Add caching to market hour and cater for (long) weekends in the 1DTE trade automation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user