Current section
Files
Jump to
Current section
Files
lib/ccxt/exchanges.ex
defmodule CCXT.Exchanges do
@moduledoc """
Compile-time generator for all exchange modules.
Reads the spec manifest and generates one module per exchange
(e.g., `CCXT.Bybit`, `CCXT.Binance`) at compile time via `Module.create/3`.
New exchange = new spec file in `priv/specs/json/output/`, zero Elixir code.
## How it works
The manifest lists all exchange IDs. For each ID, this module calls
`CCXT.Exchange.prepare_generate_data/1` to build the AST, then creates
the module directly — same pipeline as `use CCXT.Exchange`, but without
needing individual stub files.
"""
@manifest_path CCXT.Spec.manifest_path()
@external_resource @manifest_path
@exchange_ids CCXT.Spec.load_manifest!()["exchanges"]
for id <- @exchange_ids do
module_name = Module.concat(CCXT, Macro.camelize(id))
data = CCXT.Exchange.prepare_generate_data(id)
display_name = data.exchange_name
body = CCXT.Exchange.build_module_body(data, moduledoc: "#{display_name} exchange — generated from spec.")
Module.create(module_name, body, Macro.Env.location(__ENV__))
end
end