Okex
CryptoExchangeAPIs.Okex.OkexClient
— TypeOkexClient <: 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.
CryptoExchangeAPIs.Okex.OkexAPIError
— TypeOkexAPIError{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.
CryptoExchangeAPIs.Okex.Data
— TypeData{D} <: AbstractAPIsData
Required fields
msg::String
: Return message.code::Int64
: Return code.data::Vector{D}
: Result values.
Common
CryptoExchangeAPIs.Okex.Common.public_client
— Constantpublic_client = OkexClient(; base_url = "https://www.okx.com")
CryptoExchangeAPIs.Okex.Common.Ticker.ticker
— Functionticker(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.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
instFamily | String | false | Instrument type: |
SPOT, SWAP, | |||
FUTURES, OPTION | |||
instrument_name | InstType | true | |
uly | String | false |
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
},
...
}
CryptoExchangeAPIs.Okex.Common.Instrument.instrument
— Functioninstrument(client::OkexClient, query::InstrumentQuery)
instrument(client::OkexClient = Okex.Common.public_client; kw...)
Retrieve a list of instruments with open contracts.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
instType | InstType | true | Instrument type: |
SPOT, MARGIN, SWAP, | |||
FUTURES, OPTION | |||
uly | String | Conditional | |
instFamily | String | Conditional | |
instId | String | false |
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
},
...
}
Spot
CryptoExchangeAPIs.Okex.Spot.public_client
— Constantpublic_client = OkexClient(; base_url = "https://www.okx.com")
CryptoExchangeAPIs.Okex.Spot.Candle.candle
— Functioncandle(client::OkexClient, query::CandleQuery)
candle(client::OkexClient = Okex.Spot.public_client; kw...)
Retrieve the candlestick charts.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
instId | String | true | |
after | DateTime | false | |
bar | TimeInterval | false | m1 m3 m5 m15 m30 h1 h2 h4 h6 h12 d1 d2 d3 w1 M1 M3 |
before | DateTime | false | |
limit | Int64 | false |
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
},
...
]
}
CryptoExchangeAPIs.Okex.Spot.Currency.currency
— Functioncurrency(client::OkexClient, query::CurrencyQuery)
currency(client::OkexClient; kw...)
Get information of coins (available for deposit and withdraw) for user.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
ccy | String | false | |
signature | String | false | |
timestamp | DateTime | false |
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
},
...
]
}