CCXT.Registry (ccxt_client v0.6.1)

Copy Markdown View Source

Compile-time exchange lookup registry.

Maps exchange ID atoms and strings to their generated module names. Built from the spec manifest at compile time — recompiles automatically when the manifest changes.

Usage

CCXT.Registry.lookup(:bybit)
#=> {:ok, CCXT.Bybit}

CCXT.Registry.lookup!("binance")
#=> CCXT.Binance

CCXT.Registry.exchanges()
#=> ["aftermath", "alpaca", "apex", ...]

CCXT.Registry.loaded?(:bybit)
#=> true  # if CCXT.Bybit module is compiled

Summary

Functions

Returns all registered exchange IDs as strings.

Checks if the exchange module is compiled and loaded.

Looks up the module for an exchange ID.

Looks up the module for an exchange ID, raising on unknown.

Returns the module for an exchange ID, or nil if unknown.

Checks if an exchange ID is registered.

Functions

exchanges()

@spec exchanges() :: [String.t()]

Returns all registered exchange IDs as strings.

Examples

CCXT.Registry.exchanges()
#=> ["aftermath", "alpaca", "apex", ...]

loaded?(id)

@spec loaded?(String.t() | atom()) :: boolean()

Checks if the exchange module is compiled and loaded.

Returns true only if the exchange is registered AND its module is available in the BEAM. Useful for distinguishing "known exchange" from "exchange module exists."

Examples

CCXT.Registry.loaded?(:bybit)
#=> true  # if CCXT.Bybit is compiled

lookup(id)

@spec lookup(String.t() | atom()) ::
  {:ok, module()} | {:error, {:unknown_exchange, String.t()}}

Looks up the module for an exchange ID.

Accepts both string and atom IDs.

Examples

CCXT.Registry.lookup("bybit")
#=> {:ok, CCXT.Bybit}

CCXT.Registry.lookup(:unknown)
#=> {:error, {:unknown_exchange, "unknown"}}

lookup!(id)

@spec lookup!(String.t() | atom()) :: module()

Looks up the module for an exchange ID, raising on unknown.

Examples

CCXT.Registry.lookup!(:bybit)
#=> CCXT.Bybit

module_for(id)

@spec module_for(String.t() | atom()) :: module() | nil

Returns the module for an exchange ID, or nil if unknown.

Examples

CCXT.Registry.module_for("bybit")
#=> CCXT.Bybit

CCXT.Registry.module_for("nope")
#=> nil

registered?(id)

@spec registered?(String.t() | atom()) :: boolean()

Checks if an exchange ID is registered.

Examples

CCXT.Registry.registered?(:bybit)
#=> true