Re-introduced stiching as a fallback for SPY too big; automatic order entry creation for SPX Put Spread works now.
This commit is contained in:
@@ -28,7 +28,7 @@ msg="Short Symbol: _${shortSymbol}_ Strike: _${shortStrike}_ Bid: _${shortBid}_
|
||||
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
|
||||
echo "${msg}"
|
||||
|
||||
jq '.putExpDateMap."2024-07-10:43"[]|map({symbol, delta, strikePrice,bid,ask}) | .[] | select(.strikePrice >= 5210-50 and .strikePrice < 5210)' temp/orderInputFile.json | head -n 7 > temp/longLeg.json
|
||||
jq '.putExpDateMap."'${dateKey}'"[]|map({symbol, delta, strikePrice,bid,ask}) | .[] | select(.strikePrice >= '${shortStrike}'-50 and .strikePrice < '${shortStrike}')' temp/orderInputFile.json | head -n 7 > temp/longLeg.json
|
||||
longStrike=$(jq -r '.strikePrice' < temp/longLeg.json)
|
||||
longBid=$(jq -r '.bid' < temp/longLeg.json)
|
||||
longAsk=$(jq -r '.ask' < temp/longLeg.json)
|
||||
@@ -37,11 +37,14 @@ msg="Long Symbol: _${longSymbol}_ Strike: _${longStrike}_ Bid: _${longBid}_ Ask:
|
||||
systemd-cat -t "`basename $0` $1" -p info <<< ${msg}
|
||||
echo "${msg}"
|
||||
|
||||
orderJson=$(cat <<-EOM
|
||||
priceOffset=0.1 # try to get $10 more in premium...
|
||||
price=$(echo "scale=2; ((${shortBid}+${shortAsk})/2 - (${longBid}+${longAsk})/2) + ${priceOffset}" | bc)
|
||||
|
||||
orderJson=$(jq -c <<-EOM
|
||||
{
|
||||
"orderType": "NET_CREDIT",
|
||||
"session": "NORMAL",
|
||||
"price": 5,
|
||||
"price": ${price},
|
||||
"duration": "DAY",
|
||||
"orderStrategyType": "SINGLE",
|
||||
"quantity": 1,
|
||||
@@ -68,14 +71,16 @@ EOM
|
||||
)
|
||||
|
||||
|
||||
echo ${orderJson}
|
||||
systemd-cat -t "`basename $0` $1" -p debug <<< "Order: _${orderJson}_"
|
||||
|
||||
#echo Enter to continue, Ctrl+C to cancel
|
||||
#read
|
||||
./getNewAccessToken.sh
|
||||
|
||||
set -x
|
||||
tempFile=temp/order.tmp.$$.json
|
||||
#curl -s -X POST "https://api.schwabapi.com/trader/v1/accounts/99114DC5A768D40C3FD47D02734C696EB1FEB1063D2EE864528135D8CF31392A/orders" -H "Authorization: Bearer $(<access_token.dat)" -d @order-vs.template.json # > ${tempFile}
|
||||
curl -s -X POST \
|
||||
'https://api.schwabapi.com/trader/v1/accounts/E8A70AE41449257FA5A7EABFF463BA93F23E629B909C3E09DA192582718D7627/orders' \
|
||||
'https://api.schwabapi.com/trader/v1/accounts/C819AC820A502BA92E55D775B22BDF0E1BC91D86C62685714347734A5827CCB3/orders' \
|
||||
-H "Authorization: Bearer $(<access_token.dat)" \
|
||||
-H 'accept: */*' \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
||||
Reference in New Issue
Block a user