Binance
CryptoExchangeAPIs.Binance.BinanceClient
— TypeBinanceClient <: 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.Binance.BinanceAPIError
— TypeBinanceAPIError{T} <: AbstractAPIsError
Exception thrown when an API method fails with code T
.
Required fields
code::Int64
: Error code.
Optional fields
type::String
: Type of error.msg::String
: Error message.
Spot
CryptoExchangeAPIs.Binance.Spot.public_client
— Constantpublic_client = BinanceClient(; base_url = "https://api.binance.com")
CryptoExchangeAPIs.Binance.Spot.AccountTrade.account_trade
— Functionaccount_trade(client::BinanceClient, query::AccountTradeQuery)
account_trade(client::BinanceClient; kw...)
Get trades for a specific account and symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Int64 | false | |
startTime | DateTime | false | |
endTime | DateTime | false | |
fromId | Int64 | false | |
limit | Int64 | false | Default: 1000 |
recvWindow | Int64 | false | |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
binance_client = BinanceClient(;
base_url = "https://api.binance.com",
public_key = ENV["BINANCE_PUBLIC_KEY"],
secret_key = ENV["BINANCE_SECRET_KEY"],
)
result = Binance.Spot.account_trade(
binance_client;
symbol = "BTCUSDT",
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BNBBTC",
"id":28457,
"orderId":100234,
"orderListId":-1,
"price":4.00000100,
"qty":12.00000000,
"quoteQty":48.000012,
"commission":10.10000000,
"commissionAsset":"BNB",
"time":"2017-07-12T13:19:09",
"isBuyer":true,
"isMaker":false,
"isBestMatch":true
},
...
]
CryptoExchangeAPIs.Binance.Spot.AvgPrice.avg_price
— Functionavg_price(client::BinanceClient, query::AvgPriceQuery)
avg_price(client::BinanceClient = Binance.Spot.public_client; kw...)
Current average price for a symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.avg_price(;
symbol = "ADAUSDT",
)
to_pretty_json(result.result)
Result:
{
"mins":5,
"price":0.64545824
}
CryptoExchangeAPIs.Binance.Spot.Candle.candle
— Functioncandle(client::BinanceClient, query::CandleQuery)
candle(client::BinanceClient = Binance.Spot.public_client; kw...)
Kline/candlestick bars for a symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
interval | Period | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 d3 w1 M1 |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.candle(;
symbol = "ADAUSDT",
interval = Binance.Spot.Candle.M1,
)
to_pretty_json(result.result)
Result:
[
{
"openTime":"2018-04-01T00:00:00",
"openPrice":0.25551,
"highPrice":0.3866,
"lowPrice":0.23983,
"closePrice":0.34145,
"volume":1.17451580874e9,
"closeTime":"2018-04-30T23:59:59.999000064",
"quoteAssetVolume":3.597636214561159e8,
"tradesNumber":759135,
"takerBuyBaseAssetVolume":5.556192707e8,
"takerBuyQuoteAssetVolume":1.706766832130686e8
},
...
]
CryptoExchangeAPIs.Binance.Spot.CoinInformation.coin_information
— Functioncoin_information(client::BinanceClient, query::CoinInformationQuery)
coin_information(client::BinanceClient; kw...)
Get information of coins (available for deposit and withdraw) for user.
GET sapi/v1/capital/config/getall
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
recvWindow | Int64 | false | |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
binance_client = BinanceClient(;
base_url = "https://api.binance.com",
public_key = ENV["BINANCE_PUBLIC_KEY"],
secret_key = ENV["BINANCE_SECRET_KEY"],
)
result = Binance.Spot.coin_information(binance_client)
to_pretty_json(result.result)
Result:
[
{
"coin":"ADA",
"depositAllEnable":true,
"free":0.0,
"freeze":0.0,
"ipoable":0.0,
"ipoing":0.0,
"isLegalMoney":false,
"locked":0.0,
"name":"Cardano",
"networkList":[
{
"addressRegex":"^(([0-9A-Za-z]{57,59})|([0-9A-Za-z]{100,104}))$",
"addressRule":null,
"busy":false,
"coin":"ADA",
"country":null,
"depositDesc":"",
"depositDust":1.0e-6,
"depositEnable":true,
"estimatedArrivalTime":"1970-01-01T00:00:00",
"isDefault":true,
"memoRegex":"",
"minConfirm":30,
"name":"Cardano",
"network":"ADA",
"resetAddressStatus":false,
"sameAddress":false,
"specialTips":"",
"specialWithdrawTips":null,
"unLockConfirm":0,
"withdrawDesc":"",
"withdrawEnable":true,
"withdrawFee":0.8,
"withdrawIntegerMultiple":1.0e-6,
"withdrawMax":5.0e7,
"withdrawMin":2.0
}
],
"storage":0.0,
"trading":true,
"withdrawAllEnable":true,
"withdrawing":0.0
},
...
]
CryptoExchangeAPIs.Binance.Spot.DepositLog.deposit_log
— Functiondeposit_log(client::BinanceClient, query::DepositLogQuery)
deposit_log(client::BinanceClient; kw...)
Fetch deposit history.
GET sapi/v1/capital/withdraw/history
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
coin | String | false | |
endTime | DateTime | false | |
limit | Int64 | false | Default: 1000 |
offset | Int64 | false | |
startTime | DateTime | false | |
status | DepositStatus | false | PENDING (0), SUCCESS (1), CREDITED_BUT_CANNOT_WITHDRAW (6), WRONG_DEPOSIT (7), WAITING_USER_CONFIRM (8) |
txId | String | false | |
recvWindow | Int64 | false | |
timestamp | DateTime | false | |
signature | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
binance_client = BinanceClient(;
base_url = "https://api.binance.com",
public_key = ENV["BINANCE_PUBLIC_KEY"],
secret_key = ENV["BINANCE_SECRET_KEY"],
)
result = Binance.Spot.deposit_log(binance_client)
to_pretty_json(result.result)
Result:
[
{
"id":769800519366885376,
"amount":0.001,
"coin":"BNB",
"network":"BNB",
"status":0,
"address":"bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23",
"addressTag":"101764890",
"txId":"98A3EA560C6B3336D348B6C83F0F95ECE4F1F5919E94BD006E5BF3BF264FACFC",
"insertTime":"2022-08-26T05:52:26",
"transferType":0,
"confirmTimes":"1/1",
"unlockConfirm":0,
"walletType":0
},
...
]
CryptoExchangeAPIs.Binance.Spot.ExchangeInfo.exchange_info
— Functionexchange_info(client::BinanceClient, query::ExchangeInfoQuery)
exchange_info(client::BinanceClient = Binance.Spot.public_client; kw...)
Current exchange trading rules and symbol information.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
permissions | Vector | false | SPOT MARGIN LEVERAGED TRD_GRP_002 TRD_GRP_003 TRD_GRP_004 TRD_GRP_005 TRD_GRP_006 TRD_GRP_007 |
symbol | String | false | |
symbols | Vector | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.exchange_info(;
symbol = "ADAUSDT"
)
to_pretty_json(result.result)
Result:
{
"exchangeFilters":[],
"rateLimits":[
{
"limit":6000,
"rateLimitType":"REQUEST_WEIGHT",
"interval":"MINUTE",
"intervalNum":1
},
...
],
"serverTime":"2024-04-01T09:35:01.003000064",
"symbols":[
{
"allowTrailingStop":true,
"allowedSelfTradePreventionModes":[
"EXPIRE_TAKER",
"EXPIRE_MAKER",
"EXPIRE_BOTH"
],
"baseAsset":"ADA",
"baseAssetPrecision":8,
"baseCommissionPrecision":8,
"cancelReplaceAllowed":true,
"defaultSelfTradePreventionMode":"EXPIRE_MAKER",
"filters":[
{
"applyToMarket":null,
"askMultiplierDown":null,
"askMultiplierUp":null,
"avgPriceMins":null,
"bidMultiplierDown":null,
"bidMultiplierUp":null,
"filterType":"PRICE_FILTER",
"limit":null,
"maxNumAlgoOrders":null,
"maxNumOrders":null,
"maxPosition":null,
"maxPrice":1000.0,
"maxQty":null,
"maxTrailingAboveDelta":null,
"maxTrailingBelowDelta":null,
"minNotional":null,
"minPrice":0.0001,
"minQty":null,
"minTrailingAboveDelta":null,
"minTrailingBelowDelta":null,
"multiplierDown":null,
"multiplierUp":null,
"stepSize":null,
"tickSize":0.0001
},
...
],
"icebergAllowed":true,
"isMarginTradingAllowed":true,
"isSpotTradingAllowed":true,
"ocoAllowed":true,
"orderTypes":[
"LIMIT",
"LIMIT_MAKER",
"MARKET",
"STOP_LOSS_LIMIT",
"TAKE_PROFIT_LIMIT"
],
"permissions":[
"SPOT",
"MARGIN",
"TRD_GRP_004",
...
],
"quoteAsset":"USDT",
"quoteAssetPrecision":8,
"quoteCommissionPrecision":8,
"quoteOrderQtyMarketAllowed":true,
"quotePrecision":8,
"status":"TRADING",
"symbol":"ADAUSDT"
}
],
"timezone":"UTC"
}
CryptoExchangeAPIs.Binance.Spot.OrderBook.order_book
— Functionorder_book(client::BinanceClient, query::OrderBookQuery)
order_book(client::BinanceClient = Binance.Spot.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
limit | Int64 | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.order_book(;
symbol = "ADAUSDT"
)
to_pretty_json(result.result)
Result:
{
"asks":[
{
"price":0.634,
"size":1478.6
},
...
],
"bids":[
{
"price":0.6339,
"size":28448.6
},
...
],
"lastUpdateId":8394873195
}
CryptoExchangeAPIs.Binance.Spot.ServerTime.server_time
— Functionserver_time(client::BinanceClient, query::ServerTimeQuery)
server_time(client::BinanceClient = Binance.Spot.public_client; kw...)
Check current server time.
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.server_time()
to_pretty_json(result.result)
Result:
{
"serverTime": "2024-07-06T11:39:06.032"
}
CryptoExchangeAPIs.Binance.Spot.Ticker.ticker
— Functionticker(client::BinanceClient, query::TickerQuery)
ticker(client::BinanceClient = Binance.Spot.public_client; kw...)
24 hour rolling window price change statistics.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false | |
symbols | Vector{String} | false | |
type | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.Spot.ticker(;
symbol = "ADAUSDT",
)
to_pretty_json(result.result)
Result:
{
"symbol":"ADAUSDT",
"askPrice":0.631,
"askQty":53.4,
"bidPrice":0.6309,
"bidQty":23714.9,
"closeTime":"2024-03-21T14:04:37.151000064",
"count":265067,
"firstId":482014355,
"highPrice":0.6459,
"lastId":482279421,
"lastPrice":0.631,
"lastQty":1282.0,
"lowPrice":0.5757,
"openPrice":0.6048,
"openTime":"2024-03-20T14:04:37.151000064",
"prevClosePrice":0.6048,
"priceChange":0.0262,
"priceChangePercent":4.332,
"quoteVolume":1.363472992331e8,
"volume":2.185537682e8,
"weightedAvgPrice":0.62386158
}
CryptoExchangeAPIs.Binance.Spot.WithdrawalLog.withdrawal_log
— Functionwithdrawal_log(client::BinanceClient, query::WithdrawalLogQuery)
withdrawal_log(client::BinanceClient; kw...)
Fetch withdraw history.
GET sapi/v1/capital/withdraw/history
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
coin | String | false | |
endTime | DateTime | false | |
limit | Int64 | false | Default: 1000 |
offset | Int64 | false | |
startTime | DateTime | false | |
status | WithdrawStatus | false | EMAIL_SENT (0), CANCELLED (1), AWAITING_APPROVAL (2), REJECTED (3), PROCESSING (4), FAILURE (5), COMPLETED (6) |
withdrawOrderId | String | false | |
recvWindow | Int64 | false | |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
binance_client = BinanceClient(;
base_url = "https://api.binance.com",
public_key = ENV["BINANCE_PUBLIC_KEY"],
secret_key = ENV["BINANCE_SECRET_KEY"],
)
result = Binance.Spot.withdrawal_log(binance_client)
to_pretty_json(result.result)
Result:
[
{
"id":"b6ae22b3aa844210a7041aee7589627c",
"amount":8.91000000,
"transactionFee":0.004,
"coin":"USDT",
"status":6,
"address":"0x94df8b352de7f46f64b01d3666bf6e936e44ce60",
"txId":"0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"
"applyTime":"2019-10-12T11:12:02",
"network":"ETH",
"transferType":0,
"info":"",
"confirmNo":3,
"walletType":1,
"txKey":"",
"completeTime":"2023-03-23T16:52:41"
},
...
]
USDMFutures
CryptoExchangeAPIs.Binance.USDMFutures.public_client
— Constantpublic_client = BinanceClient(; base_url = "https://fapi.binance.com")
CryptoExchangeAPIs.Binance.USDMFutures.Candle.candle
— Functioncandle(client::BinanceClient, query::CandleQuery)
candle(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Kline/candlestick bars for a symbol.
Wrapper for method: GET fapi/v3/klines
.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
interval | TimeInterval | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 d3 w1 M1 |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.candle(;
symbol = "ADAUSDT",
interval = Binance.USDMFutures.Candle.M1,
)
to_pretty_json(result.result)
Result:
[
{
"openTime":"2020-01-01T00:00:00",
"openPrice":0.0545,
"highPrice":0.05559,
"lowPrice":0.05209,
"closePrice":0.05387,
"volume":2.44632854e8,
"closeTime":"2020-01-31T23:59:59.999000064",
"quoteAssetVolume":1.313060288191e7,
"tradesNumber":40186,
"takerBuyBaseAssetVolume":1.16954492e8,
"takerBuyQuoteAssetVolume":6.28735588554e6
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.ContinuousCandle.continuous_candle
— Functioncontinuous_candle(client::BinanceClient, query::ContinuousCandleQuery)
continuous_candle(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Kline/candlestick bars for a specific contract type.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
pair | String | true | |
contractType | ContractType | true | PERPETUAL CURRENT_QUARTER NEXT_QUARTER |
interval | TimeInterval | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 d3 w1 M1 |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.continuous_candle(;
pair = "BTCUSDT",
contractType = Binance.USDMFutures.ContinuousCandle.PERPETUAL,
interval = Binance.USDMFutures.ContinuousCandle.M1,
)
to_pretty_json(result.result)
Result:
[
{
"openTime":"2019-09-01T00:00:00",
"openPrice":8042.08,
"highPrice":10475.54,
"lowPrice":7700.67,
"closePrice":8041.96,
"volume":608742.1109999999,
"closeTime":"2019-09-30T23:59:59.999000064",
"quoteAssetVolume":5.61187924896223e9,
"tradesNumber":998055,
"takerBuyVolume":298326.244,
"takerBuyQuoteAssetVolume":2.7368038906708302e9
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.ExchangeInfo.exchange_info
— Functionexchange_info(client::BinanceClient, query::ExchangeInfoQuery)
exchange_info(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Current exchange trading rules and symbol information.
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.exchange_info()
to_pretty_json(result.result)
Result:
{
"futuresType":"U_MARGINED",
"symbols":
[
{
"baseAsset":"BTC",
"baseAssetPrecision":8,
"contractType":"PERPETUAL",
"deliveryDate":"2100-12-25T08:00:00",
"filters":[
{
"filterType":"PRICE_FILTER",
"limit":null,
"maxPrice":4.529764e6,
"maxQty":null,
"minPrice":556.8,
"minQty":null,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":null,
"tickSize":0.1
},
...
],
"liquidationFee":0.0125,
"maintMarginPercent":2.5,
"marginAsset":"USDT",
"marketTakeBound":0.05,
"maxMoveOrderLimit":10000,
"onboardDate":"2019-09-25T08:00:00",
"orderTypes":[
"LIMIT",
"MARKET",
"STOP",
"STOP_MARKET",
"TAKE_PROFIT",
"TAKE_PROFIT_MARKET",
"TRAILING_STOP_MARKET"
],
"pair":"BTCUSDT",
"pricePrecision":2,
"quantityPrecision":3,
"quoteAsset":"USDT",
"quotePrecision":8,
"requiredMarginPercent":5.0,
"settlePlan":0,
"status":"TRADING",
"symbol":"BTCUSDT",
"timeInForce":[
"GTC",
"IOC",
"FOK",
"GTX",
"GTD"
],
"triggerProtect":0.05,
"underlyingSubType":[
"PoW"
],
"underlyingType":"COIN"
},
...
]
"assets":
[
{
"asset":"USDT",
"autoAssetExchange":-10000.0,
"marginAvailable":true
},
...
]
"serverTime":"2024-03-21T20:00:09.139000064",
"exchangeFilters":null,
"timezone":"UTC",
"rateLimits":
[
{
"interval":"MINUTE",
"intervalNum":1,
"limit":2400,
"rateLimitType":"REQUEST_WEIGHT"
},
...
]
}
CryptoExchangeAPIs.Binance.USDMFutures.FundingRate.funding_rate
— Functionfunding_rate(client::BinanceClient, query::FundingRateQuery)
funding_rate(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Get funding rate history.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.funding_rate(;
symbol = "BTCUSDT",
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSDT",
"fundingRate":0.00011242,
"fundingTime":"2024-02-21T08:00:00",
"markPrice":51595.13521986
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.HistoricalTrades.historical_trades
— Functionhistorical_trades(client::BinanceClient, query::HistoricalTradesQuery)
historical_trades(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
limit | Int64 | false | Default: 500; Max: 1000 |
fromId | Int64 | false | TradeId to fetch from. Default gets most recent trades |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.historical_trades(;
symbol = "BTCUSDT"
)
to_pretty_json(result.result)
Result:
[
{
"id":3697954552,
"price":66428.01,
"qty":0.0038,
"quoteQty":252.426438,
"time":"2024-07-23T12:50:24.951000064",
"isBuyerMaker":false
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.LongShortRatio.long_short_ratio
— Functionlong_short_ratio(client::BinanceClient, query::LongShortRatioQuery)
long_short_ratio(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
GET futures/data/globalLongShortAccountRatio
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
period | TimeInterval | true | m5 m15 m30 h1 h2 h4 h6 h12 d1 |
endTime | DateTime | false | |
limit | Int64 | false | Default: 30, Max: 500 |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.long_short_ratio(;
symbol = "BTCUSDT",
period = Binance.USDMFutures.LongShortRatio.h1,
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSDT",
"longShortRatio":1.3305,
"longAccount":0.5709,
"shortAccount":0.4291,
"timestamp":"2024-03-29T12:00:00"
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.OpenInterestHist.open_interest_hist
— Functionopen_interest_hist(client::BinanceClient, query::OpenInterestHistQuery)
open_interest_hist(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
GET futures/data/openInterestHist
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
period | TimeInterval | true | m5 m15 m30 h1 h2 h4 h6 h12 d1 |
endTime | DateTime | false | |
limit | Int64 | false | Default: 30, Max: 500 |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.open_interest_hist(;
symbol = "BTCUSDT",
period = Binance.USDMFutures.OpenInterestHist.h1,
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSDT",
"sumOpenInterest":81737.468,
"sumOpenInterestValue":5.730969977716018e9,
"timestamp":"2024-03-29T15:00:00"
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.OrderBook.order_book
— Functionorder_book(client::BinanceClient, query::OrderBookQuery)
order_book(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
limit | Int64 | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.order_book(;
symbol = "ADAUSDT"
)
to_pretty_json(result.result)
Result:
{
"T":"2024-03-21T21:25:53.671000064",
"E":"2024-03-21T21:25:53.680999936",
"asks":[
{
"price":0.6337,
"size":20325.0
},
...
],
"lastUpdateId":4248628084740,
"bids":[
{
"price":0.6336,
"size":58607.0
},
...
]
}
CryptoExchangeAPIs.Binance.USDMFutures.PremiumIndex.premium_index
— Functionpremium_index(client::BinanceClient, query::PremiumIndexQuery)
premium_index(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.premium_index(;
symbol = "BTCUSDT",
)
to_pretty_json(result.result)
Result:
{
"symbol":"BTCUSDT",
"markPrice":70901.2,
"indexPrice":70794.23404255,
"estimatedSettlePrice":70699.56121556,
"lastFundingRate":0.000442,
"interestRate":0.0001,
"nextFundingTime":"2024-04-01T00:00:00",
"time":"2024-03-31T19:00:35"
}
CryptoExchangeAPIs.Binance.USDMFutures.TakerLongShortRatio.taker_long_short_ratio
— Functiontaker_long_short_ratio(client::BinanceClient, query::TakerLongShortRatioQuery)
taker_long_short_ratio(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
GET futures/data/takerlongshortRatio
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
period | TimeInterval | true | m5 m15 m30 h1 h2 h4 h6 h12 d1 |
endTime | DateTime | false | |
limit | Int64 | false | Default: 30, Max: 500 |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.taker_long_short_ratio(;
symbol = "BTCUSDT",
period = Binance.USDMFutures.TakerLongShortRatio.h1,
)
to_pretty_json(result.result)
Result:
[
{
"buySellRatio":0.6366,
"buyVol":1277.042,
"sellVol":2005.878,
"timestamp":"2024-03-30T14:00:00"
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.Ticker.ticker
— Functionticker(client::BinanceClient, query::TickerQuery)
ticker(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
24 hour rolling window price change statistics.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.ticker(;
symbol = "ADAUSDT",
)
to_pretty_json(result.result)
Result:
{
"closeTime":"2024-03-21T21:40:44.384999936",
"count":952934,
"firstId":1090483662,
"highPrice":0.649,
"lastId":1091436596,
"lastPrice":0.631,
"lastQty":1000.0,
"lowPrice":0.6182,
"openPrice":0.6389,
"openTime":"2024-03-20T21:40:00",
"priceChange":-0.0079,
"priceChangePercent":-1.237,
"quoteVolume":4.378010427731e8,
"symbol":"ADAUSDT",
"volume":6.89939719e8,
"weightedAvgPrice":0.63455
}
CryptoExchangeAPIs.Binance.USDMFutures.TopLongShortAccountRatio.top_long_short_account_ratio
— Functiontop_long_short_account_ratio(client::BinanceClient, query::TopLongShortAccountRatioQuery)
top_long_short_account_ratio(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
GET futures/data/topLongShortAccountRatio
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
period | TimeInterval | true | m5 m15 m30 h1 h2 h4 h6 h12 d1 |
endTime | DateTime | false | |
limit | Int64 | false | Default: 30, Max: 500 |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.top_long_short_account_ratio(;
symbol = "BTCUSDT",
period = Binance.USDMFutures.TopLongShortAccountRatio.h1,
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSDT",
"longShortRatio":1.5189,
"longAccount":0.603,
"shortAccount":0.397,
"timestamp":"2024-03-30T15:00:00"
},
...
]
CryptoExchangeAPIs.Binance.USDMFutures.TopLongShortPositionRatio.top_long_short_position_ratio
— Functiontop_long_short_position_ratio(client::BinanceClient, query::TopLongShortPositionRatioQuery)
top_long_short_position_ratio(client::BinanceClient = Binance.USDMFutures.public_client; kw...)
GET futures/data/topLongShortPositionRatio
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
period | TimeInterval | true | m5 m15 m30 h1 h2 h4 h6 h12 d1 |
endTime | DateTime | false | |
limit | Int64 | false | Default: 30, Max: 500 |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.USDMFutures.top_long_short_position_ratio(;
symbol = "BTCUSDT",
period = Binance.USDMFutures.TopLongShortPositionRatio.h1,
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSDT",
"longShortRatio":1.3855,
"longAccount":0.5808,
"shortAccount":0.4192,
"timestamp":"2024-03-30T15:00:00"
},
...
]
CoinMFutures
CryptoExchangeAPIs.Binance.CoinMFutures.public_client
— Constantpublic_client = BinanceClient(; base_url = "https://dapi.binance.com")
CryptoExchangeAPIs.Binance.CoinMFutures.Candle.candle
— Functioncandle(client::BinanceClient, query::CandleQuery)
candle(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Kline/candlestick bars for a symbol.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
interval | Period | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 d3 w1 M1 |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.candle(;
symbol = "ADAUSD_PERP",
interval = Binance.CoinMFutures.Candle.M1,
)
to_pretty_json(result.result)
Result:
[
{
"openTime":"2023-10-01T00:00:00",
"openPrice":0.2538,
"highPrice":0.3049,
"lowPrice":0.2387,
"closePrice":0.2931,
"volume":3.1780325e7,
"closeTime":"2023-10-31T23:59:59.999000064",
"baseAssetVolume":1.189509044956558e9,
"tradesNumber":795986,
"takerBuyVolume":1.5506238e7,
"takerBuyBaseAssetVolume":5.799281977142488e8
},
...
]
CryptoExchangeAPIs.Binance.CoinMFutures.ContinuousCandle.continuous_candle
— Functioncontinuous_candle(client::BinanceClient, query::ContinuousCandleQuery)
continuous_candle(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Kline/candlestick bars for a specific contract type.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
pair | String | true | |
contractType | ContractType | true | PERPETUAL CURRENT_QUARTER NEXT_QUARTER |
interval | TimeInterval | true | |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.continuous_candle(;
pair = "BTCUSD",
contractType = Binance.CoinMFutures.ContinuousCandle.PERPETUAL,
interval = Binance.CoinMFutures.ContinuousCandle.M1,
)
to_pretty_json(result.result)
Result:
[
{
"openTime":"2023-10-01T00:00:00",
"openPrice":26957.3,
"highPrice":35811.9,
"lowPrice":26516.7,
"closePrice":34679.8,
"volume":4.49110256e8,
"closeTime":"2023-10-31T23:59:59.999000064",
"baseAssetVolume":1.50363571181441e6,
"tradesNumber":11775107,
"takerBuyVolume":2.24708613e8,
"takerBuyBaseAssetVolume":752475.86725638
},
...
]
CryptoExchangeAPIs.Binance.CoinMFutures.ExchangeInfo.exchange_info
— Functionexchange_info(client::BinanceClient, query::ExchangeInfoQuery)
exchange_info(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Current exchange trading rules and symbol information.
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.exchange_info()
to_pretty_json(result.result)
Result:
{
"symbols":[
{
"baseAsset":"BTC",
"baseAssetPrecision":8,
"contractSize":100,
"contractStatus":"TRADING",
"contractType":"PERPETUAL",
"deliveryDate":"2100-12-25T08:00:00",
"equalQtyPrecision":4,
"filters":[
{
"filterType":"PRICE_FILTER",
"limit":null,
"maxPrice":4.520958e6,
"maxQty":null,
"minPrice":1000.0,
"minQty":null,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":null,
"tickSize":0.1
},
{
"filterType":"LOT_SIZE",
"limit":null,
"maxPrice":null,
"maxQty":1.0e6,
"minPrice":null,
"minQty":1.0,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":1.0,
"tickSize":null
},
{
"filterType":"MARKET_LOT_SIZE",
"limit":null,
"maxPrice":null,
"maxQty":60000.0,
"minPrice":null,
"minQty":1.0,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":1.0,
"tickSize":null
},
{
"filterType":"MAX_NUM_ORDERS",
"limit":200,
"maxPrice":null,
"maxQty":null,
"minPrice":null,
"minQty":null,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":null,
"tickSize":null
},
{
"filterType":"MAX_NUM_ALGO_ORDERS",
"limit":20,
"maxPrice":null,
"maxQty":null,
"minPrice":null,
"minQty":null,
"multiplierDecimal":null,
"multiplierDown":null,
"multiplierUp":null,
"notional":null,
"stepSize":null,
"tickSize":null
},
{
"filterType":"PERCENT_PRICE",
"limit":null,
"maxPrice":null,
"maxQty":null,
"minPrice":null,
"minQty":null,
"multiplierDecimal":4.0,
"multiplierDown":0.95,
"multiplierUp":1.05,
"notional":null,
"stepSize":null,
"tickSize":null
}
],
"liquidationFee":0.015,
"maintMarginPercent":2.5,
"marginAsset":"BTC",
"marketTakeBound":0.05,
"maxMoveOrderLimit":10000,
"onboardDate":"2020-08-10T07:00:00",
"orderTypes":[
"LIMIT",
"MARKET",
"STOP",
"STOP_MARKET",
"TAKE_PROFIT",
"TAKE_PROFIT_MARKET",
"TRAILING_STOP_MARKET"
],
"pair":"BTCUSD",
"pricePrecision":1,
"quantityPrecision":0,
"quoteAsset":"USD",
"quotePrecision":8,
"requiredMarginPercent":5.0,
"symbol":"BTCUSD_PERP",
"timeInForce":[
"GTC",
"IOC",
"FOK",
"GTX"
],
"triggerProtect":0.05,
"underlyingSubType":[
"PoW"
],
"underlyingType":"COIN"
},
...
],
"serverTime":"2024-03-21T22:00:07.956",
"exchangeFilters":null,
"timezone":"UTC",
"rateLimits":[
{
"interval":"MINUTE",
"intervalNum":1,
"limit":2400,
"rateLimitType":"REQUEST_WEIGHT"
},
...
]
}
CryptoExchangeAPIs.Binance.CoinMFutures.FundingRate.funding_rate
— Functionfunding_rate(client::BinanceClient, query::FundingRateQuery)
funding_rate(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.funding_rate(;
symbol = "BTCUSD_PERP",
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSD_PERP",
"fundingTime":"2024-02-22T16:00:00",
"fundingRate":0.00034808,
"markPrice":51610.0
},
...
]
CryptoExchangeAPIs.Binance.CoinMFutures.IncomeLog.income_log
— Functionincome_log(client::BinanceClient, query::IncomeLogQuery)
income_log(client::BinanceClient; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false | |
incomeType | String | false | |
startTime | DateTime | false | |
endTime | DateTime | false | |
limit | Int64 | false | |
recvWindow | Int64 | false | |
timestamp | DateTime | false | |
signature | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
binance_client = BinanceClient(;
base_url = "https://dapi.binance.com",
public_key = ENV["BINANCE_PUBLIC_KEY"],
secret_key = ENV["BINANCE_SECRET_KEY"],
)
result = Binance.CoinMFutures.income_log(
binance_client
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"ETHUSD_PERP",
"incomeType":"FUNDING_FEE",
"info":null,
"income":1.2e-7,
"asset":"ETH",
"time":"2023-09-04T08:00:00",
"tranId":84092344523696865420,
"tradeId":null
},
...
]
CryptoExchangeAPIs.Binance.CoinMFutures.OrderBook.order_book
— Functionorder_book(client::BinanceClient, query::OrderBookQuery)
order_book(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Gets current exchange orders. GET dapi/v1/depth
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
limit | Int64 | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.order_book(;
symbol = "ADAUSD_PERP",
)
to_pretty_json(result.result)
Result:
{
"E":"2024-03-21T22:59:25.734000128",
"T":"2024-03-21T22:59:25.724999936",
"asks":[
{
"price":0.6312,
"size":1140.0
},
...
],
"symbol":"ADAUSD_PERP",
"lastUpdateId":895428654926,
"bids":[
{
"price":0.6311,
"size":9.0
},
...
],
"pair":"ADAUSD"
}
CryptoExchangeAPIs.Binance.CoinMFutures.PremiumIndex.premium_index
— Functionpremium_index(client::BinanceClient, query::PremiumIndexQuery)
premium_index(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false | |
pair | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.premium_index(;
pair = "BTCUSD",
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSD_240329",
"pair":"BTCUSD",
"markPrice":70397.85306869,
"indexPrice":70195.20240214,
"estimatedSettlePrice":70128.01636024,
"lastFundingRate":"",
"interestRate":"",
"nextFundingTime":"1970-01-01T00:00:00",
"time":"2024-03-26T18:22:48"
},
...
]
CryptoExchangeAPIs.Binance.CoinMFutures.Ticker.ticker
— Functionticker(client::BinanceClient, query::TickerQuery)
ticker(client::BinanceClient = Binance.CoinMFutures.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | false | |
pair | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Binance
result = Binance.CoinMFutures.ticker(;
pair = "BTCUSD",
)
to_pretty_json(result.result)
Result:
[
{
"symbol":"BTCUSD_240329",
"pair":"BTCUSD",
"pricechange":null,
"pricechangePercent":null,
"weightedAvgPrice":70683.35523318,
"lastPrice":70261.6,
"lastQty":11,
"openPrice":71004.7,
"highPrice":71750.0,
"lowPrice":69500.4,
"volume":1027906,
"baseVolume":1454.24053033,
"openTime":"2024-03-25T19:03:00",
"closeTime":"2024-03-26T19:03:03.286000128",
"firstId":7968276,
"lastId":8038563,
"count":70288
},
...
]