# Common Functions

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

```javascript
getBalances(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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

#### OKX Example:

```javascript
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);
    }  
```

</details>

<details>

<summary>⚠️  FTX</summary>

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

#### FTX Example:

```javascript
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);
    }

```

</details>

<details>

<summary>⚠️ FTX US</summary>

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

#### FTX US Example:

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // 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);
    }
```

</details>

## Trading

### Place Order

```javascript
placeOrder(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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-order>

#### OKX Example

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
// Place order
// parameters are per the exchange's api requirements  
const result = 
    try {
          return await exchange.placeOrder(
          { 
            market: "BTC/USD", 
            side: "buy", 
            price: null, 
            type: "market", 
            size: 0.0009009
          }
    }
    catch (err) {
      console.log(err);
    }

```

</details>

<details>

<summary>⚠️ FTX</summary>

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

#### FTX Example

<pre class="language-javascript"><code class="lang-javascript"><strong>// Create exchange
</strong>const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
// Place order
// parameters are per the exchange's api requirements
const result = 
    try {
          return await exchange.placeOrder(
          { 
            market: "BTC/USD", 
            side: "buy", 
            price: null, 
            type: "market", 
            size: 0.0009009
          }
    }
    catch (err) {
      console.log(err);
    }


</code></pre>

</details>

<details>

<summary>⚠️ FTX US</summary>

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

#### FTX US Example

```javascript
// Create exchange
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any Value
});
// Place order
// parameters are per the exchange's api requirements
const result = 
    try {
          return await exchange.placeOrder(
          { 
            market: "BTC/USD", 
            side: "buy", 
            price: null, 
            type: "market", 
            size: 0.0009009
          }
    }
    catch (err) {
      console.log(err);
    }


```

</details>

### Cancel Order

```javascript
cancelOrder(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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-order>

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
const result = 
    try {
          return await exchange.cancelOrder(
          { 
            instId: "BTC/USD",         // required
            ordId: "87757021604562009" // ordId OR clOrdId required 
          }
    }
    catch (err) {
      console.log(err);
    }
```

</details>

<details>

<summary>⚠️ FTX</summary>

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

#### FTX Example:

```javascript
// Create exchange
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
          return await exchange.cancelOrder(
          { 
              order_id: "265102861651009"
          }
    }
    catch (err) {
      console.log(err);
    }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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

#### FTX US Example:

```javascript
// Create exchange
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
          return await exchange.cancelOrder(
          { 
              order_id: "265102861651009"
          }
    }
    catch (err) {
      console.log(err);
    }
```

</details>

### Cancel All Orders

```javascript
cancellAllOrders(options)
```

#### Available Exchanges:

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

{% hint style="warning" %}
***Not supported on OKX (Use combination of*** getLiveOrders() or the native getOrderList() and cancelMultiOrder() ***) - WARNING - Okx rate-limits*** cancelMultiOrder() - see documents for details: <https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-multiple-orders>
{% endhint %}

<details>

<summary>⚠️ FTX</summary>

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

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

#### FTX Example:

```javascript
// options:
// {
//   market: 'BTC-PERP', //optional; restrict to cancelling orders only on this market
//   side: 'buy', //optional; restrict to cancelling orders only on this side
//   conditionalOrdersOnly: false, //	optional; restrict to cancelling conditional orders only
//   limitOrdersOnly: false, //optional; restrict to cancelling existing limit orders (non-conditional orders) only
// }
// Create exchange
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
          return await exchange.cancelAllOrders(
          { 
              side: 'buy'
          }
    }
    catch (err) {
      console.log(err);
    }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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

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

#### FTX US Example:

```javascript
// options:
// {
//   market: 'BTC-PERP', //optional; restrict to cancelling orders only on this market
//   side: 'buy', //optional; restrict to cancelling orders only on this side
//   conditionalOrdersOnly: false, //	optional; restrict to cancelling conditional orders only
//   limitOrdersOnly: false, //optional; restrict to cancelling existing limit orders (non-conditional orders) only
// }
// Create exchange
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
          return await exchange.cancelAllOrders(
          { 
              side: 'buy'
          }
    }
    catch (err) {
      console.log(err);
    }
```

</details>

### Get Open Positions

```javascript
getPositions(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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-positions>

#### OKX Example

<pre class="language-javascript"><code class="lang-javascript">// positionType: &#x3C;'SPOT', 'FUTURE'>, - optional - if omitted, all are fetched
<strong>// markets: ..., - optional array of markets - 10 max if type is FUTURE - 20 max if SPOT
</strong>// posIds: ..., - optional array of posId's - 20 max if type is FUTURE -  ignored if SPOT
// openClosed: &#x3C;open/closed>} - optional - defaults to open AND closed
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
const result = 
    try {
      let result = await exchange.getPositions ({
      positionType: 'FUTURE',
      markets: ['BTC-USDT-SWAP'],
      posIds: ['307173036051017730', '33049853605101720'],
      openClosed: 'open'
     });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
</code></pre>

</details>

<details>

<summary>⚠️ FTX</summary>

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

* 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-positions><br>

#### FTX Example:

```javascript
// positionType: <'SPOT', 'FUTURE'>, - optional - if omitted, all are fetched
// markets: ..., - optional array of markets - 10 max if type is FUTURE - 20 max if SPOT
// openClosed: <open/closed>} - optional - defaults to open AND closed
// showAvgPrice: <true/false> - pertains to positions only - balances not affected
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
      let result = await exchange.getPositions ({
      positionType: 'FUTURE',
      markets: ['BTC-USDT-SWAP'],
      openClosed: 'open'
     });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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:

```javascript
// positionType: <'SPOT', 'FUTURE'>, - optional - if omitted, all are fetched
// markets: ..., - optional array of markets - 10 max if type is FUTURE - 20 max if SPOT
// openClosed: <open/closed>} - optional - defaults to open AND closed
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getPositions ({
        tokens: ['BTC', 'USDT'],  //(optional)
     });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

### Get Open Orders

```javascript
getLiveOrders(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
const result = 
    try {
      let result = await exchange.getLiveOrders ({
        instType: 'SPOT',
        ordType: 'limit',
        state: 'partially_filled'
     });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

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

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
      let result = await exchange.getLiveOrders ('BTC-PERP');
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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

#### FTX US Example:

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getLiveOrders ('BTC');
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

## Market Info

### Get Markets

```javascript
getMarkets()
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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 [getTickers](https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickers)() 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-tickers>

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getMarkets();
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

#### 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.

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getMarkets();
      if (result.result) {
        result = result.result;
        markets = result
          .filter((coin) => {
            return coin.enabled == true;
          })
          .map((coin) => {
            return coin.name;
          });
      }      
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

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

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
      let result = await exchange.getMarkets();
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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

#### FTX US Example:

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getMarkets();
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

### Get Market

```javascript
getMarket()
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*
* *FTX US (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

Fetches details on a given market. Relays a call to endpoint [getTicker](https://www.okx.com/docs-v5/en/#rest-api-market-data-get-ticker)(). 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-ticker>

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getMarket({instId: 'BTC-USDT-SWAP'});
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

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-market>

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
      let result = await exchange.getMarket('BTC/USD');
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX US</summary>

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-market>

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getMarket('BTC/USD');
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

### Get Open Interest

```
getOpenInterest(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

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

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getOpenInterest({
          instType: 'SWAP', 
          instId: 'BTC-USDT-SWAP'
          });
      console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

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

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftx",   // any value
});
const result = 
    try {
      let result = await exchange.getOpenInterest(
          {
           market:'BTC-PERP'
          });
      console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

### Get Current Funding Rate

```javascript
getCurrentFundingRate(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

Fetches the current funding rate on a futures instrument

#### OKX Example:

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getCurrentFundingRate({ future_name: 'BTC-USDT-SWAP'});
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

Fetches the current funding rate on a futures instrument.

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getCurrentFundingRate(
         {
           future_name: future_name: 'BTC-PERP'
         });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

### Get Next Funding Rate

```
getNextFundingRate(options)
```

#### Available Exchanges:

* [OKX](https://www.okx.com/join/COMPENDIUM)
* *FTX (* ⚠️ *Exchange Unavailable - For Documentation Purposes ONLY)*

<details>

<summary>OKX</summary>

Fetches the next funding rate on a futures market

```javascript
const exchange = createExchange({
    exchange: "okx",
    key: "jdsklsakh-76sruuu2",
    secret: "GASDF45II@kkkk",
    label: "okx",  // any value
    passphrase: "hhsgr$!kkks",
    margintype: "usdt"  // coin, usdt 
  });
  const result = 
    try {
      let result = await exchange.getNextFundingRate({ future_name: 'BTC-USDT-SWAP'});
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>

<details>

<summary>⚠️ FTX</summary>

Fetches the next funding rate on a futures market

#### FTX Example:

```javascript
const exchange = createExchange({
  exchange: "ftxus",
  authenticate: true,
  key: "123455676890",
  secret: "abcdefghijk",
  subaccount: "subaccountname",
  label: "ftxus",   // any value
});
const result = 
    try {
      let result = await exchange.getNextFundingRate(
         {
           future_name: future_name: 'BTC-PERP'
         });
     console.log(result);
   } catch (error) {
      console.log(error.message);
   }
```

</details>
