Skip to main content

Currency Examples Overview

Practical examples showing how to use the Django-CFG Currency Module in real applications across different industries.

What You'll Learn

This examples section demonstrates real-world currency conversion use cases:

Currency Module Capabilities

The Django-CFG Currency Module supports:

14,000+ Currencies

  • Fiat currencies (USD, EUR, JPY, etc.)
  • Cryptocurrencies (BTC, ETH, ADA, etc.)
  • Stocks (AAPL, TSLA, GOOGL, etc.)
  • Commodities (Gold, Silver, Oil, etc.)

Multi-Threading

  • Parallel data fetching for better performance
  • Automatic retries with exponential backoff
  • Request pooling and connection reuse

Multiple Data Sources

  • YFinance - Stocks, forex, crypto
  • CoinGecko - 14K+ cryptocurrencies
  • Automatic fallback between sources

Production-Ready

  • Built-in caching
  • Error handling
  • Type-safe API
  • Django integration

Basic Usage

from django_cfg.modules.django_currency import convert_currency

# Simple conversion
amount_eur = convert_currency(100, "USD", "EUR")
# Returns: 92.45 (example rate)

# Crypto conversion
btc_amount = convert_currency(1000, "USD", "BTC")
# Returns: 0.0234 (example rate)

# Stock price conversion
tsla_in_eur = convert_currency(1, "TSLA", "EUR")
# Returns: Tesla stock price in EUR

Advanced Features

CurrencyConverter Class

For more control and batch operations:

from django_cfg.modules.django_currency import CurrencyConverter

converter = CurrencyConverter(
max_workers=10, # Parallel threads
max_retries=3, # Retry attempts
retry_delay=1.0 # Delay between retries (seconds)
)

# Batch conversions
rates = converter.get_multiple_rates(
base_currency="USD",
target_currencies=["EUR", "GBP", "JPY", "BTC"]
)

Caching Strategy

The module uses intelligent caching to reduce API calls:

# First call - fetches from API
rate1 = convert_currency(100, "USD", "EUR")

# Second call (within cache period) - uses cached value
rate2 = convert_currency(100, "USD", "EUR") # Instant!

Industry Examples

E-Commerce

Perfect for online stores with international customers:

  • Dynamic currency conversion on product pages
  • Multi-currency shopping carts
  • International pricing strategies

Finance

Essential for investment platforms:

  • Crypto portfolio tracking
  • Multi-asset investment calculators
  • P&L calculations across currencies

Import/Export

Critical for global trade:

  • Vehicle import duty calculations
  • International shipping cost estimates
  • Regional pricing optimization

Gaming

Useful for in-game economies:

  • Real-money to gem conversion
  • Regional pricing for game items
  • Dynamic currency packages

Business Intelligence

Valuable for analytics:

  • Multi-currency revenue normalization
  • Cross-border sales analysis
  • Currency exposure reporting

Next Steps

Explore industry-specific examples:

  1. E-commerce Examples - Start here for online retail
  2. Financial Examples - Investment and portfolio tracking
  3. Import/Export Examples - Global trade calculations
  4. Gaming Examples - In-game currency systems
  5. Business Intelligence Examples - Analytics dashboards

See Also