Bingex.Swap (Bingex v0.2.1)

Provides an interface to interact with the BingX Swap API.

Summary

Functions

Requests to cancel all orders by their market symbol (ex. BTC-USDT) with account credentials.

Request to close all positions by market symbol (ex. BTC-USDT) with account credentials.

Requests to get current swap balance.

Query USDT-M futures symbols and their support status.

Query the capital flow of the perpetual contract under the current account.

Request the opening leverage and available positions of the user in the specified symbol contract.

Query the user's margin mode on the specified symbol contract.

Request to get all user's orders (pending, active, ...) by an optional period (start_time, end_time) and an optional limit of returned amount of orders with account credentials.

Request to the positions state of perpetual contracts by with account credentials.

Request to the position history of perpetual contracts by an optional period (start_time, end_time) with account credentials.

Query price and funding rate.

Requests to get current server time.

Requests to place an order using order data with account credentials.

Requests to place bunch of orders using list of order data with account credentials.

Requests to place a test order using order data with account credentials.

Request to set user's leverage amount by market symbol, position side and account credentials. Position side can be either :crossed or :isolated. Currently, BingX allows leverage from 1 to 125.

Request to set user's margin mode by market symbol and account credentials. Margin mode can be either :crossed or :isolated.

Functions

cancel_all_orders(symbol, api_key, secret_key)

@spec cancel_all_orders(
  Bingex.Types.symbol(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.CancelAllOrders.t())
  )

Requests to cancel all orders by their market symbol (ex. BTC-USDT) with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20All%20Open%20Orders

close_all_positions(symbol, api_key, secret_key)

@spec close_all_positions(
  Bingex.Types.symbol(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.CloseAllPositions.t())
  )

Request to close all positions by market symbol (ex. BTC-USDT) with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Close%20All%20Positions

get_balance(api_key, secret_key)

@spec get_balance(Bingex.Types.api_key(), Bingex.Types.secret_key()) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetBalance.t())
  )

Requests to get current swap balance.

https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20account%20data

get_contracts(symbol \\ nil)

@spec get_contracts(symbol :: nil | binary()) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetQuotes.t())
  )

Query USDT-M futures symbols and their support status.

https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#USDT-M%20Perp%20Futures%20symbols

get_income_history(symbol, api_key, secret_key, opts \\ [])

@spec get_income_history(
  Bingex.Types.symbol(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key(),
  opts :: [
    income_type: Bingex.Types.income_type(),
    start_time: pos_integer(),
    end_time: pos_integer(),
    limit: pos_integer()
  ]
) :: Bingex.Types.request_result()

Query the capital flow of the perpetual contract under the current account.

https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Get%20Account%20Profit%20and%20Loss%20Fund%20Flow

get_leverage(symbol, api_key, secret_key)

Request the opening leverage and available positions of the user in the specified symbol contract.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Leverage%20and%20Available%20Positions

get_margin_mode(symbol, api_key, secret_key)

Query the user's margin mode on the specified symbol contract.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Type

get_orders_history(symbol, api_key, secret_key, opts \\ [])

@spec get_orders_history(
  Bingex.Types.symbol(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key(),
  opts :: [
    start_time: pos_integer(),
    end_time: pos_integer(),
    limit: pos_integer()
  ]
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetOrdersHistory.t())
  )

Request to get all user's orders (pending, active, ...) by an optional period (start_time, end_time) and an optional limit of returned amount of orders with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All%20Orders

get_positions(symbol, api_key, secret_key)

@spec get_positions(
  Bingex.Types.symbol(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetPositions.t())
  )

Request to the positions state of perpetual contracts by with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data

get_positions_history(symbol, start_time, end_time, api_key, secret_key)

@spec get_positions_history(
  Bingex.Types.symbol(),
  start_time :: pos_integer(),
  end_time :: pos_integer(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetPositionsHistory.t())
  )

Request to the position history of perpetual contracts by an optional period (start_time, end_time) with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Position%20History

get_quotes(symbol \\ nil)

@spec get_quotes(symbol :: nil | binary()) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetQuotes.t())
  )

Query price and funding rate.

https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate

get_server_time()

@spec get_server_time() ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.GetServerTime.t())
  )

Requests to get current server time.

https://bingx-api.github.io/docs/#/en-us/swapV2/base-info.html#Get%20Server%20Time

place_order(order, api_key, secret_key)

Requests to place an order using order data with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place%20order

place_orders(orders, api_key, secret_key)

@spec place_orders(
  [Bingex.Model.Order.t()],
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.PlaceOrders.t())
  )

Requests to place bunch of orders using list of order data with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place%20multiple%20orders

place_test_order(order, api_key, secret_key)

@spec place_test_order(
  Bingex.Model.Order.t(),
  Bingex.Types.api_key(),
  Bingex.Types.secret_key()
) ::
  Bingex.Types.request_result(
    Bingex.API.Reply.t(Bingex.Swap.Data.PlaceTestOrder.t())
  )

Requests to place a test order using order data with account credentials.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Test%20Order

set_leverage(symbol, position_side, leverage, api_key, secret_key)

Request to set user's leverage amount by market symbol, position side and account credentials. Position side can be either :crossed or :isolated. Currently, BingX allows leverage from 1 to 125.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set%20Leverage

set_margin_mode(symbol, margin_mode, api_key, secret_key)

Request to set user's margin mode by market symbol and account credentials. Margin mode can be either :crossed or :isolated.

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Change%20Margin%20Type