Overview
The Python CryptoPrice library is a powerful tool designed to fetch price and candle history data for cryptocurrency assets from multiple sources. Developed by EtWnn, this open-source project aims to simplify crypto price retrieval while supporting various exchange APIs under one unified interface.
Key Features
- Multi-exchange support: Integrates with Binance and KuCoin APIs
- Cross-API functionality: Compare prices across different exchanges
- Flexible price retrieval: Get historical prices using timestamps
- Smart pathfinding: Calculate prices even for non-direct trading pairs
- Open-source: Community-driven development on GitHub
Getting Started
Installation Options
Stable version (via PyPI):
pip install python-CryptoPriceDevelopment version (latest features):
pip install git+https://github.com/EtWnn/CryptoPrice.git@develop
๐ Explore more crypto tools for your trading toolkit.
Practical Usage Examples
Basic Price Retrieval
import datetime
from CryptoPrice import get_default_retriever
retriever = get_default_retriever()
asset = 'BTC'
ref_asset = 'USDT'
timestamp = int(datetime.datetime(2021, 1, 1, 15, 14).timestamp())
price = retriever.get_closest_price(asset, ref_asset, timestamp)
print(price)Output:
Price(value=29480.0, asset='BTC', ref_asset='USDT', timestamp=1609510440, source='binance')Advanced Cross-Pair Calculation
asset = 'LTC'
ref_asset = 'XRP'
timestamp = int(datetime.datetime(2021, 3, 3, 15, 14).timestamp())
price = retriever.get_mean_price(asset, ref_asset, timestamp)
if price:
print(f"{asset} = {price.value:.5f} {ref_asset}, sources: {price.source}")Output:
LTC = 420.76841 XRP, sources: {'binance', 'kucoin'}Technical Documentation
- Source Code: Available on GitHub
- Documentation: Comprehensive guides at ReadTheDocs
๐ Discover advanced trading APIs to complement your crypto projects.
Project Status
This library is currently in active development. Contributors are welcome to:
- Submit suggestions via GitHub discussions
- Open pull requests for new features
- Report issues or bugs
FAQs
What exchanges does CryptoPrice support?
Currently supports Binance and KuCoin, with plans to add more exchanges in future updates.
How accurate is the price calculation for non-direct pairs?
The library uses sophisticated algorithms to find the most reliable trading paths across available pairs, providing weighted average prices.
Can I use this for real-time trading?
While suitable for historical data analysis, consider exchange-specific WebSocket APIs for low-latency trading applications.
Is there rate limiting?
Yes, the library respects each exchange's API rate limits. For intensive use, consider implementing your own caching system.
How can I contribute?
Check the GitHub repository for open issues or feature requests. The maintainer welcomes code contributions and documentation improvements.
Support the Project
If you find this library valuable, consider supporting development:
- BTC: 14ou4fMYoMVYbWEKnhADPJUNVytWQWx9HG
- ETH: 0xfb0ebcf8224ce561bfb06a56c3b9a43e1a4d1be2
- LTC: LfHgc969RFUjnmyLn41SRDvmT146jUg9tE
- EGLD: erd1qk98xm2hgztvmq6s4jwtk06g6laattewp6vh20z393drzy5zzfrq0gaefh
๐ Explore more blockchain resources to enhance your crypto experience.