Skip to main content

A utility library that wraps grabbing the current spot price of $XRP from various exchanges.

Project description

xrp-price-aggregate

Based on XRPL-Labs/XRP-Price-Aggregator

PyPI PyPI - Python Version PyPI - Wheel PyPI - Downloads PyPI - Implementation PyPI - License

Usage

  1. pip install xrp-price-aggregate

  2. Run directly as a module or import and provide aggregation count (how many rounds) along with delay between each round.

    # run xrp_price_aggregate.__main__ and also beautify the results
    python -m xrp_price_aggregate | python -m json.tool
    {
        "raw_results_named": {
            "hitbtc": [
                "0.72235"
            ],
            ...
        },
        "raw_results": [
            "0.72110",
            "0.72236",
            "0.72202",
            ...
        ],
        "raw_median": "0.72219",
        "raw_stdev": "0.00071",
        "filtered_results": [
            "0.72236",
            "0.72202",
            "0.72240",
            ...
        ],
        "filtered_median": "0.72236",
        "filtered_mean": "0.72219"
    }
    
    >>> # await it yourself
    >>> import asyncio
    >>> import xrp_price_aggregate
    >>> asyncio.run(xrp_price_aggregate.as_awaitable_json())
    '{"raw_results_named": {"hitbtc": ["0.711729"], "binance": ["0.7131"], "bitrue": ["0.71292"], "bitfinex": ["0.7122"], "ftx": ["0.712675", "0.7126"], "kraken": ["0.71223"], "cex": ["0.71334", "0.7135"], "bitstamp": ["0.71328"]}, "raw_results": ["0.7131", "0.7122", "0.71328", "0.71334", "0.7135", "0.712675", "0.7126", "0.711729", "0.71223", "0.71292"], "raw_median": "0.7127975", "raw_stdev": "0.0005759840275563203497399309551", "filtered_results": ["0.71310", "0.71328", "0.71334", "0.71268", "0.71260", "0.71223", "0.71292"], "filtered_median": "0.71292", "filtered_mean": "0.71288"}'
    
    >>> # synchronous is the default case
    >>> import xrp_price_aggregate
    >>> xrp_price_aggregate.as_json()
    '{"raw_results_named": {"cex": ["0.72039", "0.72136"], "hitbtc": ["0.72122"], "kraken": ["0.72132"], "bitfinex": ["0.72145"], "bitstamp": ["0.72047"], "bitrue": ["0.72122"], "binance": ["0.72150"], "ftx": ["0.72078", "0.72155"]}, "raw_results": ["0.72150", "0.72145", "0.72047", "0.72039", "0.72136", "0.72078", "0.72155", "0.72122", "0.72132", "0.72122"], "raw_median": "0.72127", "raw_stdev": "0.00043", "filtered_results": ["0.72150", "0.72145", "0.72136", "0.72155", "0.72122", "0.72132", "0.72122"], "filtered_median": "0.72136", "filtered_mean": "0.72137"}'
    >>> xrp_price_aggregate.as_dict(count=3, delay=2)
    {'raw_results_named': {'binance': [Decimal('0.721'), Decimal('0.7213'), Decimal('0.7211')], 'ftx': [Decimal('0.7208'), Decimal('0.720975'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.7208'), Decimal('0.720975')], 'bitfinex': [Decimal('0.7215'), Decimal('0.7215'), Decimal('0.72141')], 'hitbtc': [Decimal('0.720796'), Decimal('0.720796'), Decimal('0.720796')], 'bitstamp': [Decimal('0.72047'), Decimal('0.72047'), Decimal('0.72047')], 'bitrue': [Decimal('0.72081'), Decimal('0.72094'), Decimal('0.72111')], 'kraken': [Decimal('0.72132'), Decimal('0.72132'), Decimal('0.72132')], 'cex': [Decimal('0.72039'), Decimal('0.72136'), Decimal('0.72039'), Decimal('0.72136'), Decimal('0.72039'), Decimal('0.72136')]}, 'raw_results': [Decimal('0.721'), Decimal('0.7215'), Decimal('0.72047'), Decimal('0.72039'), Decimal('0.72136'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72081'), Decimal('0.7213'), Decimal('0.7215'), Decimal('0.72047'), Decimal('0.72039'), Decimal('0.72136'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72094'), Decimal('0.7211'), Decimal('0.72141'), Decimal('0.72047'), Decimal('0.72039'), Decimal('0.72136'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72111')], 'raw_median': Decimal('0.720975'), 'raw_stdev': Decimal('0.0003566360729171225136133563969'), 'filtered_results': [Decimal('0.721'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72081'), Decimal('0.7213'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72094'), Decimal('0.7211'), Decimal('0.7208'), Decimal('0.720975'), Decimal('0.720796'), Decimal('0.72132'), Decimal('0.72111')], 'filtered_median': Decimal('0.720975'), 'filtered_mean': Decimal('0.7209962777777777777777777778')}
    

Note on Jupyter

When running in Jupyter notebooks, be sure to use nest_asyncio

import nest_asyncio
import xrp_price_aggregate


nest_asyncio.apply()


agg_results = xrp_price_aggregate.as_dict(count=6, delay=3)

Public Colab Example Notebook, backup of the .ipynb as a Gist

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xrp-price-aggregate-0.0.10.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

xrp_price_aggregate-0.0.10-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file xrp-price-aggregate-0.0.10.tar.gz.

File metadata

  • Download URL: xrp-price-aggregate-0.0.10.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10

File hashes

Hashes for xrp-price-aggregate-0.0.10.tar.gz
Algorithm Hash digest
SHA256 34dd9f8995ce396168bcaf95bbd3a589a221802d9f6e0fbd3a2874c620fce362
MD5 f5c1974b72478a59862ecf56c6b1c8c9
BLAKE2b-256 917c12469d71a1a668a4dafdb3fba8875953dde4232796d6ba744cd359dd38bc

See more details on using hashes here.

File details

Details for the file xrp_price_aggregate-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: xrp_price_aggregate-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10

File hashes

Hashes for xrp_price_aggregate-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c70cfbc3461897718d20231cd9a703cabfe3b2daeaaedf1b581b0eb9ee9b720d
MD5 96b8ec20be05720c37b166e18fa05c55
BLAKE2b-256 1ea0eaf3455b8dac4a1a05929f234c8f3712d0a32d07b10647e70051f78e7cbf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page