Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# pyOnvista specific
# Exclude development scripts and enhanced fork exploration
scripts/
pyonvista_enhanced_fork/

# Test coverage and reports
*.coverage
.coverage.*
coverage.xml
htmlcov/
197 changes: 158 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,169 @@
# pyonvista
A tiny python wrapper to the non-public onvista.de REST-Api.
# pyOnvista v2.0

As the API is not public user shall assume that the usage of this package harms the
website user agreements. However, this version now avoids any web scrapping for metadata.
> **Acknowledgment**: This project builds upon the excellent foundation of the original [pyOnvista](https://github.com/cloasdata/pyOnvista) by [cloasdata](https://github.com/cloasdata). The v2.0 enhancements add comprehensive fundamental data extraction capabilities while maintaining full backward compatibility with the original API.

You can search for an instrument and get its quote data.
The quote data can be limit by resolution and date.
A Python library for accessing financial data from onvista.de

The wrapper now also works with instruments other than stocks. Also for example data from ETF
can be requested.
**NEW in v2.0: Comprehensive fundamental data extraction**

Im not planing to add other API Endpoints at the moment as long as nobody gives me a good reason for this.

Additionally the wrapper now is asynchronous. User should be aware of asyncio or async programming.
## Features

- Real-time stock quotes and historical data
- Enhanced search with international stock support
- Direct ISIN lookup
- **NEW**: Financial ratios (P/E, P/B, EPS, dividend yield, market cap)
- **NEW**: Performance metrics (returns, volatility, technical indicators)
- **NEW**: Company information (sector, industry, employees)
- **NEW**: ESG/sustainability data

## Installation
pip install pyonvista

## Usage
```bash
pip install pyonvista-v2
```

> **Package Name**: This enhanced v2.0 fork is published as `pyonvista-v2` on PyPI to avoid conflicts with the original package. The import statements remain the same (`from pyonvista.api import PyOnVista`).

## Quick Start

### Basic Usage

```python
import asyncio
import aiohttp
import pprint

from pyonvista import PyOnVista

async def main():
client = aiohttp.ClientSession()
api = PyOnVista()
await api.install_client(client)
async with client:
instruments = await api.search_instrument("VW")
instrument = await api.request_instrument(instruments[0])
quotes = await api.request_quotes(instrument, )
pprint.pprint(instrument)
pprint.pprint(quotes[:3])
# prints a lot of information of VW Stonk
# try a etf
instruments = await api.search_instrument(key="IE00B42NKQ00")
quotes = await api.request_quotes(instruments[0])
pprint.pprint(quotes[0].instrument)

await client.close()
await asyncio.sleep(.1)

if __name__ == '__main__':
asyncio.run(main())
```
from pyonvista.api import PyOnVista

async def example():
async with aiohttp.ClientSession() as session:
api = PyOnVista()
await api.install_client(session)

# Search for instruments
results = await api.search_instrument("Apple")

# Get detailed data
instrument = await api.request_instrument(isin="US0378331005")
print(f"{instrument.name}: €{instrument.quote.close:.2f}")

asyncio.run(example())
```

### v2.0 Fundamental Data

```python
async def fundamental_data():
async with aiohttp.ClientSession() as session:
api = PyOnVista()
await api.install_client(session)

instrument = await api.request_instrument(isin="DE0007164600") # SAP

# Financial ratios
ratios = instrument.get_financial_ratios()
print(f"P/E Ratio: {ratios.pe_ratio:.2f}")
print(f"Market Cap: €{ratios.market_cap:,.0f}")

# Performance metrics
performance = instrument.get_performance_metrics()
print(f"1-Year Return: {performance.performance_1y:+.2f}%")

# Company info
company = instrument.get_company_info()
print(f"Sector: {company.sector}")
print(f"Employees: {company.employees:,}")

asyncio.run(fundamental_data())
```

### Enhanced Search

```python
async def enhanced_search():
async with aiohttp.ClientSession() as session:
api = PyOnVista()
await api.install_client(session)

# International symbol search
apple_stocks = await api.search_international_stocks("AAPL")

# Search with filters
us_stocks = await api.search_instrument("Microsoft",
country="US",
instrument_type="STOCK")

# Direct ISIN lookup
apple = await api.search_by_isin("US0378331005")

asyncio.run(enhanced_search())
```

## v2.0 Data Classes

### FinancialRatios
Financial metrics: `pe_ratio`, `pb_ratio`, `eps`, `dividend_yield`, `market_cap`, `return_on_equity`, `debt_to_equity`

### PerformanceMetrics
Performance data: `performance_1d`, `performance_1w`, `performance_1y`, `volatility_30d`, `beta`

### TechnicalIndicators
Technical analysis: `moving_avg_20d`, `moving_avg_200d`, `rsi_14d`, `bollinger_upper`, `bollinger_lower`

### CompanyInfo
Company data: `sector`, `industry`, `country`, `employees`, `headquarters`

### SustainabilityData
ESG metrics: `esg_score`, `environmental_score`, `social_score`, `governance_score`

## Migration from v1.0

v2.0 is fully backward compatible. All existing v1.0 code continues to work unchanged.

New capabilities are accessed through additional methods on `Instrument` objects:
- `instrument.get_financial_ratios()`
- `instrument.get_performance_metrics()`
- `instrument.get_technical_indicators()`
- `instrument.get_company_info()`
- `instrument.get_sustainability_data()`

## Rate Limiting

Built-in rate limiting with configurable delays:

```python
api = PyOnVista(request_delay=0.2, timeout=60)
```

## PyPI Package

This enhanced v2.0 fork is available on PyPI as **[pyonvista-v2](https://pypi.org/project/pyonvista-v2/)**:

- **Package Name**: `pyonvista-v2`
- **Current Version**: 2.0.2
- **Installation**: `pip install pyonvista-v2`
- **Import**: `from pyonvista.api import PyOnVista` (unchanged from v1.0)

The package includes both source distribution and universal wheel for easy installation across Python 3.8+ environments.

## Changelog

### 2.0.2 (2024-12-18)
- Documentation update: added changelog section to README

### 2.0.1 (2024-12-18)
- Added `currency` field to `Notation` class to distinguish notations by currency (e.g., SWX with CHF vs USD)
- Contributed by [@ralf1070](https://github.com/ralf1070)

### 2.0.0 (2024-12-15)
- Initial v2.0 release with comprehensive fundamental data extraction
- Added financial ratios, performance metrics, technical indicators
- Added company information and ESG/sustainability data
- Enhanced search with international stock support
- Full backward compatibility with v1.0

## License

MIT License - see [LICENSE.md](LICENSE.md) for details.

## Acknowledgments

- Original pyOnvista by [cloasdata](https://github.com/cloasdata)
Loading