Ccxt.Pro.Binance (CCXT Elixir v0.1.0-binance-pro-preview)

Copy Markdown View Source

Generated Binance CCXT Pro target.

This module is generated from ts/src/pro/binance.ts; do not edit the generated Elixir file by hand. Public method coverage, source spans, IR lowering status, runtime-owned contracts, and test evidence are recorded in lib/ccxt/pro_manifest.json.

The target supports both stateless calls and CCXT-style instance calls:

binance =
  Ccxt.Pro.binance(%{
    apiKey: "...",
    secret: "...",
    binanceEnv: "prod",
    options: %{recvWindow: 5_000}
  })

{:ok, ticker} = Ccxt.Pro.Binance.watch_ticker(binance, "BTC/USDT")

watch_* methods follow CCXT Pro semantics: each call waits for the next matching websocket message and returns {:ok, value} or {:error, reason}. The subscription remains active on the shared websocket connection after a successful call.

Elixir stream_* helpers repeatedly call the generated watch_* methods and return an Enumerable. For public streams, pass unwatch_on_halt: true when the enumerable should send the matching Binance unsubscribe request as it halts.

Private websocket API methods use explicit instance credentials, per-call :api_key / :api_secret, or environment-specific Pro credentials such as BINANCE_PROD_API_KEY and BINANCE_PROD_API_SECRET. Production, testnet, and demo credentials are intentionally separate.

Summary

Functions

Types

t()

@type t() :: %Ccxt.Pro.Binance{
  api_key: String.t() | nil,
  api_secret: String.t() | nil,
  binance_env: String.t() | nil,
  id: String.t(),
  options: map() | keyword()
}

Functions

authenticate()

authenticate(exchange)

@spec authenticate(keyword()) :: {:ok, term()} | {:error, term()}

authenticate(exchange, opts)

cancel_all_orders_ws()

cancel_all_orders_ws(exchange)

cancel_all_orders_ws(exchange, symbol)

@spec cancel_all_orders_ws(
  String.t() | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

cancel_all_orders_ws(exchange, symbol, opts)

cancel_order_ws(id)

cancel_order_ws(id, symbol)

cancel_order_ws(id, symbol, opts)

@spec cancel_order_ws(String.t(), String.t() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}

cancel_order_ws(exchange, id, symbol, opts)

create_order_ws(symbol, type, side, amount)

create_order_ws(exchange, symbol, type, side, amount)

create_order_ws(exchange, symbol, type, side, amount, price)

@spec create_order_ws(
  String.t(),
  String.t(),
  String.t(),
  number(),
  number() | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

create_order_ws(exchange, symbol, type, side, amount, price, opts)

describe()

@spec describe() :: map()

describe_data()

@spec describe_data() :: map()

edit_order_ws(id, symbol, type, side)

edit_order_ws(id, symbol, type, side, amount)

edit_order_ws(id, symbol, type, side, amount, price)

edit_order_ws(id, symbol, type, side, amount, price, opts)

@spec edit_order_ws(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  number() | nil,
  number() | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

edit_order_ws(exchange, id, symbol, type, side, amount, price, opts)

ensure_user_data_stream_ws_subscribe_listen_token()

ensure_user_data_stream_ws_subscribe_listen_token(exchange)

ensure_user_data_stream_ws_subscribe_listen_token(exchange, market_type)

@spec ensure_user_data_stream_ws_subscribe_listen_token(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

ensure_user_data_stream_ws_subscribe_listen_token(exchange, market_type, opts)

ensure_user_data_stream_ws_subscribe_signature()

ensure_user_data_stream_ws_subscribe_signature(exchange)

ensure_user_data_stream_ws_subscribe_signature(exchange, market_type)

@spec ensure_user_data_stream_ws_subscribe_signature(
  String.t(),
  keyword()
) :: {:ok, integer()} | {:error, term()}

ensure_user_data_stream_ws_subscribe_signature(exchange, market_type, opts)

fetch_balance_ws()

fetch_balance_ws(exchange)

@spec fetch_balance_ws(keyword()) :: {:ok, map()} | {:error, term()}

fetch_balance_ws(exchange, opts)

fetch_closed_orders_ws()

fetch_closed_orders_ws(symbol)

fetch_closed_orders_ws(symbol, since)

fetch_closed_orders_ws(symbol, since, limit)

fetch_closed_orders_ws(symbol, since, limit, opts)

@spec fetch_closed_orders_ws(
  String.t() | nil,
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  {:ok, list()} | {:error, term()}

fetch_closed_orders_ws(exchange, symbol, since, limit, opts)

fetch_my_trades_ws()

fetch_my_trades_ws(symbol)

fetch_my_trades_ws(symbol, since)

fetch_my_trades_ws(symbol, since, limit)

fetch_my_trades_ws(symbol, since, limit, opts)

@spec fetch_my_trades_ws(
  String.t() | nil,
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  {:ok, list()} | {:error, term()}

fetch_my_trades_ws(exchange, symbol, since, limit, opts)

fetch_ohlcv_ws(symbol)

fetch_ohlcv_ws(symbol, timeframe)

fetch_ohlcv_ws(symbol, timeframe, since)

fetch_ohlcv_ws(symbol, timeframe, since, limit)

fetch_ohlcv_ws(symbol, timeframe, since, limit, opts)

@spec fetch_ohlcv_ws(
  String.t(),
  String.t(),
  integer() | nil,
  integer() | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

fetch_ohlcv_ws(exchange, symbol, timeframe, since, limit, opts)

fetch_open_orders_ws()

fetch_open_orders_ws(symbol)

fetch_open_orders_ws(symbol, since)

fetch_open_orders_ws(symbol, since, limit)

fetch_open_orders_ws(symbol, since, limit, opts)

@spec fetch_open_orders_ws(
  String.t() | nil,
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  {:ok, list()} | {:error, term()}

fetch_open_orders_ws(exchange, symbol, since, limit, opts)

fetch_order_book_ws(symbol)

fetch_order_book_ws(symbol, limit)

fetch_order_book_ws(symbol, limit, opts)

@spec fetch_order_book_ws(String.t(), integer() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}

fetch_order_book_ws(exchange, symbol, limit, opts)

fetch_order_ws(id)

fetch_order_ws(id, symbol)

fetch_order_ws(id, symbol, opts)

@spec fetch_order_ws(String.t(), String.t() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}

fetch_order_ws(exchange, id, symbol, opts)

fetch_orders_ws()

fetch_orders_ws(symbol)

fetch_orders_ws(symbol, since)

fetch_orders_ws(symbol, since, limit)

fetch_orders_ws(symbol, since, limit, opts)

@spec fetch_orders_ws(String.t() | nil, integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

fetch_orders_ws(exchange, symbol, since, limit, opts)

fetch_position_ws(symbol)

fetch_position_ws(symbol, opts)

@spec fetch_position_ws(
  String.t(),
  keyword()
) :: {:ok, list()} | {:error, term()}

fetch_position_ws(exchange, symbol, opts)

fetch_positions_ws()

fetch_positions_ws(exchange)

fetch_positions_ws(exchange, symbols)

@spec fetch_positions_ws(
  [String.t()] | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

fetch_positions_ws(exchange, symbols, opts)

fetch_ticker_ws(symbol)

fetch_ticker_ws(symbol, opts)

@spec fetch_ticker_ws(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

fetch_ticker_ws(exchange, symbol, opts)

fetch_trades_ws(symbol)

fetch_trades_ws(symbol, since)

fetch_trades_ws(symbol, since, limit)

fetch_trades_ws(symbol, since, limit, opts)

@spec fetch_trades_ws(String.t(), integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

fetch_trades_ws(exchange, symbol, since, limit, opts)

get_account_type_from_subscriptions(subscriptions)

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

get_future_ws_category(channel)

@spec get_future_ws_category(String.t()) :: String.t()

get_market_type(method, market \\ nil, opts \\ [])

@spec get_market_type(String.t(), map() | nil, keyword()) :: String.t() | nil

get_private_ws_url(arg1, listen_key, env)

@spec get_private_ws_url(String.t(), String.t(), String.t()) :: String.t()

get_ws_api_url(arg1, env)

@spec get_ws_api_url(String.t(), String.t()) :: String.t()

get_ws_url(arg1, category, env)

@spec get_ws_url(String.t(), String.t(), String.t()) :: String.t()

is_spot_url(url)

@spec is_spot_url(String.t() | map()) :: boolean()

keep_alive_listen_key(type, listen_key)

keep_alive_listen_key(type, listen_key, opts)

@spec keep_alive_listen_key(String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}

keep_alive_listen_key(exchange, type, listen_key, opts)

new(config \\ %{})

@spec new(map() | keyword()) :: t()

parse_ws_liquidation(liquidation, symbol_hint \\ nil)

@spec parse_ws_liquidation(map(), String.t() | nil) :: map()

parse_ws_ohlcv(message)

@spec parse_ws_ohlcv(map()) :: list()

parse_ws_order(message, symbol_hint \\ nil)

@spec parse_ws_order(map(), String.t() | nil) :: map()

parse_ws_position(position)

@spec parse_ws_position(map()) :: map()

parse_ws_ticker(message, market_type \\ "spot", symbol_hint \\ nil)

@spec parse_ws_ticker(map(), String.t(), String.t() | nil) :: map()

parse_ws_tickers(messages, symbols_hint \\ nil, market_type \\ "spot")

@spec parse_ws_tickers(map() | list(), [String.t()] | nil, String.t()) :: map()

parse_ws_trade(trade, symbol_hint \\ nil)

@spec parse_ws_trade(map(), String.t() | nil) :: map()

renew_listen_token()

renew_listen_token(exchange)

@spec renew_listen_token(keyword()) :: {:ok, map()} | {:error, term()}

renew_listen_token(exchange, opts)

sign_params()

sign_params(exchange)

sign_params(exchange, params)

@spec sign_params(
  map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

sign_params(exchange, params, opts)

stream(arg1, stream_hash)

@spec stream(String.t(), String.t()) :: String.t()

stream_balance(opts \\ [])

@spec stream_balance(keyword()) :: Enumerable.t()

stream_balance(exchange, opts)

stream_my_trades(symbol \\ nil, since \\ nil, limit \\ nil, opts \\ [])

@spec stream_my_trades(String.t() | nil, integer() | nil, integer() | nil, keyword()) ::
  Enumerable.t()

stream_my_trades(exchange, symbol, since, limit, opts)

stream_ohlcv(symbol, timeframe \\ "1m", since \\ nil, limit \\ nil, opts \\ [])

@spec stream_ohlcv(
  String.t(),
  String.t(),
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  Enumerable.t()

stream_ohlcv(exchange, symbol, timeframe, since, limit, opts)

stream_order_book(symbol, limit \\ nil, opts \\ [])

@spec stream_order_book(String.t(), integer() | nil, keyword()) :: Enumerable.t()

stream_order_book(exchange, symbol, limit, opts)

stream_orders(symbol \\ nil, since \\ nil, limit \\ nil, opts \\ [])

@spec stream_orders(String.t() | nil, integer() | nil, integer() | nil, keyword()) ::
  Enumerable.t()

stream_orders(exchange, symbol, since, limit, opts)

stream_positions(symbols \\ nil, since \\ nil, limit \\ nil, opts \\ [])

@spec stream_positions(
  [String.t()] | nil,
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  Enumerable.t()

stream_positions(exchange, symbols, since, limit, opts)

stream_ticker(symbol, opts \\ [])

@spec stream_ticker(
  String.t(),
  keyword()
) :: Enumerable.t()

stream_ticker(exchange, symbol, opts)

stream_trades(symbol, since \\ nil, limit \\ nil, opts \\ [])

@spec stream_trades(String.t(), integer() | nil, integer() | nil, keyword()) ::
  Enumerable.t()

stream_trades(exchange, symbol, since, limit, opts)

unsubscribe_user_data_stream(subscription_id \\ nil, opts \\ [])

@spec unsubscribe_user_data_stream(
  integer() | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

unsubscribe_user_data_stream(exchange, subscription_id, opts)

unwatch_mark_price(symbol)

unwatch_mark_price(symbol, opts)

@spec unwatch_mark_price(
  String.t(),
  keyword()
) :: :ok | {:error, term()}

unwatch_mark_price(exchange, symbol, opts)

unwatch_mark_prices()

unwatch_mark_prices(exchange)

unwatch_mark_prices(exchange, symbols)

@spec unwatch_mark_prices(
  [String.t()] | nil,
  keyword()
) :: :ok | {:error, term()}

unwatch_mark_prices(exchange, symbols, opts)

unwatch_ohlcv(symbol)

unwatch_ohlcv(symbol, timeframe)

unwatch_ohlcv(symbol, timeframe, opts)

@spec unwatch_ohlcv(String.t(), String.t(), keyword()) :: :ok | {:error, term()}

unwatch_ohlcv(exchange, symbol, timeframe, opts)

unwatch_ohlcv_for_symbols(symbols_and_timeframes)

unwatch_ohlcv_for_symbols(symbols_and_timeframes, opts)

@spec unwatch_ohlcv_for_symbols(
  [[String.t()]],
  keyword()
) :: :ok | {:error, term()}

unwatch_ohlcv_for_symbols(exchange, symbols_and_timeframes, opts)

unwatch_order_book(symbol)

unwatch_order_book(symbol, opts)

@spec unwatch_order_book(
  String.t(),
  keyword()
) :: :ok | {:error, term()}

unwatch_order_book(exchange, symbol, opts)

unwatch_order_book_for_symbols(symbols)

unwatch_order_book_for_symbols(symbols, opts)

@spec unwatch_order_book_for_symbols(
  [String.t()],
  keyword()
) :: :ok | {:error, term()}

unwatch_order_book_for_symbols(exchange, symbols, opts)

unwatch_ticker(symbol)

unwatch_ticker(symbol, opts)

@spec unwatch_ticker(
  String.t(),
  keyword()
) :: :ok | {:error, term()}

unwatch_ticker(exchange, symbol, opts)

unwatch_tickers()

unwatch_tickers(exchange)

unwatch_tickers(exchange, symbols)

@spec unwatch_tickers(
  [String.t()] | nil,
  keyword()
) :: :ok | {:error, term()}

unwatch_tickers(exchange, symbols, opts)

unwatch_trades(symbol)

unwatch_trades(symbol, opts)

@spec unwatch_trades(
  String.t(),
  keyword()
) :: :ok | {:error, term()}

unwatch_trades(exchange, symbol, opts)

unwatch_trades_for_symbols(symbols)

unwatch_trades_for_symbols(symbols, opts)

@spec unwatch_trades_for_symbols(
  [String.t()],
  keyword()
) :: :ok | {:error, term()}

unwatch_trades_for_symbols(exchange, symbols, opts)

user_data_stream_status(opts \\ [])

@spec user_data_stream_status(keyword()) :: {:ok, map()} | {:error, term()}

user_data_stream_status(exchange, opts)

user_data_stream_subscriptions(opts \\ [])

@spec user_data_stream_subscriptions(keyword()) :: {:ok, list()} | {:error, term()}

user_data_stream_subscriptions(exchange, opts)

watch_balance()

watch_balance(exchange)

@spec watch_balance(keyword()) :: {:ok, map()} | {:error, term()}

watch_balance(exchange, opts)

watch_bids_asks()

watch_bids_asks(exchange)

watch_bids_asks(exchange, symbols)

@spec watch_bids_asks(
  [String.t()] | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_bids_asks(exchange, symbols, opts)

watch_liquidations(symbol)

watch_liquidations(symbol, since)

watch_liquidations(symbol, since, limit)

watch_liquidations(symbol, since, limit, opts)

@spec watch_liquidations(String.t(), integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_liquidations(exchange, symbol, since, limit, opts)

watch_liquidations_for_symbols(symbols)

watch_liquidations_for_symbols(symbols, since)

watch_liquidations_for_symbols(symbols, since, limit)

watch_liquidations_for_symbols(symbols, since, limit, opts)

@spec watch_liquidations_for_symbols(
  [String.t()],
  integer() | nil,
  integer() | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

watch_liquidations_for_symbols(exchange, symbols, since, limit, opts)

watch_mark_price(symbol)

watch_mark_price(symbol, opts)

@spec watch_mark_price(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_mark_price(exchange, symbol, opts)

watch_mark_prices()

watch_mark_prices(exchange)

watch_mark_prices(exchange, symbols)

@spec watch_mark_prices(
  [String.t()] | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_mark_prices(exchange, symbols, opts)

watch_multi_ticker_helper(method_name, channel_name)

watch_multi_ticker_helper(method_name, channel_name, symbols)

watch_multi_ticker_helper(method_name, channel_name, symbols, opts)

watch_multi_ticker_helper(method_name, channel_name, symbols, opts, is_unsubscribe)

@spec watch_multi_ticker_helper(
  String.t(),
  String.t(),
  [String.t()] | nil,
  keyword(),
  boolean()
) :: {:ok, map()} | :ok | {:error, term()}

watch_multi_ticker_helper(exchange, symbols, channel_name, unified_prefix, suffix, opts)

watch_my_liquidations(symbol)

watch_my_liquidations(symbol, since)

watch_my_liquidations(symbol, since, limit)

watch_my_liquidations(symbol, since, limit, opts)

@spec watch_my_liquidations(
  String.t(),
  integer() | nil,
  integer() | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

watch_my_liquidations(exchange, symbol, since, limit, opts)

watch_my_liquidations_for_symbols(symbols)

watch_my_liquidations_for_symbols(symbols, since)

watch_my_liquidations_for_symbols(symbols, since, limit)

watch_my_liquidations_for_symbols(symbols, since, limit, opts)

@spec watch_my_liquidations_for_symbols(
  [String.t()],
  integer() | nil,
  integer() | nil,
  keyword()
) :: {:ok, list()} | {:error, term()}

watch_my_liquidations_for_symbols(exchange, symbols, since, limit, opts)

watch_my_trades()

watch_my_trades(symbol)

watch_my_trades(symbol, since)

watch_my_trades(symbol, since, limit)

watch_my_trades(symbol, since, limit, opts)

@spec watch_my_trades(String.t() | nil, integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_my_trades(exchange, symbol, since, limit, opts)

watch_ohlcv(symbol)

watch_ohlcv(symbol, timeframe)

watch_ohlcv(symbol, timeframe, since)

watch_ohlcv(symbol, timeframe, since, limit)

watch_ohlcv(symbol, timeframe, since, limit, opts)

@spec watch_ohlcv(String.t(), String.t(), integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_ohlcv(exchange, symbol, timeframe, since, limit, opts)

watch_ohlcv_for_symbols(symbols_and_timeframes)

watch_ohlcv_for_symbols(symbols_and_timeframes, since)

watch_ohlcv_for_symbols(symbols_and_timeframes, since, limit)

watch_ohlcv_for_symbols(symbols_and_timeframes, since, limit, opts)

@spec watch_ohlcv_for_symbols(
  [[String.t()]],
  integer() | nil,
  integer() | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_ohlcv_for_symbols(exchange, symbols_and_timeframes, since, limit, opts)

watch_order_book(symbol)

watch_order_book(symbol, limit)

watch_order_book(symbol, limit, opts)

@spec watch_order_book(String.t(), integer() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}

watch_order_book(exchange, symbol, limit, opts)

watch_order_book_for_symbols(symbols)

watch_order_book_for_symbols(symbols, limit)

watch_order_book_for_symbols(symbols, limit, opts)

@spec watch_order_book_for_symbols([String.t()], integer() | nil, keyword()) ::
  {:ok, map()} | {:error, term()}

watch_order_book_for_symbols(exchange, symbols, limit, opts)

watch_orders()

watch_orders(symbol)

watch_orders(symbol, since)

watch_orders(symbol, since, limit)

watch_orders(symbol, since, limit, opts)

@spec watch_orders(String.t() | nil, integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_orders(exchange, symbol, since, limit, opts)

watch_positions()

watch_positions(symbols)

watch_positions(symbols, since)

watch_positions(symbols, since, limit)

watch_positions(symbols, since, limit, opts)

@spec watch_positions([String.t()] | nil, integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_positions(exchange, symbols, since, limit, opts)

watch_ticker(symbol)

watch_ticker(exchange, symbol)

@spec watch_ticker(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_ticker(exchange, symbol, opts)

watch_tickers()

watch_tickers(exchange)

watch_tickers(exchange, symbols)

@spec watch_tickers(
  [String.t()] | nil,
  keyword()
) :: {:ok, map()} | {:error, term()}

watch_tickers(exchange, symbols, opts)

watch_trades(symbol)

watch_trades(symbol, since)

watch_trades(symbol, since, limit)

watch_trades(symbol, since, limit, opts)

@spec watch_trades(String.t(), integer() | nil, integer() | nil, keyword()) ::
  {:ok, list()} | {:error, term()}

watch_trades(exchange, symbol, since, limit, opts)

watch_trades_for_symbols(symbols)

watch_trades_for_symbols(symbols, since)

watch_trades_for_symbols(symbols, since, limit)

watch_trades_for_symbols(symbols, since, limit, opts)

@spec watch_trades_for_symbols(
  [String.t()],
  integer() | nil,
  integer() | nil,
  keyword()
) ::
  {:ok, list()} | {:error, term()}

watch_trades_for_symbols(exchange, symbols, since, limit, opts)