Metadata-Version: 2.4
Name: ticker-price-data
Version: 0.1.1
Summary: Unified ticker price data from Yahoo Finance, CoinGecko, and TradingView.
Project-URL: Homepage, https://github.com/StephanAkkerman/ticker-price-data
Author: Stephan Akkerman
License: MIT License
        
        Copyright (c) 2024 Stephan Akkerman
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: aiohttp
Requires-Dist: ticker-classifier>=0.1.4
Requires-Dist: tradingview-scraper>=0.4.20
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# ticker-price-data

Unified ticker price data from **Yahoo Finance** (stocks/indices/forex/futures),
**CoinGecko** (crypto), and **TradingView** (universal fallback).

One normalized quote shape for every asset, with sensible fallbacks and built-in
caching. Extracted from [fintwit-web](https://github.com/StephanAkkerman/fintwit-web)
so the pricing logic can be reused across projects.

## Key Features 🔑

- `get_price(ticker, asset_type)` — single entry point; `asset_type="auto"` uses
  [ticker-classifier](https://github.com/StephanAkkerman/ticker-classifier) to decide
  stock vs crypto vs forex automatically.
- `get_ticker(ticker)` — everything known about a symbol in one call: classification
  metadata (sector, industry, market cap, company profile, ...) **plus** the live quote,
  classifying only once.
- `get_stock_info(ticker)` — Yahoo Finance, with a TradingView fallback.
- `get_crypto_info(ticker)` — CoinGecko via the website `search_v2` endpoint (avoids the
  public API's free-tier rate limits), with Yahoo → TradingView fallbacks.
- `get_tradingview_quote(symbol, asset_hint)` — realtime websocket pool + scraper fallback.
- In-memory caching, stale/negative caching, and concurrency limits built in.

All helpers return `Optional[dict]`:

```python
{
    "price": float,
    "change_percent": float,
    "volume": float,
    "website": str,
    "source": str,            # "yahoo" | "coingecko" | "tradingview"
    # yahoo also includes "last_close": float | None
}
```

## Installation ⚙️

```bash
pip install git+https://github.com/StephanAkkerman/ticker-price-data.git
```

or, for local development:

```bash
pip install -e .
```

## Usage ⌨️

```python
import asyncio
from ticker_price_data import get_price, get_ticker, get_stock_info, get_crypto_info

async def main():
    print(await get_stock_info("AAPL"))     # Yahoo
    print(await get_crypto_info("BTC"))     # CoinGecko
    print(await get_price("BTC", "auto"))   # classified automatically
    print(await get_ticker("AAPL"))         # metadata (sector, industry, ...) + quote

asyncio.run(main())
```

## License 📜

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
