Package: yahoo_finance_async
yahoo-finance-asyncA simple Python async API wrapper for the deprecated (but currently still working) Yahoo Finance API.Although the Yahoo Finance API has officially been closed down, it does still work and it provides a free access to a vast number of stocks.Warning- The Yahoo Finance API could be removed or shut down at any point.  You use this package at your own risk.Why async?There are many Yahoo Finance API libraries available on PyPi which use synchronous functions.  There do not seem to be async functions available yet (as far as I could find).  I needed an async version for a simple project to collect candle data (OHLC) for various stocks.Endpoints availableNote that currently this API wrapper does not cover all the Yahoo Finance endpoints.  In fact currently it only covers:Collecting the OHLC (candlestick) data for stocks on Yahoo FinanceGetting startedInstall fromPyPiusingpip install yahoo-finance-asyncNote that you import it into your module with underscoresimport yahoo_finance_asyncThis library has a simple class calledOHLCwhich has a simple class method (actually an async coroutine) calledfetch()which will fetch and parse the candle (OHLC) data.You need toawaitthe response of this coroutine.For example to fetch this historical data for the stockAAPL:importasynciofromyahoo_finance_asyncimportOHLCasyncdefmain():result=awaitOHLC.fetch(symbol='AAPL')# Do something with the resultasyncio.run(main())The returnedresultis a dictionary with two parts:candles- these are list of candle dictionary objects.  For example:# result['candles'] gives ...[{"datetime":datetime.datetime(2020,4,1,0,0),"open":235.3,"high":245.667,"low":213.33,"close":233.5,"volume":23},{...},{...}]meta- this is the information about the symbol and timing that is returned by the Yahoo API which can be used for error checking.  For example confirming you got the right symbol and time intervalsAdditional parametersAdditional parameters can be passed to theOHLC.fetch()class methodfromyahoo_finance_asyncimportOHLC,Interval,History# Fetch weekly candles for the last yearawaitOHLC('AAPL',interval=Interval.WEEK,history=History.YEAR)# Fetch hourly candles for the last five daysawaitOHLC('AAPL',interval=Interval.HOUR,history=History.FIVE_DAYS)TheIntervalandHistoryobjects are Enums which show which time periods are available on the API.Example notebookTo see a live example you can look at theattached notebookRate limitsBe careful and kind to the Yahoo Finance API and don't hit it too hard.ContributingCurrently this API is focused just on the OHLC candle data.  If you wish to contribute and extend the functionality please do.  Comments, suggestions and pull requests are welcome.Developers should clone the GitHub repo, and then install the development dependencies in therequirement-dev.txtfile.  Run all tests withpytest.If you do contribute please also keep tests and documentation up to date.  Thanks.Release Notes0.1.2 - Fix to stop processing when None values are received from the API when parsing candles0.1.3 - Revised fix to the None values from API when parsing.  Now the API will drop candles that cannot be parsed but will raise a Python warning message when this happens.