Flexibility changes in generic Long call trader
This commit is contained in:
@@ -4,15 +4,21 @@ IFS=$'\0'
|
||||
|
||||
. helpers.sh
|
||||
|
||||
|
||||
msg=$(echo "Called with parameters: _$@_")
|
||||
log "$msg" info
|
||||
|
||||
Symbol="$1"
|
||||
if [[ -z ${Symbol} ]]; then
|
||||
throw "A Stock symbol must be given as first parameter. exiting." err 2
|
||||
fi
|
||||
shift
|
||||
|
||||
AccountName="$2"
|
||||
AccountName="$1"
|
||||
if [[ -z ${AccountName} ]]; then
|
||||
throw "An Account name must be given as first parameter. exiting." err 2
|
||||
fi
|
||||
shift
|
||||
|
||||
if [[ -z $(./getAccountNumbers.sh "${AccountName}") ]]; then
|
||||
throw "An the account with name _${AccountName}_ doesn't exist. exiting." err 2
|
||||
@@ -23,16 +29,23 @@ if [[ ${marketOpen} == false ]]; then
|
||||
throw "The market is closed, exiting." info 2
|
||||
fi
|
||||
|
||||
#Trade variables - overwrite with -VAR_<variable name>=<value>
|
||||
daysOutMin=87
|
||||
daysOutMax=91
|
||||
deltaMin=0.35
|
||||
deltaMax=0.40
|
||||
priceOffset=0.0
|
||||
checkPositionExists=true
|
||||
|
||||
marketOpen=$([[ $(./getMarketHours.sh | jq '.option[].isOpen' | grep true | wc -l) -ne 0 ]] && echo true || echo false)
|
||||
if [[ ${marketOpen} == false ]]; then
|
||||
throw "The market is closed, exiting." info 2
|
||||
fi
|
||||
|
||||
#Allow to overwrite any variable by a commandline parameter with the name of the variable:
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
if [[ ${1:0:5} == "-VAR_" ]]; then
|
||||
log "Setting Variable: ${1:5}" info
|
||||
eval ${1:5}
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
inputFile=temp/orderInputFile.$$.json
|
||||
./getOptionChain.sh ''${Symbol}'' fromDate $(date "+%Y-%m-%d" -d "+${daysOutMin} days") toDate $(date "+%Y-%m-%d" -d "+${daysOutMax} days") > "${inputFile}"
|
||||
@@ -65,15 +78,16 @@ longAsk=$(jq -r '.ask' < temp/longLeg.json)
|
||||
longSymbol=$(jq -r '.symbol' < temp/longLeg.json)
|
||||
log "Long Symbol: _${longSymbol}_ Strike: _${longStrike}_ Bid: _${longBid}_ Ask: _${longAsk}_" info
|
||||
|
||||
#Check if this order has already been submitted.
|
||||
./getOrders.sh | grep '\(WORKING\|FILLED\),'"${longSymbol:0:12}" > temp/existingOrders.$$
|
||||
if [[ $(wc -l < temp/existingOrders.$$) -eq 0 ]];then
|
||||
log "Not Yet traded, continuing" info
|
||||
else
|
||||
throw "Already traded, exiting" info
|
||||
fi
|
||||
if [[ "${checkPositionExists}" = true ]]; then
|
||||
#Check if this order has already been submitted.
|
||||
./getOrders.sh | grep '\(WORKING\|FILLED\),'"${longSymbol:0:12}" > temp/existingOrders.$$
|
||||
if [[ $(wc -l < temp/existingOrders.$$) -eq 0 ]];then
|
||||
log "Not Yet traded, continuing" info
|
||||
else
|
||||
throw "Already traded, exiting" info
|
||||
fi
|
||||
fi
|
||||
|
||||
priceOffset=0.0
|
||||
# Get the Middle price...
|
||||
price=$(echo "scale=2; ((${longBid}+${longAsk})/2) + ${priceOffset}" | bc)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ noconfirm=true
|
||||
# m h dom mon dow command
|
||||
|
||||
# Export crontab to have it in version control too
|
||||
30 9 * * 1-5 crontab -l > ~/OptionRecorderSchwab/crontabExport.txt
|
||||
29 8 * * 1-5 crontab -l > ~/OptionRecorderSchwab/crontabExport.txt
|
||||
|
||||
# Recording
|
||||
*/15 8-15 * * 1-5 cd ~/OptionRecorderSchwab && ./recordAllSymbolsSingleRun.sh
|
||||
@@ -35,12 +35,13 @@ noconfirm=true
|
||||
|
||||
##Auto-trading
|
||||
# Weekly put credit spreads
|
||||
35 10 * * 4 cd ~/OptionRecorderSchwab && ./autoTradeSPXPutCreditSpread.sh
|
||||
# Paused, too many outstanding contracts 35 10 * * 4 cd ~/OptionRecorderSchwab && ./autoTradeSPXPutCreditSpread.sh
|
||||
# Weekly long SPY position
|
||||
37 10 * * 4 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh SPY Roth -VAR_checkPositionExists=flase -VAR_daysOutMax=120
|
||||
#Paused, market downturn might take long... 37 10 * * 4 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh SPY Roth -VAR_checkPositionExists=flase -VAR_daysOutMax=120
|
||||
# 90 day out trades as soon as those options pop up
|
||||
36 10 * * 1-5 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh QQQ IRA
|
||||
38 10 * * 1-5 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh DIA IRA
|
||||
37 10 * * 1-5 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh SPY Roth
|
||||
38 10 * * 1-5 cd ~/OptionRecorderSchwab && ./autoTradeGenericLongCall.sh DIA IRA -VAR_daysOutMin=85
|
||||
|
||||
#1DTE SPX trading every day right after the market closes.
|
||||
#59 14 * * 1-5 cd ~/OptionRecorderSchwab && ./autoTradeSPX_IB_1DTE.sh
|
||||
|
||||
@@ -26,6 +26,7 @@ fi
|
||||
cacheFileName=temp/marketHours.`date +%Y%m%d`.${markets//&markets=/_}.tmp
|
||||
|
||||
if [[ -f ${cacheFileName} ]]; then
|
||||
log "Answering from cache file _${cacheFileName}_ query string: _${queryString}_" debug
|
||||
jq < ${cacheFileName}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user