Getting Option data from Option Symbol into Thinkscript


Category:
1
1

Playing with an Options Volume script. Needed some help with directly getting the Option series data from a Symbol instead of inputting the data separately. This will make life much more easier since one can just select and paste the specific option symbol and the script can pick up the rest. Following is the link to the thinkscript.

https://usethinkscript.com/threads/option-volume-open-interest-indicator-for-thinkorswim.313/

.SPY200207P323

declare lower;
input optionSeriesPrefix = “.SPY200207”;
input strike = 323.0;
input strikeSpacing = 10.0;
input mode = {default volume, totalVolume, openInterest, volumePercentOI};
input totalStrikes = {default Five, Three, One};

Marked as spam
Posted by (Questions: 5, Answers: 7)
Asked on February 2, 2020 5:44 pm
2447 views
1
Private answer

There are no tools in the Thinkorswim language to parse strings.

So it is not possible to take an OPRA code as an input and parse that string out into it's individual components.

There are two functions that can assist us. But not for this particular solution.

GetStrike(): https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related/GetStrike

IsPut(): https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related/IsPut

Each of these functions will only work for the ticker symbol loaded on the chart. So if your chart is displaying the underlying, say AAPL then neither of these functions will be useful. Those functions are only useful if your chart were set to an option string, such as .AAPL200228C305. You can also use those two functions in a custom watchlist column.

If it were possible to parse strings in Thinkorswim, I am certain the author of that code you referenced would have already included such functionality in the tool they built.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 3, 2020 11:02 am
-1
Private answer

The degree of complexity in solving this is WAY beyond the scope of anything I provide for no charge in the Q&A forum. There is over 200 lines of code in that chart study.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 2, 2020 9:47 pm
0
ut only need help with the first part. Need to grab the symbol and declare these variables currently set as inputs. The script should work once the symbol is parsed correctly for the 'optionSeriesPrefix' and 'input strike'. I can work with rest of the code to correct any other discrepancy if I can get this part to work
( at February 3, 2020 8:14 am)
0
It's no where near as simple as you think. It requires more than 60 lines of code be modified.
( at February 3, 2020 9:07 am)