Binance.Margin (binance v2.0.1)

Margin Account/Trade

Summary

Functions

Disable Isolated Margin Account (TRADE)

Margin Account Cancel all Open Orders on a Symbol (TRADE)

Margin Account Cancel Order (TRADE)

Margin Account Cancel OCO (TRADE)

Get BNB Burn Status (USER_DATA)

Query Cross Margin Account Details (USER_DATA)

Get All Margin Assets (MARKET_DATA)

Query Margin Account's all OCO (USER_DATA)

Query Margin Account's All Orders (USER_DATA)

Get All Cross Margin Pairs (MARKET_DATA)

Query Margin Asset (MARKET_DATA)

Cross margin collateral ratio (MARKET_DATA)

Query Cross Margin Fee Data (USER_DATA)

Get tokens or symbols delist schedule for cross margin and isolated margin (MARKET_DATA)

Margin Dustlog (USER_DATA)

Get Assets That Can Be Converted Into BNB (USER_DATA)

Get Small Liability Exchange Coin List (USER_DATA)

Get Small Liability Exchange History (USER_DATA)

Get Force Liquidation Record (USER_DATA)

Get Interest History (USER_DATA)

Query Margin Interest Rate History (USER_DATA)

Query Isolated Margin Account Info (USER_DATA)

Query Enabled Isolated Margin Account Limit (USER_DATA)

Get All Isolated Margin Symbol (USER_DATA)

Query Isolated Margin Fee Data (USER_DATA)

Query Isolated Margin Tier Data (USER_DATA)

Query Isolated Margin Symbol (USER_DATA)

Get Isolated Margin Transfer History (USER_DATA)

Query Loan Record (USER_DATA)

Query Max Borrow (USER_DATA)

Query Max Transfer-Out Amount (USER_DATA)

Query Margin Account's Trade List (USER_DATA)

Get a future hourly interest rate (USER_DATA)

Query Margin Account's Open OCO (USER_DATA)

Query Margin Account's Open Orders (USER_DATA)

Query Margin Account's Order (USER_DATA)

Query Margin Account's OCO (USER_DATA)

Query Cross Margin Pair (MARKET_DATA)

Query Margin PriceIndex (MARKET_DATA)

Query Current Margin Order Count Usage (TRADE)

Query Repay Record (USER_DATA)

Get Summary of Margin account (USER_DATA)

Get Cross Margin Transfer History (USER_DATA)

Toggle BNB Burn On Spot Trade And Margin Interest (USER_DATA)

Dust Transfer (TRADE)

Enable Isolated Margin Account (TRADE)

Margin Account Borrow (MARGIN)

Adjust cross margin max leverage (USER_DATA)

Margin Account New Order (TRADE)

Margin Account Repay (MARGIN)

Cross Margin Account Transfer (MARGIN)

Functions

Link to this function

delete_margin_isolated_account(symbol, opts \\ [])

@spec delete_margin_isolated_account(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Disable Isolated Margin Account (TRADE)

Disable isolated margin account for a specific symbol. Each trading pair can only be deactivated once every 24 hours .

Weight(UID): 300

Details:

  • METHOD: delete
  • URL: /sapi/v1/margin/isolated/account

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

delete_margin_open_orders(symbol, opts \\ [])

@spec delete_margin_open_orders(any(),
  recvWindow: any(),
  isIsolated: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Margin Account Cancel all Open Orders on a Symbol (TRADE)

  • Cancels all active orders on a symbol for margin account.
  • This includes OCO orders.

Weight(IP): 1

Details:

  • METHOD: delete
  • URL: /sapi/v1/margin/openOrders

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • recvWindow - The value cannot be greater than 60000
Link to this function

delete_margin_order(symbol, opts \\ [])

@spec delete_margin_order(any(),
  recvWindow: any(),
  newClientOrderId: any(),
  origClientOrderId: any(),
  orderId: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account Cancel Order (TRADE)

Cancel an active order for margin account.

Either orderId or origClientOrderId must be sent.

Weight(IP): 10

Details:

  • METHOD: delete
  • URL: /sapi/v1/margin/order

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • orderId - Order id
  • origClientOrderId - Order id from client
  • newClientOrderId - Used to uniquely identify this cancel. Automatically generated by default
  • recvWindow - The value cannot be greater than 60000
Link to this function

delete_margin_order_list(symbol, opts \\ [])

@spec delete_margin_order_list(any(),
  recvWindow: any(),
  newClientOrderId: any(),
  listClientOrderId: any(),
  orderListId: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account Cancel OCO (TRADE)

Cancel an entire Order List for a margin account

  • Canceling an individual leg will cancel the entire OCO
  • Either orderListId or listClientOrderId must be provided

Weight(UID): 1

Details:

  • METHOD: delete
  • URL: /sapi/v1/margin/orderList

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • orderListId - Order list id
  • listClientOrderId - A unique Id for the entire orderList
  • newClientOrderId - Used to uniquely identify this cancel. Automatically generated by default
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_bnb_burn(opts \\ [])

@spec get_bnb_burn(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get BNB Burn Status (USER_DATA)

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/bnbBurn

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_account(opts \\ [])

@spec get_margin_account(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Query Cross Margin Account Details (USER_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/account

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_all_assets(opts \\ [])

@spec get_margin_all_assets([]) :: {:ok, any()} | {:error, any()}

Get All Margin Assets (MARKET_DATA)

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/allAssets

Mandatory params:

Optional params:

Link to this function

get_margin_all_order_list(opts \\ [])

@spec get_margin_all_order_list(
  recvWindow: any(),
  limit: any(),
  endTime: any(),
  startTime: any(),
  fromId: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Account's all OCO (USER_DATA)

Retrieves all OCO for a specific margin account based on provided optional parameters

Weight(IP): 200

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/allOrderList

Mandatory params:

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - Mandatory for isolated margin, not supported for cross margin
  • fromId - If supplied, neither startTime or endTime can be provided
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • limit - Default Value: 500; Max Value: 1000
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_all_orders(symbol, opts \\ [])

@spec get_margin_all_orders(any(),
  recvWindow: any(),
  limit: any(),
  endTime: any(),
  startTime: any(),
  orderId: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Account's All Orders (USER_DATA)

  • If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.

Weight(IP): 200

Request Limit: 60 times/min per IP

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/allOrders

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • orderId - Order id
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • limit - Default 500; max 1000.
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_all_pairs(opts \\ [])

@spec get_margin_all_pairs([]) :: {:ok, any()} | {:error, any()}

Get All Cross Margin Pairs (MARKET_DATA)

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/allPairs

Mandatory params:

Optional params:

Link to this function

get_margin_asset(asset, opts \\ [])

@spec get_margin_asset(
  any(),
  []
) :: {:ok, any()} | {:error, any()}

Query Margin Asset (MARKET_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/asset

Mandatory params:

  • asset -

Optional params:

Link to this function

get_margin_cross_margin_collateral_ratio(opts \\ [])

@spec get_margin_cross_margin_collateral_ratio([]) :: {:ok, any()} | {:error, any()}

Cross margin collateral ratio (MARKET_DATA)

Weight(IP): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/crossMarginCollateralRatio

Mandatory params:

Optional params:

Link to this function

get_margin_cross_margin_data(opts \\ [])

@spec get_margin_cross_margin_data(
  recvWindow: any(),
  coin: any(),
  vipLevel: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Cross Margin Fee Data (USER_DATA)

Get cross margin fee data collection with any vip level or user's current specific data as https://www.binance.com/en/margin-fee

Weight(IP): 1 when coin is specified; 5 when the coin parameter is omitted

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/crossMarginData

Mandatory params:

Optional params:

  • timestamp - timestamp
  • vipLevel - Defaults to user's vip level
  • coin - Coin name
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_delist_schedule(opts \\ [])

@spec get_margin_delist_schedule(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get tokens or symbols delist schedule for cross margin and isolated margin (MARKET_DATA)

Get tokens or symbols delist schedule for cross margin and isolated margin

Weight(UID): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/delist-schedule

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_dribblet(opts \\ [])

@spec get_margin_dribblet(
  recvWindow: any(),
  endTime: any(),
  startTime: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Margin Dustlog (USER_DATA)

Query the historical information of user's margin account small-value asset conversion BNB.

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/dribblet

Mandatory params:

Optional params:

  • timestamp - timestamp
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_dust(opts \\ [])

@spec get_margin_dust(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get Assets That Can Be Converted Into BNB (USER_DATA)

Get assets that can be converted into BNB.

Weight(IP): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/dust

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_exchange_small_liability(opts \\ [])

@spec get_margin_exchange_small_liability(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get Small Liability Exchange Coin List (USER_DATA)

Query the coins which can be small liability exchange

Weight(UID): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/exchange-small-liability

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_exchange_small_liability_history(current, size, opts \\ [])

@spec get_margin_exchange_small_liability_history(any(), any(),
  recvWindow: any(),
  endTime: any(),
  startTime: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Small Liability Exchange History (USER_DATA)

Get Small liability Exchange History

Weight(UID): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/exchange-small-liability-history

Mandatory params:

  • current - Currently querying page. Start from 1. Default:1
  • size - Default:10, Max:100

Optional params:

  • timestamp - timestamp
  • startTime - Default: 30 days from current timestamp
  • endTime - Default: present timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_force_liquidation_rec(opts \\ [])

@spec get_margin_force_liquidation_rec(
  recvWindow: any(),
  size: any(),
  current: any(),
  isolatedSymbol: any(),
  endTime: any(),
  startTime: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Force Liquidation Record (USER_DATA)

  • Response in descending order

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/forceLiquidationRec

Mandatory params:

Optional params:

  • timestamp - timestamp
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • isolatedSymbol - Isolated symbol
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_interest_history(opts \\ [])

@spec get_margin_interest_history(
  recvWindow: any(),
  archived: any(),
  size: any(),
  current: any(),
  endTime: any(),
  startTime: any(),
  isolatedSymbol: any(),
  asset: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Interest History (USER_DATA)

  • Response in descending order
  • If isolatedSymbol is not sent, crossed margin data will be returned
  • Set archived to true to query data from 6 months ago
  • type in response has 4 enums:
    • PERIODIC interest charged per hour
    • ON_BORROW first interest charged on borrow
    • PERIODIC_CONVERTED interest charged per hour converted into BNB
    • ON_BORROW_CONVERTED first interest charged on borrow converted into BNB

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/interestHistory

Mandatory params:

Optional params:

  • timestamp - timestamp
  • asset -
  • isolatedSymbol - Isolated symbol
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • archived - Default: false. Set to true for archived data from 6 months ago
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_interest_rate_history(asset, opts \\ [])

@spec get_margin_interest_rate_history(any(),
  recvWindow: any(),
  endTime: any(),
  startTime: any(),
  vipLevel: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Interest Rate History (USER_DATA)

The max interval between startTime and endTime is 30 days.

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/interestRateHistory

Mandatory params:

  • asset -

Optional params:

  • timestamp - timestamp
  • vipLevel - Defaults to user's vip level
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_account(opts \\ [])

@spec get_margin_isolated_account(recvWindow: any(), symbols: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Query Isolated Margin Account Info (USER_DATA)

  • If "symbols" is not sent, all isolated assets will be returned.
  • If "symbols" is sent, only the isolated assets of the sent symbols will be returned.

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolated/account

Mandatory params:

Optional params:

  • timestamp - timestamp
  • symbols - Max 5 symbols can be sent; separated by ','
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_account_limit(opts \\ [])

@spec get_margin_isolated_account_limit(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Query Enabled Isolated Margin Account Limit (USER_DATA)

Query enabled isolated margin account limit.

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolated/accountLimit

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_all_pairs(opts \\ [])

@spec get_margin_isolated_all_pairs(recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get All Isolated Margin Symbol (USER_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolated/allPairs

Mandatory params:

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_margin_data(opts \\ [])

@spec get_margin_isolated_margin_data(
  recvWindow: any(),
  symbol: any(),
  vipLevel: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Isolated Margin Fee Data (USER_DATA)

Get isolated margin fee data collection with any vip level or user's current specific data as https://www.binance.com/en/margin-fee

Weight(IP): 1 when a single is specified; 10 when the symbol parameter is omitted

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolatedMarginData

Mandatory params:

Optional params:

  • timestamp - timestamp
  • vipLevel - Defaults to user's vip level
  • symbol - Trading symbol, e.g. BNBUSDT
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_margin_tier(symbol, opts \\ [])

@spec get_margin_isolated_margin_tier(any(),
  recvWindow: any(),
  tier: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Isolated Margin Tier Data (USER_DATA)

Get isolated margin tier data collection with any tier as https://www.binance.com/en/margin-data

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolatedMarginTier

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • tier - All margin tier data will be returned if tier is omitted
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_pair(symbol, opts \\ [])

@spec get_margin_isolated_pair(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Query Isolated Margin Symbol (USER_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolated/pair

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_isolated_transfer(symbol, opts \\ [])

@spec get_margin_isolated_transfer(any(),
  recvWindow: any(),
  archived: any(),
  size: any(),
  current: any(),
  endTime: any(),
  startTime: any(),
  transTo: any(),
  transFrom: any(),
  asset: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Isolated Margin Transfer History (USER_DATA)

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/isolated/transfer

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • asset -
  • transFrom -
  • transTo -
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • archived - Default: false. Set to true for archived data from 6 months ago
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_loan(asset, opts \\ [])

@spec get_margin_loan(any(),
  recvWindow: any(),
  archived: any(),
  size: any(),
  current: any(),
  endTime: any(),
  startTime: any(),
  txId: any(),
  isolatedSymbol: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Loan Record (USER_DATA)

  • txId or startTime must be sent. txId takes precedence.
  • Response in descending order
  • If isolatedSymbol is not sent, crossed margin data will be returned
  • Set archived to true to query data from 6 months ago

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/loan

Mandatory params:

  • asset -

Optional params:

  • timestamp - timestamp
  • isolatedSymbol - Isolated symbol
  • txId - the tranId in POST /sapi/v1/margin/loan
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • archived - Default: false. Set to true for archived data from 6 months ago
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_max_borrowable(asset, opts \\ [])

@spec get_margin_max_borrowable(any(),
  recvWindow: any(),
  isolatedSymbol: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Max Borrow (USER_DATA)

Weight(IP): 50

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/maxBorrowable

Mandatory params:

  • asset -

Optional params:

  • timestamp - timestamp
  • isolatedSymbol - Isolated symbol
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_max_transferable(asset, opts \\ [])

@spec get_margin_max_transferable(any(),
  recvWindow: any(),
  isolatedSymbol: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Max Transfer-Out Amount (USER_DATA)

  • If isolatedSymbol is not sent, crossed margin data will be sent.

Weight(IP): 50

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/maxTransferable

Mandatory params:

  • asset -

Optional params:

  • timestamp - timestamp
  • isolatedSymbol - Isolated symbol
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_my_trades(symbol, opts \\ [])

@spec get_margin_my_trades(any(),
  recvWindow: any(),
  limit: any(),
  fromId: any(),
  endTime: any(),
  startTime: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Account's Trade List (USER_DATA)

  • If fromId is set, it will get orders >= that fromId. Otherwise most recent trades are returned.

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/myTrades

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • fromId - Trade id to fetch from. Default gets most recent trades.
  • limit - Default 500; max 1000.
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_next_hourly_interest_rate(assets, isIsolated, opts \\ [])

@spec get_margin_next_hourly_interest_rate(any(), any(), []) ::
  {:ok, any()} | {:error, any()}

Get a future hourly interest rate (USER_DATA)

Get user the next hourly estimate interest

Weight(UID): 100

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/next-hourly-interest-rate

Mandatory params:

  • assets - List of assets, separated by commas, up to 20
  • isIsolated - for isolated margin or not, TRUE, FALSE

Optional params:

Link to this function

get_margin_open_order_list(opts \\ [])

@spec get_margin_open_order_list(
  recvWindow: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Margin Account's Open OCO (USER_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/openOrderList

Mandatory params:

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - Mandatory for isolated margin, not supported for cross margin
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_open_orders(opts \\ [])

@spec get_margin_open_orders(
  recvWindow: any(),
  isIsolated: any(),
  symbol: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Margin Account's Open Orders (USER_DATA)

  • If the symbol is not sent, orders for all symbols will be returned in an array.
  • When all symbols are returned, the number of requests counted against the rate limiter is equal to the number of symbols currently trading on the exchange
  • If isIsolated ="TRUE", symbol must be sent.

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/openOrders

Mandatory params:

Optional params:

  • timestamp - timestamp
  • symbol - Trading symbol, e.g. BNBUSDT
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_order(symbol, opts \\ [])

@spec get_margin_order(any(),
  recvWindow: any(),
  origClientOrderId: any(),
  orderId: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Account's Order (USER_DATA)

  • Either orderId or origClientOrderId must be sent.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/order

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • orderId - Order id
  • origClientOrderId - Order id from client
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_order_list(opts \\ [])

@spec get_margin_order_list(
  recvWindow: any(),
  origClientOrderId: any(),
  orderListId: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Margin Account's OCO (USER_DATA)

Retrieves a specific OCO based on provided optional parameters

  • Either orderListId or origClientOrderId must be provided

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/orderList

Mandatory params:

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - Mandatory for isolated margin, not supported for cross margin
  • orderListId - Order list id
  • origClientOrderId - Order id from client
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_pair(symbol, opts \\ [])

@spec get_margin_pair(
  any(),
  []
) :: {:ok, any()} | {:error, any()}

Query Cross Margin Pair (MARKET_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/pair

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

Link to this function

get_margin_price_index(symbol, opts \\ [])

@spec get_margin_price_index(
  any(),
  []
) :: {:ok, any()} | {:error, any()}

Query Margin PriceIndex (MARKET_DATA)

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/priceIndex

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

Link to this function

get_margin_rate_limit_order(opts \\ [])

@spec get_margin_rate_limit_order(
  recvWindow: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Query Current Margin Order Count Usage (TRADE)

Displays the user's current margin order count usage for all intervals.

Weight(IP): 20

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/rateLimit/order

Mandatory params:

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - isolated symbol, mandatory for isolated margin
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_repay(asset, opts \\ [])

@spec get_margin_repay(any(),
  recvWindow: any(),
  archived: any(),
  size: any(),
  current: any(),
  endTime: any(),
  startTime: any(),
  txId: any(),
  isolatedSymbol: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Query Repay Record (USER_DATA)

  • txId or startTime must be sent. txId takes precedence.
  • Response in descending order
  • If isolatedSymbol is not sent, crossed margin data will be returned
  • Set archived to true to query data from 6 months ago

Weight(IP): 10

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/repay

Mandatory params:

  • asset -

Optional params:

  • timestamp - timestamp
  • isolatedSymbol - Isolated symbol
  • txId - the tranId in POST /sapi/v1/margin/repay
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • archived - Default: false. Set to true for archived data from 6 months ago
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_trade_coeff(email, opts \\ [])

@spec get_margin_trade_coeff(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Get Summary of Margin account (USER_DATA)

  • If isolatedSymbol is not sent, crossed margin data will be sent.

Weight(IP): 50

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/tradeCoeff

Mandatory params:

  • email -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

get_margin_transfer(opts \\ [])

@spec get_margin_transfer(
  recvWindow: any(),
  archived: any(),
  size: any(),
  current: any(),
  endTime: any(),
  startTime: any(),
  type: any(),
  asset: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Get Cross Margin Transfer History (USER_DATA)

  • Response in descending order
  • Returns data for last 7 days by default
  • Set archived to true to query data from 6 months ago

Weight(IP): 1

Details:

  • METHOD: get
  • URL: /sapi/v1/margin/transfer

Mandatory params:

Optional params:

  • timestamp - timestamp
  • asset -
  • type - Transfer Type
  • startTime - UTC timestamp in ms
  • endTime - UTC timestamp in ms
  • current - Current querying page. Start from 1. Default:1
  • size - Default:10 Max:100
  • archived - Default: false. Set to true for archived data from 6 months ago
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_bnb_burn(opts \\ [])

@spec post_bnb_burn(
  recvWindow: any(),
  interestBNBBurn: any(),
  spotBNBBurn: any(),
  timestamp: any()
) ::
  {:ok, any()} | {:error, any()}

Toggle BNB Burn On Spot Trade And Margin Interest (USER_DATA)

  • "spotBNBBurn" and "interestBNBBurn" should be sent at least one.

Weight(IP): 1

Details:

  • METHOD: post
  • URL: /sapi/v1/bnbBurn

Mandatory params:

Optional params:

  • timestamp - timestamp
  • spotBNBBurn - Determines whether to use BNB to pay for trading fees on SPOT
  • interestBNBBurn - Determines whether to use BNB to pay for margin loan's interest
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_dust(asset, opts \\ [])

@spec post_margin_dust(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Dust Transfer (TRADE)

Convert dust assets to BNB.

You need to openEnable Spot & Margin Trading permission for the API Key which requests this endpoint.

Weight(UID): 3000

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/dust

Mandatory params:

  • asset - The asset being converted. For example: asset=BTC,USDT

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_exchange_small_liability(assetNames, opts \\ [])

@spec post_margin_exchange_small_liability(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Small Liability Exchange (MARGIN)

Cross Margin Small Liability Exchange Only convert once within 6 hours Only liability valuation less than 10 USDT are supported The maximum number of coin is 10

Weight(UID): 3000

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/exchange-small-liability

Mandatory params:

  • assetNames - The assets list of small liability exchange, Example: assetNames = BTC,ETH

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_isolated_account(symbol, opts \\ [])

@spec post_margin_isolated_account(any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Enable Isolated Margin Account (TRADE)

Enable isolated margin account for a specific symbol.

Weight(UID): 300

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/isolated/account

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_isolated_transfer(asset, symbol, transFrom, transTo, amount, opts \\ [])

@spec post_margin_isolated_transfer(any(), any(), any(), any(), any(),
  recvWindow: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Isolated Margin Account Transfer (MARGIN)

Weight(UID): 600

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/isolated/transfer

Mandatory params:

  • asset -
  • symbol - Trading symbol, e.g. BNBUSDT
  • transFrom -
  • transTo -
  • amount -

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_loan(asset, amount, opts \\ [])

@spec post_margin_loan(any(), any(),
  recvWindow: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account Borrow (MARGIN)

Apply for a loan.

  • If "isIsolated" = "TRUE", "symbol" must be sent
  • "isIsolated" = "FALSE" for crossed margin loan

Weight(UID): 3000

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/loan

Mandatory params:

  • asset -
  • amount -

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - Trading symbol, e.g. BNBUSDT
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_max_leverage(maxLeverage, opts \\ [])

@spec post_margin_max_leverage(
  any(),
  []
) :: {:ok, any()} | {:error, any()}

Adjust cross margin max leverage (USER_DATA)

Adjust cross margin max leverage The margin level need higher than the initial risk ratio of adjusted leverage, the initial risk ratio of 3x is 1.5 and the initial risk ratio of 5x is 1.25

Weight(IP): 3000

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/max-leverage

Mandatory params:

  • maxLeverage - UTC timestamp in ms

Optional params:

Link to this function

post_margin_order(symbol, side, type, opts \\ [])

@spec post_margin_order(any(), any(), any(),
  recvWindow: any(),
  autoRepayAtCancel: any(),
  selfTradePreventionMode: any(),
  timeInForce: any(),
  sideEffectType: any(),
  newOrderRespType: any(),
  icebergQty: any(),
  newClientOrderId: any(),
  stopPrice: any(),
  price: any(),
  quoteOrderQty: any(),
  quantity: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account New Order (TRADE)

Post a new order for margin account.

Weight(UID): 6

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/order

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT
  • side -
  • type - Order type

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • quantity -
  • quoteOrderQty - Quote quantity
  • price - Order price
  • stopPrice - Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
  • newClientOrderId - Used to uniquely identify this cancel. Automatically generated by default
  • icebergQty - Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
  • newOrderRespType - Set the response JSON.
  • sideEffectType - Default NO_SIDE_EFFECT
  • timeInForce - Order time in force
  • selfTradePreventionMode - The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE
  • autoRepayAtCancel - Only when MARGIN_BUY or AUTO_BORROW_REPAY order takes effect, true means that the debt generated by the order needs to be repay after the order is cancelled. The default is true
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_order_oco(symbol, side, quantity, price, stopPrice, opts \\ [])

@spec post_margin_order_oco(any(), any(), any(), any(), any(),
  recvWindow: any(),
  autoRepayAtCancel: any(),
  selfTradePreventionMode: any(),
  sideEffectType: any(),
  newOrderRespType: any(),
  stopLimitTimeInForce: any(),
  stopIcebergQty: any(),
  stopLimitPrice: any(),
  stopClientOrderId: any(),
  limitIcebergQty: any(),
  limitClientOrderId: any(),
  listClientOrderId: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account New OCO (TRADE)

Send in a new OCO for a margin account

  • Price Restrictions:
    • SELL: Limit Price > Last Price > Stop Price
    • BUY: Limit Price < Last Price < Stop Price
  • Quantity Restrictions:
    • Both legs must have the same quantity
    • ICEBERG quantities however do not have to be the same.
  • Order Rate Limit
    • OCO counts as 2 orders against the order rate limit.

Weight(UID): 6

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/order/oco

Mandatory params:

  • symbol - Trading symbol, e.g. BNBUSDT
  • side -
  • quantity -
  • price - Order price
  • stopPrice -

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • listClientOrderId - A unique Id for the entire orderList
  • limitClientOrderId - A unique Id for the limit order
  • limitIcebergQty -
  • stopClientOrderId - A unique Id for the stop loss/stop loss limit leg
  • stopLimitPrice - If provided, stopLimitTimeInForce is required.
  • stopIcebergQty -
  • stopLimitTimeInForce -
  • newOrderRespType - Set the response JSON.
  • sideEffectType - Default NO_SIDE_EFFECT
  • selfTradePreventionMode - The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE
  • autoRepayAtCancel - Only when MARGIN_BUY or AUTO_BORROW_REPAY order takes effect, true means that the debt generated by the order needs to be repay after the order is cancelled. The default is true
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_repay(asset, amount, opts \\ [])

@spec post_margin_repay(any(), any(),
  recvWindow: any(),
  symbol: any(),
  isIsolated: any(),
  timestamp: any()
) :: {:ok, any()} | {:error, any()}

Margin Account Repay (MARGIN)

Repay loan for margin account.

  • If "isIsolated" = "TRUE", "symbol" must be sent
  • "isIsolated" = "FALSE" for crossed margin repay

Weight(IP): 3000

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/repay

Mandatory params:

  • asset -
  • amount -

Optional params:

  • timestamp - timestamp
  • isIsolated - * TRUE - For isolated margin
  • FALSE - Default, not for isolated margin
  • symbol - Trading symbol, e.g. BNBUSDT
  • recvWindow - The value cannot be greater than 60000
Link to this function

post_margin_transfer(asset, amount, type, opts \\ [])

@spec post_margin_transfer(any(), any(), any(), recvWindow: any(), timestamp: any()) ::
  {:ok, any()} | {:error, any()}

Cross Margin Account Transfer (MARGIN)

Execute transfer between spot account and cross margin account.

Weight(IP): 600

Details:

  • METHOD: post
  • URL: /sapi/v1/margin/transfer

Mandatory params:

  • asset -
  • amount -
  • type - * 1 - transfer from main account to margin account
  • 2 - transfer from margin account to main account

Optional params:

  • timestamp - timestamp
  • recvWindow - The value cannot be greater than 60000