Okex

CryptoExchangeAPIs.Okex.OkexClientType
OkexClient <: AbstractAPIsClient

Client info.

Required fields

  • base_url::String: Base URL for the client.

Optional fields

  • public_key::String: Public key for authentication.
  • secret_key::String: Secret key for authentication.
  • interface::String: Interface for the client.
  • proxy::String: Proxy information for the client.
  • account_name::String: Account name associated with the client.
  • description::String: Description of the client.
source
CryptoExchangeAPIs.Okex.OkexAPIErrorType
OkexAPIError{T} <: AbstractAPIsError

Exception thrown when an API method fails with code T.

Required fields

  • code::Int64: Error code.
  • msg::String: Error message.

Optional fields

  • data::Vector{Any}: Error result data.
source

Common

CryptoExchangeAPIs.Okex.Common.Ticker.tickerFunction
ticker(client::OkexClient, query::TickerQuery)
ticker(client::OkexClient = Okex.Common.public_client; kw...)

Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.

GET api/v5/market/tickers

Parameters:

ParameterTypeRequiredDescription
instFamilyStringfalseInstrument type:
SPOT, SWAP,
FUTURES, OPTION
instrument_nameInstTypetrue
ulyStringfalse

Code samples:

using Serde
using CryptoExchangeAPIs.Okex

result = Okex.Common.ticker(;
    instType = Okex.Common.Ticker.SPOT,
)

to_pretty_json(result.result)

Result:

{
  "msg":"",
  "code":0,
  "data":[
    {
      "instId":"MDT-USDT",
      "askPx":0.04625,
      "askSz":130.0,
      "bidPx":0.04615,
      "bidSz":130.0,
      "high24h":0.04779,
      "instType":"SPOT",
      "last":0.04621,
      "lastSz":189.496477,
      "low24h":0.04483,
      "open24h":0.04557,
      "sodUtc0":0.04593,
      "sodUtc8":0.04688,
      "ts":"2024-09-23T13:53:17.512999936",
      "vol24h":1.626763924978e6,
      "volCcy24h":75454.11949093638
    },
    ...
}
source
CryptoExchangeAPIs.Okex.Common.Instrument.instrumentFunction
instrument(client::OkexClient, query::InstrumentQuery)
instrument(client::OkexClient = Okex.Common.public_client; kw...)

Retrieve a list of instruments with open contracts.

GET api/v5/public/instruments

Parameters:

ParameterTypeRequiredDescription
instTypeInstTypetrueInstrument type:
SPOT, MARGIN, SWAP,
FUTURES, OPTION
ulyStringConditional
instFamilyStringConditional
instIdStringfalse

Code samples:

using Serde
using CryptoExchangeAPIs.Okex

result = Okex.Common.instrument(;
    instType = Okex.Common.Instrument.SPOT,
)

to_pretty_json(result.result)

Result:

{
  "msg":"",
  "code":0,
  "data":[
    {
      "instId":"BTC-AUD",
      "baseCcy":"BTC",
      "quoteCcy":"AUD",
      "ctMult":null,
      "ctType":null,
      "ctVal":null,
      "ctValCcy":null,
      "expTime":null,
      "instFamily":null,
      "instType":"SPOT",
      "lever":null,
      "listTime":"2024-08-16T01:21:44",
      "lotSz":1.0e-7,
      "maxIcebergSz":9.9999999999e10,
      "maxLmtAmt":2.0e7,
      "maxLmtSz":99999999999,
      "maxMktAmt":1.0e6,
      "maxMktSz":1000000,
      "maxStopSz":1000000,
      "maxTriggerSz":9.9999999999e10,
      "maxTwapSz":9.9999999999e10,
      "minSz":0.0001,
      "optType":null,
      "settleCcy":null,
      "state":"live",
      "ruleType":"normal",
      "stk":null,
      "tickSz":0.1,
      "uly":null
    },
    ...
}
source

Spot

CryptoExchangeAPIs.Okex.Spot.Candle.candleFunction
candle(client::OkexClient, query::CandleQuery)
candle(client::OkexClient = Okex.Spot.public_client; kw...)

Retrieve the candlestick charts.

GET api/v5/market/candles

Parameters:

ParameterTypeRequiredDescription
instIdStringtrue
afterDateTimefalse
barTimeIntervalfalsem1 m3 m5 m15 m30 h1 h2 h4 h6 h12 d1 d2 d3 w1 M1 M3
beforeDateTimefalse
limitInt64false

Code samples:

using Serde
using CryptoExchangeAPIs.Okex

result = Okex.Spot.candle(;
    instId = "BTC-USDT",
    bar = Okex.Spot.Candle.d1,
)

to_pretty_json(result.result)

Result:

{
  "msg":"",
  "code":0,
  "data":[
    {
      "openTime":"2024-04-11T00:00:00",
      "openPrice":70637.1,
      "highPrice":71315.9,
      "lowPrice":69544.8,
      "closePrice":70211.3,
      "vol":9281.9689485,
      "volCcy":6.537022764980018e8,
      "volCcyQuote":6.537022764980018e8,
      "confirm":0
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Okex.Spot.Currency.currencyFunction
currency(client::OkexClient, query::CurrencyQuery)
currency(client::OkexClient; kw...)

Get information of coins (available for deposit and withdraw) for user.

GET api/v5/asset/currencies

Parameters:

ParameterTypeRequiredDescription
ccyStringfalse
signatureStringfalse
timestampDateTimefalse

Code samples:

using Serde
using CryptoExchangeAPIs.Okex

okex_client = OkexClient(;
    base_url = "https://www.okx.com",
    public_key = ENV["OKEX_PUBLIC_KEY"],
    secret_key = ENV["OKEX_SECRET_KEY"],
    passphrase = ENV["OKEX_PASSPHRASE"],
)

result = Okex.Spot.currency(okex_client; ccy = "BTC")

to_pretty_json(result.result)

Result:

{
  "msg":"",
  "code":0,
  "data":[
    {
      "canDep":true,
      "canInternal":true,
      "canWd":true,
      "ccy":"BTC",
      "chain":"BTC-Bitcoin",
      "depQuotaFixed":null,
      "depQuoteDailyLayer2":null,
      "logoLink":"https://static.coinall.ltd/cdn/oksupport/asset/currency/icon/btc20230419112752.png",
      "mainNet":true,
      "maxFee":0.0006,
      "maxWd":500.0,
      "minDep":0.0005,
      "minDepArrivalConfirm":1,
      "minFee":0.0003,
      "minWd":0.001,
      "minWdUnlockConfirm":2,
      "name":"Bitcoin",
      "needTag":false,
      "usedDepQuotaFixed":null,
      "usedWdQuota":0,
      "wdQuota":40000000,
      "wdTickSz":8
    },
    ...
  ]
}
source