How to determine if a symbol is an option or an equity?

Cujuju

New member
I'm trying to tweak my profit/loss label and if it's an option I want to multiple the profit/loss to match the contract size. I've searched and I figure this has to be out there, but I can't figure out how to search for what I want.
 
@Cujuju Hopefully I understand what you're asking. So to view the profit/loss of an option contract, it is necessary to use the specific option symbol. As an example, the May 21, 2021 413 put contract symbol for the SPY is ".SPY210521P413". Once you pull up a chart of the option contract, the profit/loss label should display the necessary data whether that be Open P/L, # of contracts, entry price, etc.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

TDA's ThinkScript Reference is a good resource for finding what the language can provide.

I don't see anything that will give you the contract size, though I didn't look very hard, but depending on what you're trading, you can almost always assume 100. There's a GetUnderlyingSymbol function you could try using to determine if the current symbol is an option. I would check on a stock to see whether it returns Double.NaN or an empty string. Then to test if it's an option you can write !IsNaN(result) or result != "".
 
I ended up using:
Code:
def qty = GetQuantity() * TickValue()/TickSize();

It doesn't tell me if it's an option or equity, but what I was really interested in was the block size and this works for the average price I'm trying to calculate.
 
I'm trying to tweak my profit/loss label and if it's an option I want to multiple the profit/loss to match the contract size. I've searched and I figure this has to be out there, but I can't figure out how to search for what I want.
How about something like this? I am not sure how this works on futures etc. which has months /different expiry.

def isStock = if (getUnderlyingSymbol()== getSymbol()) then yes else no;
AddLabel(yes, isStock);
 
How about something like this? I am not sure how this works on futures etc. which has months /different expiry.

def isStock = if (getUnderlyingSymbol()== getSymbol()) then yes else no;
AddLabel(yes, isStock);

Not all stocks are optionable. Stocks, etfs, futures, forex (maybe nfts?) can be optionable. Therefore the only thing IsOptionable() tells you reliably is the current symbol isn't an option. GetUnderlyingSymbol() tells you reliably if the current symbol is an option. Neither of them tells you reliably if the current symbol is a stock, is an etf, is a forex pair or is a futures contract.
 
Last edited:
IsOptionable() simply tells whether the symbol is optionable or, to put it another way, has an option chain... It tells nothing else about the underlying...
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
212 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top