TradeNote icon indicating copy to clipboard operation
TradeNote copied to clipboard

Error when view chart for options using Polygon

Open hassan-elamir opened this issue 1 year ago • 1 comments

I added an API key from Polygon, but I get this error message. TypeError: Cannot read properties of undefined (reading 'length') image

Polygon is capable of charting aggregates (Bars) for options. Please see below link for Polygon documentations. https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__range__multiplier___timespan___from___to

The issue is that Polygon ticker symbol for options starts with O: image

But the csv file from Interactive Brockers does not come with this extra "O:" by default image

hassan-elamir avatar Dec 26 '24 01:12 hassan-elamir

I faced with exactly this problem as well. The problem as I see is that the symbol in option trades is actually an underlying stock, which is SPY in your case. There are two problems with this approach:

  1. In the trades you will only see SPY. You won't see wether it's a Call/Put, expiration date, strike price
  2. The app sends a ticker as "O:SPY" which doesn't make any sense for Polygon because in this format it expects an option.

I ended up writing a simple python script to process an exported CSV file from IBKR. What it does:

  1. Removes spaces in the Symbol column to convert SPY 250904P00642000 to SPY250904P00642000
  2. Copies the value to the UnderlyingSymbol column to replace SPY with SPY250904P00642000

Now Polygon recognises them properly and I have charts

Image

TradeNoteConvert.py

radionoise avatar Sep 04 '25 11:09 radionoise