💻Common Functions

This page documents common functions across exchanges within the PENDAX SDK that developers can utilize while integrating.

Common functions are widely used calls available on different platforms and will work by just changing the "exchange" parameter and making edits to API credential layouts (depending on the selected exchange).

Some exchanges may not be included in common functions due to unique API layouts native to that platform. If a common function is not found here for your selected exchange then please visit that exchange's functions page.

Account Data

Get Balances

getBalances(options)

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Please refer to the official OKX API documentation for all available and/or required parameters to send.

OKX Example:

const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
// If no param passed, returns balances of all coins/assets, etc.
// To filter to specific assets, pass an object with a property 'tokens',
// where tokens is an array of asset names (see example)
const result = 
    try {
          return await exchange.getBalances(
            {
              tokens: ['BTC', 'USD']
            }
          )
    }
    catch (err) {
      console.log(err);
    }  
chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send.

FTX Example:

const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
// If no param passed, returns balances of all coins/assets, etc.
// To filter to specific assets, pass an object with a property 'tokens',
// where tokens is an array of asset names (see example)
const result = 
    try {
          return await exchange.getBalances(
            {
              tokens: ['BTC', 'USD']
            }
          )
    }
    catch (err) {
      console.log(err);
    }

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX US API documentation for all available and/or required parameters to send.

FTX US Example:

Trading

Place Order

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-trade-place-orderarrow-up-right

OKX Example

chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#place-orderarrow-up-right

FTX Example

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#place-orderarrow-up-right

FTX US Example

Cancel Order

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-orderarrow-up-right

OKX Example:

chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#cancel-orderarrow-up-right

FTX Example:

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.us/#cancel-orderarrow-up-right

FTX US Example:

Cancel All Orders

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

circle-exclamation
chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#cancel-all-ordersarrow-up-right

If no options are passed in, then all orders on the account will be canceled without regard to any other considerations.

FTX Example:

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#cancel-all-ordersarrow-up-right

If no options are passed in, then all orders on the account will be canceled without regard to any other considerations.

FTX US Example:

Get Open Positions

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-account-get-positionsarrow-up-right

OKX Example

chevron-right⚠️ FTXhashtag

This is a hybrid function that calls api getBalances() and api getPositions(). It adds the ability to filter results by:

  • open or closed (does not affect balances)

  • markets (must contain an array of market names)

  • market type (spot or future - spot returns account balances, future returns account positions)

  • in addition, the boolean parameter 'showAvgPrice' is supported as shown in the FTX getPositions api document: https://docs.ftx.com/#get-positionsarrow-up-right

FTX Example:

chevron-right⚠️ FTX UShashtag

This function when used in FTX US responds with the information from the getBalances() function, but adds the ability to filter by token as shown below.

FTX US Example:

Get Open Orders

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Please refer to the official OKX API documentation for all available and/or required parameters to send.

OKX Example:

chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send.

FTX Example:

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX US API documentation for all available and/or required parameters to send.

FTX US Example:

Market Info

Get Markets

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Okx does not actually offer a getMarkets api. So this function calls api getTickers() twice. Once using parameter "SPOT", and once using parameter "SWAP". This returns markets for each in a combined format. If you want more detailed information you can call getTickersarrow-up-right() directly, using the parameters detailed in the OKX api document. Please refer to the official OKX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickersarrow-up-right

OKX Example:

OKX Example with filtering:

OKX returns coins whether they are 'enabled' or not. An example of how to filter the results to include only enabled coins is below.

chevron-right⚠️ FTXhashtag

Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#get-marketsarrow-up-right

FTX Example:

chevron-right⚠️ FTX UShashtag

Please refer to the official FTX US API documentation for all available and/or required parameters to send. https://docs.ftx.us/#get-marketsarrow-up-right

FTX US Example:

Get Market

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

  • FTX US ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Fetches details on a given market. Relays a call to endpoint getTickerarrow-up-right(). Please refer to the official FTX API documentation for all available and/or required parameters to send. https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickerarrow-up-right

OKX Example:

chevron-right⚠️ FTXhashtag

Fetches details on a given market. Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.com/#get-single-marketarrow-up-right

FTX Example:

chevron-right⚠️ FTX UShashtag

Fetches details on a given market. Please refer to the official FTX API documentation for all available and/or required parameters to send. https://docs.ftx.us/#get-single-marketarrow-up-right

Get Open Interest

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Fetches the Open Interest on a Futures Market for a given symbol

OKX Example:

chevron-right⚠️ FTXhashtag

Fetches the Open Interest on a Futures Market for a given symbol

FTX Example:

Get Current Funding Rate

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Fetches the current funding rate on a futures instrument

OKX Example:

chevron-right⚠️ FTXhashtag

Fetches the current funding rate on a futures instrument.

FTX Example:

Get Next Funding Rate

Available Exchanges:

  • FTX ( ⚠️ Exchange Unavailable - For Documentation Purposes ONLY)

chevron-rightOKXhashtag

Fetches the next funding rate on a futures market

chevron-right⚠️ FTXhashtag

Fetches the next funding rate on a futures market

FTX Example:

Last updated