Exchanges API

The Exchanges module provides unified interfaces for connecting to cryptocurrency exchanges through the CCXT library. It handles exchange connectivity, market data access, and order management across multiple exchanges.

Overview

The Exchanges module includes:

  • Exchange connection and authentication management
  • Unified market data interfaces
  • Order placement and management
  • Account and balance information
  • Market information and trading rules
  • Sandbox and live trading modes

Complete API Reference

PlanarCore.Exchanges.LEVERAGED_PAIR_OPTIONSConstant

A leveraged pair is a pair like BTC3L/USD.

  • :yes : Leveraged pairs will not be filtered.
  • :only : ONLY leveraged will be kept.
  • :from : Selects non leveraged pairs, that also have at least one leveraged sibling.
source
PlanarCore.Exchanges.CcxtTradeType

A named tuple representing a trade in the CCXT (CryptoCurrency eXchange Trading) library.

  • timestamp

  • symbol

  • order

  • type

  • side

  • takerOrMaker

  • price

  • amount

  • cost

  • fee

  • fees

source
PlanarCore.Exchanges.CurrencyCashMethod

Create a CurrencyCash object.

CurrencyCash(
    id::Type{<:ExchangeID},
    cash_type::Type{<:PlanarCore.Instruments.Cash},
    v;
    sandbox,
    account
) -> PlanarCore.Exchanges.CurrencyCash
source
PlanarCore.Data.load_ohlcvMethod

Loads all pairs for a given timeframe, matching the global exc (Exchange object) and config.

load_ohlcv(timeframe::AbstractString; kwargs...) -> Any
source
PlanarCore.Data.load_ohlcvMethod

Loads all pairs for a given exchange and timeframe, matching the global config and zi (Zarr Instance).

load_ohlcv(
    exc::PlanarCore.ExchangeTypes.Exchange,
    timeframe::AbstractString;
    kwargs...
)
source
PlanarCore.Data.load_ohlcvMethod

Load given pairs from the global exc (Exchange object) and zi (Zarr Instance).

load_ohlcv(
    pairs::Union{AbstractDict, AbstractArray},
    timeframe::AbstractString;
    kwargs...
) -> Union{Dict{String, Zarr.ZArray}, Dict{String, PlanarCore.Data.PairData}}
source
PlanarCore.Data.save_ohlcvMethod

Updates pair data of the globally set Exchange instance.

save_ohlcv(
    pair,
    timeframe,
    data;
    kwargs...
) -> Union{Nothing, Zarr.ZArray}
source
PlanarCore.Exchanges._elconvertMethod

Converts a nested structure (Dict/Vector) recursively into a standard Julia Dict.

_elconvert(v) -> Any

Handles JSON3.Object and JSON3.Array types from gateway responses.

source
PlanarCore.Exchanges.checkMethod

Checks if the exchange instance supports all the calls required by Planar.

check(exc::PlanarCore.ExchangeTypes.Exchange; type)
  • exc: an Exchange object to perform the check on.
  • type (optional, default is :basic): a symbol representing the type of check to perform.
source
PlanarCore.Exchanges.getexchange!Function

getexchange!: Get ccxt exchange by symbol, either from cache or create anew via CcxtGateway.

getexchange!(
    x::Symbol;
    ...
) -> PlanarCore.ExchangeTypes.Exchange
getexchange!(
    x::Symbol,
    params;
    account,
    sandbox,
    markets,
    kwargs...
) -> PlanarCore.ExchangeTypes.Exchange
source
PlanarCore.Exchanges.isfileyoungerMethod

Checks if a file is younger than a specified period.

isfileyounger(f::AbstractString, p::Dates.Period) -> Any
  • f: a string that represents the path to the file.
  • p: a Period object that represents the time period.
source
PlanarCore.Exchanges.lastpriceMethod

Fetch the latest price for a specific pair from an exchange.

lastprice(
    pair::AbstractString,
    exc::PlanarCore.ExchangeTypes.Exchange;
    kwargs...
)
source
PlanarCore.Exchanges.loadmarkets!Method

Load exchange markets from gateway or cache.

loadmarkets!(exc; cache, agemax)
  • exc: an Exchange object that represents the exchange to load markets from.
  • cache (optional, default is true): a boolean that indicates whether to rely on storage cache.
  • agemax (optional, default is Day(1)): a Period object that represents the maximum cache valid period.
source
PlanarCore.Exchanges.market_feesMethod

Get the maker and taker fee for a given pair from an exchange.

market_fees(
    pair,
    exc;
    only_taker
) -> NamedTuple{(:taker, :maker, :min, :max), <:NTuple{4, Any}}
source
PlanarCore.Exchanges.market_limitsMethod

Get the minimum and maximum amount, cost, and price for a given pair from an exchange.

market_limits(
    pair,
    exc;
    precision,
    default_leverage,
    default_amount,
    default_price,
    default_cost
) -> NamedTuple
source
PlanarCore.Exchanges.marketsidMethod

Get vector of market ids from exchange.

  • exclude (optional, default is nothing): a symbol or vector of symbols representing market types to exclude.
source
PlanarCore.Exchanges.sandbox!Method

Enable sandbox mode for exchange via gateway.

sandbox!(
    exc::PlanarCore.ExchangeTypes.Exchange;
    flag,
    remove_keys
) -> Union{Nothing, Bool}
source
PlanarCore.Exchanges.setexchange!Method

Initializes a gateway-based exchange struct.

setexchange!(
    exc::PlanarCore.ExchangeTypes.Exchange,
    args...;
    markets,
    kwargs...
) -> PlanarCore.ExchangeTypes.CcxtExchange
  • exc: an Exchange object to be set up.
  • markets (optional, default is :yes): whether to load markets during setup.

Configures the exchange timeframes, loads markets, and sets API keys.

source
PlanarCore.Exchanges.ticker!Method

Fetch the ticker for a specific pair from an exchange via gateway.

ticker!(
    pair,
    exc::PlanarCore.ExchangeTypes.Exchange;
    timeout,
    func,
    delay
) -> Any
source
PlanarCore.Exchanges.tickersFunction

Fetch and filter tickers from an exchange, or use the global exchange.

tickers(; ...) -> Union{Dict{String, Any}, Vector{String}}
tickers(
    exc::PlanarCore.ExchangeTypes.Exchange;
    ...
) -> Union{Dict{String, Any}, Vector{String}}
tickers(
    exc::PlanarCore.ExchangeTypes.Exchange,
    quot;
    min_vol,
    skip_fiat,
    with_margin,
    with_leverage,
    as_vec,
    verbose,
    type,
    cross_match
) -> Union{Dict{String, Any}, Vector{String}}
source
PlanarCore.ExchangeTypes._supports_ws_methodMethod
_supports_ws_method(exc::Exchange, sym::AbstractString, suffix::String) -> Bool

Check whether the WebSocket-based fetch method should be used for the given exchange, symbol, and method suffix.

Some exchanges advertise WS methods in their has dict but restrict them to specific market types (e.g., Binance fetchOrderBookWs only works for swap markets). This function encodes those exchange-specific restrictions.

Returns true by default (respects the has dict).

source

See Also