Skip to main content

Shared Exchange Configuration Library

A Python library for managing cryptocurrency exchange configurations, providing clean access to exchange data and configuration override capabilities.

Features

  • Load and manage multiple exchange configurations from JSON files
  • Clean Python API for accessing currency, network, and exchange-specific data
  • Configuration override system for testing and customization

Installation

pip install shared-exchange-config

# Requirements: Python 3.10+

PyPI deploy

pip install build twine
rm -rf dist/ build/ *.egg-info
python -m build
python -m twine check dist/*
python -m twine upload dist/*

# Requirements: Python 3.10+, build, twine

Quick Start

Basic Usage (with default configurations)

from exchange_config import ExchangeConfigManager

# Initialize the manager (loads default JSON configs)
manager = ExchangeConfigManager()

# Access exchange configurations
binance = manager.get_exchange('binance')
print(f"Binance supports {len(binance.available_currencies))} currencies")

Production Usage (with startup configuration)

Check examples/ folder for more detailed usage

Configuration Management

For Django/FastAPI applications, configure overrides once at startup:

from exchange_config import configure_exchanges

# Multiple configuration sources supported
configure_exchanges(
    config_dict=EXCHANGE_OVERRIDES,        # From Django/FastAPI settings
    config_file="/path/to/overrides.json", # From file
    override_dir="/config/overrides/",     # From directory
    load_env=True,                         # From environment variables
    env_prefix="EXCHANGE_CONFIG_"          # Custom env prefix
)

Configuration Sources:

  1. Dictionary (Django/FastAPI settings):
EXCHANGE_OVERRIDES = {
    "exchanges": {
        "binance": {
            "add_currencies": ["CUSTOM_TOKEN"],
            "remove_currencies": ["OLD_TOKEN"],
            "add_fiat_currencies": ["GBP"]
        }
    },
    "global": {
        "add_currencies": ["PLATFORM_TOKEN", "UNIVERSAL_COIN"],
        "add_fiat_currencies": ["GBP", "CAD"]
    }
}
  1. Environment Variables:
EXCHANGE_CONFIG_BINANCE_ADD_CURRENCIES=CUSTOM_TOKEN,COMPANY_COIN
EXCHANGE_CONFIG_GLOBAL_ADD_CURRENCIES=PLATFORM_TOKEN,UNIVERSAL_COIN
EXCHANGE_CONFIG_GLOBAL_ADD_FIAT_CURRENCIES=GBP,CAD
  1. JSON Configuration File:
{
  "exchanges": {
    "binance": {
      "add_currencies": ["CUSTOM_TOKEN"],
      "set_api_base_url": "https://api.custom.com"
    }
  }
}

Configuration Operations

The library provides a complete, consistent API for both exchange-specific and global configurations. All operations support both single values and lists, and there are add_ operations available for all core configuration fields:

Currency Operations:

  • add_currencies - Add cryptocurrencies (supports both single values and lists)
  • add_fiat_currencies - Add fiat currencies (supports both single values and lists)
  • remove_currencies - Remove currencies (supports both single values and lists)

Network Operations:

  • add_currency_networks - Add network mappings for currencies
  • add_networks - Add networks to the networks dictionary (format: {"NETWORK_NAME": "network_value"})
  • add_currency_and_network_to_alias_map - Add currency-network to alias mappings

Field Operations:

  • set_* - Set any configuration field directly (e.g., set_api_timeout, set_custom_field)

Supported Override Fields:

  • available_currencies - List of available cryptocurrencies
  • available_fiat_currencies - List of available fiat currencies
  • currencies_to_networks - Currency to networks mapping
  • networks - Available networks
  • currency_and_network_to_alias_map - Currency-network to alias mapping

Usage Examples:

# Exchange-specific configuration
"binance": {
    "add_currencies": ["TOKEN1", "TOKEN2"],        # Multiple currencies
    "add_fiat_currencies": "GBP",                  # Single currency (string)
    "remove_currencies": ["OLD_TOKEN"],            # Remove multiple
    "add_currency_networks": {                     # Add network mappings
        "BTC": ["LIGHTNING"], 
        "ETH": ["ARBITRUM"]
    },
    "add_networks": {"POLYGON": "polygon", "BSC": "bsc"},            # Add available networks
    "add_currency_and_network_to_alias_map": {     # Add alias mappings
        "BTC-LIGHTNING": "BTC_LN",
        "ETH-ARBITRUM": "ETH_ARB"
    }
}

# Global configuration (applies to all exchanges)
"global": {
    "add_currencies": ["PLATFORM_TOKEN", "GLOBAL_COIN"],  # Multiple currencies
    "add_fiat_currencies": ["EUR", "JPY"],                # Multiple fiat currencies
    "remove_currencies": "DEPRECATED_TOKEN",              # Single removal (string)
    "add_networks": {"SOLANA": "solana"}                  # Add network globally
}

Development

Code Organization

The library has a clean, focused structure:

  • overrides/: Configuration override management with clear separation of concerns:
    • __init__.py: Public API (configure_exchanges, apply_startup_configuration) and module functions
    • settings_parser.py: ExchangeOverridesConfigSettings class for loading override configuration from various sources
    • applicator.py: ConfigurationApplicator class for applying overrides to exchange configurations
  • exchanges/: Exchange-specific classes with specialized functionality
  • manager.py: High-level manager for working with multiple exchanges
  • __init__.py: Main package exports for public API

This structure provides a clean, organized codebase with clear separation of concerns.

Metadata

Release files for shared-exchange-config 0.0.21

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

Source distribution (sdist)

Source distribution for shared-exchange-config 0.0.21
File Size Uploaded Provenance Actions
shared_exchange_config-0.0.21.tar.gz 21.3 kB Without provenance Details for shared_exchange_config-0.0.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shared-exchange-config 0.0.21
File Interpreter ABI Platform Actions
shared_exchange_config-0.0.21-py3-none-any.whl Python 3 none any Details for shared_exchange_config-0.0.21-py3-none-any.whl

Total release size: 51.8 kB

Release files / shared_exchange_config-0.0.21.tar.gz

Download URL shared_exchange_config-0.0.21.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
53d5e2120b436021e8fddf713a65b1b9cb9599ed22538d1157d4c0ac738c2c74
BLAKE2b-256 checksum
How to use checksums
aaea5207abd5b24d34751cc5e575d49673066a1f09762b292bf7f71986ba63b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / shared_exchange_config-0.0.21-py3-none-any.whl

Download URL shared_exchange_config-0.0.21-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b157a6ad65704a64f100bab7c52469e9646441897d065af0ca77e3db7167dd88
BLAKE2b-256 checksum
How to use checksums
9bbddedf75ce775fe8d86b864e27e52510fbf7c8b80fa5f6694ce53cffad0c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for shared-exchange-config 0.0.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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