Files
OptionRecorderSchwab/record90dayOut.sh
Joe Tretter e9a651f92e - 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
2024-07-17 14:08:55 -05:00

33 lines
995 B
Bash
Executable File

#!/bin/bash
#set -x
IFS=$'\0'
daysOutMin=90
daysOutMax=91
inputFile="$1"
latestFile="$1"
if [[ "" == "$inputFile" ]]; then
latestFile="$(ls data/`date +%Y-%m-%d`/*SPY* | sort | tail -n 1)"
systemd-cat -t "`basename $0` $1" -p debug <<< "Latest File: _${latestFile}_"
inputFile=temp/orderInputFile.json
bzip2 -dc < "${latestFile}" > "${inputFile}"
fi
if [[ ! -f "${inputFile}" ]]; then
errMsg="ERROR: Input file _${inputFile}_ does not exist."
systemd-cat -t "`basename $0` $1" -p err <<< ${errMsg}
>&2 echo "${errMsg}"
exit 1
fi
dateKey=$(jq -r '.callExpDateMap | keys | .[]' temp/orderInputFile.json | sort -r -t ":" +2 | awk -F ":" -e '{theDay=$2; if (theDay < '${daysOutMin}') { print lastDay; exit; } else { lastDay=$0; } }')
systemd-cat -t "`basename $0` $1" -p debug <<< "Date-Key: _${dateKey}_"
daysOut=$(cut -d : -f 2 <<< ${dateKey})
if [[ ${daysOut} -gt ${daysOutMax} ]]; then
exit
fi
echo "$(date +%Y-%m-%d): ${dateKey} (${latestFile})" >> record90dayOut.log