Skip to main content

Welcome to CryptoPrice 0.2.0

Note

This library is under development by EtWnn, feel free to drop your suggestions or remarks in the discussion tab of the git repo. You are also welcome to contribute by submitting PRs.

This library is made to retrieve price or candle history of crypto assets using multiple sources.

Source Code:

https://github.com/EtWnn/CryptoPrice

Documentation:

https://cryptoprice.readthedocs.io

Features

The idea is to have under a single library several price history API to be able to fetch effortlessly the price of large amount of different tokens or to compare the price difference between exchanges.

It currently includes:
  • Binance API

  • Kucoin API

  • Cross-API logic

Quick Tour

Installation

CryptoPrice is available on PYPI, install with pip:

pip install python-CryptoPrice

You can also install the latest developments (not stable):

pip install git+https://github.com/EtWnn/CryptoPrice.git@develop

Examples

A price retriever is already provided by the library, but feel free to check the documentation to instantiate one yourself.

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())

# will return the first price price found close to the timestamp
retriever.get_closest_price(asset, ref_asset, timestamp)
>>Price(value=29480.0, asset='BTC', ref_asset='USDT', timestamp=1609510440, source='binance')

You can also fetch a price even if the trading pair does not exist: The retriever (MetaRetriever) will find a path with several trading pairs to estimate the price between the asset and the ref asset. This method takes much more time than the one above as several API calls (or database requests) may be needed.

import datetime
from CryptoPrice import get_default_retriever

retriever = get_default_retriever()

asset = 'LTC'
ref_asset = 'XRP'
timestamp = int(datetime.datetime(2021, 3, 3, 15, 14).timestamp())

# will return an average price of several trading path
price = retriever.get_mean_price(asset, ref_asset, timestamp)
if price is not None:  # price found
    print(f"{asset} = {price.value:.5f} {ref_asset}, source: {price.source}")
>>LTC = 420.76841 XRP, source: {'binance', 'kucoin'}

Donation

If this library has helped you in any way, feel free to donate:

  • BTC: 14ou4fMYoMVYbWEKnhADPJUNVytWQWx9HG

  • ETH: 0xfb0ebcf8224ce561bfb06a56c3b9a43e1a4d1be2

  • LTC: LfHgc969RFUjnmyLn41SRDvmT146jUg9tE

  • EGLD: erd1qk98xm2hgztvmq6s4jwtk06g6laattewp6vh20z393drzy5zzfrq0gaefh

Metadata

Release files for python-CryptoPrice 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-CryptoPrice 0.2.0
File Size Uploaded
python-CryptoPrice-0.2.0.tar.gz 15.0 kB Details

Release files / python-CryptoPrice-0.2.0.tar.gz

Download URL python-CryptoPrice-0.2.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9a0099f70266d54d14e7c56ada8f45cd4e0ac29a47861cd2c85ef4600d0bc1f4
BLAKE2b-256 checksum
How to use checksums
16338602f1345556b4ea3afba90760441f2e482b5825cffbbeb5f7b99f33d02e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.3

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page