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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user