Metadata-Version: 2.4
Name: btcpriceticker
Version: 0.3.1
Summary: Python lib for getting the bitcoin price
Author-email: Holger Nahrstaedt <nahrstaedt@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Holger
        
        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.
        
Project-URL: Homepage, https://github.com/holgern/btcpriceticker
Keywords: price,btc,ticker
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >3.8.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: urllib3
Requires-Dist: pycoingecko
Requires-Dist: coinpaprika-sdk
Requires-Dist: pymempool
Requires-Dist: pandas
Requires-Dist: ccxt
Requires-Dist: typer
Requires-Dist: rich
Requires-Dist: requests
Dynamic: license-file

[![PyPI - Version](https://img.shields.io/pypi/v/btcpriceticker)](https://pypi.org/project/btcpriceticker/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/btcpriceticker)
![PyPI - Downloads](https://img.shields.io/pypi/dm/btcpriceticker)
[![codecov](https://codecov.io/gh/holgern/btcpriceticker/graph/badge.svg?token=AtcFpVooWk)](https://codecov.io/gh/holgern/btcpriceticker)

# btcpriceticker

## Overview

`btcpriceticker` is a lightweight toolkit for fetching current and historical Bitcoin
pricing data from multiple services. It powers both a handy CLI and a Python API that
can return spot prices, time series, and OHLC or OHLCV candles for BTC against your
preferred fiat currency.

## Features

- Unified interface over CoinGecko, CoinPaprika, Kraken, and mempool.space data sources
- Optional time series tracking with resampling utilities
- OHLC and OHLCV aggregation backed by pandas DataFrames
- Typer-based CLI for quick terminal access to prices, history, and candles

## Installation

```bash
pip install btcpriceticker
```

To work on the project locally:

```bash
git clone https://github.com/holgern/btcpriceticker
cd btcpriceticker
pip install -e .[test]
pip install -r requirements-test.txt  # optional extras used in this repo
```

## CLI Usage

Use the Typer-powered CLI after installation:

```bash
btcpriceticker price eur            # Show spot price in EUR
btcpriceticker history usd 1h       # Print recent hourly prices
btcpriceticker ohlc usd 1h          # Display OHLC candles
btcpriceticker ohlcv usd 1h         # Display OHLCV candles (requires services that support volume)
```

Flags such as `--service` and `--verbose` allow switching providers and log verbosity,
e.g. `btcpriceticker --service kraken price usd`.

## Python API

```python
from btcpriceticker.price import Price

price = Price(service="kraken", fiat="usd", enable_ohlcv=True)
price.refresh()

spot = price.get_price_now()
ohlcv_frame = price.ohlcv
change = price.get_price_change()
```

The `Price` object caches provider instances and exposes helper methods such as
`get_usd_price`, `get_timeseries_list`, and `set_next_service` for provider rotation.

## Testing

Run the test suite and collect coverage with:

```bash
pytest
pytest --cov=btcpriceticker
```

The project follows Ruff formatting rules and includes optional pre-commit hooks:

```bash
ruff check --fix
pre-commit run --all-files
```

## Contributing

Issues and pull requests are welcome. Please open an issue describing proposed changes
and ensure tests pass before submitting.

## License

Licensed under the MIT License. See `LICENSE` for details.
