Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ETF's are not supported #90

Closed
shortland opened this issue Oct 1, 2022 · 6 comments
Closed

ETF's are not supported #90

shortland opened this issue Oct 1, 2022 · 6 comments

Comments

@shortland
Copy link

It seems that ETF symbols are not supported, is there any planned work for that?

@maread99
Copy link
Owner

maread99 commented Oct 1, 2022

Hi @shortland, thanks for raising this.

The default PricesYahoo class should support all symbols as defined by Yahoo.

It might be that it's not able to evaluate which calendar and/or real-time delay to assign to one or more symbols. Are you getting a CalendarError or a ValueError advising that the delay can't be ascertained?

If either of these is the issue then it's simply a matter of passing the calendar and/or delay to the PricesYahoo constructor.

For example, I noticed that a calendar isn't automatically evaluated for ETF 'SPY', so you could do...

>>> from market_prices import PricesYahoo
>>> import exchange_calendars as xcals
>>> xnys = xcals.get_calendar("XNYS")  # create calendar for New York Stock Exchange
>>> prices = PricesYahoo("SPY", calendars=xnys)
CalendarTooShortWarning: Calendar 'XNYS' is too short to support all available price history. Calendar starts '2002-10-01 00:00:00' whilst earliest date for which price history is available is '1993-01-29 00:00:00'. Prices will not be available for any date prior to 2002-10-01 00:00:00.

The warning is simply advising that the calendar is too short for the data that might be requested (xcals by default cover the last 20 years). If you're going to be working with data earlier than this then just define an appropriate start date for the calendar...

>>> xnys = xcals.get_calendar("XNYS", start="1993-01-01")
>>> prices = PricesYahoo("SPY", calendars=xnys)
>>> prices.get("1d", start="1997-10-22", days=3)
symbol           SPY
                open       high        low     close   volume
1997-10-22  97.34375  97.390625  96.531250  96.84375  4485200
1997-10-23  94.93750  95.750000  94.281250  94.93750  8054100
1997-10-24  96.15625  96.156250  93.671875  94.00000  6778700

>>> prices.get("5min", minutes=15)  # last 15 minutes of data
symbol                                             SPY
                                                  open        high         low       close    volume
[2022-09-30 15:45:00, 2022-09-30 15:50:00)  359.454987  360.049988  359.279999  359.609985   2333468
[2022-09-30 15:50:00, 2022-09-30 15:55:00)  359.619995  359.619995  358.105011  358.179901   7712651
[2022-09-30 15:55:00, 2022-09-30 16:00:00)  358.170013  358.269989  357.109985  357.179993  19516953

The above example is for a single symbol. If you've got multiple symbols trading on exchanges represented by different calendars and with different delays then the calendars/delays kwargs can be passed as mappings of symbols to calendars/delays. See help(PricesYahoo) for more info.

In any event, could you let me have a list of the symbols that weren't working for you. If it is a calendar/delay issue then I'll look to improve the mappings so that they are automatically assigned.

@shortland
Copy link
Author

Ah thank you. It was the calendar issue you mentioned. I wasn't sure exactly what the issue was based on the error message.

Thank you.

@maread99
Copy link
Owner

maread99 commented Oct 7, 2022

Glad it's sorted.

If you can let me know the symbols that you're using and I'll improve the mappings so that it's not necessary to assign the calendar.

@shortland
Copy link
Author

shortland commented Oct 11, 2022

Hey, thanks for the support.

SPY,QQQ,TQQQ,SQQQ,XRT,VOO,IWD,ARKK,ARKQ,ARKF

These are just some etf symbols I'm using - although maybe add a bunch of the top ETFs by market cap instead of my weird list.

https://8marketcap.com/etfs/

Greatly appreciate everything you're doing!

@maread99
Copy link
Owner

@shortland, the new release 0.9.10 includes the necessary mappings so that these symbols can be passed to PricesYahoo without the need to additionally pass a calendar.

I checked the first 100 @ https://8marketcap.com/etfs/ and they are all covered too. I'd anticipate the new mappings will cover pretty much all the US-traded ETFs.

@shortland
Copy link
Author

That's amazing!!! ❤️

Thank you so much!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants