Query Financial Data Conveniently with vistafetch
TL;DR
vistafetch
is a small and simple Python library to fetch financial data for stocks, ETFs, funds, etc. from Onvista.
Within this blog post, I'd like to introduce vistafetch
: a small and simple library to fetch financial data for stocks, ETFs, funds, etc. from Onvista. vistafetch
makes retrieving data for financial data a blast by providing an easy and simple-to-remember syntax. It is available on PyPI and can therefore be easily installed by using pip:
Discover Financial Assets ๐
The first step to work with vistafetch
is to create an instance of the VistaFetchClient
:
=
This client enables you to search for various financial assets on Onvista. You can simply use the search for keywords, like 'Apple':
=
This visualizes the found items as a tabular structure:
)
)
If you want to continue working with one of these assets you simply select your desired financial asset by its index shown in the table:
=
As an alternative, you can also directly search with identifiers, e.g., the ISIN or WKN:
=
=
Since we pass a unique identifier, we can be sure to get only one result. For this case, we can simply get the corresponding financial asset by using get()
.
A financial asset has the following metadata available:
entity_type
: The type of the financial asset, e.g., stock or bondisin
: The ISIN of the financial assetname
: The full name of the financial assettiny_name
: The short name of the financial assetwkn
: The WKN of the financial asset
All attributes can directly be accessed on the financial asset, e.g., vanguard_etf.wkn
. The full financial asset record looks the following:
# or alternatively as dictionary
{
}
Retrieve Price Data ๐ค
vistafetch
provides two different ways to retrieve price data for a financial asset. The first one simply returns the most recent available price data. This can be queried by running:
=
This returns an instance of PriceData which encompasses several price-related values and their corresponding timestamp. The full structure looks the following (via price_data.as_json()
):
{
}
Every value can directly be accessed as attribute on price_data
, e.g., price_data.open
. Second, we can also query the price data for a specific date:
> .
77.891
Future Roadmap
In next future, more time intervals are planned to be supported for price data retrieval so that data can also be queried for a month, a year, etc.
If you have any ideas or wishes beyond that, please feel to create a feature request.
Problems? ๐
Feel free to open an issue if you experience strange behavior or bugs when using vistafetch
. If you are not sure if your problem should be considered a bug or if you have a question in general, reach out via discussions.