Getting underlying's current price

jphalip

New member
Hi,

I feel like this might be a super trivial question, but I can't seem to find something that consistently works. In a script for a custom quote displayed in the option chain, I'm trying to get the underlying's current (last) price.

I'm using this:

Code:
def underlyingStockLastPrice = close(GetUnderlyingSymbol(), priceType = PriceType.LAST);

However, this seems to return different values for each strike in the option chain. What am I missing?

Thanks,

Julien
 
it works for me. i added a plot to display the values.

a couple of notes,
...it takes time for valid prices to show up , 10+ seconds
...if option volume is 0, then the price seems to be an error or wrong. so a check for volume == 0 should be used.

def underlyingStockLastPrice = close(GetUnderlyingSymbol(), priceType = PriceType.LAST);
plot z = underlyingStockLastPrice;
 

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

Thanks for your reply. That's odd, it is 8pm PST on July 13 2021 here and I'm looking at the July 16 option chain for ABNB. The last stock price is 143.41 and yet, "close(GetUnderlyingSymbol(), priceType = PriceType.LAST)" returns weird values for some strikes. For example on the call side:

  • 65: 144.85
  • 70: 151.78
  • 75: 149.94
  • 85: 150.7
  • 90: 148.37
  • etc.

Am I missing something?
 
Thanks for your reply. That's odd, it is 8pm PST on July 13 2021 here and I'm looking at the July 16 option chain for ABNB. The last stock price is 143.41 and yet, "close(GetUnderlyingSymbol(), priceType = PriceType.LAST)" returns weird values for some strikes. For example on the call side:

  • 65: 144.85
  • 70: 151.78
  • 75: 149.94
  • 85: 150.7
  • 90: 148.37
  • etc.

Am I missing something?
You only receive strange stock prices for strike prices with zero volume. Otherwise, it works when the option has volume.
 
Ok I see. That seems like a bug, no? I'm not sure why the volume for a given strike would affect the returned price value for the underlying. I might report it to the developers.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
533 Online
Create Post

Similar threads

Similar threads

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