Python CryptoPrice Library: Retrieve Crypto Asset Prices Effortlessly

ยท

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

Getting Started

Installation Options

  1. Stable version (via PyPI):

    pip install python-CryptoPrice
  2. Development 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

๐Ÿ‘‰ Discover advanced trading APIs to complement your crypto projects.

Project Status

This library is currently in active development. Contributors are welcome to:

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:

๐Ÿ‘‰ Explore more blockchain resources to enhance your crypto experience.