TradingView
natronix
1 dec 2021 05:32

options_expiration_and_strike_price_calculator 

BTC Perpetual Futures ContractBinance

Beskrivning

Library "options_expiration_and_strike_price_calculator"
TODO: add library description here

fun()

this is a library to help calculate options strike price and expiration that you can add to a script i use it mainly for symbol calulation to place orders to buy options on TD ameritrade so it will be set up to order options on TD ameritrade using json order placer and webhook it fills in the area in the json under symbol i suggest manually adding the year it should look like this is an example of an order to buy 10 call options using json through td ameritrade api


"complexOrderStrategyType": "NONE",
"orderType": "LIMIT",
"session": "NORMAL",
"price": "6.45",
"duration": "DAY",
"orderStrategyType": "SINGLE",
"orderLegCollection": [
{
"instruction": "BUY_TO_OPEN",
"quantity": 10,
"instrument": {
"symbol": "QQQ_{{plot("expmonth")}}{{plot(“expday”)}}21C{{plot("strike")}}",
"assetType": "OPTION"
}
}
]
}
Kommentarer
natronix
also i should add that this calculates the strike price perfectly but is just an estimate for the expiration date as their is only about 14 to 16 days a month on larger option like qqq and spy in a month.
natronix
the example json did not fully paste here it is again with the order properly their

{{
"complexOrderStrategyType": "NONE",
"orderType": "LIMIT",
"session": "NORMAL",
"price": "6.45",
"duration": "DAY",
"orderStrategyType": "SINGLE",
"orderLegCollection": [
{
"instruction": "BUY_TO_OPEN",
"quantity": 10,
"instrument": {
"symbol": "QQQ_{{plot("expmonth")}}{{plot(“expday”)}}21C{{plot("strike")}}",
"assetType": "OPTION"

}
}
]
}
natronix
@natronix,
"complexOrderStrategyType": "NONE",
"orderType": "LIMIT",
"session": "NORMAL",
"price": "6.45",
"duration": "DAY",
"orderStrategyType": "SINGLE",
"orderLegCollection":
this is a better example edited to be able to post of how to enter the plots and names
"instruction": "BUY_TO_OPEN",
"quantity": 10,
"instrument":
"symbol": "QQQ_{{plot("expmonth")}}{{plot(“expday”)}}21C{{plot("strike")}}",
"assetType": "OPTION"
natronix
@natronix, this is an example in of json to place an order for a call option through TDA api you can see the difened plot points that tradingview alerts fill in on symbol with year 21 and call option the letter C put in manualey the year can be put in through the script as well although it will need an update in the year 3000
Mer