Skip to main content

No project description provided

Project description

DeFinance

DeFinance is a Python library designed to abstract the APIs of various cryptocurrency exchanges and fetch cryptocurrency market data. Currently, it supports spot prices in Binance, Bitget, and OKX exchanges. This library simplifies the process of retrieving cryptocurrency price data by providing a unified interface.

Features

  • Fetch spot price data from Binance, Bitget, and OKX.
  • Unified interface to handle data retrieval from multiple exchanges.
  • Automatic fallback mechanism to fetch data from other exchanges if the symbol is not found in one of the exchange.

Installation

To install DeFinance, you can use pip:

pip install definance

Usage

Here's a quick example of how to use DeFinance to fetch cryptocurrency price data:

Importing the Library

from definance import fetch_price_data, Exchange

Fetching Price Data from a Specific Exchange

To fetch price data from a specific exchange, you can specify the exchange as an argument:

price_data = fetch_price_data('BTC/USDT', Exchange.BINANCE)
print(price_data)

Fetching Price Data from Any Exchange

If you do not specify an exchange, DeFinance will attempt to fetch the data from all supported exchanges in the following order: Binance, Bitget, and OKX.

price_data = fetch_price_data('BTC/USDT')
print(price_data)

Handling Symbol Not Found

If the symbol is not found in any of the exchanges, an exception will be raised:

from definance.exceptions import SymbolNotFound

try:
    price_data = fetch_price_data('INVALID_SYMBOL')
except SymbolNotFound as e:
    print(e)

API Reference

fetch_price_data(symbol: str, exchange: Exchange = None) -> PriceData

Fetches the cryptocurrency price data from the specified exchange or from all exchanges if none is specified.

Arguments

  • symbol (str): The symbol of the cryptocurrency. Example: 'BTC/USDT', 'ETH/BTC', 'BTC'.
  • exchange (Exchange, optional): The exchange to fetch the data from. If None, the function will try to fetch the data from all exchanges.

Returns

  • PriceData: The price data object containing the fetched price data.

Supported Exchanges

  • Exchange.BINANCE
  • Exchange.BITGET
  • Exchange.OKX

Contributing

Contributions are welcome! If you'd like to contribute to DeFinance, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes.
  4. Submit a pull request.

License

DeFinance is released under the MIT License. See the LICENSE file for more details.

Contact

For any questions or inquiries, please contact thymus_bleep.0u@icloud.com.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

definance-0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

definance-0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file definance-0.1.tar.gz.

File metadata

  • Download URL: definance-0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.9

File hashes

Hashes for definance-0.1.tar.gz
Algorithm Hash digest
SHA256 43f0c2d8ebabcc72364a8ec038edd45b06e5d04ae3b4754c7e74ff7619d715fa
MD5 6735321d5acf216610cba43cadbf7e3d
BLAKE2b-256 13fd4fa666f3b409f8b305157e605bd72963d198c27c04b0a7ed0f495c81d00e

See more details on using hashes here.

File details

Details for the file definance-0.1-py3-none-any.whl.

File metadata

  • Download URL: definance-0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.9

File hashes

Hashes for definance-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 abc640650157340ff24ea6b5135828ac8d2a9b1394b4fec903d5cdf0db46fc5d
MD5 36b04c9c4e567efbf26dbd9257992d60
BLAKE2b-256 29843f222e96c1d87ae714e00d063025b6872ef408bdbc06a6350b461871819e

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page