Skip to main content

Small & simple library to fetch financial data for stocks, ETFs, funds, etc. from Onvista.

Project description


VistaFetch Logo
VistaFetch

VistaFetch is a simple and lightweight Python library for financial asset data retrieval (stocks, ETFs, etc.) from onvista.de.

License Apache 2.0 Continuous Integration status PyPI released version PyPI supported Python versions Code Style: Black Typed: MyPy Linting: Ruff Dependency & Build Management: Poetry pre-commit Pydantic v2

[!WARNING]
The API used by this package is not public. Therefore, users should assume that using this package may violate the site's terms of use. The author of this package takes no responsibility for how individuals use the code. It is important to use the code respectfully and judiciously, keeping in mind the potential consequences of violating the terms of service and applicable laws. Users are encouraged to read the API Terms and Conditions, Acceptable Use Policy, and License Agreements before using any API. These agreements outline the legal, business, and technical considerations that apply to the use of an API.

โšก๏ธ Quickstart

Please ensure that vistafetch is installed on your machine by running the following command:

pip install vistafetch

The first step is to initiate the client (VistaFetchClient):

from vistafetch import VistaFetchClient

client = VistaFetchClient()

๐Ÿ”Ž Exploratory search

The client now enables you to search for assets and allows you to investigate the results:

result = client.search_asset(
    search_term="S&P",
)
result.visualize()

This produces the following console output:

               Financial assets discovered                
โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Index โ”ƒ      Name      โ”ƒ   Asset Type   โ”ƒ     ISIN     โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚   0   โ”‚    S&P 500     โ”‚     INDEX      โ”‚ US78378X1072 โ”‚
โ”‚   1   โ”‚ Siemens Energy โ”‚     STOCK      โ”‚ DE000ENER6Y0 โ”‚
โ”‚   2   โ”‚  Silberpreis   โ”‚ PRECIOUS_METAL โ”‚ XC0009653103 โ”‚
โ”‚   3   โ”‚      SAP       โ”‚     STOCK      โ”‚ DE0007164600 โ”‚
โ”‚   4   โ”‚ EURO STOXX 50  โ”‚     INDEX      โ”‚ EU0009658145 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

One now can access the asset of choice:

asset = result.get(3)  # returns SAP in this case

# in case one simply wants the first one, the following shorthand takes you there
asset = result.get()

One can now access several parameters of the asset or convert them to a JSON string as show below.

print(asset.isin)
print(asset.as_json())
DE0007164600
{
  "display_type":"Aktie",
  "entity_type":"STOCK",
  "isin":"DE0007164600",
  "name":"SAP",
  "tiny_name":"SAP",
  "wkn":"716460",
}

As a final step, the asset provides some recent price-related data:

print(asset.get_latest_price_data().as_json())
{
  "currency_symbol":"EUR",
  "datetime_high":"2023-08-25T14:17:15Z",
  "datetime_last":"2023-08-25T15:37:14Z",
  "datetime_low":"2023-08-25T15:02:12Z",
  "datetime_open":"2023-08-25T07:00:26.999000Z",
  "high":127.24,
  "last":126.16,
  "low":125.66,
  "open":126.2,
}

In addition, you directly access the individual values, e.g., price value last:

asset.get_latest_price_data().last
126.16

[!NOTE]
Price data are currently only supported for funds and stocks. Feel free to send me a feature request if you'd like to see this feature supported for other asset types as well: https://github.com/bossenti/vistafetch/issues/new. As an alternative, contributions are welcome at any time.

๐ŸŽฏ Targeted search

In case you already know the identifier for your asset (both ISIN and WKN are supported), you can directly query them. This returns then only one result:

result = client.search_asset(
    search_term="DE0007164600",  # alternatively pass the WKN here
)
sap_stock = result.get()

๐Ÿ› Facing 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 disussions.

๐Ÿ’ป Contributing

We welcome and appreciate contributions of any size. or smaller or straightforward changes, feel free to create a pull request directly. If you plan to make significant improvements or extensions, please open an issue or disussion beforehand.

Initial Setup

For your convenience, please ensure that you have Poetry and Just installed. You can read more on them by following the links below:

To get all required dependencies installed, simply start with:

just poetry-install

Additionally, we make use of pre-commit. To set it up, run the following command:

pre-commit install

To verify that everything is set up correctly, execute the test suite:

just unit-tests

Code Conformance

Once you implemented your changes, please run the following commands:

just pretty   # formats the code and applies automatic linting fixes
just check  # checks code for conformance

Opening PR

Please be aware that this repository follows conventional commit. So please choose a PR title corresponding to the following:

<scope>(#<IssueID>): <description>  # supported scopes can be found here: https://github.com/commitizen/conventional-commit-types/blob/master/index.json

# e.g.
docs(#8): provide extensive project readme

# issue id is optional, so the following si valid as well
docs: provide extensive project readme

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vistafetch-1.2.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

vistafetch-1.2.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file vistafetch-1.2.1.tar.gz.

File metadata

  • Download URL: vistafetch-1.2.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for vistafetch-1.2.1.tar.gz
Algorithm Hash digest
SHA256 4e93be9ba96b19504ca160dd0a44668b1a77f2ae7156ad4aa6e90aee297432f7
MD5 8be58dc8edb74acf3db67757c2a1921e
BLAKE2b-256 ffc322a913b101f4ff85d704d4b7d04dad658ff2a3e3f9e13f4e3f43e3506755

See more details on using hashes here.

File details

Details for the file vistafetch-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: vistafetch-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for vistafetch-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 327bd9c5952fcc51bdb6af4b89284c5df7da0af82a5a8d1c0d6df9e0d4c9822f
MD5 0eaaaf0b6acf917ef9c1dc44dbbac402
BLAKE2b-256 80e656b6d4579af612294889c282736baa45d35d96923fbec98073fcb960567e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page