Bourse.Okx (bourse v0.1.0)

Copy Markdown View Source

OKX exchange client (okx).

Generated from the owned vendored spec at compile time. Provides raw REST endpoint wrappers, unified-method mapping, and response parsers.

Metadata

  • Hostname: www.okx.com
  • API version: v5
  • Countries: CN, US
  • Certified: yes
  • Pro: yes

Signing

Pattern: hmac_sha256_iso_passphrase — ISO timestamp + passphrase HMAC

Capabilities

  • Enabled: fetchTicker, fetchOrderBook, fetchOHLCV, fetchBalance, fetchPositions, createOrder, cancelOrder, fetchOpenOrders, fetchMyTrades, fetchFundingRate, fetchMarkets, fetchCurrencies (108 total — see __features__/0)

Credentials

Private endpoints require: apiKey, password, secret.

Introspection

Usage

{:ok, exchange} = Bourse.Exchange.new("okx")
endpoints = Bourse.Okx.__endpoints__()

API Functions

FunctionArityDescriptionParam Kinds

Summary

Functions

Returns all pre-computed endpoint configs.

Returns the exchange capability map.

Returns the owned normalization field maps (per response-type slot).

Returns the exchange ID string.

Returns the exchange display name.

Returns per-slot unified-method response envelope configs.

Returns the signing pattern and config for this exchange.

Returns the lean spec (runtime describe minus API tree).

Returns endpoint configs for a specific unified method, or [] if unknown.

Returns the full unified method → endpoint configs mapping.

Parses a raw account response into Bourse.Account.

Parses a raw adl_rank response into Bourse.ADLRank.

Parses a raw balance response into Bourse.Balance.

Parses a raw borrow_interest response into Bourse.BorrowInterest.

Parses a raw borrow_rate response into Bourse.BorrowRate.

Parses a raw conversion response into Bourse.Conversion.

Parses a raw currency response into Bourse.Currency.

Parses a raw deposit_address response into Bourse.DepositAddress.

Parses a raw funding_history response into Bourse.FundingHistory.

Parses a raw funding_rate response into Bourse.FundingRate.

Parses a raw funding_rate_history response into Bourse.FundingRateHistory.

Parses a raw greeks response into Bourse.Greeks.

Parses a raw ledger_entry response into Bourse.LedgerEntry.

Parses a raw leverage response into Bourse.Leverage.

Parses a raw leverage_tiers response into Bourse.LeverageTier.

Parses a raw liquidation response into Bourse.Liquidation.

Parses a raw long_short_ratio response into Bourse.LongShortRatio.

Parses a raw margin_loan response into Bourse.MarginLoan.

Parses a raw margin_mode response into Bourse.MarginMode.

Parses a raw margin_modification response into Bourse.MarginModification.

Parses a raw market response into Bourse.Market.

Parses a raw ohlcv response into Bourse.OHLCV.

Parses a raw open_interest response into Bourse.OpenInterest.

Parses a raw option response into Bourse.OptionData.

Parses a raw order response into Bourse.Order.

Parses a raw position response into Bourse.Position.

Parses a raw ticker response into Bourse.Ticker.

Parses a raw trade response into Bourse.Trade.

Parses a raw trading_fee response into Bourse.TradingFee.

Parses a raw transaction response into Bourse.Transaction.

Parses a raw transfer response into Bourse.TransferEntry.

Parses a raw volatility_history response into Bourse.VolatilityHistory.

Functions

__endpoints__()

@spec __endpoints__() :: [map()]

Returns all pre-computed endpoint configs.

__features__()

@spec __features__() :: map()

Returns the exchange capability map.

__field_maps__()

@spec __field_maps__() :: map()

Returns the owned normalization field maps (per response-type slot).

__id__()

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

Returns the exchange ID string.

__name__()

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

Returns the exchange display name.

__response_envelopes__()

@spec __response_envelopes__() :: map()

Returns per-slot unified-method response envelope configs.

__signing__()

@spec __signing__() :: %{pattern: atom(), config: map()}

Returns the signing pattern and config for this exchange.

__spec__()

@spec __spec__() :: map()

Returns the lean spec (runtime describe minus API tree).

__unified_endpoint__(method)

@spec __unified_endpoint__(atom()) :: [map()]

Returns endpoint configs for a specific unified method, or [] if unknown.

__unified_endpoints__()

@spec __unified_endpoints__() :: %{required(atom()) => [map()]}

Returns the full unified method → endpoint configs mapping.

parse_account(data, opts \\ [])

@spec parse_account(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw account response into Bourse.Account.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_adl_rank(data, opts \\ [])

@spec parse_adl_rank(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw adl_rank response into Bourse.ADLRank.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_balance(data, opts \\ [])

@spec parse_balance(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw balance response into Bourse.Balance.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_borrow_interest(data, opts \\ [])

@spec parse_borrow_interest(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw borrow_interest response into Bourse.BorrowInterest.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_borrow_rate(data, opts \\ [])

@spec parse_borrow_rate(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw borrow_rate response into Bourse.BorrowRate.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_conversion(data, opts \\ [])

@spec parse_conversion(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw conversion response into Bourse.Conversion.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_currency(data, opts \\ [])

@spec parse_currency(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw currency response into Bourse.Currency.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_deposit_address(data, opts \\ [])

@spec parse_deposit_address(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw deposit_address response into Bourse.DepositAddress.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_funding_history(data, opts \\ [])

@spec parse_funding_history(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw funding_history response into Bourse.FundingHistory.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_funding_rate(data, opts \\ [])

@spec parse_funding_rate(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw funding_rate response into Bourse.FundingRate.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_funding_rate_history(data, opts \\ [])

@spec parse_funding_rate_history(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw funding_rate_history response into Bourse.FundingRateHistory.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_greeks(data, opts \\ [])

@spec parse_greeks(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw greeks response into Bourse.Greeks.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_ledger_entry(data, opts \\ [])

@spec parse_ledger_entry(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw ledger_entry response into Bourse.LedgerEntry.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_leverage(data, opts \\ [])

@spec parse_leverage(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw leverage response into Bourse.Leverage.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_leverage_tiers(data, opts \\ [])

@spec parse_leverage_tiers(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw leverage_tiers response into Bourse.LeverageTier.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_liquidation(data, opts \\ [])

@spec parse_liquidation(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw liquidation response into Bourse.Liquidation.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_long_short_ratio(data, opts \\ [])

@spec parse_long_short_ratio(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw long_short_ratio response into Bourse.LongShortRatio.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_margin_loan(data, opts \\ [])

@spec parse_margin_loan(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw margin_loan response into Bourse.MarginLoan.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_margin_mode(data, opts \\ [])

@spec parse_margin_mode(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw margin_mode response into Bourse.MarginMode.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_margin_modification(data, opts \\ [])

@spec parse_margin_modification(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw margin_modification response into Bourse.MarginModification.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_market(data, opts \\ [])

@spec parse_market(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw market response into Bourse.Market.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_ohlcv(data, opts \\ [])

@spec parse_ohlcv(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw ohlcv response into Bourse.OHLCV.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_open_interest(data, opts \\ [])

@spec parse_open_interest(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw open_interest response into Bourse.OpenInterest.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_option(data, opts \\ [])

@spec parse_option(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw option response into Bourse.OptionData.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_order(data, opts \\ [])

@spec parse_order(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw order response into Bourse.Order.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_position(data, opts \\ [])

@spec parse_position(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw position response into Bourse.Position.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_ticker(data, opts \\ [])

@spec parse_ticker(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw ticker response into Bourse.Ticker.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_trade(data, opts \\ [])

@spec parse_trade(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw trade response into Bourse.Trade.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_trading_fee(data, opts \\ [])

@spec parse_trading_fee(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw trading_fee response into Bourse.TradingFee.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_transaction(data, opts \\ [])

@spec parse_transaction(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw transaction response into Bourse.Transaction.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_transfer(data, opts \\ [])

@spec parse_transfer(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw transfer response into Bourse.TransferEntry.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.

parse_volatility_history(data, opts \\ [])

@spec parse_volatility_history(
  term(),
  keyword()
) :: {:ok, struct() | [struct()]} | {:error, term()}

Parses a raw volatility_history response into Bourse.VolatilityHistory.

Delegates to Bourse.Parser.parse/4 with this exchange's upstream normalization field map. Returns {:error, :no_field_map} when the slot is unmapped and {:error, {:unresolved, reason}} when upstream flagged it as not safely derivable. opts may carry :market for discriminated maps.