# Platform Overview

A deep look into the Compendium platform and our underlying infrastructure.

## Exploring Our Trading Tool Ecosystem

The Compendium Platform was built to offer traders a comprehensive suite of tools for a list of growing ecosystems to *make life simpler*. Our offerings and full tool suite can be broken down into several different entities.

![The Compendium Ecosystem currently consists of three main core products. The Compendium Trading Tool Platform, Compendex, and PENDAX.](/files/ofytSnfIoyXvQMesD1eK)

### ⚫ [**PENDAX**](/pendax/what-is-pendax) **- The Underlying Trading & Data Engine**

*Simplified exchange commands and interoperability*. Our underlying high-frequency trading engine, PENDAX, is available for all developers, traders, financial analysts, and data scientists to build custom integrations on. It provides simple access to a variety of different use cases revolving around trading and data deployments with easy-to-integrate packages, modules, and commands.

{% content-ref url="/pages/z0DmchdDhKNJcDRd52YI" %}
[What is PENDAX?](/pendax/what-is-pendax)
{% endcontent-ref %}

### 🟣 **Compendium - Automation Terminal & Trading Tools**

The automation and trading terminal of our consumer-facing application, a hub of advanced trading capabilities available for everyone. Here, you have the flexibility to create, subscribe, or leverage a vast array of verified trading bots, automated trading signals, copy trading groups, and more. Our platform supports and integrates with a growing list of leading centralized cryptocurrency exchanges, including OKX, Binance, Bybit, BitMex, BitGet, Kucoin, Huobi, and MEXC, which will launch in multiple phases. Our automation terminal is powered by cutting-edge PENDAX technology and features a state-of-the-art load-balancing system, ensuring industry-leading performance and reliability.

{% content-ref url="/pages/vHaBXHc4uvvFWQu8NiAo" %}
[Compendium Trading Tools](/automation-terminal/compendium-trading-tools)
{% endcontent-ref %}

### 🔵 **Compendex - Multi-Chain Decentralized Exchange Tools**

We are revolutionizing the decentralized trading landscape by enhancing the on-chain trading capabilities of cutting-edge protocols like Solana, Ethereum, Stellar, Binance Smart Chain, and more. Our approach is methodical and driven by a phased rollout of state-of-the-art trading tools and solutions. Our current priority is to optimize the user experience on Solana with advanced offerings such as on-chain spot markets, a sophisticated smart swap aggregator, cutting-edge metaverse markets, and powerful DeFi analytics. The Ethereum, Stellar, and Binance Smart Chain products are poised for imminent launch, further consolidating our position as a leading provider of decentralized trading solutions.

{% content-ref url="/pages/PAwrZGtd7og7CGnfcudq" %}
[DeFi With Compendex](/decentralized-trading-tools/defi-with-compendex)
{% endcontent-ref %}

{% hint style="info" %}
Automation and simplicity are key to all of our offerings. We're here to help make crypto trading easier for everyone. Looking to get started? You're in the right place.
{% endhint %}

## User Testimonials and Feedback

Here are a couple of testimonials from the industry's best and brightest regarding their use of the Compendium Platform:

{% tabs %}
{% tab title="From A Trading Bot Author" %}

> I personally use several different tools offered by the CEX suite for algo-trading. I usually set up new strategies as signal groups for forward testing, and once enough data is gathered, I can share that group with a selected few with ease - no hassle with handling complicated invite systems, or the need to send my signals to different webhooks managed by others. Once I'm happy with how the algo is performing, it's a smooth process to transition to an actual bot and offer the strategy in the marketplace.
>
> The team has been very reactive and helpful from the beginning, always took feedback into account, fixed issues in very short periods, and been around to support and implement specific requirements I had through the past 1+ year I've worked with them. I think Compendium will easily dominate the automated trading industry with its flexibility and offering of a wide range of products.
>
> — From a Verified Trading Bot Author - [Overhead Gains](https://twitter.com/OverheadGains)
> {% endtab %}

{% tab title="From A Copy Trading Group Leader" %}

> For nearly a year now, I've had the upmost privilege of working with the team at Compendium and the multitude of tools and products the team offers. While the copy trading system has been a core part of the features I use, the Compendium platform offers a wide range of products and features.&#x20;
>
> Whether the latest and cutting edge DEX, NFT platform, trading strategies and bots, or simply copy trading systems, the Compendium platform is hands down the best and by far ahead of any of its competitors when it comes to offering like features and products. However, and most importantly, the team itself sets the bar extremely high when it comes to delivering a quality product. Take the copy trading system for example, there's none like out there that exists today, yet it offers all of the features the perfect copy trading system should offer. Real time execution of copied trades directly within the exchange, not from some third party platform. And best of all, risk management is tied directly into the copy trading system so if/when the trader executes a trade with 1% risk, that same 1% risk applies across to all users connected to the copy trader, regardless of their account size and value. With the sound risk management functionality, copy traders are also in complete control of the trade (ability to exit/close trade if desired) and their funds as well.&#x20;
>
> Lastly, the team themselves are down to earth, helpful, and some of the most genuine people in the space. The team is quick to respond and address any issues that may arise, which is not many or often, but they are "one of us" when it comes to trading and they know what traders want and look for when it comes to trading tools. I can't recommend enough the team and tools they have built within Compendium platform and I know I'll personally be using for the years to come. Thank you to the team at Compendium for what they have built for the traders of today.
>
> — From a Copy Trading Group Leader - [SatoshiScalper](https://twitter.com/SatoshiScalper)
> {% endtab %}
> {% endtabs %}

## **What Makes Compendium Different?**

Other trading tool providers often suffer from limitations in their offerings or restrict access to advanced features through paywalls and other obstructive tactics. At Compendium, we envisioned a comprehensive suite of trading tools that cater to the needs of retail traders and veterans alike, while providing minimal barriers to entry. Our products have undergone rigorous refinement and have been put to the test in various market conditions and sentiments, ensuring optimal efficiency at all times. Our platform represents a commitment to delivering unparalleled trading solutions that are both robust and accessible to all users.\
\
The Compendium Ecosystem offers a few key advantages:

### **Simple To Set Up And Use**

With a foundation in communication and user experience design, we have engineered our platform to provide a seamless user experience for all. Our goal is to empower every user to easily register for an account and start leveraging any of our extensive suite of tools within mere minutes. We have meticulously documented the user journey to facilitate a smooth onboarding process for new users. Our focus on delivering an intuitive and efficient platform represents our commitment to empowering traders of all levels to achieve their full potential.

### Cheaper Than All Competitors

Our platform defies the conventional wisdom that cost and efficiency are directly proportional. Say goodbye to exorbitant fees for access to cutting-edge trading tools. Our suite of tools spans multiple ecosystems and is available at **ZERO COST\*** to both developers and users. This means that you can access advanced trading solutions without breaking the bank. With our platform, you can enjoy unparalleled efficiency at a fraction of the cost.

*\*Users may encounter subscription costs or associated fees while utilizing verified third-party strategies or platform integrations.*

### **Efficient and Optimized Trading Routers**

Our state-of-the-art backend system is powered by our highly efficient PENDAX SDK technology. Our system is designed to deliver unparalleled performance, with full scalability and self-sustainability capabilities. Our platform ensures the optimal execution of strategies and tools at all times, even in the face of market turbulence. The advanced error handling and retry mechanisms, along with customizable settings, guarantee seamless and uninterrupted operation. Furthermore, we offer our robust backend engine as a flexible SDK, empowering technically proficient users to build their own platforms and integrations, leveraging the full potential of our technology.

### **Expanding beyond centralized exchanges**

Introducing our latest cutting-edge solution for the decentralized landscape, harnessing the potential of next-generation Layer 1 blockchains like Solana. With this integration, we bring to the table a comprehensive suite of highly optimized on-chain programs designed to elevate your overall experience. Our platform aggregates market data to empower you with real-time insights, enabling you to make informed decisions and secure the best rates. Additionally, our aggregation of advanced tools guarantees that you stay ahead of the curve, executing the optimal play at all times.

{% hint style="info" %}
We work around the clock to ensure that our systems stay up to date with the industry's latest concepts in all facets and offerings on the Compendium and PENDAX platforms.
{% endhint %}

## Getting Started: Find The Right Tool

{% tabs %}
{% tab title="PENDAX (Developers)" %}
Looking to create your own trading or market data systems? Follow our developer guides to get started with the hosted API or SDK version of the PENDAX engine.<br>

{% content-ref url="/pages/z0DmchdDhKNJcDRd52YI" %}
[What is PENDAX?](/pendax/what-is-pendax)
{% endcontent-ref %}

{% content-ref url="/pages/u0w0Uln4CY8ubP9n1euU" %}
[Installing PENDAX modules](/pendax/installing-pendax-modules)
{% endcontent-ref %}

{% content-ref url="/pages/hd2z9dtlygYJWRtVwWyi" %}
[PENDAX Capabilities](/pendax/pendax-capabilities)
{% endcontent-ref %}

{% content-ref url="/pages/JhQml6vxmTtaUrYdSlKP" %}
[Using PENDAX SDK](/pendax/using-pendax-sdk)
{% endcontent-ref %}

{% endtab %}

{% tab title="Compendium (Trading & Automation)" %}
Explore the fundamentals of some of our most popular products from different user perspectives. Our intuitive documentation makes it easier to get started with automated trading tools than ever before.<br>

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

{% content-ref url="/pages/hIMYKWCaGzgJGqly69d7" %}
[Verified Trading Bots](/automation-terminal/verified-trading-bots)
{% endcontent-ref %}

{% content-ref url="/pages/00VzoTrTi8iJAKHEd5ZP" %}
[Signal Provider Groups](/automation-terminal/signal-provider-groups)
{% endcontent-ref %}

{% content-ref url="/pages/4iHFBdFzLxB7R1KXnzyG" %}
[Copy Trading Groups](/automation-terminal/copy-trading-groups)
{% endcontent-ref %}
{% endtab %}

{% tab title="Compendex (DeFi)" %}
Explore documentation and step-by-step instructions for the utilization of our on-chain trading terminal, available for multiple blockchains.<br>

{% content-ref url="/pages/PAwrZGtd7og7CGnfcudq" %}
[DeFi With Compendex](/decentralized-trading-tools/defi-with-compendex)
{% endcontent-ref %}

{% content-ref url="/pages/DrlJ2F4Hk9l8mwlnSuBk" %}
[Solana Integrations](/decentralized-trading-tools/solana-integrations)
{% endcontent-ref %}
{% endtab %}
{% endtabs %}


# What is PENDAX?

A Javascript library allowing simplified interaction with advanced commands on a growing list of cryptocurrency exchanges and financial applications.

Introducing PENDAX, our high-frequency trading engine designed for developers, traders, financial analysts, and data scientists. PENDAX simplifies exchange commands and provides interoperability, empowering users to build custom integrations tailored to their specific needs. Our engine provides seamless access to a multitude of use cases related to trading and data deployment, streamlining the process and maximizing efficiency. Whether you're a seasoned professional or a beginner, PENDAX offers the versatility and ease of use required to achieve your trading and data deployment goals.

![](/files/Yb31A2sKmGfzHE0On6yS)

{% hint style="success" %}
**Did you know? The best way to showcase a product is to build on it!** Our consumer-facing application on [Compendium.Fi](https://compendium.finance) is built utilizing PENDAX in parallel with a state-of-the-art load-balancing system to ensure industry-leading trading performance.
{% endhint %}

## Current Feature Overview

For a complete capability and usage guidelines list please visit [PENDAX Usage Capabilities](/pendax/pendax-capabilities).

* PENDAX integrates full public and private HTTP REST APIs in an efficient manner, enabling seamless secondary deployment across all supported platforms.
* Our unified package leverages aggregated, normalized commands, making PENDAX exceptionally easy to integrate into existing systems.
* All supported exchanges are equipped with WebSocket and real-time data capabilities, ensuring access to up-to-date information.
* PENDAX offers a cost-effective solution, with all commands and capabilities freely accessible to all developers, traders, and integrators, without the need for a subscription to a "Professional" version.

{% content-ref url="/pages/hd2z9dtlygYJWRtVwWyi" %}
[PENDAX Capabilities](/pendax/pendax-capabilities)
{% endcontent-ref %}

## Supported Platform Integrations

The following table outlines the integration status of exchanges and financial institutions within our open-source systems. By being included in the PENDAX modules, these systems will also be made available on our consumer-facing application and automation terminal, providing a wide range of functionalities to end users. Integrators utilizing PENDAX commands to post orders may also benefit from variable trading discount rates, further enhancing their trading experience.

{% tabs %}
{% tab title="Currently Integrated" %}

<table><thead><tr><th>Exchange</th><th>PENDAX ID</th><th>SDK Status</th><th data-hidden>Hosted API</th></tr></thead><tbody><tr><td><a href="/pages/gsNucVoTMTxAB5ELHuFf">OKX</a></td><td>okx</td><td>✅ Live</td><td></td></tr><tr><td><a href="/pages/veVpaMByNPaTfIiW243M">Bybit</a></td><td>bybit</td><td>✅ Live</td><td></td></tr><tr><td><a href="/pages/8SRJZOHoOjKz56cizzh6">Bitget</a></td><td>bitget</td><td>✅ Live</td><td></td></tr><tr><td><a href="/pages/xMUECFglJFvcrUs8jqWB">Mexc</a></td><td>mexc</td><td>✅ Live</td><td></td></tr></tbody></table>
{% endtab %}

{% tab title="In Development" %}
The following exchanges are currently undergoing development integration for availability within the PENDAX SDK. This list is provided in alphabetical order and not by integration availability.<br>

| Exchange     | PENDAX ID | SDK Status     |
| ------------ | --------- | -------------- |
| Binance      | binance   | In Development |
| Binance US   | binanceus | In Development |
| Bitmex       | bitmex    | In Development |
| Deribit      | deribit   | In Development |
| Gate         | gate      | In Development |
| Huobi        | huobi     | In Development |
| Kucoin       | kucoin    | In Development |
| Phemex       | phemex    | In Development |
| {% endtab %} |           |                |

{% tab title="Deprecated Support" %}
The following exchanges will be deprecated from future PENDAX npm pushes<br>

| Exchange      | PENDAX ID | SDK Status     |
| ------------- | --------- | -------------- |
| FTX           | ftx       | ⚠️ Deprecating |
| FTX US        | ftxus     | ⚠️ Deprecating |
| {% endtab %}  |           |                |
| {% endtabs %} |           |                |

{% hint style="info" %}
**Want a new platform or exchange integrated?** Please reach out in the #dev-chat channel of our official Discord server. Inquiries can also be forwarded to our email address at <support@compendium.finance> from official exchange representatives. *You can also post a link to the exchange by opening an issue on the official GitHub page.*
{% endhint %}

The list above is updated regularly as new integrations are tested and approved for merging into the main systems.&#x20;

## What Makes PENDAX better?

PENDAX is a highly sophisticated software development kit (SDK) designed for developers, traders, and analysts. PENDAX leverages our extensive expertise in trading infrastructure to deliver an optimized, high-performance solution. The underlying code has been optimized for speed and efficiency, incorporating proprietary enhancements that result in low-latency connections and rapid time to market.

PENDAX's normalized common functions make it easy to adapt to different platforms, saving valuable time and effort compared to other SDKs that may require extensive code rewrites. Additionally, we are committed to providing the most comprehensive documentation, with all functions and capabilities clearly outlined and accessible. This, coupled with our intuitive walkthrough, sets PENDAX apart from other development teams and provides a smooth and effortless experience for users.

In comparison to platforms like CCXT, PENDAX offers improved performance, normalized common functions, and comprehensive documentation, making it a superior choice for developers, traders, and analysts. All functions, exchanges, and WebSocket capabilities are available for NO COST in the Javascript SDK.


# PENDAX Capabilities

A complete usage guide for PENDAX integrations with both public and private commands.

PENDAX consists of both public and private integrations. A public integration can be accessed immediately after integration and provides unrestricted access to data for all supported exchange markets and integrations without an API key. Private integrations feature the ability to interact with an account or post trades and require authorization methods in order to complete command tasks. Users will need to create an API key on their selected exchange. Documentation within the [Connect An Exchange Account](/automation-terminal/connect-an-exchange-account) segment can help you find how to create keys for each integrated exchange.

## Public API Capabilities

Public APIs provide immediate and unrestricted access to the following commands without the need for authorization.

* Fetch all market pairs from each integrated platform and exchange
* Fetch tickers and trading parameters for all market pairs
* Live and historical price feeds and exchange rates for each market pair
* Live order book data for each market pair
* Fetch trade history for all market pairs
* Live and historical charting capabilities utilizing trading data
* Other supported public endpoints for individual exchanges outside of this list

{% hint style="warning" %}
Capabilities may vary depending on the specific exchange integrations and their public access data feeds. Each exchange also has its own rate limiting guidelines that each user will be required to follow.
{% endhint %}

## Private API Capabilities

Authorized commands provide the ability to interact with trade orders, account data, and more. As mentioned before you will need to generate an API key from the selected exchange and then insert the authorization parameters into PENDAX to access these commands.

* Fetch and manage personal account information
* Create and edit subaccounts associated with the main account on supported exchanges
* Query account and subaccount balances
* Ability to deposit and withdraw from accounts and subaccounts
* Query current orders and historical personal orders
* Fetch personal ledger history for accounts and subaccounts
* Transfer funds between exchanges, accounts, and subaccounts
* Trade with all supported order types on supported exchanges
* Trade on all supported markets on supported exchanges
* Open and manage WebSockets on supported exchanges

{% hint style="warning" %}
Capabilities may vary depending on the specific exchange integrations and their documented capabilities for authorized API calls. Each exchange also has its own rate limiting guidelines that each user will be required to follow.
{% endhint %}

## Example Use Cases

Below are just a few sample use cases of products that can be built on top of PENDAX.

* Aggregated order books and optimal trade routing
* Fully customized private trading bot strategy
* Dollar-Cost Averaging strategies
* Cryptocurrency arbitrage strategies
* Grid-Trading Strategies
* Market Making for Cryptocurrency exchange markets
* Customized graphical interfaces for trading
* New market or statistics notifications
* Discord, Telegram, & Slack bots (or any other platform!)
* Custom hardware macro development (Streamdeck, etc)
* Compiling custom market charts
* Portfolio management, Trade journals, and PnL% tracking
* Data visualization and analytics interface
* Custom low-latency command-line interfaces (CLI)
* Advanced trading strategy indicators
* Tax Reporting Software

## Example Code Repositories

{% embed url="<https://github.com/CompendiumFi/PENDAX-SDK/tree/main/Examples/OKX-WebSocket-Template>" %}
Example Code For Full WebSocket Connector For OKX.COM
{% endembed %}


# Installing PENDAX modules

Instructions for installation of the PENDAX Source Developer Kit. Built by the team at Compendium.

## Install the NPM

```javascript
npm i @compendiumfi/pendax
```

The PENDAX SDK is currently available through npm and works with Javascript.

{% embed url="<https://www.npmjs.com/package/@compendiumfi/pendax>" %}

## Official GitHub Page

The GitHub repository can be found at the link below. The repository currently hosts instructions and documentation similar to what can be found in the official documentation on these pages. The GitHub repository will be updated with example code snippets and programs our team has written utilizing the PENDAX SDK to improve the developer experience.

{% embed url="<https://github.com/CompendiumFi/PENDAX-SDK>" %}

## SourceForge

Information on the PENDAX SDK is also available via SourceForge.&#x20;

{% embed url="<https://sourceforge.net/software/product/PENDAX/>" %}


# Using PENDAX SDK

NPM module that allows simplified connections and commands for data collection and trading on a growing list of cryptocurrency exchanges and platforms.

## Understanding Common Functions

It is important to understand how functions are dictated within the PENDAX SDK.

Our team has done an excellent job in aggregating what we will refer to as "common functions" for a plethora of integrated platforms. 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).

Examples of common functions include calls like **placing trade orders** or **getting account balances**. By normalizing these commands developers can work in a more efficient manner while customizing integrations or code bases for multiple or different supported platforms.

{% content-ref url="/pages/9KeEAlgJuWwrG3iFeAmH" %}
[Common Functions](/pendax/using-pendax-sdk/common-functions)
{% endcontent-ref %}

## Exchange Specific Functions

While there are a large variety of commonly normalized functions, there also may be a number of exchange-specific calls available for your selected platform. Many exchanges may include API features native to their interface and not found on other platforms so designating a common function is difficult in this manner.

We recommend browsing both the [Common Functions](/pendax/using-pendax-sdk/common-functions) and exchange-specific documentation pages while creating any instrument with PENDAX to ensure your code is designed to interact with the SDK in the correct manner.

{% content-ref url="/pages/gsNucVoTMTxAB5ELHuFf" %}
[OKX Functions](/pendax/using-pendax-sdk/okx-functions)
{% endcontent-ref %}

{% content-ref url="/pages/veVpaMByNPaTfIiW243M" %}
[ByBit Functions](/pendax/using-pendax-sdk/bybit-functions)
{% endcontent-ref %}

{% content-ref url="/pages/8SRJZOHoOjKz56cizzh6" %}
[Bitget Functions](/pendax/using-pendax-sdk/bitget-functions)
{% endcontent-ref %}

{% content-ref url="/pages/xMUECFglJFvcrUs8jqWB" %}
[Mexc Functions](/pendax/using-pendax-sdk/mexc-functions)
{% endcontent-ref %}

{% content-ref url="/pages/9aQoXZbAYeF0kMUiHJG3" %}
[FTX Functions](/pendax/using-pendax-sdk/ftx-functions)
{% endcontent-ref %}


# 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

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


# OKX Functions

Documentation for interacting with OKX functions and API endpoints through the PENDAX Javascript SDK.

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myOkxAccount = createExchange({
  exchange: "okx",
  authenticate: true,
  key: "myKeys",
  secret: "mySecret",
  passphrase: "myPassphrase",
  label: "okx",
  marginType: "usdt" // coin or usdt
});
```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myOkxAccount = createExchange({
  exchange: "okx",
  authenticate: false,
  label: "okx",
  marginType: "usdt" // coin or usdt
});
```

Once an Exchange object has been created you may use any of the available functions allowed by that exchange by referencing the name of the Exchange object you created.

#### Example using multiple Exchange Objects for executing PENDAX functions:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

let myOkxAccount = createExchange({
  exchange: "okx",
  authenticate: true,
  key: "myKeys",
  secret: "mySecret",
  passphrase: "myPassphrase",
  label: "okx",
  marginType: "usdt"
});

let myOtherOkxAccount = createExchange({
  exchange: "okx",
  authenticate: true,
  key: "myOtherKeys",
  secret: "myOtherSecret",
  passphrase: "myOtherPassphrase",
  label: "okx2",
  marginType: "usdt"
});

<strong> async function placeOrder(options){
</strong>    try {
      let result = await myOkxAccount.placeOrder (options);
      console.log(result);
    } catch (error) {
      console.log(error.message);
    }
  }  
  async function placeOrder(options){
    try {
      let result = await myOtherOkxAccount.placeOrder (options);
      console.log(result);
    } catch (error) {
      console.log(error.message);
    }
  }
</code></pre>

## All Available OKX Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% content-ref url="/pages/a3O9Is2cglcZFpURWcuA" %}
[Trading & Orders](/pendax/using-pendax-sdk/okx-functions/trading-and-orders)
{% endcontent-ref %}

{% content-ref url="/pages/FsGmSzVibV9iKQB2DSth" %}
[Funding](/pendax/using-pendax-sdk/okx-functions/funding)
{% endcontent-ref %}

{% content-ref url="/pages/TbE1wx77J4p15Q5vu5Sa" %}
[Convert](/pendax/using-pendax-sdk/okx-functions/convert)
{% endcontent-ref %}

{% content-ref url="/pages/SRf3T5btLHeuPdGfVpzZ" %}
[Account & Subaccount](/pendax/using-pendax-sdk/okx-functions/account-and-subaccount)
{% endcontent-ref %}

{% content-ref url="/pages/AaItv1DRUuQh6FoIXKII" %}
[Grid Trading](/pendax/using-pendax-sdk/okx-functions/grid-trading)
{% endcontent-ref %}

{% content-ref url="/pages/c5X4D1LQALpDasjac0Fd" %}
[Market Data](/pendax/using-pendax-sdk/okx-functions/market-data)
{% endcontent-ref %}

{% content-ref url="/pages/4nrxZVGOaa7Hu6TzbP74" %}
[Public Data](/pendax/using-pendax-sdk/okx-functions/public-data)
{% endcontent-ref %}

{% content-ref url="/pages/nF65xorg09rOZa6DzIKR" %}
[Trading Data](/pendax/using-pendax-sdk/okx-functions/trading-data)
{% endcontent-ref %}

## Exchange API Availability Status

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-status>
{% endhint %}

#### Function name:

```javascript
getStatus() 
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getStatus(exchange) {
    try {
        let result = await exchange.getStatus();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getStatus(myOkxAccount)
```

## WebSocket Example Code

Please refer to the attached repository to utilize OKX WebSocket connections for trading and data deployments through the PENDAX SDK

{% embed url="<https://github.com/CompendiumFi/PENDAX-SDK/tree/main/Examples/OKX-WebSocket-Template>" %}


# Trading & Orders

Documentation on interacting with a variety of OKX trading and order API functions through the PENDAX SDK.

All Trading & Order API endpoints require authentication. Please create OKX API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post. Please note that some endpoints for Algo & Block trading are currently under development.

## Placing and Manipulating Orders

### Place Order

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters. *You can place an order only if you have sufficient funds.*

<https://www.okx.com/docs-v5/en/#rest-api-trade-place-order>
{% endhint %}

#### Function Name:

```javascript
placeOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

    async function placeOrder(exchange, options) {
        try {
            let result = await exchange.placeOrder(options);
            return result
            console.log(result);
        } catch (error) {
            console.log(error.message);
        }
    }
  
    const result = await placeOrder(myOkxAccount, {
         instId: "BTC-USDT",
         tdMode: "cash",
         side: "buy",
         ordType: "limit",
         px: "10000",
         sz: ".01",         // for SWAPS sz is number of contracts which is .01 BTC
    })
```

### Place Multiple Orders

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-place-multiple-orders>
{% endhint %}

#### Function Name:

```javascript
placeMultiOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function placeMultiOrder(exchange, options) {
    try {
        let result = await exchange.placeMultiOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeMultiOrder(myOkxAccount, [

    {
        instId:"BTC-USDT",
        tdMode:"cash",
        clOrdId:"b15",
        side:"buy",
        ordType:"limit",
        px:"2.15",
        sz:"2"
    },
    {
        instId:"BTC-USDT",
        tdMode:"cash",
        clOrdId:"b15",
        side:"buy",
        ordType:"limit",
        px:"2.15",
        sz:"2"
    }
])
```

### Cancel Order

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-order>
{% endhint %}

#### Function Name:

```
cancelOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function cancelOrder(exchange, options) {
    try {
        let result = await exchange.cancelOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelOrder(myOkxAccount, {
    ordId:"2510789768709120",
    instId:"BTC-USD-190927"
})
```

### Cancel Multiple Orders

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-multiple-orders>
{% endhint %}

#### Function Name:

```
cancelMultiOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function cancelMultiOrder(exchange, options) {
    try {
        let result = await exchange.cancelMultiOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelOrder(myOkxAccount, [
{
    ordId:"2510789768709120",
    instId:"BTC-USD-190927"
},
{
    ordId:"12312",
    instId:"BTC-USDT"
}
])
```

### Amend Order

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-amend-order>
{% endhint %}

#### Function Name:

```javascript
modifyOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function modifyOrder(exchange, options) {
    try {
        let result = await exchange.modifyOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyOrder(myOkxAccount, {
    ordId:"2510789768709120",
    newSz:"2",
    instId:"BTC-USDT"
})
```

### Amend Multiple Orders

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-amend-multiple-orders>
{% endhint %}

#### Function Name:

```javascript
modifyMultiOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function modifyMultiOrder(exchange, options) {
    try {
        let result = await exchange.modifyMultiOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyMultiOrder(myOkxAccount, [
    {
        ordId:"2510789768709120",
        newSz:"2",
        instId:"BTC-USDT"
    },
    {
        ordId:"2510789768709121",
        newSz:"2",
        instId:"BTC-USDT"
    }
])
```

### Close Positions

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-close-positions>
{% endhint %}

#### Function Name:

```javascript
closePositions()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function closePositions(exchange, options) {
    try {
        let result = await exchange.closePositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await closePositions(myOkxAccount, {
    instId:"BTC-USDT-SWAP",
    mgnMode:"cross"
})
```

## Order Details And Transaction History

### Get Order Details

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-details>
{% endhint %}

#### Function Name:

```javascript
getOrderDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOrderDetails(exchange, options) {
    try {
        let result = await exchange.getOrderDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderDetails(myOkxAccount, {
    instId: "BTC-USDT"
})
```

### Get Order List

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-list>
{% endhint %}

#### Function Name:

```javascript
getOrderList()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOrderList(exchange, options) {
    try {
        let result = await exchange.getOrderList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderList(myOkxAccount)
```

### Get Order History (last 7 days)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-history-last-7-days>
{% endhint %}

#### Function Name:

```javascript
getOrderHistoryWeek()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOrderHistoryWeek(exchange, options) {
    try {
        let result = await exchange.getOrderHistoryWeek(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderHistoryWeek(myOkxAccount, {
                instType: "SPOT"
                })
```

### Get Order History (last 3 months)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-history-last-3-months>
{% endhint %}

#### Function Name:

```javascript
getOrderHistoryArchive()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOrderHistoryArchive(exchange, options) {
    try {
        let result = await exchange.getOrderHistoryArchive(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderHistoryArchive(myOkxAccount, {
                instType: "SPOT"
                })
```

### Get Transaction Details (last 3 days)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-days>
{% endhint %}

#### Function Name:

```javascript
getRecentTransactionDetailsShort()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getRecentTransactionDetailsShort(exchange, options) {
    try {
        let result = await exchange.getRecentTransactionDetailsShort(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRecentTransactionDetailsShort(myOkxAccount)
```

### Get Transaction Details (last 3 months)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-months>
{% endhint %}

#### Function Name:

```javascript
getRecentTransactionDetailsLong()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getRecentTransactionDetailsLong(exchange, options) {
    try {
        let result = await exchange.getRecentTransactionDetailsLong(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRecentTransactionDetailsLong(myOkxAccount)
```

## Placing & Editing Algo Orders

### Place Algo Order

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-place-algo-order>
{% endhint %}

#### Function Name:

```javascript
placeAlgoOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function placeAlgoOrder(exchange, options) {
    try {
        let result = await exchange.placeAlgoOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeAlgoOrder(myOkxAccount, {
    instId:"BTC-USDT",
    tdMode:"cross",
    side:"buy",
    ordType:"conditional",
    sz:"2",
    tpTriggerPx:"15",
    tpOrdPx:"18")
    })
```

### Cancel Algo Order

{% hint style="warning" %}
This endpoint is currently under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-algo-order>
{% endhint %}

#### Function Name:

```javascript
cancelAlgoOrder()
```

#### Usage:

```javascript
// 
```

### Cancel Advance Algo Order

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-advance-algo-order>
{% endhint %}

#### Function Name:

```javascript
cancelAdvAlgoOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function cancelAdvAlgoOrder(exchange, options) {
    try {
        let result = await exchange.cancelAdvAlgoOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelAdvAlgoOrder(myOkxAccount, 
[
    {
        algoId:"198273485",
        instId:"BTC-USDT"
    },
    {
        algoId:"198273485",
        instId:"BTC-USDT"
    }
])
```

### Get Algo Order List

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-algo-order-list>
{% endhint %}

#### Function Name:

```javascript
getAlgoOrderList()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getAlgoOrderList(exchange, options) {
    try {
        let result = await exchange.getAlgoOrderList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAlgoOrderList(myOkxAccount, {
            ordType: "conditional"
    })
```

### Get Algo Order History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trade-get-algo-order-history>
{% endhint %}

#### Function Name:

```javascript
getAlgoOrderHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getAlgoOrderHistory(exchange, options) {
    try {
        let result = await exchange.getAlgoOrderHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAlgoOrderHistory(myOkxAccount, {
            state: "effective",
            ordType: "conditional"
    })
```

## One-Click & Easy Convert

### Get Easy Convert Currency List

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

### Place Easy Convert

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

### Get Easy Convert History

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

### Get One-Click Repay Currency List

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

### Trade One-Click Repay

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

### Get One-Click Repay History

{% hint style="warning" %}
This endpoint is currently under development.
{% endhint %}

## Block Trading

### Get Counterparties

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-counterparties>
{% endhint %}

#### Function Name:

```javascript
getCounterparties()
```

#### Usage:

```javascript
// 
```

### Create RFQ

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-create-rfq>
{% endhint %}

#### Function Name:

```javascript
createRfq()
```

#### Usage:

```javascript
// 
```

### Cancel RFQ

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-rfq>
{% endhint %}

#### Function Name:

```javascript
cancelRfq()
```

#### Usage:

```javascript
//
```

### Cancel Multiple RFQ's

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-multiple-rfqs>
{% endhint %}

#### Function Name:

```javascript
cancelBatchRfq()
```

#### Usage:

```javascript
//
```

### Cancel All RFQ's

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-all-rfqs>
{% endhint %}

#### Function Name:

```javascript
cancelAllRfqs()
```

#### Usage:

```javascript
//
```

### Execute Quote

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-execute-quote>
{% endhint %}

#### Function Name:

```javascript
executeQuote()
```

#### Usage:

```javascript
//
```

### Set Quote Products

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-set-quote-products>
{% endhint %}

#### Function Name:

```javascript
//
```

#### Usage:

```javascript
//
```

### Reset MMP Status

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-reset-mmp-status>
{% endhint %}

#### Function Name:

```javascript
//
```

#### Usage:

```javascript
//
```

### Create Quote

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-create-quote>
{% endhint %}

#### Function Name:

```javascript
createQuote()
```

#### Usage:

```javascript
//
```

### Cancel Quote

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-quote>
{% endhint %}

#### Function Name:

```javascript
cancelQuote()
```

#### Usage:

```javascript
//
```

### Cancel Multiple Quotes

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-multiple-quotes>
{% endhint %}

#### Function Name:

```javascript
cancelBatchQuotes()
```

#### Usage:

```javascript
//
```

### Cancel All Quotes

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-all-quotes>
{% endhint %}

#### Function Name:

```javascript
cancelAllQuotes()
```

#### Usage:

```javascript
//
```

### Get RFQ's

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-rfqs>
{% endhint %}

#### Function Name:

```javascript
getRfqs()
```

#### Usage:

```javascript
//
```

### Get Quotes

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-quotes>
{% endhint %}

#### Function Name:

```javascript
getQuotes()
```

#### Usage:

```javascript
//
```

### Get Trades

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-trades>
{% endhint %}

#### Function Name:

```javascript
getUserBlockTrades()
```

#### Usage:

```javascript
//
```

### Get Public Trades

{% hint style="warning" %}
This endpoint is under development
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-public-trades>
{% endhint %}

#### Function Name:

```javascript
getPublicBlockTrades()
```

#### Usage:

```javascript
//
```


# Funding

Documentation on interacting with a variety of OKX API functions related to Funding data and information through the PENDAX SDK.

All Funding & Account API endpoints require authentication. Please create OKX API keys to interact with these functions successfully.&#x20;

## Funding

### Get Currencies

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies>
{% endhint %}

#### Function Name:

```javascript
fundingGetCurrencies()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetCurrencies(exchange, options) {
    try {
        let result = await exchange.fundingGetCurrencies(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetCurrencies(myOkxAccount)
```

### Get Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-balance>
{% endhint %}

#### Function Name:

```javascript
fundingGetBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetBalance(exchange, options) {
    try {
        let result = await exchange.fundingGetBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetBalance(myOkxAccount)
```

### Get Account Asset Valuation

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-account-asset-valuation>
{% endhint %}

#### Function Name:

```javascript
fundingGetAssetValuation()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetAssetValuation(exchange, options) {
    try {
        let result = await exchange.fundingGetAssetValuation(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetAssetValuation(myOkxAccount)
```

### Funds Transfer

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-funds-transfer>
{% endhint %}

#### Function Name:

```javascript
fundingAssetTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingAssetTransfer(exchange, options) {
    try {
        let result = await exchange.fundingAssetTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingAssetTransfer(myOkxAccount,
{
    ccy:"USDT",
    amt:"1.5",
    from:"6",
    to:"18"
})
```

### Get Funds Transfer State

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-funds-transfer-state>
{% endhint %}

#### Function Name:

```javascript
fundingGetFundsTransferState()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetFundsTransferState(exchange, options) {
    try {
        let result = await exchange.fundingGetFundsTransferState(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetFundsTransferState(myOkxAccount,
{
    transId: "1",
    type: "1"
})
```

### Asset Bill Details

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-asset-bills-details>
{% endhint %}

#### Function Name:

```javascript
fundingGetAssetBillsDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetAssetBillsDetails(exchange, options) {
    try {
        let result = await exchange.fundingGetAssetBillsDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetAssetBillsDetails(myOkxAccount)
```

### Get Deposit Address

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-address>
{% endhint %}

#### Function Name:

```javascript
fundingGetDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetDepositAddress(exchange, options) {
    try {
        let result = await exchange.fundingGetDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetDepositAddress(myOkxAccount, 
            {
                ccy: "BTC"
            })
```

### Get Deposit History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetDepositHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetDepositHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetDepositHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetDepositHistory(myOkxAccount)
```

### Withdrawal

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-withdrawal>
{% endhint %}

#### Function Name:

```javascript
fundingWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingWithdrawal(myOkxAccount, 
{
    amt:"1",
    fee:"0.0005",
    dest:"4",
    ccy:"BTC",
    chain:"BTC-Bitcoin",
    toAddr:"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"
})
```

### Get Withdrawal History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-withdrawal-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetWithdrawalHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetWithdrawalHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetWithdrawalHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetWithdrawalHistory(myOkxAccount)
```

### Small Assets Convert

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-small-assets-convert>
{% endhint %}

#### Function Name:

```javascript
fundingConvertDust()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingConvertDust(exchange, options) {
    try {
        let result = await exchange.fundingConvertDust(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingConvertDust(myOkxAccount,
{
   ccy:["BTC","USDT"]
})
```

### Get Saving Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-saving-balance>
{% endhint %}

#### Function Name:

```javascript
fundingGetSavingBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetSavingBalance(exchange, options) {
    try {
        let result = await exchange.fundingGetSavingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetSavingBalance(myOkxAccount)
```

### Savings Purchase/Redemption

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-savings-purchase-redemption>
{% endhint %}

#### Function Name:

```javascript
fundingSavingsAndPurchaseRedemption()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingSavingsAndPurchaseRedemption(exchange, options) {
    try {
        let result = await exchange.fundingSavingsAndPurchaseRedemption(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingSavingsAndPurchaseRedemption(myOkxAccount,
{
    ccy:"BTC",
    amt:"1",
    side:"purchase",
    rate:"0.01"
}
)
```

### Set Lending Rate

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-set-lending-rate>
{% endhint %}

#### Function Name:

```javascript
fundingSetLendingRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingSetLendingRate(exchange, options) {
    try {
        let result = await exchange.fundingSetLendingRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingSetLendingRate(myOkxAccount,
{
    ccy:"BTC",
    rate:"0.02"
}
)
```

### Get Lending History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-lending-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetLendingHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetLendingHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetLendingHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetLendingHistory(myOkxAccount)
```

### Get Public Borrow Info

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-public-borrow-info-public>
{% endhint %}

#### Function Name:

```javascript
fundingGetPublicBorrowInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetPublicBorrowInfo(exchange, options) {
    try {
        let result = await exchange.fundingGetPublicBorrowInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetPublicBorrowInfo(myOkxAccount)
```

### Get Public Borrow History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-public-borrow-history-public>
{% endhint %}

#### Function Name:

```javascript
fundingGetPublicBorrowHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetPublicBorrowHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetPublicBorrowHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetPublicBorrowHistory(myOkxAccount)
```

### Lightning Deposits

{% hint style="warning" %}
Not currently supported
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-lightning-deposits>
{% endhint %}

#### Function Name:

```javascript
fundingLightningDeposit()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingLightningDeposit(exchange, options) {
    try {
        let result = await exchange.fundingLightningDeposit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingLightningDeposit(myOkxAccount,
{
        ccy: "BTC",
        amt: "0.1"
}
)
```

### Lightning Withdrawals

{% hint style="warning" %}
Not currently supported
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-lightning-withdrawals>
{% endhint %}

#### Function Name:

```javascript
fundingLightningWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingLightningWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingLightningWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingLightningWithdrawal(myOkxAccount,
{
    ccy:"BTC",
    invoice:"lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hz"
}
)
```

### Cancel Withdrawal

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-cancel-withdrawal>
{% endhint %}

#### Function Name:

```javascript
fundingCancelWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingCancelWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingCancelWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingCancelWithdrawal(myOkxAccount,
{
   wdId:"1123456"
}
)
```


# Convert

Documentation on interacting with a variety of OKX Convert and Convert History API functions through the PENDAX SDK.

The API endpoints of `Convert` require authentication. Please start by creating an OKX API key. Only the assets in the funding account can be used for conversion.

## Convert

### Get Convert Currencies

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-currencies>
{% endhint %}

#### Function Name:

```javascript
getConvertCurrencies()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getConvertCurrencies(exchange, options) {
    try {
        let result = await exchange.getConvertCurrencies(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getConvertCurrencies(myOkxAccount)
```

### Get Convert Currency Pair

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-currency-pair>
{% endhint %}

#### Function Name:

```javascript
getConvertCurrencyPair()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getConvertCurrencyPair(exchange, options) {
    try {
        let result = await exchange.getConvertCurrencyPair(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getConvertCurrencyPair(myOkxAccount,
{
        fromCcy: "USDT",
        toCcy: "BTC"
})
```

### Estimate Quote

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-convert-estimate-quote>
{% endhint %}

#### Function Name:

```javascript
convertEstimateQuote()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function convertEstimateQuote(exchange, options) {
    try {
        let result = await exchange.convertEstimateQuote(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await convertEstimateQuote(myOkxAccount,
{
    baseCcy: "ETH",
    quoteCcy: "USDT",
    side: "buy",
    rfqSz: "30",
    rfqSzCcy: "USDT"
}
)
```

### Convert Trade

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-convert-convert-trade>
{% endhint %}

#### Function Name:

```javascript
convertTrade()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function convertTrade(exchange, options) {
    try {
        let result = await exchange.convertTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await convertTrade(myOkxAccount,
{
    baseCcy: "ETH",
    quoteCcy: "USDT",
    side: "buy",
    sz: "30",
    szCcy: "USDT",
    quoteId: "quoterETH-USDT16461885104612381"
}
)
```

### Get Convert History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-convert-get-convert-history>
{% endhint %}

#### Function Name:

```javascript
getConvertHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getConvertHistory(exchange, options) {
    try {
        let result = await exchange.getConvertHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getConvertHistory(myOkxAccount)
```


# Account & Subaccount

Documentation on interacting with a variety of OKX account and subaccount API endpoint functions through the PENDAX Javascript SDK.

All Account and Subaccount API endpoints require authentication. Please create OKX API keys to interact with these functions successfully.&#x20;

## Account

### Get Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance>
{% endhint %}

#### Function Name:

```javascript
getBalances()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getBalances(exchange, options) {
    try {
        let result = await exchange.getBalances(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBalances(myOkxAccount)
```

### Get Positions

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-positions>
{% endhint %}

#### Function Name:

```javascript
getPositions()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPositions(exchange, options) {
    try {
        let result = await exchange.getPositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositions(myOkxAccount)
```

### Get Positions History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-positions-history>
{% endhint %}

#### Function Name:

```javascript
getPositionsHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPositionsHistory(exchange, options) {
    try {
        let result = await exchange.getPositionsHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositionsHistory(myOkxAccount)
```

### Get Account and Position Risk

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-account-and-position-risk>
{% endhint %}

#### Function Name:

```javascript
getAccountPosAndRisk()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getAccountPosAndRisk(exchange, options) {
    try {
        let result = await exchange.getAccountPosAndRisk(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountPosAndRisk(myOkxAccount)
```

### Get Bills Details (last 7 days)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days>
{% endhint %}

#### Function Name:

```javascript
getBills()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getBills(exchange, options) {
    try {
        let result = await exchange.getBills(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBills(myOkxAccount)
```

### Get Bills Details (last 3 months)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months>
{% endhint %}

#### Function Name:

```javascript
getBillsArchive()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getBillsArchive(exchange, options) {
    try {
        let result = await exchange.getBillsArchive(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBillsArchive(myOkxAccount)
```

### Get Account Configuration

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-account-configuration>
{% endhint %}

#### Function Name:

```javascript
getAccountConfig()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getAccountConfig(exchange, options) {
    try {
        let result = await exchange.getAccountConfig(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountConfig(myOkxAccount)
```

### Set Position Mode

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-set-position-mode>
{% endhint %}

#### Function Name:

```javascript
setPosMode()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function setPosMode(exchange, options) {
    try {
        let result = await exchange.setPosMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setPosMode(myOkxAccount,
{
    posMode:"long_short_mode"
}
)
```

### Set Leverage

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-set-leverage>
{% endhint %}

#### Function Name:

```javascript
setLeverage()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverage(myOkxAccount,
{
    instId:"BTC-USDT",
    lever:"5",
    mgnMode:"isolated"
}
)
```

### Get Maximum Buy/Sell Amount or Open Amount

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-buy-sell-amount-or-open-amount>
{% endhint %}

#### Function Name:

```javascript
getMaxSize()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMaxSize(exchange, options) {
    try {
        let result = await exchange.getMaxSize(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxSize(myOkxAccount,
{
    instId:"BTC-USDT",
    tdMode:"isolated"
}
)
```

### Get Maximum Available Tradable Amount

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-available-tradable-amount>
{% endhint %}

#### Function Name:

```javascript
getMaxAvailSize()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMaxAvailSize(exchange, options) {
    try {
        let result = await exchange.getMaxAvailSize(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxAvailSize(myOkxAccount,
{
    instId:"BTC-USDT",
    tdMode:"isolated"
}
)
```

### Increase/Decrease Margin

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-increase-decrease-margin>
{% endhint %}

#### Function Name:

```javascript
adjustMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function adjustMargin(exchange, options) {
    try {
        let result = await exchange.adjustMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await adjustMargin(myOkxAccount,
{
    instId:"BTC-USDT-200626",
    posSide:"short",
    type:"add",
    amt:"1"
}
)
```

### Get Leverage

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-leverage>
{% endhint %}

#### Function Name:

```javascript
getLeverage()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getLeverage(exchange, options) {
    try {
        let result = await exchange.getLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLeverage(myOkxAccount,
{
    instId:"BTC-USDT-200626",
    mgnMode: "cross"
}
)
```

### Get The Maximum Loan Of Instrument

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-the-maximum-loan-of-instrument>
{% endhint %}

#### Function Name:

```javascript
getMaxLoan()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMaxLoan(exchange, options) {
    try {
        let result = await exchange.getMaxLoan(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxLoan(myOkxAccount,
{
    instId:["BTC-USDT-200626"],
    mgnMode: "cross"
}
)
```

### Get Fee Rates

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-fee-rates>
{% endhint %}

#### Function Name:

```javascript
getFeeRates()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getFeeRates(exchange, options) {
    try {
        let result = await exchange.getFeeRates(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFeeRates(myOkxAccount,
{
    instType: "SPOT",
    instID: "BTC-USDT"
}
)
```

### Get Interest Accrued Data

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-accrued-data>
{% endhint %}

#### Function Name:

```javascript
getFeeRates()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getInterestAccrued(exchange, options) {
    try {
        let result = await exchange.getInterestAccrued(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestAccrued(myOkxAccount)
```

### Get Interest Rate

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-rate>
{% endhint %}

#### Function Name:

```javascript
getInterestRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getInterestRate(exchange, options) {
    try {
        let result = await exchange.getInterestRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestRate(myOkxAccount)
```

### Set Greeks

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-set-greeks-pa-bs>
{% endhint %}

#### Function Name:

```javascript
setGreeks()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function setGreeks(exchange, options) {
    try {
        let result = await exchange.setGreeks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setGreeks(myOkxAccount, {
    greeksType:"PA"
})
```

### Isolated Margin Trading Settings

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-isolated-margin-trading-settings>
{% endhint %}

#### Function Name:

```javascript
setIsolatedMode()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function setIsolatedMode(exchange, options) {
    try {
        let result = await exchange.setIsolatedMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setIsolatedMode(myOkxAccount, {
    isoMode:"automatic",
    type:"MARGIN"
})
```

### Get Maximum Withdrawals

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-withdrawals>
{% endhint %}

#### Function Name:

```javascript
getMaxWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMaxWithdrawal(exchange, options) {
    try {
        let result = await exchange.getMaxWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxWithdrawal(myOkxAccount)
```

### Get Account Risk State

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-account-risk-state>
{% endhint %}

#### Function Name:

```javascript
getRiskState()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getRiskState(exchange, options) {
    try {
        let result = await exchange.getRiskState(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRiskState(myOkxAccount)
```

### VIP Loans Borrow and Repay

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay>
{% endhint %}

#### Function Name:

```javascript
vipLoanBorrowRepay()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function vipLoanBorrowRepay(exchange, options) {
    try {
        let result = await exchange.vipLoanBorrowRepay(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await vipLoanBorrowRepay(myOkxAccount, {
    ccy:"USDT",
    side:"borrow",
    amt:"100"
})
```

### Get Borrow and Repay History for VIP Loans

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-borrow-and-repay-history-for-vip-loans>
{% endhint %}

#### Function Name:

```javascript
getVipLoanHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getVipLoanHistory(exchange, options) {
    try {
        let result = await exchange.getVipLoanHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getVipLoanHistory(myOkxAccount)
```

### Get Borrow Interest and Limit

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-borrow-interest-and-limit>
{% endhint %}

#### Function Name:

```javascript
getBorrowInterestAndLimit()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getBorrowInterestAndLimit(exchange, options) {
    try {
        let result = await exchange.getBorrowInterestAndLimit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowInterestAndLimit(myOkxAccount)
```

### Position Builder

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-position-builder>
{% endhint %}

#### Function Name:

```javascript
positionBuilder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function positionBuilder(exchange, options) {
    try {
        let result = await exchange.positionBuilder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await positionBuilder(myOkxAccount,
{
   instType:"SWAP",
   inclRealPos:"true",
   simPos:[
     {
          pos:"10",
          instId:"BTC-USDT-SWAP"
     },
     {
          pos:"10",
          instId:"LTC-USDT-SWAP"
     }
   ]
})
```

### Get Greeks

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-account-get-greeks>
{% endhint %}

#### Function Name:

```javascript
getGreeks()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getGreeks(exchange, options) {
    try {
        let result = await exchange.getGreeks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGreeks(myOkxAccount)
```

## Subaccount

### View Subaccount List

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-view-sub-account-list>
{% endhint %}

#### Function Name:

```javascript
getSubaccountList()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSubaccountList(exchange, options) {
    try {
        let result = await exchange.getSubaccountList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountList(myOkxAccount)
```

### Get Subaccount Trading Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-sub-account-trading-balance>
{% endhint %}

#### Function Name:

```javascript
getSubaccountTradingBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSubaccountTradingBalance(exchange, options) {
    try {
        let result = await exchange.getSubaccountTradingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountTradingBalance(myOkxAccount, {
    subAcct: "mySubaccount"
    })
```

### Get Subaccount Funding Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-sub-account-funding-balance>
{% endhint %}

#### Function Name:

```javascript
getSubaccountFundingBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSubaccountFundingBalance(exchange, options) {
    try {
        let result = await exchange.getSubaccountFundingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountFundingBalance(myOkxAccount, {
    subAcct: "mySubaccount"
    })
```

### History of Subaccount Transfer

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-history-of-sub-account-transfer>

Applies to master accounts only.
{% endhint %}

#### Function Name:

```javascript
getSubaccountBills()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSubaccountBills(exchange, options) {
    try {
        let result = await exchange.getSubaccountBills(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountBills(myOkxAccount)
```

### Master Accounts Manage the Transfers Between Subaccounts

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-master-accounts-manage-the-transfers-between-sub-accounts>
{% endhint %}

#### Function Name:

```javascript
subaccountTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function subaccountTransfer(exchange, options) {
    try {
        let result = await exchange.subaccountTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await subaccountTransfer(myOkxAccount, 
{
    ccy:"USDT",
    amt:"1.5",
    from:"6",
    to:"6",
    fromSubAccount:"test-1",
    toSubAccount:"test-2"
})
```

### Set Permission of Transfer Out

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-set-permission-of-transfer-out>
{% endhint %}

#### Function Name:

```javascript
canTransferOut()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function canTransferOut(exchange, options) {
    try {
        let result = await exchange.canTransferOut(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await canTransferOut(myOkxAccount, 
{
    subAcct:"test-1",
    canTransOut:true
})
```

### Get Custody Trading Subaccount List

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-custody-trading-sub-account-list>
{% endhint %}

#### Function Name:

```javascript
getCustodyTradingAccountList()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getCustodyTradingAccountList(exchange, options) {
    try {
        let result = await exchange.getCustodyTradingAccountList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCustodyTradingAccountList(myOkxAccount)
```


# Grid Trading

Documentation on interacting with a OKX's native Grid Trading programmatic API functions through the PENDAX Javascript SDK.

All Grid Trading API endpoints require authentication. Please create OKX API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post.

## Grid Trading

### Place Grid Algo Order

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-place-grid-algo-order>
{% endhint %}

#### Function Name:

```javascript
placeGridAlgoOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function placeGridAlgoOrder(exchange, options) {
    try {
        let result = await exchange.placeGridAlgoOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeGridAlgoOrder(myOkxAccount,
{
    instId: "BTC-USDT",
    algoOrdType: "grid",
    maxPx: "5000",
    minPx: "400",
    gridNum: "10",
    runType: "1",
    quoteSz: "25"
})
```

### Amend Grid Algo Order

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-amend-grid-algo-order>
{% endhint %}

#### Function Name:

```javascript
amendGrid()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function amendGrid(exchange, options) {
    try {
        let result = await exchange.amendGrid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await amendGrid(myOkxAccount,
{
    algoId:"448965992920907776",
    instId:"BTC-USDT-SWAP",
    slTriggerPx:"1200",
    tpTriggerPx:""
})
```

### Stop Grid Algo Order

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-stop-grid-algo-order>
{% endhint %}

#### Function Name:

```javascript
stopGrid()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function stopGrid(exchange, options) {
    try {
        let result = await exchange.stopGrid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await stopGrid(myOkxAccount,
{
    [
    {
        algoId:"198273485",
        instId:"BTC-USDT",
        stopType:"1",
        algoOrdType:"grid"
    }
    ]
})
```

### Get Grid Algo Order List

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-list>
{% endhint %}

#### Function Name:

```javascript
getPendingGridOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPendingGridOrders(exchange, options) {
    try {
        let result = await exchange.getPendingGridOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPendingGridOrders(myOkxAccount,
{
        algoOrdType:"grid"
})
```

### Get Grid Algo Order History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-history>
{% endhint %}

#### Function Name:

```javascript
getGridOrderHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getGridOrderHistory(exchange, options) {
    try {
        let result = await exchange.getGridOrderHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGridOrderHistory(myOkxAccount,
{
        algoOrdType:"grid"
})
```

### Get Grid Algo Order Details

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-details>
{% endhint %}

#### Function Name:

```javascript
getGridOrderDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getGridOrderDetails(exchange, options) {
    try {
        let result = await exchange.getGridOrderDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGridOrderDetails(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "grid"
})
```

### Get Grid Algo Sub Orders

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-sub-orders>
{% endhint %}

#### Function Name:

```javascript
getGridSubOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getGridSubOrders(exchange, options) {
    try {
        let result = await exchange.getGridSubOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGridSubOrders(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "grid"
})
```

### Get Grid Algo Order Positions

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-positions>
{% endhint %}

#### Function Name:

```javascript
getGridPositions()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getGridPositions(exchange, options) {
    try {
        let result = await exchange.getGridPositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGridPositions(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "contract_grid"
})
```

### Spot Grid Withdraw Income

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-grid-trading-spot-moon-grid-withdraw-income>
{% endhint %}

#### Function Name:

```javascript
spotGridWithdraw()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function spotGridWithdraw(exchange, options) {
    try {
        let result = await exchange.spotGridWithdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await spotGridWithdraw(myOkxAccount,
{
    algoId:"448965992920907776"
})
```


# Market Data

Documentation on interacting with a variety of OKX's Market Data API functions through the PENDAX Javascript SDK.

API calls for market data functions do not require account authentication/authorization.

## Market Data

### Get Tickers

{% hint style="success" %}
This function is also included in "Common Functions" as getMarkets()
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickers>
{% endhint %}

#### Function Name:

```javascript
getTickers()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTickers(exchange, options) {
    try {
        let result = await exchange.getTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTickers(myOkxAccount,
<strong>{
</strong>    instType:"SWAP"
})
</code></pre>

### Get Ticker

{% hint style="success" %}
This function is also included in "Common Functions" as getMarket()
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-ticker>
{% endhint %}

#### Function Name:

```javascript
getTicker()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTicker(exchange, options) {
    try {
        let result = await exchange.getTicker(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTicker(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD-SWAP"
</strong>})
</code></pre>

### Get Index Tickers

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-tickers>
{% endhint %}

#### Function Name:

```javascript
getIndexTickers()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getIndexTickers(exchange, options) {
    try {
        let result = await exchange.getIndexTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexTickers(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT"
</strong>})
</code></pre>

### Get Order Book

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-order-book>
{% endhint %}

#### Function Name:

```javascript
getOrderBook()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOrderBook(exchange, options) {
    try {
        let result = await exchange.getOrderBook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderBook(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT"
</strong>})
</code></pre>

### Get Candlesticks

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getCandles(exchange, options) {
    try {
        let result = await exchange.getCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT-SWAP"
</strong>})
</code></pre>

### Get Candlesticks History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-candlesticks-history>
{% endhint %}

#### Function Name:

```javascript
getCandleHistory()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getCandleHistory(exchange, options) {
    try {
        let result = await exchange.getCandleHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandleHistory(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USDT-SWAP"
</strong>})
</code></pre>

### Get Index Candlesticks

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getIndexCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getIndexCandles(exchange, options) {
    try {
        let result = await exchange.getIndexCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>})
</code></pre>

### Get Mark Price Candlesticks

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-mark-price-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getMarkPriceCandles()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMarkPriceCandles(exchange, options) {
    try {
        let result = await exchange.getMarkPriceCandles(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarkPriceCandles(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>})
</code></pre>

### Get Trades

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-trades>
{% endhint %}

#### Function Name:

```javascript
getTrades()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getTrades(exchange, options) {
    try {
        let result = await exchange.getTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTrades(myOkxAccount,
<strong>{
</strong><strong>    instId: "BTC-USD"
</strong>});
</code></pre>

### Get Trades History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-trades-history>
{% endhint %}

#### Function Name:&#x20;

```javascript
getTradesHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getTradesHistory(exchange, options) {
    try {
        let result = await exchange.getTradesHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTradesHistory(myOkxAccount,
{
    instId: "BTC-USDT"
});
```

### Get 24H Total Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-24h-total-volume>
{% endhint %}

#### Function Name:&#x20;

```javascript
get24HrPlatformVolume()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function get24HrPlatformVolume(exchange, options) {
    try {
        let result = await exchange.get24HrPlatformVolume(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await get24HrPlatformVolume(myOkxAccount);
```

### Get Oracle

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-oracle>
{% endhint %}

#### Function Name:&#x20;

```javascript
getOracle()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getOracle(exchange, options) {
    try {
        let result = await exchange.getOracle(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOracle(myOkxAccount);
```

### Get Exchange Rate

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-exchange-rate>
{% endhint %}

#### Function Name:

```javascript
getExchangeRate()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getExchangeRate(exchange, options) {
    try {
        let result = await exchange.getExchangeRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getExchangeRate(myOkxAccount);
```

### Get Index Components

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-index-components>
{% endhint %}

#### Function Name:

```javascript
getIndexComponents()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getIndexComponents(exchange, options) {
    try {
        let result = await exchange.getIndexComponents(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getIndexComponents(myOkxAccount,
{
    index: "BTC-USD"
});
```

### Get Block Tickers

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-tickers>
{% endhint %}

#### Function Name:

```javascript
getBlockTickers()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getBlockTickers(exchange, options) {
    try {
        let result = await exchange.getBlockTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTickers(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Block Ticker

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-ticker>
{% endhint %}

#### Function Name:

```javascript
getBlockTicker()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getBlockTicker(exchange, options) {
    try {
        let result = await exchange.getBlockTicker(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTicker(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USD-SWAP"
});
</code></pre>

### Get Block Trades

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-market-data-get-block-trades>
{% endhint %}

#### Function Name:

```javascript
getBlockTrades()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getBlockTrades(exchange, options) {
    try {
        let result = await exchange.getBlockTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBlockTrades(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USDT"
});
</code></pre>


# Public Data

Documentation on interacting with a variety of OKX's Public Data API functions through the PENDAX Javascript SDK.

The API endpoints of `Public Data` do not require authentication.

## Public Data

### Get Instruments

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-instruments>
{% endhint %}

#### Function Name:

```javascript
getInstruments()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getInstruments(exchange, options) {
    try {
        let result = await exchange.getInstruments(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstruments(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Delivery/Exercise Data

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-delivery-exercise-history>
{% endhint %}

#### Function Name:

```javascript
getDeliveryAndRequestHistory()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getDeliveryAndRequestHistory(exchange, options) {
    try {
        let result = await exchange.getDeliveryAndRequestHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDeliveryAndRequestHistory(myOkxAccount,
<strong>{
</strong>  instType: "OPTION",
  uly: "BTC-USD"
});
</code></pre>

### Get Open Interest

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest>
{% endhint %}

#### Function Name:

```javascript
getOpenInterest()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getOpenInterest(exchange, options) {
    try {
        let result = await exchange.getOpenInterest(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenInterest(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Funding Rate

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-funding-rate>
{% endhint %}

#### Function Name:

```javascript
getFundingRate()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getFundingRate(exchange, options) {
    try {
        let result = await exchange.getFundingRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFundingRate(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USD-SWAP"
});
</code></pre>

### Get Funding Rate History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-funding-rate-history>
{% endhint %}

#### Function Name:

```javascript
getFundingHistory()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getFundingHistory(exchange, options) {
    try {
        let result = await exchange.getFundingHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFundingHistory(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USD-SWAP"
});
</code></pre>

### Get Limit Price

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-limit-price>
{% endhint %}

#### Function Name:

```javascript
getLimitPrice()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getLimitPrice(exchange, options) {
    try {
        let result = await exchange.getLimitPrice(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLimitPrice(myOkxAccount,
<strong>{
</strong>    instId: "BTC-USDT-SWAP"
});
</code></pre>

### Get Option Market Data

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-option-market-data>
{% endhint %}

#### Function Name:

```javascript
getOptionMarketData()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getOptionMarketData(exchange, options) {
    try {
        let result = await exchange.getOptionMarketData(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOptionMarketData(myOkxAccount,
<strong>{
</strong>    uly: "BTC-USD"
});
</code></pre>

### Get Estimated Delivery/Exercise Price

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-estimated-delivery-exercise-price>
{% endhint %}

#### Function Name:

```javascript
getEstimatedDelExpPrice()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getEstimatedDelExpPrice(exchange, options) {
    try {
        let result = await exchange.getEstimatedDelExpPrice(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getEstimatedDelExpPrice(myOkxAccount,
<strong>{
</strong>  instId: "BTC-USD-230106-16200-P"
});
</code></pre>

### Get Discount Rate and Interest-Free Quota

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-discount-rate-and-interest-free-quota>
{% endhint %}

#### Function Name:

```javascript
getDiscRateAndIntFreeQuota()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getDiscRateAndIntFreeQuota(exchange, options) {
    try {
        let result = await exchange.getDiscRateAndIntFreeQuota(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDiscRateAndIntFreeQuota(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get System Time

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-system-time>
{% endhint %}

#### Function Name:

```javascript
getServerTime()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getServerTime(exchange, options) {
    try {
        let result = await exchange.getServerTime(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getServerTime(myOkxAccount);
```

### Get Liquidation Orders

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-liquidation-orders>
{% endhint %}

#### Function Name:

```javascript
getLiqOrders()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getLiqOrders(exchange, options) {
    try {
        let result = await exchange.getLiqOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLiqOrders(myOkxAccount,
<strong>{
</strong>  instType: "MARGIN",
  instId: "BTC-USDT"
}));
</code></pre>

### Get Mark Price

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-mark-price>
{% endhint %}

#### Function Name:

```javascript
getMarkPrice()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getMarkPrice(exchange, options) {
    try {
        let result = await exchange.getMarkPrice(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarkPrice(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Position Tiers

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-position-tiers>
{% endhint %}

#### Function Name:

```javascript
getPositionTiers()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getPositionTiers(exchange, options) {
    try {
        let result = await exchange.getPositionTiers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositionTiers(myOkxAccount,
<strong>{
</strong>  instType: "SWAP",
  tdMode: "cross",
  uly: ["BTC-USD"]
});
</code></pre>

### Get Interest Rate and Loan Quota

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-interest-rate-and-loan-quota>
{% endhint %}

#### Function Name:

```javascript
getInterestRateAndLoanQuota()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getInterestRateAndLoanQuota(exchange, options) {
    try {
        let result = await exchange.getInterestRateAndLoanQuota(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestRateAndLoanQuota(myOkxAccount);
```

### Get Interest Rate and Loan Quota for VIP Loans

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-interest-rate-and-loan-quota-for-vip-loans>
{% endhint %}

#### Function Name:

```javascript
getVipInterestRateAndLoanQuota()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getVipInterestRateAndLoanQuota(exchange, options) {
    try {
        let result = await exchange.getVipInterestRateAndLoanQuota(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getVipInterestRateAndLoanQuota(myOkxAccount);
```

### Get Underlying

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-underlying>
{% endhint %}

#### Function Name:

```javascript
getUnderlying()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getUnderlying(exchange, options) {
    try {
        let result = await exchange.getUnderlying(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getUnderlying(myOkxAccount,
<strong>{
</strong>    instType: "SWAP"
});
</code></pre>

### Get Insurance Fund

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-get-insurance-fund>
{% endhint %}

#### Function Name:

```javascript
getInsuranceFund()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function getInsuranceFund(exchange, options) {
    try {
        let result = await exchange.getInsuranceFund(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInsuranceFund(myOkxAccount,
<strong>{
</strong>  instType: "SWAP",
  uly: "BTC-USD"
});
</code></pre>

### Unit Convert

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-public-data-unit-convert>
{% endhint %}

#### Function Name:

```javascript
unitConvert()
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

​
async function unitConvert(exchange, options) {
    try {
        let result = await exchange.unitConvert(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await unitConvert(myOkxAccount,
<strong>{
</strong>  instId: "BTC-USD-SWAP",
  px: "35000",
  sz: "0.888"
});
</code></pre>


# Trading Data

Documentation on interacting with a variety of OKX's Trading Data API functions through the PENDAX JavaScript SDK.

The API endpoints of `Trading Data` do not require authentication.

## Trading Data

### Get Support Coin

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-support-coin>
{% endhint %}

#### Function name:

```javascript
getSupportCoin()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSupportCoin(exchange) {
    try {
        let result = await exchange.getSupportCoin();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSupportCoin(myOkxAccount)
```

### Get Taker Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-volume>
{% endhint %}

#### Function name:

```javascript
getTakerVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerVolume(exchange) {
    try {
        let result = await exchange.getTakerVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerVolume(myOkxAccount, 
{
    ccy: "BTC",
    instType: "SPOT"
})
```

### Get Margin Lending Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-margin-lending-ratio>
{% endhint %}

#### Function name:

```javascript
getMarginLendingRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMarginLendingRatio(exchange) {
    try {
        let result = await exchange.getMarginLendingRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarginLendingRatio(myOkxAccount, 
{
        ccy: "BTC"
})
```

### Get Long/Short Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-long-short-ratio>
{% endhint %}

#### Function name:

```javascript
getLongShortRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getLongShortRatio(exchange) {
    try {
        let result = await exchange.getLongShortRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLongShortRatio(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Contracts Open Interest and Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-contracts-open-interest-and-volume>
{% endhint %}

#### Function name:

```javascript
getContractsOiAndVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getContractsOiAndVolume(exchange) {
    try {
        let result = await exchange.getContractsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getContractsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Options Open Interest and Volume

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-options-open-interest-and-volume>
{% endhint %}

#### Function name:

```javascript
getOptionsOiAndVolume()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOptionsOiAndVolume(exchange) {
    try {
        let result = await exchange.getOptionsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOptionsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Put/Call Ratio

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-put-call-ratio>
{% endhint %}

#### Function name:

```javascript
getPutCallRatio()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPutCallRatio(exchange) {
    try {
        let result = await exchange.getPutCallRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPutCallRatio(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Open Interest and Volume (expiry)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-expiry>
{% endhint %}

#### Function name:

```javascript
getOiAndVolumeExpiry()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeExpiry(exchange) {
    try {
        let result = await exchange.getOiAndVolumeExpiry();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeExpiry(myOkxAccount, 
{
    ccy: "BTC"
})
```

### Get Open Interest and Volume (strike)

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-strike>
{% endhint %}

#### Function name:

```javascript
getOiAndVolumeStrike()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeStrike(exchange) {
    try {
        let result = await exchange.getOiAndVolumeStrikegetOiAndVolumeStrike();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeStrike(myOkxAccount, 
{
    ccy: "BTC",
    expTime: "<get example>"
})
```

### Get Taker Flow

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-flow>
{% endhint %}

#### Function name:

```javascript
getTakerFlow()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerFlow(exchange) {
    try {
        let result = await exchange.getTakerFlow();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerFlow(myOkxAccount, 
{
    ccy: "BTC"
})
```


# Bitget Functions

Documentation for interacting with Bitget functions and API endpoints through the PENDAX Javascript SDK.

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let bitget_exchange = createExchange({
  exchange: "bitget",
  key: "key",
  secret: "secret",
  passphrase: "passphrase",
  authenticate: true,
  label: "bitget",
});
```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myBitgetAccount = createExchange({
  exchange: "bitget",
  authenticate: false,
  label: "bitget",
});
```

{% hint style="warning" %}
These documents are under development and will be updated shortly with all finalized functions
{% endhint %}

## All Available Bitget Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% hint style="info" %}
Bitget SPOT & FUTURES markets functions are split into two different sections of the documentation. Please ensure you are trying to interact with the right section when implementing functions.
{% endhint %}

### Bitget SPOT Market Functions

Documented PENDAX functions applicable to Bitget spot markets.

{% content-ref url="/pages/Yk8EAsXpKVS2SAN6sVZ1" %}
[Public (Spot)](/pendax/using-pendax-sdk/bitget-functions/public-spot)
{% endcontent-ref %}

{% content-ref url="/pages/CWqAFkRDIvaBmT2Cuu55" %}
[Market (Spot)](/pendax/using-pendax-sdk/bitget-functions/market-spot)
{% endcontent-ref %}

{% content-ref url="/pages/GjrzfD2Or1E8U43d0NuQ" %}
[Wallet (Spot)](/pendax/using-pendax-sdk/bitget-functions/wallet-spot)
{% endcontent-ref %}

{% content-ref url="/pages/2eQbfSibWVcuFzhepRkO" %}
[Account (Spot)](/pendax/using-pendax-sdk/bitget-functions/account-spot)
{% endcontent-ref %}

{% content-ref url="/pages/YxoxNBTTbq1NsA5H3ZRf" %}
[Trade (Spot)](/pendax/using-pendax-sdk/bitget-functions/trade-spot)
{% endcontent-ref %}

### Bitget FUTURES Market Functions

Documented PENDAX functions applicable to Bitget futures markets.

{% content-ref url="/pages/GvtXk76o1h8F3FMZKpoR" %}
[Account (Futures)](/pendax/using-pendax-sdk/bitget-functions/account-futures)
{% endcontent-ref %}

{% content-ref url="/pages/8ygoeGBeBFoQLsh9IHoo" %}
[Trade (Futures)](/pendax/using-pendax-sdk/bitget-functions/trade-futures)
{% endcontent-ref %}

{% content-ref url="/pages/XnGPcbXaXo2RjYYte5Kq" %}
[Market (Futures)](/pendax/using-pendax-sdk/bitget-functions/market-futures)
{% endcontent-ref %}


# Public (Spot)

Documentation on interacting with Bitget's Spot Market Public Data API functions through the PENDAX Javascript SDK.

### Get Server Time <a href="#get-server-time" id="get-server-time"></a>

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-server-time>
{% endhint %}

#### Function name:

```javascript
getServerTime()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getServerTime(exchange) {
    try {
        let result = await exchange.getServerTime();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getServerTime(myBitgetAccount)
```

### Get Coin List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-coin-list>
{% endhint %}

#### Function name:

```javascript
getCoinList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCoinList(exchange) {
    try {
        let result = await exchange.getCoinList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCoinList(myBitgetAccount)
```

### Get Symbols

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-symbols>
{% endhint %}

#### Function name:

```javascript
getSymbols()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSymbols(exchange) {
    try {
        let result = await exchange.getSymbols();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSymbols(myBitgetAccount)
```

### Get Single Symbol

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-single-symbol>
{% endhint %}

#### Function name:

```javascript
getSingleSymbol()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSingleSymbol(exchange) {
    try {
        let result = await exchange.getSingleSymbol();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSingleSymbol(myBitgetAccount, 
{
    symbol: "BTCUSDT_SPBL"
})
```


# Market (Spot)

Documentation on interacting with Bitget's Spot Market Data API functions through the PENDAX Javascript SDK.

### Get Single Ticker <a href="#get-single-ticker" id="get-single-ticker"></a>

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-single-ticker>
{% endhint %}

#### Function name:

```javascript
getSingleTicker()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSingleTicker(exchange) {
    try {
        let result = await exchange.getSingleTicker();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSingleTicker(myBitgetAccount, 
    {
        symbol: "BTCUSDT_SPBL"
    })
```

### Get All Tickers

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-all-tickers>
{% endhint %}

#### Function name:

```javascript
getAllTickers()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAllTickers(exchange) {
    try {
        let result = await exchange.getAllTickers();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllTickers(myBitgetAccount)
```

### Get Market Trades

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-market-trades>
{% endhint %}

#### Function name:

```javascript
getMarketTrades()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getMarketTrades(exchange) {
    try {
        let result = await exchange.getMarketTrades();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarketTrades(myBitgetAccount, 
    {
        symbol: "BTCUSDT_SPBL"
    })

```

### Get Candle Data

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-candle-data>
{% endhint %}

#### Function name:

```javascript
getCandleData()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCandleData(exchange) {
    try {
        let result = await exchange.getCandleData();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandleData(myBitgetAccount, 
    {
        symbol: "BTCUSDT_SPBL",
        period: "1min",
    })
```

### Get Depth

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-depth>
{% endhint %}

#### Function name:

```javascript
getServerTime()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getDepth(exchange) {
    try {
        let result = await exchange.getDepth();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

    const result = await getDepth(myBitgetAccount , {
      symbol: "BTCUSDT_SPBL",
      type: "step0",
    });
```


# Wallet (Spot)

Documentation on interacting with Bitget's Spot Market Wallet API functions through the PENDAX Javascript SDK.

All Spot Market Wallet API endpoints require authentication. Please create Bitget API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post.

### Transfer

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#transfer>
{% endhint %}

#### Function name:

```javascript
spotWalletTransfer()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function spotWalletTransfer(exchange) {
    try {
        let result = await exchange.spotWalletTransfer();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await spotWalletTransfer(myBitgetAccount, 
    {
        fromType: "spot",
        toType: "mix_usdt",
        amount: "0.1",
        coin: "USDT"
    })
```

### Sub Transfer

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#sub-transfer>
{% endhint %}

#### Function name:

```javascript
subaccountTransfer()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function subaccountTransfer(exchange, options) {
    try {
        let result = await exchange.subaccountTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await subaccountTransfer(myBitgetAccount, {
 fromType: "spot",
 toType: "spot",
 amount: "5",
 coin: "USDT",
 clientOid: "12345",
 fromUserId: "1",
 toUserId: "2"});
```

### Get Coin Address

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-coin-address>
{% endhint %}

#### Function name:

```javascript
getCoinDepositAddress()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCoinDepositAddress(exchange, options) {
    try {
        let result = await exchange.getCoinDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCoinDepositAddress(myBitgetAccount, 
    {
        coin: "USDT",
        chain: "trc20"
    });
```

### Withdraw

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#withdraw>
{% endhint %}

{% hint style="warning" %}
This function is under construction
{% endhint %}

#### Function name:

```javascript
spotWalletWithdraw()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function spotWalletWithdraw(exchange) {
    try {
        let result = await exchange.spotWalletWithdraw();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await spotWalletWithdraw(myBitgetAccount)
```

### Inner Withdraw

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#inner-withdraw>
{% endhint %}

#### Function name:

```javascript
innerWithdraw()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function innerWithdraw(exchange) {
    try {
        let result = await exchange.innerWithdraw();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await innerWithdraw(myBitgetAccount, {
    coin: "USDT",
    toUid: "234567",
    amount: "5"
  });
```

### Get Withdraw List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-withdraw-list>
{% endhint %}

#### Function name:

```javascript
getWithdrawalList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getWithdrawalList(exchange) {
    try {
        let result = await exchange.getWithdrawalList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getWithdrawalList(myBitgetAccount, {
    coin: "USDT",
    startTime: "1659036670000",
    endTime: "1659076670000",
    pageNo: "1",
    pageSize: "20"
    });
```

### Get Deposit List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-deposit-list>
{% endhint %}

#### Function name:

```javascript
getDepositList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getDepositList(exchange, options) {
    try {
        let result = await exchange.getDepositList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDepositList(myBitgetAccount, {
    coin: "USDT",
    startTime: "1659036670000",
    endTime: "1659076670000",
    pageNo: "1",
    pageSize: "20"
    })
```


# Account (Spot)

Documentation on interacting with Bitget's Spot Market Account Data API functions through the PENDAX Javascript SDK.

All Spot Market Account & Account Data API endpoints require authentication. Please create Bitget API keys to interact with these functions successfully.

### Get ApiKey Info

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-apikey-info>
{% endhint %}

#### Function name:

```javascript
getApiKeyInfo()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getApiKeyInfo(exchange) {
    try {
        let result = await exchange.getApiKeyInfo();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getApiKeyInfo(myBitgetAccount)
```

### Get Account Assets

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

[https://bitgetlimited.github.io/apidoc/en/spot/#get-account-asset](https://bitgetlimited.github.io/apidoc/en/spot/#get-account-assets)
{% endhint %}

#### Function name:

```javascript
getAccountAssets()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAccountAssets(exchange) {
    try {
        let result = await exchange.getAccountAssets();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountAssets(myBitgetAccount)
```

### Get sub Account Spot Assets

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-sub-account-spot-assets>
{% endhint %}

#### Function name:

```javascript
getSubaccountSpotAssets()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubaccountSpotAssets(exchange) {
    try {
        let result = await exchange.getSubaccountSpotAssets();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountSpotAssets(myBitgetAccount)
```

### Get Bills

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-bills>
{% endhint %}

#### Function name:

```javascript
getBills()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getBills(exchange) {
    try {
        let result = await exchange.getBills();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBills(myBitgetAccount)
```

### Get Transfer List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-transfer-list>
{% endhint %}

#### Function name:

```javascript
getTransferList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTransferList(exchange) {
    try {
        let result = await exchange.getTransferList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTransferList(myBitgetAccount)
```


# Trade (Spot)

Documentation on interacting with Bitget's Spot Market Trading & Order API functions through the PENDAX Javascript SDK.

All Spot Market Trading & Order API endpoints require authentication. Please create Bitget API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post.

## Place Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#place-order>
{% endhint %}

#### Function name:

```javascript
placeOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placeOrder(exchange, options) {
    try {
        let result = await exchange.placeOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeOrder(myBitgetAccount, 
    {
     symbol: 'BTCUSDT_SPBL',
     side: 'buy',
     orderType: 'market',
     force: 'normal',
     quantity: '10'
   });
```

### Batch Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#batch-order>
{% endhint %}

#### Function name:

```javascript
placeBatchOrder()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placeBatchOrder(exchange) {
    try {
        let result = await exchange.placeBatchOrder();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}
const result = await placeBatchOrder(myBitgetAccount, 
    {
    symbol: 'BTCUSDT_SPBL',
    orderList: [{
     symbol: 'BTCUSDT_SPBL',
     side: 'buy',
     orderType: 'market',
     force: 'normal',
     quantity: '10'
    },
  {
     symbol: 'BTCUSDT_SPBL',
     side: 'buy',
     orderType: 'market',
     force: 'normal',
     quantity: '20'
  }]
  });
```

### Cancel Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#cancel-order>
{% endhint %}

#### Function name:

```javascript
cancelOrder()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelOrder(exchange) {
    try {
        let result = await exchange.getServerTime();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelOrder(bitget_exchange, 
    {
      symbol:'BTCUSDT_SPBL',
      orderId:'1002321893754589184'
    })
```

### Cancel Order in Batch (single instruments)

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#cancel-order-in-batch-single-instruments>
{% endhint %}

#### Function name:

```javascript
cancelBatchOrders()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelBatchOrders(exchange) {
    try {
        let result = await exchange.cancelBatchOrders();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelBatchOrders(bitget_exchange, {
    symbol: 'BTCUSDT_SPBL',
    orderIds: [
      '111111111111111111',
      '222222222222222222'
    ]
  });
```

### Get Order Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-order-details>
{% endhint %}

#### Function name:

```javascript
getOrderDetails()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrderDetails(exchange) {
    try {
        let result = await exchange.getServerTime();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderDetails(myBitgetAccount
    {
        symbol:'BTCUSDT_SPBL',
        orderId:'1002341348069003264'
    }
);
```

### Get Order List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-order-list>
{% endhint %}

#### Function name:

```javascript
getOrderList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrderList(exchange) {
    try {
        let result = await exchange.getOrderList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderList(bitget_exchange, {symbol: ""});
```

### Get Order History

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-order-history>
{% endhint %}

#### Function name:

```javascript
getOrderHistory()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrderHistory(exchange) {
    try {
        let result = await exchange.getOrderHistory();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderHistory(myBitgetAccount, 
    {
        symbol: 'BTCUSDT_SPBL'
    }
);
```

### Get Transaction Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-transaction-details>
{% endhint %}

#### Function name:

```javascript
getTransactionDetails()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTransactionDetails(exchange) {
    try {
        let result = await exchange.getTransactionDetails();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTransactionDetails(myBitgetAccount, 
    {
        "symbol: BTCUSDT_SPBL"
    });
```

### Place Plan Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#place-plan-order>
{% endhint %}

#### Function name:

```javascript
placePlanOrder()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placePlanOrder(exchange) {
    try {
        let result = await exchange.placePlanOrder();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placePlanOrder(myBitgetAccount, 
    {
        symbol: "BTCUSDT_SPBL",
        side: "buy",
        triggerPrice: "20000",
        size: "20",
        triggerType: "market_price",
        orderType: "market"       
    });
```

### Modify Plan Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#modify-plan-order>
{% endhint %}

#### Function name:

```javascript
modifyPlanOrder()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifyPlanOrder(exchange) {
    try {
        let result = await exchange.modifyPlanOrder();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyPlanOrder(myBitgetAccount 
    {
        orderId: "123456",
        triggerPrice: "19999",
        orderType: "market"
    });
```

### Cancel Plan Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#cancel-plan-order>
{% endhint %}

#### Function name:

```javascript
cancelPlanOrder()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelPlanOrder(exchange) {
    try {
        let result = await exchange.cancelPlanOrder();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelPlanOrder(myBitgetAccount,
    {
        orderId: "123456"
    })
```

### Get Current Plan Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-current-plan-orders>
{% endhint %}

#### Function name:

```javascript
getCurrentPlanOrders()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCurrentPlanOrders(exchange) {
    try {
        let result = await exchange.getCurrentPlanOrders();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCurrentPlanOrders(myBitgetAccount,
{symbol: "BTCUSDT_SPBL"});
```

### Get History Plan Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/spot/#get-history-plan-orders>
{% endhint %}

#### Function name:

```javascript
getHistoryPlanOrders()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getHistoryPlanOrders(exchange) {
    try {
        let result = await exchange.getHistoryPlanOrders();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getHistoryPlanOrders(myBitgetAccount,
    {
        symbol: "BTCUSDT_SPBL",
        pageSize: "20",
        startTime: "1667889483000",
        endTime: "1668134732000"
    });
```


# Market (Futures)

Documentation on interacting with Bitget's Futures Market Data API functions through the PENDAX Javascript SDK.

## Get All Symbols

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-all-symbols>
{% endhint %}

#### Function name:

```javascript
getAllFuturesSymbols(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt",
      testnet: "false"
});

async function getAllFuturesSymbols(exchange, options) {
    try {
        let result = await exchange.getAllFuturesSymbols(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllFuturesSymbols(myBitgetAccount, {productType: "umcbl"})
```

## Get Depth

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-depth>
{% endhint %}

#### Function name:

```javascript
getDepthFutures(options)
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getDepthFutures(exchange, options) {
    try {
        let result = await exchange.getDepthFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDepthFutures(myBitgetAccount,
<strong>{ symbol: "BTCUSDT_UMCBL" });
</strong></code></pre>

## Get Single Symbol Tracker

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-single-symbol-ticker>
{% endhint %}

#### Function name:

```javascript
getSingleTickerFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSingleTickerFutures(exchange) {
    try {
        let result = await exchange.getSingleTickerFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSingleTickerFutures(myBitgetAccount, 
{ symbol: "BTCUSDT_UMCBL" });
```

## Get All Symbol Tracker

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-all-symbol-ticker>
{% endhint %}

#### Function name:

```javascript
getAllTickersFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAllTickersFutures(exchange) {
    try {
        let result = await exchange.getAllTickersFutures();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllTickersFutures(myBitgetAccount 
    {
        productType: umcbl
    });
```

## Get Fills

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-fills>
{% endhint %}

#### Function name:

```javascript
getFillsFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getFillsFutures(exchange) {
    try {
        let result = await exchange.getFillsFutures();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFillsFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Candle Data

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-candle-data>
{% endhint %}

#### Function name:

```javascript
getCandlesFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCandlesFutures(exchange, options) {
    try {
        let result = await exchange.getCandlesFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCandlesFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        granularity: "300",
        startTime: "1659406928000",
        endTime: "1659410528000"
    });
```

## Get Symbol Index Price

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-index-price>
{% endhint %}

#### Function name:

```javascript
getSymbolIndexPriceFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSymbolIndexPriceFutures(exchange, options) {
    try {
        let result = await exchange.getSymbolIndexPriceFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSymbolIndexPriceFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Symbol Next Funding Time

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-next-funding-time>
{% endhint %}

#### Function name:

```javascript
getNextFundingTimeFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getNextFundingTimeFutures(exchange, options) {
    try {
        let result = await exchange.getNextFundingTimeFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getNextFundingTimeFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get History Funding Rate

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-history-funding-rate>
{% endhint %}

#### Function name:

```javascript
getHistoricFundingRateFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getHistoricFundingRateFutures(exchange, options) {
    try {
        let result = await exchange.getHistoricFundingRateFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getHistoricFundingRateFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Current Funding Rate

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-current-funding-rate>
{% endhint %}

#### Function name:

```javascript
getCurrentFundingRateFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCurrentFundingRateFutures(exchange, options) {
    try {
        let result = await exchange.getCurrentFundingRateFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCurrentFundingRateFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Open Interest

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-open-interest>
{% endhint %}

#### Function name:

```javascript
getOpenInterestFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOpenInterestFutures(exchange, options) {
    try {
        let result = await exchange.getOpenInterestFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenInterestFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Symbol Mark Price

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-mark-price>
{% endhint %}

#### Function name:

```javascript
getMarkPriceFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getMarkPriceFutures(exchange, options) {
    try {
        let result = await exchange.getMarkPriceFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarkPriceFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get Symbol Leverage

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-leverage>
{% endhint %}

#### Function name:

```javascript
getSymbolLeverageFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSymbolLeverageFutures(exchange, options) {
    try {
        let result = await exchange.getSymbolLeverageFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSymbolLeverageFutures(myBitgetAccount, 
    { 
        symbol: "BTCUSDT_UMCBL"
    });
```


# Account (Futures)

Documentation on interacting with Bitget's Futures Market Account API functions through the PENDAX Javascript SDK.

## Get Single Account

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-single-account>
{% endhint %}

#### Function name:

```javascript
getSingleAccountFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt",
      testnet: "false"
});

async function getSingleAccountFutures(exchange, options) {
    try {
        let result = await exchange.getSingleAccountFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSingleAccountFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT"
    });
```

## Get Account List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-account-list>
{% endhint %}

#### Function name:

```javascript
getAccountListFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAccountListFutures(exchange, options) {
    try {
        let result = await exchange.getAccountListFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountListFutures(myBitgetAccount, 
    {
        productType: "umcbl"
    });
```

## Get Sub-Account Contract Assets

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-sub-account-contract-assets>
{% endhint %}

#### Function name:

```javascript
getSubaccountContractAssets(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubaccountContractAssets(exchange, options) {
    try {
        let result = await exchange.getSubaccountContractAssets(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountContractAssets(myBitgetAccount, 
    {
        productType: "umcbl"
    });
```

## Get Open Count

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-open-count>
{% endhint %}

#### Function name:

```javascript
getOpenCountFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOpenCountFutures(exchange, options) {
    try {
        let result = await exchange.getOpenCountFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenCountFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        openPrice: "23189.5",
        leverage: "20",
        openAmount:"5000"
    });
```

## Change Leverage

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#change-leverage>
{% endhint %}

#### Function name:

```javascript
setLeverage(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverage(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        leverage: "2"
    });
```

## Change Margin

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#change-margin>
{% endhint %}

#### Function name:

```javascript
getApiKeyInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function changeMargin(exchange, options) {
    try {
        let result = await exchange.changeMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await changeMargin(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        amount: "-10"
    });
```

## Change Margin Mode

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#change-margin-mode>
{% endhint %}

#### Function name:

```javascript
setMarginMode(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function setMarginMode(exchange, options) {
    try {
        let result = await exchange.setMarginMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setMarginMode(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        marginMode: "crossed"
    });
```

## Change Hold Mode

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#change-hold-mode>
{% endhint %}

#### Function name:

```javascript
changeHoldMode(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function changeHoldMode(exchange, options) {
    try {
        let result = await exchange.changeHoldMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await changeHoldMode(myBitgetAccount, 
    {
        productType: "umcbl",
        holdMode: "double_hold"
    });
```

## Get Symbol Position

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-position>
{% endhint %}

#### Function name:

```javascript
getSymbolPosition(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSymbolPosition(exchange, options) {
    try {
        let result = await exchange.getSymbolPosition(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSymbolPosition(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT"
    });
```

## Get All Position

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-all-position>
{% endhint %}

#### Function name:

```javascript
getAllPositionsFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAllPositionsFutures(exchange, options) {
    try {
        let result = await exchange.getAllPositionsFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllPositionsFutures(myBitgetAccount, 
    {
        productType: "umcbl",
        marginCoin: "USDT"
    });
```

## Get Account Bill

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-account-bill>
{% endhint %}

#### Function name:

```javascript
getAccountBill(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAccountBill(exchange, options) {
    try {
        let result = await exchange.getAccountBill(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountBill(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL", 
        marginCoin: "USDT",
        startTime: "1659403328000",
        endTime: "1659406928000",
        pageSize: "20"
    });
```

## Get Business Account Bill

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-business-account-bill>
{% endhint %}

#### Function name:

```javascript
getBusinessAccountBill(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getBusinessAccountBill(exchange, options) {
    try {
        let result = await exchange.getBusinessAccountBill(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBusinessAccountBill(myBitgetAccount, 
    {
        productType: "umcbl",
        startTime: "1659403328000",
        endTime: "1659406928000",
        pageSize: "20"
    });
```


# Trade (Futures)

Documentation on interacting with Bitget's Futures Trading & Order API functions through the PENDAX Javascript SDK.

## Place Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#place-order>
{% endhint %}

#### Function name:

```javascript
placeOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt",
      testnet: "false"
});

async function placeOrderFutures(exchange, options) {
    try {
        let result = await exchange.placeOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeOrderFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        size: "0.01",
        side: "open_long",
        orderType: "market"
    });
```

## Batch Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#batch-order>
{% endhint %}

#### Function name:

```javascript
placeBatchOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placeBatchOrderFutures(exchange, options) {
    try {
        let result = await exchange.placeBatchOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeBatchOrderFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderDataList:[
      {
          size: "0.003",
          side: "open_long",
          orderType: "limit",
          price: "10000"

      },
      {
          size: "0.004",
          side: "open_long",
          orderType: "limit",
          price: "10000"
      }]
    });
```

## Cancel Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#cancel-order>
{% endhint %}

#### Function name:

```javascript
cancelOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelOrderFutures(exchange, options) {
    try {
        let result = await exchange.cancelOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelOrderFutures(myBitgetAccount
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderId: "1009818807293329409"
    });
```

## Batch Cancel Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#batch-cancel-order>
{% endhint %}

#### Function name:

```javascript
cancelBatchOrdersFutures(options)
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelBatchOrdersFutures(exchange, options) {
    try {
        let result = await exchange.cancelBatchOrdersFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelBatchOrdersFutures(myBitgetAccount,
<strong>    {
</strong>      symbol: "BTCUSDT_UMCBL",
      marginCoin: "USDT",
      orderIds:["1011271303899529219", "1011271303903723526"]
    });
</code></pre>

## Cancel All Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-order>
{% endhint %}

#### Function name:

```javascript
cancelAllOrdersFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelAllOrdersFutures(exchange, options) {
    try {
        let result = await exchange.cancelAllOrdersFutures(optionsoptions);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelAllOrdersFutures(myBitgetAccount,
    {
        productType: "umcbl",
        marginCoin: "USDT"
    });
```

## Get Open Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-open-order>
{% endhint %}

#### Function name:

```javascript
getOpenOrdersFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOpenOrdersFutures(exchange, options) {
    try {
        let result = await exchange.getOpenOrdersFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenOrdersFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get All Open Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-all-open-order>
{% endhint %}

#### Function name:

```javascript
getAllOpenOrdersFutures()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getAllOpenOrdersFutures(exchange, options) {
    try {
        let result = await exchange.getAllOpenOrdersFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllOpenOrdersFutures(myBitgetAccount,
    {
        productType: "umcbl",
        marginCoin: "USDT"
    });
```

## Get History Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-history-orders>
{% endhint %}

#### Function name:

```javascript
getOrdersHistoryFutures(options)
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

<strong>async function getOrdersHistoryFutures(exchange, options) {
</strong>    try {
        let result = await exchange.getOrdersHistoryFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrdersHistoryFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        startTime: "1659403328000", 
        endTime: "1659410528000",
        pageSize: "20"
    });
</code></pre>

## Get ProductType History Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-producttype-history-orders>
{% endhint %}

#### Function name:

```javascript
getOrdersHistoryByProductTypeFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrdersHistoryByProductTypeFutures(exchange, options) {
    try {
        let result = await exchange.getOrdersHistoryByProductTypeFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrdersHistoryByProductTypeFutures(myBitgetAccount,
    {
        productType: "umcbl",
        startTime: "1659403328000", 
        endTime: "1659410528000",
        pageSize: "20"
    });
```

## Get Order Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-order-details>
{% endhint %}

#### Function name:

```javascript
getOrderDetailsFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrderDetailsFutures(exchange, options) {
    try {
        let result = await exchange.getOrderDetailsFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderDetailsFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        orderId: "12345"
    });
```

## Get Order Fill Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-order-fill-detail>
{% endhint %}

#### Function name:

```javascript
getOrderFillDetailFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getOrderFillDetailFutures(exchange, options) {
    try {
        let result = await exchange.getOrderFillDetailFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderFillDetailFutures(myBitgetAccount,
    {
      symbol: "BTCUSDT_UMCBL",
      startTime: "1659403328000", 
      orderId: "1010182528922435618"
  });
```

## Get ProductType Order Fill Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-producttype-order-fill-detail>
{% endhint %}

#### Function name:

```javascript
getProductTypeOrderFillDetailFutures(options)
```

#### Usage:&#x20;

{% hint style="warning" %}
API requires either endTime and startTime or lastEndId as parameters
{% endhint %}

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getProductTypeOrderFillDetailFutures(exchange, options) {
    try {
        let result = await exchange.getProductTypeOrderFillDetailFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getProductTypeOrderFillDetailFutures(myBitgetAccount,
    {
        productType: "umcbl",
        startTime: "0",
        endTime: "1676832767000"
    });
```

## Place Plan Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#place-plan-order>
{% endhint %}

#### Function name:

```javascript
placePlanOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placePlanOrderFutures(exchange, options) {
    try {
        let result = await exchange.placePlanOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placePlanOrderFutures(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        size: "0.05",
        side: "open_long",
        orderType: "market",
        triggerPrice: "22000",
        triggerType: "market_price"
    });
```

## Modify Plan Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#modify-plan-order>
{% endhint %}

#### Function name:

```javascript
modifyPlanOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifyPlanOrderFutures(exchange, options) {
    try {
        let result = await exchange.modifyPlanOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyPlanOrderFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderId: "12345",
        side: "open_long",
        orderType: "market",
        triggerPrice: "21000",
        triggerType: "market_price"
    });
```

## Modify Plan Order TPSL

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#modify-plan-order-tpsl>
{% endhint %}

#### Function name:

```javascript
modifyPlanOrderTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifyPlanOrderTpslFutures(exchange, options) {
    try {
        let result = await exchange.modifyPlanOrderTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyPlanOrderTpslFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderId: "12345"
    });
```

## Place Stop Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#place-stop-order>
{% endhint %}

#### Function name:

```javascript
placeStopOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placeStopOrderFutures(exchange, options) {
    try {
        let result = await exchange.placeStopOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeStopOrderFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        size: "0.001",
        planType: "profit_plan",
        triggerPrice:"23555.5",
        holdSide:"long"
    });  
```

## Place Trailing Stop Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#place-trailing-stop-order>
{% endhint %}

{% hint style="warning" %}
This function is under construction
{% endhint %}

#### Function name:

```javascript
placeTrailingStopOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placeTrailingStopOrderFutures(exchange, options) {
    try {
        let result = await exchange.placeTrailingStopOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeTrailingStopOrderFutures(myBitgetAccount,
    {
      symbol: "BTCUSDT_UMCBL",
      marginCoin: "USDT",
      triggerPrice:"22000",
      holdSide: "long",
      rangeRate: "1"
  });  
```

## Place Position TPSL

{% hint style="warning" %}
This Function is currently under construction
{% endhint %}

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#place-position-tpsl>
{% endhint %}

#### Function name:

```javascript
placePositionTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function placePositionTpslFutures(exchange, options) {
    try {
        let result = await exchange.placePositionTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placePositionTpslFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        planType: "pos_profit",
        triggerPrice:"24720",
        holdSide:"long"
    });
```

## Modify Stop Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#modify-stop-order>
{% endhint %}

#### Function name:

```javascript
modifyStopOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifyStopOrderFutures(exchange, options) {
    try {
        let result = await exchange.modifyStopOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyStopOrderFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderId: "1010239532700766209",
        planType: "pos_profit",
        triggerPrice:"24620",
        holdSide:"long"
    });  
```

## Cancel Plan Order TPSL

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#cancel-plan-order-tpsl>
{% endhint %}

#### Function name:

```javascript
cancelPlanOrderTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelPlanOrderTpslFutures(exchange, options) {
    try {
        let result = await exchange.cancelPlanOrderTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelPlanOrderTpslFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        marginCoin: "USDT",
        orderId: "1010239532700766209",
        planType: "pos_profit"
        
    });  
```

## Cancel All Trigger Order TPSL

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-trigger-order-tpsl>
{% endhint %}

#### Function name:

```javascript
cancelAllTriggerOrdersTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function cancelAllTriggerOrdersTpslFutures(exchange, options) {
    try {
        let result = await exchange.cancelAllTriggerOrdersTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelAllTriggerOrdersTpslFutures(myBitgetAccount,
    {
        productType: "umcbl",
        planType: "pos_profit"
        
    });  
```

## Get Plan Order TPSL List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-plan-order-tpsl-list>
{% endhint %}

#### Function name:

```javascript
getPlanOrderListTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getPlanOrderListTpslFutures(exchange, options) {
    try {
        let result = await exchange.getPlanOrderListTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPlanOrderListTpslFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL"
    });
```

## Get History Plan Orders TPSL

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-history-plan-orders-tpsl>
{% endhint %}

#### Function name:

```javascript
getHistoryPlanOrdersTpslFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getHistoryPlanOrdersTpslFutures(exchange, options) {
    try {
        let result = await exchange.getHistoryPlanOrdersTpslFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getHistoryPlanOrdersTpslFutures(myBitgetAccount,
    {
        symbol: "BTCUSDT_UMCBL",
        startTime: "1659403328000", 
        endTime: "1659410528000",
        pageSize: "20"
    });
```


# CopyTrade (Futures)

{% hint style="danger" %}
This section is under construction. Some functions may not work correctly.
{% endhint %}

## Get Trader Open Order

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-open-order>
{% endhint %}

#### Function name:

```javascript
getTraderOpenOrderCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderOpenOrderCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderOpenOrderCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderOpenOrderCopyTrade(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        productType: "umcbl",
        pageSize: "20",
        pageNo: "1"
    });
```

## Get Follower Open Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-follower-open-orders>
{% endhint %}

#### Function name:

```javascript
getFollowersOpenOrderCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getFollowersOpenOrderCopyTrade(exchange, options) {
    try {
        let result = await exchange.getFollowersOpenOrderCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFollowersOpenOrderCopyTrade(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        productType: "umcbl",
        pageSize: "20",
        pageNo: "1"
    });
```

## Get Follower History Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-follower-history-orders>
{% endhint %}

#### Function name:

```javascript
getFollowerHistoryOrdersCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getFollowerHistoryOrdersCopyTrade(exchange, options) {
    try {
        let result = await exchange.getFollowerHistoryOrdersCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFollowerHistoryOrdersCopyTrade(myBitgetAccount, 
    {
        startTime: "1668073994000",
        endTime: "1668073994206",
        pageSize: "20",
        pageNo: "1"
    });
```

## Trader Close Position

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#trader-close-position>
{% endhint %}

#### Function name:

```javascript
traderClosePositionCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function traderClosePositionCopyTrade(exchange, options) {
    try {
        let result = await exchange.traderClosePositionCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await traderClosePositionCopyTrade(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        trackingNo: "6258224712558517"
    });
```

## Trader Modify TPSL

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#trader-modify-tpsl>
{% endhint %}

#### Function name:

```javascript
traderModifyTsplCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function traderModifyTsplCopyTrade(exchange, options) {
    try {
        let result = await exchange.traderModifyTsplCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await traderModifyTsplCopyTrade(myBitgetAccount, 
    {
        symbol: "BTCUSDT_UMCBL",
        trackingNo: "6258224712558517",
        stopProfitPrice:"24123.5",
        stopLossPrice:"21487.5"
    });
```

## Get Traders History Orders

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-traders-history-orders>
{% endhint %}

#### Function name:

```javascript
getTradersHistoryOrdersCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTradersHistoryOrdersCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTradersHistoryOrdersCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTradersHistoryOrdersCopyTrade(myBitgetAccount, 
    {
        startTime: "1668073994000",
        endTime: "1668073994206",
        pageSize: "20",
        pageNo: "1"
    });
```

## Get Trader Profit Summary

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-profit-summary>
{% endhint %}

#### Function name:

```javascript
getTraderProfitSummaryCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderProfitSummaryCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderProfitSummaryCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderProfitSummaryCopyTrade(myBitgetAccount);
```

## Get Trader History Profit Summary (currency)

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-history-profit-summary-according-to-settlement-currency>
{% endhint %}

#### Function name:

```javascript
getTraderHistoryProfitSummaryCurrencyCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderHistoryProfitSummaryCurrencyCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderHistoryProfitSummaryCurrencyCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderHistoryProfitSummaryCurrencyCopyTrade(myBitgetAccount);
```

## Get Trader History Profit Summary (currency/date)

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-history-profit-summary-according-to-settlement-currency-and-date>
{% endhint %}

#### Function name:

```javascript
getTraderHistoryProfitSummaryByCurrencyAndDateCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderHistoryProfitSummaryByCurrencyAndDateCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderHistoryProfitSummaryByCurrencyAndDateCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderHistoryProfitSummaryByCurrencyAndDateCopyTrade(myBitgetAccount);
```

## Get Trader History Profit Detail

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-history-profit-detail>
{% endhint %}

#### Function name:

```javascript
getTraderHistoryProfitDetailCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderHistoryProfitDetailCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderHistoryProfitDetailCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderHistoryProfitDetailCopyTrade(myBitgetAccount, 
    {
        marginCoin: "USDT",
        date: "1627354109502",
        pageSize: "20",
        pageNo: "1"
    });
```

## Get Trader Profits Details

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-trader-profits-details>
{% endhint %}

#### Function name:

```javascript
getTraderProfitDetailsCopyTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getTraderProfitDetailsCopyTrade(exchange, options) {
    try {
        let result = await exchange.getTraderProfitDetailsCopyTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTraderProfitDetailsCopyTrade(myBitgetAccount, 
    {
        pageSize: "20",
        pageNo: "1"
    });
```

## Get CopyTrade Symbols

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#get-copytrade-symbols>
{% endhint %}

#### Function name:

```javascript
getCopyTradeSymbols(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getCopyTradeSymbols(exchange, options) {
    try {
        let result = await exchange.getCopyTradeSymbols(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCopyTradeSymbols(myBitgetAccount);
```

## Trader Change CopyTrade Symbol

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/mix/#trader-change-copytrade-symbol>
{% endhint %}

#### Function name:

```javascript
traderChangeCopyTradeSymbol(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function traderChangeCopyTradeSymbol(exchange, options) {
    try {
        let result = await exchange.traderChangeCopyTradeSymbol(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await traderChangeCopyTradeSymbol(myBitgetAccount);
```


# Sub Account Interface (Broker)

{% hint style="danger" %}
This section is under construction. Some functions may not work correctly.
{% endhint %}

## Get Broker Info&#x20;

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-broker-info>
{% endhint %}

#### Function name:

```javascript
getBrokerInfo()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getBrokerInfo(exchange) {
    try {
        let result = await exchange.getBrokerInfo();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBrokerInfo(myBitgetAccount);
```

## Create Sub Account

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#create-sub-account>
{% endhint %}

#### Function name:

```javascript
createSubaccount()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function createSubaccount(exchange) {
    try {
        let result = await exchange.createSubaccount();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createSubaccount(myBitgetAccount
```

## Get Sub List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-list>
{% endhint %}

#### Function name:

```javascript
getSubList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubList(exchange) {
    try {
        let result = await exchange.getSubList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubList(myBitgetAccount
```

## Modify Sub Account

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#modify-sub-account>
{% endhint %}

#### Function name:

```javascript
modifySubaccount()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifySubaccount(exchange) {
    try {
        let result = await exchange.modifySubaccount();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifySubaccount(myBitgetAccount
```

## Modify Sub Email

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#modify-sub-email>
{% endhint %}

#### Function name:

```javascript
modifySubaccountEmail()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifySubaccountEmail(exchange) {
    try {
        let result = await exchange.modifySubaccountEmail();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifySubaccountEmail(myBitgetAccount
```

## Get Sub Email

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-email>
{% endhint %}

#### Function name:

```javascript
getSubId()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubId(exchange) {
    try {
        let result = await exchange.getSubId();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubId(myBitgetAccount
```

## Get Sub Spot Assets

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-spot-assets>
{% endhint %}

#### Function name:

```javascript
getSubSpotAssets()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubSpotAssets(exchange) {
    try {
        let result = await exchange.getSubSpotAssets();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubSpotAssets(myBitgetAccount
```

## Get Sub Future Assets

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-future-assets>
{% endhint %}

#### Function name:

```javascript
getSubFuturesAssets()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubFuturesAssets(exchange) {
    try {
        let result = await exchange.getSubFuturesAssets();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubFuturesAssets(myBitgetAccount
```

## Get Sub Deposit Address

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-deposit-address-only-broker>
{% endhint %}

#### Function name:

```javascript
getSubDepositAddressBrokerOnly()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubDepositAddressBrokerOnly(exchange) {
    try {
        let result = await exchange.getSubDepositAddressBrokerOnly();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubDepositAddressBrokerOnly(myBitgetAccount
```

## Sub Withdrawal

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#sub-withdrawal-only-broker>
{% endhint %}

#### Function name:

```javascript
subWithdrawalBrokerOnly()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function subWithdrawalBrokerOnly(exchange) {
    try {
        let result = await exchange.subWithdrawalBrokerOnly();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await subWithdrawalBrokerOnly(myBitgetAccount
```

## Sub Deposit Auto Transfer

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#sub-deposit-auto-transfer-only-broker>
{% endhint %}

#### Function name:

```javascript
subDepositAutoTransferBrokerOnly()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function subDepositAutoTransferBrokerOnly(exchange) {
    try {
        let result = await exchange.subDepositAutoTransferBrokerOnly();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await subDepositAutoTransferBrokerOnly(myBitgetAccount
```


# Sub API Interface (Broker)

{% hint style="danger" %}
This section is under construction. Some functions may not work correctly.
{% endhint %}

## Create Sub ApiKey

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#create-sub-apikey-only-broker>
{% endhint %}

#### Function name:

```javascript
createSubApiKeyBrokerOnly()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function createSubApiKeyBrokerOnly(exchange) {
    try {
        let result = await exchange.createSubApiKeyBrokerOnly();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createSubApiKeyBrokerOnly(myBitgetAccount
```

## Get Sub ApiKey List

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#get-sub-apikey-list>
{% endhint %}

#### Function name:

```javascript
getSubApiKeyList()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function getSubApiKeyList(exchange) {
    try {
        let result = await exchange.getSubApiKeyList();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubApiKeyList(myBitgetAccount
```

## Modify Sub ApiKey

{% hint style="info" %}
Please refer to the official Bitget API Docs for the required parameters.

<https://bitgetlimited.github.io/apidoc/en/broker/#modify-sub-apikey-only-broker>
{% endhint %}

#### Function name:

```javascript
modifySubApiKeyBrokerOnly()
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myBitgetAccount = createExchange({
      exchange: "bitget",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bitget",
      marginType: "usdt"
});

async function modifySubApiKeyBrokerOnly(exchange) {
    try {
        let result = await exchange.modifySubApiKeyBrokerOnly();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifySubApiKeyBrokerOnly(myBitgetAccount
```


# ByBit Functions

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let bybit_exchange = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});


```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myBybitAccount= createExchange({
      exchange: "bybit",
      authenticate: "false",
      label: "bybit",
      testnet: "false"
});
```

{% hint style="warning" %}
These documents are under development and will be updated shortly with all finalized functions
{% endhint %}

## All Available ByBit Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% content-ref url="/pages/EDSmPJUax5VIe6AvJY7Y" %}
[Account](/pendax/using-pendax-sdk/bybit-functions/account)
{% endcontent-ref %}

{% content-ref url="/pages/deJPmu1Y5767ZBS0XKtw" %}
[Asset](/pendax/using-pendax-sdk/bybit-functions/asset)
{% endcontent-ref %}

{% content-ref url="/pages/Wynk94AUVIqZfmGu3FM2" %}
[Institutional Lending](/pendax/using-pendax-sdk/bybit-functions/institutional-lending)
{% endcontent-ref %}

{% content-ref url="/pages/zz4VPCjC8ZWGVN8rNjzi" %}
[Market](/pendax/using-pendax-sdk/bybit-functions/market)
{% endcontent-ref %}

{% content-ref url="/pages/rXkOa4HDnYLbPLwgSyd6" %}
[Position](/pendax/using-pendax-sdk/bybit-functions/position)
{% endcontent-ref %}

{% content-ref url="/pages/WlvU0l6ph60TMWxZVxBX" %}
[Spot Leverage Token](/pendax/using-pendax-sdk/bybit-functions/spot-leverage-token)
{% endcontent-ref %}

{% content-ref url="/pages/EOKNd1qW18jp6Zd8XFLR" %}
[Spot Margin Trade (Normal)](/pendax/using-pendax-sdk/bybit-functions/spot-margin-trade-normal)
{% endcontent-ref %}

{% content-ref url="/pages/2UbE1jZ8rPbqu6PLRIkk" %}
[Spot Margin Trade (UTA)](/pendax/using-pendax-sdk/bybit-functions/spot-margin-trade-uta)
{% endcontent-ref %}

{% content-ref url="/pages/AIJEcIqYdrV0XfKaB73e" %}
[Trading](/pendax/using-pendax-sdk/bybit-functions/trading)
{% endcontent-ref %}

{% content-ref url="/pages/39vUIEKOyYYpfAEW3uLX" %}
[User](/pendax/using-pendax-sdk/bybit-functions/user)
{% endcontent-ref %}


# Market

Documentation on interacting with ByBit's Market API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Kline

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/kline>
{% endhint %}

#### Function name:

```javascript
getKline(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getKline(exchange, options) {
    try {
        let result = await exchange.getKline(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getKline(myByBitAccount , 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       interval: '60'
     });
```

## Get Mark Price Kline

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/mark-kline>
{% endhint %}

#### Function name:

```javascript
getMarkPriceKline(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
       
      passphrase: "myPassphrase",
      label: "bybit",
      marginType: "usdt",
      testnet: "false"
});

async function getMarkPriceKline(exchange, options) {
    try {
        let result = await exchange.getMarkPriceKline(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarkPriceKline(myByBitAccount , 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       interval: '60'
     });
```

## Get Index Price Kleine

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/index-kline>
{% endhint %}

#### Function name:

```javascript
placeOrderFutures(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getKline(exchange, options) {
    try {
        let result = await exchange.getKline(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getKline(myByBitAccount , 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       interval: '60'
     });
```

## Get Premium Index Price Kline

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/preimum-index-kline>
{% endhint %}

#### Function name:

```javascript
getPremiumIndexPriceKline(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getPremiumIndexPriceKline(exchange, options) {
    try {
        let result = await exchange.getPremiumIndexPriceKline(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPremiumIndexPriceKline(myByBitAccount , 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       interval: '60'
     });
```

## Get Instruments Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/instrument>
{% endhint %}

#### Function name:

```javascript
getInstrumentsInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInstrumentsInfo(exchange, options) {
    try {
        let result = await exchange.getInstrumentsInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstrumentsInfo(myByBitAccount, 
    {
        category: 'linear'
    });
```

## Get Orderbook

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/orderbook>
{% endhint %}

#### Function name:

```javascript
getOrderbook(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getOrderbook(exchange, options) {
    try {
        let result = await exchange.getOrderbook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderbook(myByBitAccount, 
    {
        category: 'linear',
        symbol: 'BTCUSD'
    });
```

## Get Tickers

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/tickers>
{% endhint %}

#### Function name:

```javascript
getTickers(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getTickers(exchange, options) {
    try {
        let result = await exchange.getTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTickers(myByBitAccount, 
    {
        category: 'linear'
    });
```

## Get Funding Rate History

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/history-fund-rate>
{% endhint %}

#### Function name:

```javascript
getFundingRateHistory(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getFundingRateHistory(exchange, options) {
    try {
        let result = await exchange.getFundingRateHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFundingRateHistory(myByBitAccount, 
    {
        category: 'linear',
        symbol: 'BTCUSD'
    });
```

## Get Public Trading History

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/recent-trade>
{% endhint %}

#### Function name:

```javascript
getPublicTradingHistory(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getPublicTradingHistory(exchange, options) {
    try {
        let result = await exchange.getPublicTradingHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPublicTradingHistory(myByBitAccount, 
    {
        category: 'linear',
        symbol: 'BTCUSD'
    });
```

## Get Open Interest

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/open-interest>
{% endhint %}

#### Function name:

```javascript
getOpenInterest(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getOpenInterest(exchange, options) {
    try {
        let result = await exchange.getOpenInterest(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenInterest(myByBitAccount, 
    {
        category: 'linear',
        symbol: 'BTCUSDT',
        intervalTime: '5min'
    });
```

## Get Historical Volatility

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/iv>
{% endhint %}

#### Function name:

```javascript
getHistoricalVolatility(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getHistoricalVolatility(exchange, options) {
    try {
        let result = await exchange.getHistoricalVolatility(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getHistoricalVolatility(myByBitAccount, 
    {
        category: 'option'
    });
```

## Get Insurance

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/insurance>
{% endhint %}

#### Function name:

```javascript
getInsurance(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInsurance(exchange, options) {
    try {
        let result = await exchange.getInsurance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInsurance(myByBitAccount);
```

## Get Risk Limit

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/risk-limit>
{% endhint %}

#### Function name:

```javascript
getRiskLimit(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getRiskLimit(exchange, options) {
    try {
        let result = await exchange.getRiskLimit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRiskLimit(myByBitAccount, 
    {
        category: 'linear'
    });
```

## Get Delivery Price

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/delivery-price>
{% endhint %}

#### Function name:

```javascript
getDeliveryPrice(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getDeliveryPrice(exchange, options) {
    try {
        let result = await exchange.getDeliveryPrice(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDeliveryPrice(myByBitAccount, 
    {
        category: 'linear'
    });
```


# Trading

Documentation on interacting with ByBit's Trading API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Place Order

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/create-order>
{% endhint %}

#### Function name:

```javascript
placeOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function placeOrder(exchange, options) {
    try {
        let result = await exchange.placeOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       side: 'Buy',
       orderType: 'Market',
       qty: '10'
     });
```

## Amend Order

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/amend-order>
{% endhint %}

#### Function name:

```javascript
amendOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function amendOrder(exchange, options) {
    try {
        let result = await exchange.amendOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await amendOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       qty: '0.000034',
       orderId: '12345'
     })
```

## Cancel Order

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/cancel-order>
{% endhint %}

#### Function name:

```javascript
cancelOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function cancelOrder(exchange, options) {
    try {
        let result = await exchange.cancelOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelOrder(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       orderId: '12345'
     });
```

## Get Open Orders

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/open-order>
{% endhint %}

#### Function name:

```javascript
getOpenOrders(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getOpenOrders(exchange, options) {
    try {
        let result = await exchange.getOpenOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOpenOrders(myByBitAccount, 
    {
       category: 'linear'
       
     });
```

## Cancel All Orders

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/cancel-all>
{% endhint %}

#### Function name:

```javascript
cancelAllOrders(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function cancelAllOrders(exchange, options) {
    try {
        let result = await exchange.cancelAllOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelAllOrders(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD'
     });
```

## Get Order History

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/order-list>
{% endhint %}

#### Function name:

```javascript
getOrderHistory(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getOrderHistory(exchange, options) {
    try {
        let result = await exchange.getOrderHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOrderHistory(myByBitAccount, 
    {
       category: 'linear'
     });
```

## Batch Place Order

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-place>
{% endhint %}

#### Function name:

```javascript
placeBatchOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function placeBatchOrder(exchange, options) {
    try {
        let result = await exchange.placeBatchOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await placeBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               category: 'linear',
               symbol: 'BTCPERP',
               side: 'Buy',
               orderType: 'Market',
               qty: '0.000033'
           },
           {
               category: 'linear',
               symbol: 'BTCPERP',
               side: 'Buy',
               orderType: 'Market',
               qty: '0.000030'
           }
       ]
     });
```

## Batch Amend Order

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-amend>
{% endhint %}

#### Function name:

```javascript
amendBatchOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function amendBatchOrder(exchange, options) {
    try {
        let result = await exchange.amendBatchOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await amendBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               symbol: 'BTCPERP',
               qty: '0.000034',
               orderId: '12345'
             },
           {
               symbol: 'BTCPERP',
               orderId: '12346'
               qty: '0.000030'
           }
       ]
     });
```

## Batch Cancel Order

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/batch-cancel>
{% endhint %}

#### Function name:

```javascript
cancelBatchOrder(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function cancelBatchOrder(exchange, options) {
    try {
        let result = await exchange.cancelBatchOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelBatchOrder(myByBitAccount, 
    {
       category: 'linear',
       request: [
           {
               symbol: 'BTCUSD',
               orderId: '12345'
             },
           {
               symbol: 'BTCUSD',
               orderId: '12346'
           }
       ]
     });
```

## Get Borrow Quota

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/spot-borrow-quota>
{% endhint %}

#### Function name:

```javascript
getBorrowQuotaSpot(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getBorrowQuotaSpot(exchange, options) {
    try {
        let result = await exchange.getBorrowQuotaSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowQuotaSpot(myByBitAccount, 
    {
       category: 'spot',
       symbol: 'BTCUSDT',
       side: 'buy'
     });
```

## Set Disconnect Cancel All

{% hint style="warning" %}
This function is under construction and may behave unexpectedly&#x20;
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/order/dcp>
{% endhint %}

#### Function name:

```javascript
setDcp(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setDcp(exchange, options) {
    try {
        let result = await exchange.setDcp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setDcp(myByBitAccount, 
    {
       timeWindow: '100'
     });
```


# Position

Documentation on interacting with ByBit's Position API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Position Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position>
{% endhint %}

#### Function name:

```javascript
getPositionInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getPositionInfo(exchange, options) {
    try {
        let result = await exchange.getPositionInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositionInfo(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSDT'
     });
```

## Set Leverage

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/leverage>
{% endhint %}

#### Function name:

```javascript
setLeverage(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverage(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       buyLeverage: '6',
       sellLeverage: '6'
     });
```

## Switch Cross/Isolated Margin

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/cross-isolate>
{% endhint %}

#### Function name:

```javascript
switchCrossIsolatedMargin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function switchCrossIsolatedMargin(exchange, options) {
    try {
        let result = await exchange.switchCrossIsolatedMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await switchCrossIsolatedMargin(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       tradeMode: '0',
       buyLeverage: '6',
       sellLeverage: '6'
     });
```

## Set TP/SL Mode

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/tpsl-mode>
{% endhint %}

#### Function name:

```javascript
setTpslMode(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setTpslMode(exchange, options) {
    try {
        let result = await exchange.setTpslMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setTpslMode(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       tpSlMode: 'Full'
     });
```

## Switch Position Mode

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/position-mode>
{% endhint %}

#### Function name:

```javascript
switchPositionMode(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function switchPositionMode(exchange, options) {
    try {
        let result = await exchange.switchPositionMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await switchPositionMode(myByBitAccount, 
    {
       category: 'linear',
       mode: '0'
     });
```

## Set Risk Limit

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/set-risk-limit>
{% endhint %}

#### Function name:

```javascript
setRiskLimit(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setRiskLimit(exchange, options) {
    try {
        let result = await exchange.setRiskLimit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setRiskLimit(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSDT',
       riskId: '4'
     });
```

## Set Trading Stop

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/trading-stop>
{% endhint %}

#### Function name:

```javascript
setTradingStop(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setTradingStop(exchange, options) {
    try {
        let result = await exchange.setTradingStop(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setTradingStop(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       positionIdx: '0',
       takeProfit: '0'
     });
```

## Set Auto Add Margin

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/add-margin>
{% endhint %}

#### Function name:

```javascript
setAutoAddMargin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setAutoAddMargin(exchange, options) {
    try {
        let result = await exchange.setAutoAddMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setAutoAddMargin(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD',
       autoAddMargin: '0'
     });
```

## Get Execution

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/execution>
{% endhint %}

#### Function name:

```javascript
getExecution(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getExecution(exchange, options) {
    try {
        let result = await exchange.getExecution(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getExecution(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD'
     });
```

## Get Closed PnL

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/position/close-pnl>
{% endhint %}

#### Function name:

```javascript
getClosedPnl(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getClosedPnl(exchange, options) {
    try {
        let result = await exchange.getClosedPnl(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getClosedPnl(myByBitAccount, 
    {
       category: 'linear',
       symbol: 'BTCUSD'
     });
```


# Account

Documentation on interacting with ByBit's Account API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Wallet Balance

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/wallet-balance>
{% endhint %}

#### Function name:

```javascript
getWalletBalance(options)
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
<strong>      key: "myKeys",
</strong>      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getWalletBalance(exchange, options) {
    try {
        let result = await exchange.getWalletBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getWalletBalance(myByBitAccount, 
    {
       accountType: "UNIFIED"
     });
</code></pre>

## Upgrade to Unified Account

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/upgrade-unified-account>
{% endhint %}

#### Function name:

```javascript
upgradeToUta(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function upgradeToUta(exchange, options) {
    try {
        let result = await exchange.upgradeToUta(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await upgradeToUta(myByBitAccount);
```

## Get Borrow History

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/borrow-history>
{% endhint %}

#### Function name:

```javascript
getBorrowHistory(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getBorrowHistory(exchange, options) {
    try {
        let result = await exchange.getBorrowHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowHistory(myByBitAccount, 
    {
       currency: "USDT"
     });
```

## Get Collateral Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/collateral-info>
{% endhint %}

#### Function name:

```javascript
getCollateralInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getCollateralInfo(exchange, options) {
    try {
        let result = await exchange.getCollateralInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCollateralInfo(myByBitAccount);
```

## Get Coin Greeks

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/coin-greeks>
{% endhint %}

#### Function name:

```javascript
getCoinGreeks(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getCoinGreeks(exchange, options) {
    try {
        let result = await exchange.getCoinGreeks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCoinGreeks(myByBitAccount);
```

## Get Fee Rate

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/fee-rate>
{% endhint %}

#### Function name:

```javascript
getFeeRate(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getFeeRate(exchange, options) {
    try {
        let result = await exchange.getFeeRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFeeRate(myByBitAccount, 
    {
       category: 'linear'
     });
```

## Get Account Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/account-info>
{% endhint %}

#### Function name:

```javascript
getAccountInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getAccountInfo(exchange, options) {
    try {
        let result = await exchange.getAccountInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountInfo(myByBitAccount);
```

## Get Transaction Log

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/transaction-log>
{% endhint %}

#### Function name:

```javascript
getTransactionLog(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getTransactionLog(exchange, options) {
    try {
        let result = await exchange.getTransactionLog(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTransactionLog(myByBitAccount);
```

## Set Margin Mode

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/set-margin-mode>
{% endhint %}

#### Function name:

```javascript
setMarginMode(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setMarginMode(exchange, options) {
    try {
        let result = await exchange.setMarginMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setMarginMode(myByBitAccount, 
    {
       setMarginMode: "REGULAR_MARGIN"
   });
```

## Set MMP

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/set-mmp>
{% endhint %}

#### Function name:

```javascript
setMmp(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setMmp(exchange, options) {
    try {
        let result = await exchange.setMmp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setMmp(myByBitAccount, 
    {
    baseCoin: "ETH",
    window: "5000",
    frozenPeriod: "100000",
    qtyLimit: "50",
    deltaLimit: "20"
    });
```

## Reset MMP

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/reset-mmp>
{% endhint %}

#### Function name:

```javascript
resetMmp(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function resetMmp(exchange, options) {
    try {
        let result = await exchange.resetMmp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await resetMmp(myByBitAccount, 
    {
    baseCoin: "BTC"
    });
```

## Get MMP State

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/account/get-mmp-state>
{% endhint %}

#### Function name:

```javascript
getMmpState(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getMmpState(exchange, options) {
    try {
        let result = await exchange.getMmpState(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMmpState(myByBitAccount, 
    {
    baseCoin: "ETH"
    });
```

##


# Asset

Documentation on interacting with ByBit's Asset API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Coin Exchange Records

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/exchange>
{% endhint %}

#### Function name:

```javascript
getCoinExchangeRecords(options)
```

#### Usage:&#x20;

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
<strong>      key: "myKeys",
</strong>      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});



async function getCoinExchangeRecords(exchange, options) {
    try {
        let result = await exchange.getCoinExchangeRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCoinExchangeRecords(myByBitAccount);
</code></pre>

## Get Delivery Record

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/delivery>
{% endhint %}

#### Function name:

```javascript
getDeliveryRecord(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

let j = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "bybit",
      marginType: "usdt",
      testnet: "false"
});

rednalknlkna
jawfpenguin
async function getDeliveryRecord(exchange, options) {
    try {
        let result = await exchange.getDeliveryRecord(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDeliveryRecord(myByBitAccount, 
    {
        category: "option"
    });
```

## Get USDC Session Settlement

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/settlement>
{% endhint %}

#### Function name:

```javascript
getUsdcSesssionSettlement(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getUsdcSesssionSettlement(exchange, options) {
    try {
        let result = await exchange.getUsdcSesssionSettlement(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getUsdcSesssionSettlement(myByBitAccount, 
    {
       category: "linear"
     });
```

## Get Asset Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/asset-info>
{% endhint %}

#### Function name:

```javascript
getAssetInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getAssetInfo(exchange, options) {
    try {
        let result = await exchange.getAssetInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAssetInfo(myByBitAccount, {accountType: "SPOT"});
```

## Get All Coins Balance

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/all-balance>
{% endhint %}

#### Function name:

```javascript
getAllCoinsBalance(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getAllCoinsBalance(exchange, options) {
    try {
        let result = await exchange.getAllCoinsBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllCoinsBalance(myByBitAccount, {accountType: "SPOT"});
```

## Get Single Coin Balance

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/account-coin-balance>
{% endhint %}

#### Function name:

```javascript
getSingleCoinBalance(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getSingleCoinBalance(exchange, options) {
    try {
        let result = await exchange.getSingleCoinBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSingleCoinBalance(myByBitAccount, 
    {
       accountType: 'UNIFIED',
       coin: 'BTC'
     });
```

## Get Transferable Coin

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/transferable-coin>
{% endhint %}

#### Function name:

```javascript
getTransferableCoin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getTransferableCoin(exchange, options) {
    try {
        let result = await exchange.getTransferableCoin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTransferableCoin(myByBitAccount,
    {
        fromAccountType: 'SPOT',
        toAccountType: 'UNIFIED'
    });
```

## Create Internal Transfer

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/create-inter-transfer>
{% endhint %}

#### Function name:

```javascript
createInternalTransfer(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function createInternalTransfer(exchange, options) {
    try {
        let result = await exchange.createInternalTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createInternalTransfer(myByBitAccount, 
    {
        transferID: '12345',
        coin: 'USDT',
        amount: '10',
        fromAccountType: 'UNIFIED',
        toAccountType: 'SPOT'
    });
```

## Get Internal Transfer Records

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/inter-transfer-list>
{% endhint %}

#### Function name:

```javascript
getInternalTransferRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInternalTransferRecords(exchange, options) {
    try {
        let result = await exchange.getInternalTransferRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInternalTransferRecords(myByBitAccount);
```

## Get Sub UID

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/sub-uid-list>
{% endhint %}

#### Function name:

```javascript
getSubUid(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getSubUid(exchange, options) {
    try {
        let result = await exchange.getSubUid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubUid(myByBitAccount);
```

## Enable Universal Transfer for Sub UID

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/enable-unitransfer-subuid>
{% endhint %}

#### Function name:

```javascript
enableUniversalTransfer(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function enableUniversalTransfer(exchange, options) {
    try {
        let result = await exchange.enableUniversalTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await enableUniversalTransfer(myByBitAccount, 
    {
        subMemberIds: ["554117,592324,592334"]
    });
```

## Create Universal Transfer

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/unitransfer>
{% endhint %}

#### Function name:

```javascript
createUniversalTransfer(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function createUniversalTransfer(exchange, options) {
    try {
        let result = await exchange.createUniversalTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createUniversalTransfer(myByBitAccount, 
    {
        transferId: "12345",
        coin: "USDT",
        amount: "10",
        fromMemberId: "12345",
        toMemberId: "123456",
        fromAccountType: "UNIFIED",
        toAccountType: "UNIFIED"
    });
```

## Get Universal Transfer Records

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/unitransfer-list>
{% endhint %}

#### Function name:

```javascript
getUniversalTransferRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getUniversalTransferRecords(exchange, options) {
    try {
        let result = await exchange.getUniversalTransferRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getUniversalTransferRecords(myByBitAccount);
```

## Get Allowed Deposit Coin Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/deposit-coin-spec>
{% endhint %}

#### Function name:

```javascript
getAllowedDepositCoinInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getAllowedDepositCoinInfo(exchange, options) {
    try {
        let result = await exchange.getAllowedDepositCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAllowedDepositCoinInfo(myByBitAccount);
```

## Set Deposit Account

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/set-deposit-acct>
{% endhint %}

#### Function name:

```javascript
setDepositAccount(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setDepositAccount(exchange, options) {
    try {
        let result = await exchange.setDepositAccount(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setDepositAccount(myByBitAccount, 
    {
        accountType: "UNIFIED"
    });
```

## Get Deposit Records (on-chain)

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/deposit-record>
{% endhint %}

#### Function name:

```javascript
getDepositRecord(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getDepositRecord(exchange, options) {
    try {
        let result = await exchange.getDepositRecord(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDepositRecord(myByBitAccount);
```

## Get Sub Deposit Records (on-chain)

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/sub-deposit-record>
{% endhint %}

#### Function name:

```javascript
getSubAccountDepositRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getSubAccountDepositRecords(exchange, options) {
    try {
        let result = await exchange.getSubAccountDepositRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubAccountDepositRecords(myByBitAccount, 
    {
        subMemberId: "12345"
    });
```

## Get Internal Deposit Records (off-chain)

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/internal-deposit-record>
{% endhint %}

#### Function name:

```javascript
getInternalDepositRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInternalDepositRecords(exchange, options) {
    try {
        let result = await exchange.getInternalDepositRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInternalDepositRecords(myByBitAccount);
```

## Get Master Deposit Address

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/master-deposit-addr>
{% endhint %}

#### Function name:

```javascript
getMasterDepositAddress(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getMasterDepositAddress(exchange, options) {
    try {
        let result = await exchange.getMasterDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMasterDepositAddress(myByBitAccount,
    {
        coin: "USDT"
    });
```

## Get Sub Deposit Address

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/sub-deposit-addr>
{% endhint %}

#### Function name:

```javascript
getSubDepositAddress(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getSubDepositAddress(exchange, options) {
    try {
        let result = await exchange.getSubDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubDepositAddress(myByBitAccount,
    {
        coin: "USDT",
        chainType: "ETH",
        subMemberId: "12345"
    });
```

## Get Coin Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/coin-info>
{% endhint %}

#### Function name:

```javascript
getCoinInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getCoinInfo(exchange, options) {
    try {
        let result = await exchange.getCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCoinInfo(myByBitAccount);
```

## Get Withdrawal Records

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/withdraw-record>
{% endhint %}

#### Function name:

```javascript
getWithdrawalRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getWithdrawalRecords(exchange, options) {
    try {
        let result = await exchange.getWithdrawalRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getWithdrawalRecords(myByBitAccount);
```

## Get Withdrawal Records

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/delay-amount>
{% endhint %}

#### Function name:

```javascript
getDelayWithdrawalAmount(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getDelayWithdrawalAmount(exchange, options) {
    try {
        let result = await exchange.getDelayWithdrawalAmount(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getDelayWithdrawalAmount(myByBitAccount, 
    {
        coin: "USDT"
    });
```

## Withdraw

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/withdraw>
{% endhint %}

#### Function name:

```javascript
withdraw(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function withdraw(exchange, options) {
    try {
        let result = await exchange.withdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await withdraw(myByBitAccount, 
    {
        coin: "USDT",
        chain: "ETH20",
        walletAddress: "12345",
        amount: "10",
        timestamp: "10000000000"
    });
```

## Cancel Withdrawal

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/asset/cancel-withdraw>
{% endhint %}

#### Function name:

```javascript
cancelWithdraw(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function cancelWithdraw(exchange, options) {
    try {
        let result = await exchange.cancelWithdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await cancelWithdraw(myByBitAccount, 
    {
        id: "12345"
    });
```


# User

Documentation on interacting with ByBit's User API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Create Sub UID

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/create-subuid>
{% endhint %}

#### Function name:

```javascript
createSubUid(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function createSubUid(exchange, options) {
    try {
        let result = await exchange.createSubUid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createSubUid(myByBitAccount, 
    {
        username: "bill",
        memberType: "1"
    });
```

## Create Sub UID API Key

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/create-subuid-apikey>
{% endhint %}

#### Function name:

```javascript
createSubUidApiKey(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function createSubUidApiKey(exchange, options) {
    try {
        let result = await exchange.createSubUidApiKey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await createSubUidApiKey(myByBitAccount, 
    {
       subuid: "62874117",
       readOnly: "0",
       permissions: {
           Spot: ["SpotTrade"]
       }
   });
```

## Get Sub UID List

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/subuid-list>
{% endhint %}

#### Function name:

```javascript
getSubUidList(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getSubUidList(exchange, options) {
    try {
        let result = await exchange.getSubUidList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubUidList(myByBitAccount);
```

## Freeze Sub UID

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/market/preimum-index-kline>
{% endhint %}

#### Function name:

```javascript
freezeSubUid(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function freezeSubUid(exchange, options) {
    try {
        let result = await exchange.freezeSubUid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await freezeSubUid(myByBitAccount, 
    {
       subuid: "62874117",
       frozen: "1"
     });
```

## Get API Key Information

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/apikey-info>
{% endhint %}

#### Function name:

```javascript
getApiKeyInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getApiKeyInfo(exchange, options) {
    try {
        let result = await exchange.getApiKeyInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getApiKeyInfo(myByBitAccount);
```

## Modify Master API Key

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/modify-master-apikey>
{% endhint %}

#### Function name:

```javascript
modifyMasterApiKey(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function modifyMasterApiKey(exchange, options) {
    try {
        let result = await exchange.modifyMasterApiKey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifyMasterApiKey(myByBitAccount, 
    {
        permissions:{
            NFT:[
                "NFTQueryProductList"
            ]
        }
    });
```

## Modify Sub API Key

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/modify-sub-apikey>
{% endhint %}

#### Function name:

```javascript
modifySubApiKey(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitSubAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function modifySubApiKey(exchange, options) {
    try {
        let result = await exchange.modifySubApiKey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await modifySubApiKey(myByBitSubAccount , 
    {
        permissions:{
            NFT:[
                "NFTQueryProductList"
            ]
        }
    });
```

## Delete Master API Key

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/rm-master-apikey>
{% endhint %}

#### Function name:

```javascript
deleteMasterApiKey(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function deleteMasterApiKey(exchange, options) {
    try {
        let result = await exchange.deleteMasterApiKey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await deleteMasterApiKey(myByBitAccount);
```

## Delete Sub API Key

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/user/rm-sub-apikey>
{% endhint %}

#### Function name:

```javascript
deleteSubApiKey(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function deleteSubApiKey(exchange, options) {
    try {
        let result = await exchange.deleteSubApiKey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await deleteSubApiKey(myByBitAccount);
```


# Spot Leverage Token

Documentation on interacting with ByBit's Spot Leverage Token API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Leverage Token Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/lt/leverage-token-info>
{% endhint %}

#### Function name:

```javascript
getLeverageTokenInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getLeverageTokenInfo(exchange, options) {
    try {
        let result = await exchange.getLeverageTokenInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLeverageTokenInfo(myByBitAccount);
```

## Get Leveraged Token Market

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/lt/leverage-token-reference>
{% endhint %}

#### Function name:

```javascript
getLeveragedTokenMarket(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getLeveragedTokenMarket(exchange, options) {
    try {
        let result = await exchange.getLeveragedTokenMarket(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLeveragedTokenMarket(myByBitAccountc,
    {
       ltCoin: "BTC3S"
    });
```

## Purchase

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/lt/purchase>
{% endhint %}

#### Function name:

```javascript
purchaseLeverageToken(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function purchaseLeverageToken(exchange, options) {
    try {
        let result = await exchange.purchaseLeverageToken(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await purchaseLeverageToken(myByBitAccount,
    {
        ltCoin: "BTC3L",
        ltAmount: ".001"
    });
```

## Redeem

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/lt/redeem>
{% endhint %}

#### Function name:

```javascript
redeemLeverageToken(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function redeemLeverageToken(exchange, options) {
    try {
        let result = await exchange.redeemLeverageToken(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await redeemLeverageToken(myByBitAccount, 
    {
       ltCoin: "BTC3L",
       quantity: "0.001"
     });
```

## Get Purchase/Redemption Records

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/lt/order-record>
{% endhint %}

#### Function name:

```javascript
getPurchaseRedemptionRecords(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getPurchaseRedemptionRecords(exchange, options) {
    try {
        let result = await exchange.getPurchaseRedemptionRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPurchaseRedemptionRecords(myByBitAccount);
```


# Spot Margin Trade (UTA)

Documentation on interacting with ByBit's Spot Margin Trade (UTA) API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Toggle Margin Trade

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-uta/switch-mode>
{% endhint %}

#### Function name:

```javascript
toggleUnifiedMarginTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function toggleUnifiedMarginTrade(exchange, options) {
    try {
        let result = await exchange.toggleUnifiedMarginTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await toggleUnifiedMarginTrade(myByBitAccount,
    {
        spotMarginMode: "1"
    });
```

## Get Leveraged Token Market

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-uta/set-leverage>
{% endhint %}

#### Function name:

```javascript
setLeverageMargin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function setLeverageMargin(exchange, options) {
    try {
        let result = await exchange.setLeverageMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverageMargin(myByBitAccount,
    {
       leverage: "4"
    });
```


# Spot Margin Trade (Normal)

Documentation on interacting with ByBit's Spot Margin Trade (Normal) API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Margin Coin Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/margin-data>
{% endhint %}

#### Function name:

```javascript
getMarginCoinInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getMarginCoinInfo(exchange, options) {
    try {
        let result = await exchange.getMarginCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarginCoinInfo(myByBitAccount);
```

## Get Borrowable Coin Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrowable-data>
{% endhint %}

#### Function name:

```javascript
getBorrowableCoinInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getBorrowableCoinInfo(exchange, options) {
    try {
        let result = await exchange.getBorrowableCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowableCoinInfo(myByBitAccount, {coin: "ETH"});
```

## Get Interest & Quota

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/interest-quota>
{% endhint %}

#### Function name:

```javascript
getInterestAndQuota(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInterestAndQuota(exchange, options) {
    try {
        let result = await exchange.getInterestAndQuota(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestAndQuota(myByBitAccount,
    {
        coin: "USDT"
    });
```

## Get Loan Account Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/account-info>
{% endhint %}

#### Function name:

```javascript
getLoanAccountInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getLoanAccountInfo(exchange, options) {
    try {
        let result = await exchange.getLoanAccountInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLoanAccountInfo(myByBitAccount);
```

## Borrow

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow>
{% endhint %}

#### Function name:

```javascript
borrowMargin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function borrowMargin(exchange, options) {
    try {
        let result = await exchange.borrowMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await borrowMargin(myByBitAccount,
    {
        coin: "USDT",
        qty: "10"
    });
```

## Repay

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay>
{% endhint %}

#### Function name:

```javascript
repayMargin(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function repayMargin(exchange, options) {
    try {
        let result = await exchange.repayMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await repayMargin(myByBitAccount,
    {
        coin: "USDT",
        completeRepayments: "1"
    });
```

## Get Borrow Order Detail

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow-order>
{% endhint %}

#### Function name:

```javascript
getBorrowOrderDetail(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getBorrowOrderDetail(exchange, options) {
    try {
        let result = await exchange.getBorrowOrderDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowOrderDetail(myByBitAccount);
```

## Get Repayment Order Detail

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay-order>
{% endhint %}

#### Function name:

```javascript
getRepaymentOrderDetail(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getRepaymentOrderDetail(exchange, options) {
    try {
        let result = await exchange.getRepaymentOrderDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRepaymentOrderDetail(myByBitAccount);
```

## Toggle Margin Trade

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/spot-margin-normal/switch-mode>
{% endhint %}

#### Function name:

```javascript
toggleNormalMarginTrade(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function toggleNormalMarginTrade(exchange, options) {
    try {
        let result = await exchange.toggleNormalMarginTrade(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await toggleNormalMarginTrade(myByBitAccount,
    {
        switch: "1"
    });
```


# Institutional Lending

Documentation on interacting with ByBit's Institutional Lending API functions through the PENDAX Javascript SDK.

{% hint style="warning" %}
**All parameters  of type INTEGER listed in the Bybit API docs need to be passed in as a string.**
{% endhint %}

## Get Product Info

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/otc/margin-product-info>
{% endhint %}

#### Function name:

```javascript
getProductInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getProductInfo(exchange, options) {
    try {
        let result = await exchange.getProductInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getProductInfo(myByBitAccount);
```

## Get Margin Coin Info

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/otc/margin-coin-info>
{% endhint %}

#### Function name:

```javascript
getInstMarginCoinInfo(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInstMarginCoinInfo(exchange, options) {
    try {
        let result = await exchange.getInstMarginCoinInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstMarginCoinInfo(myByBitAccount);
```

## Get Loan Orders

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/otc/loan-info>
{% endhint %}

#### Function name:

```javascript
getInstLoanOrders(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInstLoanOrders(exchange, options) {
    try {
        let result = await exchange.getInstLoanOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstLoanOrders(myByBitAccount);
```

## Get Repay Orders

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/otc/repay-info>
{% endhint %}

#### Function name:

```javascript
getInstRepayOrders(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInstRepayOrders(exchange, options) {
    try {
        let result = await exchange.getInstRepayOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstRepayOrders(myByBitAccount);
```

## Get LTV

{% hint style="warning" %}
This function is under construction and may not behave as expected
{% endhint %}

{% hint style="info" %}
Please refer to the official ByBit API Docs for the required parameters.

<https://bybit-exchange.github.io/docs/v5/otc/ltv>
{% endhint %}

#### Function name:

```javascript
getInstLtv(options)
```

#### Usage:&#x20;

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myByBitAccount = createExchange({
      exchange: "bybit",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "bybit",
      testnet: "false"
});

async function getInstLtv(exchange, options) {
    try {
        let result = await exchange.getInstLtv(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInstLtv(myByBitAccount);
```


# Mexc Functions

Documentation for interacting with Mexc functions and API endpoints through the PENDAX Javascript SDK.

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let mexc_exchange = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "mexc"
});


```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myMexcAccount= createExchange({
      exchange: "mexc",
      authenticate: "false",
      label: "mexc"
});
```

{% hint style="warning" %}
These documents are under development and will be updated shortly with all finalized functions
{% endhint %}

## All Available Mexc Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% content-ref url="/pages/6WfxPNavndua7f1Cc4AK" %}
[ETF](/pendax/using-pendax-sdk/mexc-functions/etf)
{% endcontent-ref %}

{% content-ref url="/pages/itIxcBwcBRrLnScJcIeH" %}
[Futures Account and Trading](/pendax/using-pendax-sdk/mexc-functions/futures-account-and-trading)
{% endcontent-ref %}

{% content-ref url="/pages/jdm3OEm7CYDt1QHjRewc" %}
[Futures Market](/pendax/using-pendax-sdk/mexc-functions/futures-market)
{% endcontent-ref %}

{% content-ref url="/pages/qfbtmEqsNvTEwI6Dahl0" %}
[Market](/pendax/using-pendax-sdk/mexc-functions/market)
{% endcontent-ref %}

{% content-ref url="/pages/X11X8cpONKJcQUqRdTVX" %}
[Rebate](/pendax/using-pendax-sdk/mexc-functions/rebate)
{% endcontent-ref %}

{% content-ref url="/pages/vQQwTRhm6FgLBkxW4KDI" %}
[Spot Account/Trade](/pendax/using-pendax-sdk/mexc-functions/spot-account-trade)
{% endcontent-ref %}

{% content-ref url="/pages/7aHC4tXwxJla2pI3BTuK" %}
[Sub-Account](/pendax/using-pendax-sdk/mexc-functions/sub-account)
{% endcontent-ref %}

{% content-ref url="<https://github.com/Compendium-Fi/product-docs/blob/main/product-docs-gitbook-space/pendax/using-pendax-sdk/mexc-functions/spot-margin-trade-uta.md>" %}
<https://github.com/Compendium-Fi/product-docs/blob/main/product-docs-gitbook-space/pendax/using-pendax-sdk/mexc-functions/spot-margin-trade-uta.md>
{% endcontent-ref %}

{% content-ref url="/pages/LJNr71TLS7ZyiGbuyJTV" %}
[Wallet](/pendax/using-pendax-sdk/mexc-functions/wallet)
{% endcontent-ref %}


# Market

Documentation on interacting with Mexc's Market API functions through the PENDAX Javascript SDK.

## Test Connectivity

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#test-connectivity>
{% endhint %}

#### Function Name:

```javascript
testConnectivitySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function testConnectivitySpot(exchange, options) {
    try {
        let result = await exchange.testConnectivitySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await testConnectivitySpot(myMexcExchanges);
```

## Check Server Time

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#check-server-time>
{% endhint %}

#### Function Name:

```javascript
getServerTimeSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getServerTimeSpot(exchange, options) {
    try {
        let result = await exchange.getServerTimeSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getServerTimeSpot(myMexcExchanges);
```

## API default symbol

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#api-default-symbol>
{% endhint %}

#### Function Name:

```javascript
getSelfSymbolsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSelfSymbolsSpot(exchange, options) {
    try {
        let result = await exchange.getSelfSymbolsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSelfSymbolsSpot(myMexcExchanges);
```

## Exchange Information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#exchange-information>
{% endhint %}

#### Function Name:

```javascript
getExchangeInformationSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getExchangeInformationSpot(exchange, options) {
    try {
        let result = await exchange.getExchangeInformationSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getExchangeInformationSpot(myMexcExchanges, {symbol: "BTCUSDT"});
```

## Order Book

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#order-book>
{% endhint %}

#### Function Name:

```javascript
getOrderBookSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOrderBookSpot(exchange, options) {
    try {
        let result = await exchange.getOrderBookSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookSpot(myMexcExchanges, 
   {
     symbol: "BTCUSDT"
   });
```

## Recent Trades List

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list>
{% endhint %}

#### Function Name:

```javascript
getRecentTradesListSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getRecentTradesListSpot(exchange, options) {
    try {
        let result = await exchange.getRecentTradesListSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRecentTradesListSpot(myMexcExchanges, 
   {
     symbol: "BTCUSDT"
   });
```

## Compressed/Aggregate Trades List

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list>
{% endhint %}

#### Function Name:

```javascript
getAggTradesSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAggTradesSpot(exchange, options) {
    try {
        let result = await exchange.getAggTradesSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAggTradesSpot(myMexcExchanges, 
   {
     symbol: "BTCUSDT"
   });
```

## Kline/Candlestick Data

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data>
{% endhint %}

#### Function Name:

```javascript
getKlinesSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getKlinesSpot(exchange, options) {
    try {
        let result = await exchange.getKlinesSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKlinesSpot(myMexcExchanges, 
   {
     symbol: "BTCUSDT",
     interval: "15m"
   });
```

## Current Average Price

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#current-average-price>
{% endhint %}

#### Function Name:

```javascript
getAvgPriceSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAvgPriceSpot(exchange, options) {
    try {
        let result = await exchange.getAvgPriceSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAvgPriceSpot(myMexcExchanges,
 {
     symbol: "BTCUSDT"
 });
```

## 24hr Ticker Price Change Statistics

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics>
{% endhint %}

#### Function Name:

```javascript
get24HrTickerSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function get24HrTickerSpot(exchange, options) {
    try {
        let result = await exchange.get24HrTickerSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HrTickerSpot(myMexcExchanges);
```

## Symbol Price Ticker

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#symbol-price-ticker>
{% endhint %}

#### Function Name:

```javascript
getPriceTickerSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getPriceTickerSpot(exchange, options) {
    try {
        let result = await exchange.getPriceTickerSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPriceTickerSpot(myMexcExchanges);
```

## Symbol Order Book Ticker

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker>
{% endhint %}

#### Function Name:

```javascript
getBookTickerSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getBookTickerSpot(exchange, options) {
    try {
        let result = await exchange.getBookTickerSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getBookTickerSpot(myMexcExchanges);
```


# Sub-Account

Documentation on interacting with Mexc's Sub-Account API functions through the PENDAX Javascript SDK.

## Create a Sub-account(For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#create-a-sub-account-for-master-account>
{% endhint %}

#### Function Name:

```javascript
createSubAccountSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function createSubAccountSpot(exchange, options) {
    try {
        let result = await exchange.createSubAccountSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await createSubAccountSpot(myMexcExchanges,
     {
         subAccount: "mikwdn443ksnsadasd",
         note: "1"
     });
```

## Query Sub-account List (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-sub-account-list-for-master-account>
{% endhint %}

#### Function Name:

```javascript
getSubaccountListSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSubaccountListSpot(exchange, options) {
    try {
        let result = await exchange.getSubaccountListSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountListSpot(myMexcExchanges);
```

## Create an APIKey for a sub-account (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#create-an-apikey-for-a-sub-account-for-master-account>
{% endhint %}

#### Function Name:

```javascript
createSubaccountApiKeySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function createSubaccountApiKeySpot(exchange, options) {
    try {
        let result = await exchange.createSubaccountApiKeySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await createSubaccountApiKeySpot(myMexcExchanges,
         {
             subAccount: "mikwdn443ksnsadasd",
             note: "meat",
             permissions: "SPOT_ACCOUNT_READ"
         });
```

## Query the APIKey of a sub-account (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-the-apikey-of-a-sub-account-for-master-account>
{% endhint %}

#### Function Name:

```javascript
getSubaccountApiKeySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSubaccountApiKeySpot(exchange, options) {
    try {
        let result = await exchange.getSubaccountApiKeySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}


let result = await getSubaccountApiKeySpot(myMexcExchanges,
         {
             subAccount: "yourSubAccountName"
         });
```

## Delete the APIKey of a sub-account (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#delete-the-apikey-of-a-sub-account-for-master-account>
{% endhint %}

#### Function Name:

```javascript
deleteSubaccountApiKeySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function deleteSubaccountApiKeySpot(exchange, options) {
    try {
        let result = await exchange.deleteSubaccountApiKeySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await deleteSubaccountApiKeySpot(myMexcExchanges,
         {
             subAccount: "22nj5499sn2nv",
             apiKey: "nfl4nfl34nrt3lku4nrl3in4"
         });
```

## Universal Transfer (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#universal-transfer-for-master-account>
{% endhint %}

#### Function Name:

```javascript
universalTransferSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function universalTransferSpot(exchange, options) {
    try {
        let result = await exchange.universalTransferSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await universalTransferSpot(myMexcExchanges,
         {
             toAccount: "ddddw3g",
             fromAccountType: "SPOT",
             toAccountType: "SPOT",
             asset: "USDT",
             amount: "10"
         });
```

## Query Universal Transfer History (For Master Account)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-universal-transfer-history-for-master-account>
{% endhint %}

#### Function Name:

```javascript
getUniversalTransferHistorySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUniversalTransferHistorySpot(exchange, options) {
    try {
        let result = await exchange.getUniversalTransferHistorySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUniversalTransferHistorySpot(myMexcExchanges,
         {
             toAccount: "22df3tg4yh45y",
             fromAccountType: "SPOT",
             toAccountType: "SPOT"
         });
```


# Spot Account/Trade

Documentation on interacting with Mexc's Spot Account/Trade API functions through the PENDAX Javascript SDK.

## User API default symbol

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#user-api-default-symbol>
{% endhint %}

#### Function Name:

```javascript
getSelfSymbolsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSelfSymbolsSpot(exchange, options) {
    try {
        let result = await exchange.getSelfSymbolsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSelfSymbolsSpot(myMexcExchanges);
```

## New Order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#test-new-order>
{% endhint %}

#### Function Name:

```javascript
newOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function newOrderSpot(exchange, options) {
    try {
        let result = await exchange.newOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await newOrderSpot(myMexcExchanges,
         {
              symbol: "MXUSDT",
              side: "BUY",
              type: "MARKET",
              quoteOrderQty: "8"
         });
```

## Test New Order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#new-order>
{% endhint %}

#### Function Name:

```javascript
testNewOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function testNewOrderSpot(exchange, options) {
    try {
        let result = await exchange.testNewOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await testNewOrderSpot(myMexcExchanges,
         {
             symbol: "BTCUSDT",
             side: "BUY",
             type: "LIMIT",
             price: "20000",
             quantity: "0.0002"
         });
```

## Cancel Order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#batch-orders>
{% endhint %}

#### Function Name:

```javascript
cancelOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function cancelOrderSpot(exchange, options) {
    try {
        let result = await exchange.cancelOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderSpot(myMexcExchanges,
         {
             symbol: "MXUSDT",
             orderId: "65f257f2b17f491393980f6e1a5a8331"
         });
```

## Cancel all Open Orders on a Symbol

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol>
{% endhint %}

#### Function Name:

```javascript
cancelOpenOrdersSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function cancelOpenOrdersSpot(exchange, options) {
    try {
        let result = await exchange.cancelOpenOrdersSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOpenOrdersSpot(myMexcExchanges,
         {
             symbol: "MXUSDT"
         });
```

## Query Order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-order>
{% endhint %}

#### Function Name:

```javascript
getOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOrderSpot(exchange, options) {
    try {
        let result = await exchange.getOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderSpot(myMexcExchanges,
         {
             symbol: "MXUSDT",
             orderId: "65f257f2b17f491393980f6e1a5a8331"
         });
```

## Current Open Orders

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#current-open-orders>
{% endhint %}

#### Function Name:

```javascript
getOpenOrdersSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOpenOrdersSpot(exchange, options) {
    try {
        let result = await exchange.getOpenOrdersSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrdersSpot(myMexcExchanges,
         {
             symbol: "MXUSDT"
         });
```

## All Orders

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#all-orders>
{% endhint %}

#### Function Name:

```javascript
getAllOrdersSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAllOrdersSpot(exchange, options) {
    try {
        let result = await exchange.getAllOrdersSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllOrdersSpot(myMexcExchanges,
         {
             symbol: "MXUSDT"
         });
```

## Account Information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#account-information>
{% endhint %}

#### Function Name:

```javascript
getSpotAccountInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSpotAccountInfo(exchange, options) {
    try {
        let result = await exchange.getSpotAccountInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSpotAccountInfo(myMexcExchanges);
```

## Account Trade List

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list>
{% endhint %}

#### Function Name:

```javascript
getAccountTradeListSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAccountTradeListSpot(exchange, options) {
    try {
        let result = await exchange.getAccountTradeListSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountTradeListSpot(myMexcExchanges, {symbol: "MXUSDT"});
```

## Enable MX Deduct

{% hint style="danger" %}
This function is currently under construction and may fail or give unexpected behavior
{% endhint %}

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#enable-mx-deduct>
{% endhint %}

#### Function Name:

```javascript
enableMxDeduct()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function enableMxDeduct(exchange, options) {
    try {
        let result = await exchange.enableMxDeduct(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await enableMxDeduct(myMexcExchanges, {mxDeductEnable: "true"});
```

## Query MX Deduct Status

{% hint style="danger" %}
This function is currently under construction and may fail or give unexpected behavior
{% endhint %}

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status>
{% endhint %}

#### Function Name:

```javascript
getMxDeductStatus()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getMxDeductStatus(exchange, options) {
    try {
        let result = await exchange.getMxDeductStatus(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMxDeductStatus(myMexcExchanges);
```


# Wallet

Documentation on interacting with Mexc's Wallet API functions through the PENDAX Javascript SDK.

## Query the currency information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information>
{% endhint %}

#### Function Name:

```javascript
getCurrencyInformationSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getCurrencyInformationSpot(exchange, options) {
    try {
        let result = await exchange.getCurrencyInformationSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getCurrencyInformationSpot(myMexcExchanges);
```

## Withdraw

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#withdraw>
{% endhint %}

#### Function Name:

```javascript
withdrawSpot()
```

#### Usage:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function withdrawSpot(exchange, options) {
    try {
        let result = await exchange.withdrawSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

<strong>let result = await withdrawSpot(myMexcExchanges, 
</strong><strong>    {
</strong><strong>        coin: "EOS",
</strong><strong>        address: "zzqqqqqqqqqq",
</strong><strong>        amount: "10"
</strong><strong>    );
</strong><strong>
</strong></code></pre>

## Cancel withdraw

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#cancel-withdraw>
{% endhint %}

#### Function Name:

```javascript
cancelWithdrawSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function cancelWithdrawSpot(exchange, options) {
    try {
        let result = await exchange.cancelWithdrawSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}
let result = await cancelWithdrawSpot(myMexcExchanges, 
    {
        id: "ca7bd51895134fb5bd749f1cf875b8af"
    );

```

## Deposit History(supporting network)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network>
{% endhint %}

#### Function Name:

```javascript
getDepositHistorySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getDepositHistorySpot(exchange, options) {
    try {
        let result = await exchange.getDepositHistorySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositHistorySpot(myMexcExchanges);
```

## Withdraw History (supporting network)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network>
{% endhint %}

#### Function Name:

```javascript
getWithdrawHistorySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getWithdrawHistorySpot(exchange, options) {
    try {
        let result = await exchange.getWithdrawHistorySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawHistorySpot(myMexcExchanges);
```

## Generate deposit address (supporting network)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network>
{% endhint %}

#### Function Name:

```javascript
generateDepositAddressSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function generateDepositAddressSpot(exchange, options) {
    try {
        let result = await exchange.generateDepositAddressSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await generateDepositAddressSpot(myMexcExchanges,
         {
             coin: "USDT",
             network: "TRC20"
         });
```

## Deposit Address (supporting network)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network>
{% endhint %}

#### Function Name:

```javascript
getDepositAddressSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getDepositAddressSpot(exchange, options) {
    try {
        let result = await exchange.getDepositAddressSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositAddressSpot(myMexcExchanges,
         {
             coin: "USDT"
         });
```

## Withdraw Address (supporting network)

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#withdraw-address-supporting-network>
{% endhint %}

#### Function Name:

```javascript
getWithdrawAddressSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getWithdrawAddressSpot(exchange, options) {
    try {
        let result = await exchange.getWithdrawAddressSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawAddressSpot(myMexcExchanges);
```

## User Universal Transfer

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer>
{% endhint %}

#### Function Name:

```javascript
userUniversalTransferSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function userUniversalTransferSpot(exchange, options) {
    try {
        let result = await exchange.userUniversalTransferSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await userUniversalTransferSpot(myMexcExchanges,
         {
             fromAccountType: "SPOT",
             toAccountType: "FUTURES",
             asset: "USDT",
             amount: "10"
         });
```

## Query User Universal Transfer History

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-user-universal-transfer-history>
{% endhint %}

#### Function Name:

```javascript
getUniversalTransferHistorySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUniversalTransferHistorySpot(exchange, options) {
    try {
        let result = await exchange.getUniversalTransferHistorySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUniversalTransferHistorySpot(myMexcExchanges,
         {
             toAccount: "mikwdn443ksnsadasd",
             fromAccountType: "SPOT",
             toAccountType: "SPOT"
         });
```

## Query User Universal Transfer History （by tranId）

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-user-universal-transfer-history-by-tranid>
{% endhint %}

#### Function Name:

```javascript
getUniversalTransferHistoryTranIdSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUniversalTransferHistoryTranIdSpot(exchange, options) {
    try {
        let result = await exchange.getUniversalTransferHistoryTranIdSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUniversalTransferHistoryTranIdSpot(myMexcExchanges,
         {
             tranId: "fedfdd5d23f94582a117a67118323db9"
         });
```

## Get Assets That Can Be Converted Into MX

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#get-assets-that-can-be-converted-into-mx>
{% endhint %}

#### Function Name:

```javascript
getMxConvertableAssetsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getMxConvertableAssetsSpot(exchange, options) {
    try {
        let result = await exchange.getMxConvertableAssetsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMxConvertableAssetsSpot(myMexcExchanges);
```

## Dust Transfer

{% hint style="danger" %}
This function is currently under construction and may fail or give unexpected behavior
{% endhint %}

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#dust-transfer>
{% endhint %}

#### Function Name:

```javascript
dustTransferSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function dustTransferSpot(exchange, options) {
    try {
        let result = await exchange.dustTransferSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

```

## DustLog

{% hint style="danger" %}
This function is currently under construction and may fail or give unexpected behavior
{% endhint %}

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#dustlog>
{% endhint %}

#### Function Name:

```javascript
getDustLogSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getDustLogSpot(exchange, options) {
    try {
        let result = await exchange.getDustLogSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDustLogSpot(myMexcExchanges);
```


# ETF

Documentation on interacting with Mexc's ETF API functions through the PENDAX Javascript SDK.

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#get-etf-info>
{% endhint %}

### Function Name:

```javascript
getEtfInfo()
```

### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getEtfInfo(exchange, options) {
    try {
        let result = await exchange.getEtfInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getEtfInfo(myMexcExchanges);
```


# Rebate

Documentation on interacting with Mexc's Rebate API functions through the PENDAX Javascript SDK.

## Get Rebate History Records

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#get-rebate-history-records>
{% endhint %}

#### Function Name:

```javascript
getRebateHistoryRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getRebateHistoryRecords(exchange, options) {
    try {
        let result = await exchange.getRebateHistoryRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRebateHistoryRecords(myMexcExchanges);
```

## Get Rebate Records Detail

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#get-rebate-records-detail>
{% endhint %}

#### Function Name:

```javascript
getRebateRecordsDetail()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getRebateRecordsDetail(exchange, options) {
    try {
        let result = await exchange.getRebateRecordsDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRebateRecordsDetail(myMexcExchanges);
```

## Get Self Rebate Records Detail

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#get-self-rebate-records-detail>
{% endhint %}

#### Function Name:

```javascript
getSelfRebateRecordsDetail()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getSelfRebateRecordsDetail(exchange, options) {
    try {
        let result = await exchange.getSelfRebateRecordsDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSelfRebateRecordsDetail(myMexcExchanges);
```

## Query ReferCode

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/spot_v3_en/#query-refercode>
{% endhint %}

#### Function Name:

```javascript
getReferCode()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getReferCode(exchange, options) {
    try {
        let result = await exchange.getReferCode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getReferCode(myMexcExchanges);
```


# Futures Market

Documentation on interacting with Mexc's Futures Market API functions through the PENDAX Javascript SDK.

## Get the server time

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time>
{% endhint %}

#### Function Name:

```javascript
getServerTimeFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getServerTimeFutures(exchange, options) {
    try {
        let result = await exchange.getServerTimeFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getServerTimeFutures(myMexcExchanges);
```

## Get the contract information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information>
{% endhint %}

#### Function Name:

```javascript
getContractDetailFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractDetailFutures(exchange, options) {
    try {
        let result = await exchange.getContractDetailFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractDetailFutures(myMexcExchanges);
```

## Get the transferable currencies

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-transferable-currencies>
{% endhint %}

#### Function Name:

```javascript
getTransferableCurrenciesFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getTransferableCurrenciesFutures(exchange, options) {
    try {
        let result = await exchange.getTransferableCurrenciesFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTransferableCurrenciesFutures(myMexcExchanges);
```

## Get a snapshot of the latest N depth information of the contract

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-a-snapshot-of-the-latest-n-depth-information-of-the-contract>
{% endhint %}

#### Function Name:

```javascript
getContractNDepthInfoFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractNDepthInfoFutures(exchange, options) {
    try {
        let result = await exchange.getContractNDepthInfoFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractNDepthInfoFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT",
             limit: "20"
         });
```

## Get contract fair price

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-fair-price>
{% endhint %}

#### Function Name:

```javascript
getContractFairPriceFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractFairPriceFutures(exchange, options) {
    try {
        let result = await exchange.getContractFairPriceFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractFairPriceFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get contract funding rate

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate>
{% endhint %}

#### Function Name:

```javascript
getContractFundingRateFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractFundingRateFutures(exchange, options) {
    try {
        let result = await exchange.getContractFundingRateFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractFundingRateFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## K-line data

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#k-line-data>
{% endhint %}

#### Function Name:

```javascript
getContractKlineFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractKlineFutures(exchange, options) {
    try {
        let result = await exchange.getContractKlineFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractKlineFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get K-line data of the index price

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-k-line-data-of-the-index-price>
{% endhint %}

#### Function Name:

```javascript
getContractIndexPriceKlineFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractIndexPriceKlineFutures(exchange, options) {
    try {
        let result = await exchange.getContractIndexPriceKlineFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractIndexPriceKlineFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get K-line data of the fair price

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-k-line-data-of-the-fair-price>
{% endhint %}

#### Function Name:

```javascript
getContractFairPriceKlineFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractFairPriceKlineFutures(exchange, options) {
    try {
        let result = await exchange.getContractFairPriceKlineFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractFairPriceKlineFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get contract transaction data

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data>
{% endhint %}

#### Function Name:

```javascript
getContractTransactionDataFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractTransactionDataFutures(exchange, options) {
    try {
        let result = await exchange.getContractTransactionDataFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractTransactionDataFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get contract trend data

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data>
{% endhint %}

#### Function Name:

```javascript
getContractTrendDataFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractTrendDataFutures(exchange, options) {
    try {
        let result = await exchange.getContractTrendDataFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractTrendDataFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get all contract risk fund balance

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-all-contract-risk-fund-balance>
{% endhint %}

#### Function Name:

```javascript
getAllContractRiskFundBalanceFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAllContractRiskFundBalanceFutures(exchange, options) {
    try {
        let result = await exchange.getAllContractRiskFundBalanceFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllContractRiskFundBalanceFutures(myMexcExchanges);
```

## Get contract risk fund balance history

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-risk-fund-balance-history>
{% endhint %}

#### Function Name:

```javascript
getContractRiskFundBalanceHistoryFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractRiskFundBalanceHistoryFutures(exchange, options) {
    try {
        let result = await exchange.getContractRiskFundBalanceHistoryFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractRiskFundBalanceHistoryFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT",
             page_num: "1",
             page_size: "20"
         });
```

## Get contract funding rate history

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history>
{% endhint %}

#### Function Name:

```javascript
getContractFundingRateHistoryFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getContractFundingRateHistoryFutures(exchange, options) {
    try {
        let result = await exchange.getContractFundingRateHistoryFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractFundingRateHistoryFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT",
             page_num: "1",
             page_size: "20"
         });
```


# Futures Account and Trading

Documentation on interacting with Mexc's Futures Account and Trading API functions through the PENDAX Javascript SDK.

## Get all informations of user's asset

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset>
{% endhint %}

#### Function Name:

```javascript
getUserAssetInfoFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUserAssetInfoFutures(exchange, options) {
    try {
        let result = await exchange.getUserAssetInfoFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserAssetInfoFutures(myMexcExchanges);
```

## Get the user's single currency asset information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-single-currency-asset-information>
{% endhint %}

#### Function Name:

```javascript
getUserSingleCurrencyAssetInfoFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUserSingleCurrencyAssetInfoFutures(exchange, options) {
    try {
        let result = await exchange.getUserSingleCurrencyAssetInfoFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserSingleCurrencyAssetInfoFutures(myMexcExchanges, 
         {
             currency: "USDT"
         });
```

## Get the user's asset transfer records

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records>
{% endhint %}

#### Function Name:

```javascript
getUserAssetTransferRecordsFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUserAssetTransferRecordsFutures(exchange, options) {
    try {
        let result = await exchange.getUserAssetTransferRecordsFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserAssetTransferRecordsFutures(myMexcExchanges, 
         {
             page_size: "10",
             currency: "USDT"
         });
```

## Get the user’s history position information

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information>
{% endhint %}

#### Function Name:

```javascript
getHistoryPositionInformationFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getHistoryPositionInformationFutures(exchange, options) {
    try {
        let result = await exchange.getHistoryPositionInformationFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoryPositionInformationFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get the user's current holding position

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-current-holding-position>
{% endhint %}

#### Function Name:

```javascript
getCurrentHoldingPositionFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getCurrentHoldingPositionFutures(exchange, options) {
    try {
        let result = await exchange.getCurrentHoldingPositionFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getCurrentHoldingPositionFutures(myMexcExchanges);
```

## Get details of user‘s funding rate

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate>
{% endhint %}

#### Function Name:

```javascript
getUserFundingRateDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUserFundingRateDetails(exchange, options) {
    try {
        let result = await exchange.getUserFundingRateDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserFundingRateDetails(myMexcExchanges);
```

## Get the user's current pending order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-current-pending-order>
{% endhint %}

#### Function Name:

```javascript
getUserCurrentPendingOrderFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getUserCurrentPendingOrderFutures(exchange, options) {
    try {
        let result = await exchange.getUserCurrentPendingOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserCurrentPendingOrderFutures(myMexcExchanges, 
         {
             symbol: "MX_USDT"
         });
```

## Get all of the user's historical orders

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders>
{% endhint %}

#### Function Name:

```javascript
getAllUserHistoricalOrdersFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAllUserHistoricalOrdersFutures(exchange, options) {
    try {
        let result = await exchange.getAllUserHistoricalOrdersFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllUserHistoricalOrdersFutures(myMexcExchanges);
```

## Query the order based on the external number

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-external-number>
{% endhint %}

#### Function Name:

```javascript
getOrderByExternalNumberFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOrderByExternalNumberFutures(exchange, options) {
    try {
        let result = await exchange.getOrderByExternalNumberFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderByExternalNumberFutures(myMexcExchanges,
         {
             symbol: "ETH_USDT",
             external_oid: "_m_f95eb99b061d4eef8f64a04e9ac4dad3"
         });
```

## Query the order based on the order number

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number>
{% endhint %}

#### Function Name:

```javascript
getOrderByOrderNumberFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOrderByOrderNumberFutures(exchange, options) {
    try {
        let result = await exchange.getOrderByOrderNumberFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderByOrderNumberFutures(myMexcExchanges,
         {
             order_id: "102015012431820288"
         });
```

## Get order transaction details based on the order ID

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-order-transaction-details-based-on-the-order-id>
{% endhint %}

#### Function Name:

```javascript
getOrderTransactionDetailsByOIDFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getOrderTransactionDetailsByOIDFutures(exchange, options) {
    try {
        let result = await exchange.getOrderTransactionDetailsByOIDFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderTransactionDetailsByOIDFutures(myMexcExchanges,
         {
             order_id: "102015012431820288"
         });
```

## Get all transaction details of the user’s order

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order>
{% endhint %}

#### Function Name:

```javascript
getAllTranscationDetailsUserOrderFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getAllTranscationDetailsUserOrderFutures(exchange, options) {
    try {
        let result = await exchange.getAllTranscationDetailsUserOrderFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllTranscationDetailsUserOrderFutures(myMexcExchanges,
         {
             symbol: "MX_USDT"
         });
```

## Gets the trigger order list

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list>
{% endhint %}

#### Function Name:

```javascript
getTriggerOrderListFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getTriggerOrderListFutures(exchange, options) {
    try {
        let result = await exchange.getTriggerOrderListFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTriggerOrderListFutures(myMexcExchanges,
         {
             symbol: "MX_USDT"
         });
```

## Get the Stop-Limit order list

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-the-stop-limit-order-list>
{% endhint %}

#### Function Name:

```javascript
getStopLimitOrderListFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getStopLimitOrderListFutures(exchange, options) {
    try {
        let result = await exchange.getStopLimitOrderListFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getStopLimitOrderListFutures(myMexcExchanges,
         {
             symbol: "MX_USDT"
         });
```

## Get risk limits

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-risk-limits>
{% endhint %}

#### Function Name:

```javascript
getRiskLimitsFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getRiskLimitsFutures(exchange, options) {
    try {
        let result = await exchange.getRiskLimitsFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRiskLimitsFutures(myMexcExchanges,
         {
             symbol: "MX_USDT"
         });
```

## Increase or decrease margin

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin>
{% endhint %}

#### Function Name:

```javascript
changeMarginFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function changeMarginFutures(exchange, options) {
    try {
        let result = await exchange.changeMarginFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await changeMarginFutures(myMexcExchanges,
         {
             positionId: "134321",
             amount: "1",
             type: "ADD"
         });
```

## Get leverage

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-leverage>
{% endhint %}

#### Function Name:

```javascript
getLeverageFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getLeverageFutures(exchange, options) {
    try {
        let result = await exchange.getLeverageFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getLeverageFutures(myMexcExchanges,
         {
             symbol: "MX_USDT"
         });
```

## Get position mode

{% hint style="info" %}
Please refer to the official Mexc API Docs for the Required parameters.

<https://mxcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode>
{% endhint %}

#### Function Name:

```javascript
getPositionModeFutures()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myMexcExchanges  = createExchange({
      exchange: "mexc",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "mexc"
  });

async function getPositionModeFutures(exchange, options) {
    try {
        let result = await exchange.getPositionModeFutures(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositionModeFutures(myMexcExchanges);
```


# Phemex Functions

Documentation for interacting with Phemex functions and API endpoints through the PENDAX Javascript SDK.

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let phemex_exchange = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      label: "phemex"
});


```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myMexcAccount= createExchange({
      exchange: "phemex",
      authenticate: "false",
      label: "phemex"
});
```

## All Available Phemex Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% content-ref url="/pages/50g4tAxy5hGWA7A0MSe4" %}
[Contract](/pendax/using-pendax-sdk/phemex-functions/contract)
{% endcontent-ref %}

{% content-ref url="/pages/FmsLNpv0H1FRohrgaMzE" %}
[Convert](/pendax/using-pendax-sdk/phemex-functions/convert)
{% endcontent-ref %}

{% content-ref url="/pages/FjUcOGM1JXwH0bOzl3aE" %}
[Deposit And Withdraw](/pendax/using-pendax-sdk/phemex-functions/deposit-and-withdraw)
{% endcontent-ref %}

{% content-ref url="/pages/68nMKiRJ5MNjGqCZOcB5" %}
[Hedged Contract](/pendax/using-pendax-sdk/phemex-functions/hedged-contract)
{% endcontent-ref %}

{% content-ref url="/pages/YtCilcb6Cu4RmzaxD2rZ" %}
[Margin Trading](/pendax/using-pendax-sdk/phemex-functions/margin-trading)
{% endcontent-ref %}

{% content-ref url="/pages/v5zIz1ZDooJVpIEdRaz3" %}
[Spot](/pendax/using-pendax-sdk/phemex-functions/spot)
{% endcontent-ref %}

{% content-ref url="/pages/LvvCLUGojNZs0CZ21nxS" %}
[Transfer](/pendax/using-pendax-sdk/phemex-functions/transfer)
{% endcontent-ref %}


# Contract

## Query product information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-product-information](https://phemex-docs.github.io/#query-product-information)
{% endhint %}

#### Function Name:

```javascript
getProductInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getProductInfo(exchange, options) {
    try {
        let result = await exchange.getProductInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getProductInfo(myMainPhemexExchange);
```

## Query server time

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-server-time](https://phemex-docs.github.io/#query-server-time)
{% endhint %}

#### Function Name:

```javascript
getServerTime()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getServerTime(exchange, options) {
    try {
        let result = await exchange.getServerTime(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getServerTime(myPhemexExchange);
```

### Place order <a href="#place-order-http-put-prefered" id="place-order-http-put-prefered"></a>

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io/#place-order-http-put-prefered>
{% endhint %}

#### Function Name:

```javascript
placeOrderPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function placeOrderPerp(exchange, options) {
    try {
        let result = await exchange.placeOrderPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderPerp(myPhemexExchange, {
        symbol: "BTCUSD",
        clOrdID: "nkluwnfkdddlnladad34o33sli4nfaao2m3",
        side: "Buy",
        orderQty: "2001",
        ordType: "Limit",
        priceEp: "100000000"
        });

```

## Cancel order by order ID or client order ID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#cancel-order-by-order-id-or-client-order-id](https://phemex-docs.github.io/#cancel-order-by-order-id-or-client-order-id)
{% endhint %}

#### Function Name:

```javascript
cancelOrderPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelOrderPerp(exchange, options) {
    try {
        let result = await exchange.cancelOrderPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderPerp(myPhemexExchange, {
         symbol: "BTCUSD",
         orderID: "e31db900-ec06-47b4-97ee-c9018e22322f"
     });
```

## Bulk cancel orders

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#bulk-cancel-orders](https://phemex-docs.github.io/#bulk-cancel-orders)
{% endhint %}

#### Function Name:

```javascript
cancelBatchOrderPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelBatchOrderPerp(exchange, options) {
    try {
        let result = await exchange.cancelBatchOrderPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelBatchOrderPerp(myMainPhemexExchange, {
        symbol: "BTCUSDT",
        orderID: "234fsfs3,d2123dada2"
     });
```

## Cancel all orders

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#cancel-all-orders](https://phemex-docs.github.io/#cancel-all-orders)
{% endhint %}

#### Function Name:

```javascript
cancelAllOrdersPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelAllOrdersPerp(exchange, options) {
    try {
        let result = await exchange.cancelAllOrdersPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query trading account and positions

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-trading-account-and-positions](https://phemex-docs.github.io/#query-trading-account-and-positions)
{% endhint %}

#### Function Name:

```javascript
getTradingAccountPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getTradingAccountPerp(exchange, options) {
    try {
        let result = await exchange.getTradingAccountPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradingAccountPerp(myMainPhemexExchange, {
        currency: "USDT"
    });
```

## Query trading account and positions with realtime unPnL

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-trading-account-and-positions-with-realtime-unpnl](https://phemex-docs.github.io/#query-trading-account-and-positions-with-realtime-unpnl)
{% endhint %}

#### Function Name:

```javascript
getTradingAccountUnPnLPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getTradingAccountUnPnLPerp(exchange, options) {
    try {
        let result = await exchange.getTradingAccountUnPnLPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradingAccountUnPnLPerp(myPhemexExchange, {
         currency: "BTC"
     });
```

## Set leverage

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#set-leverage](https://phemex-docs.github.io/#set-leverage)
{% endhint %}

#### Function Name:

```javascript
setLeverage()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setLeverage(myPhemexExchange, {
         symbol: "BTCUSD",
         leverage: "10"
     });
```

## Set position risklimit

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#set-position-risklimit](https://phemex-docs.github.io/#set-position-risklimit)
{% endhint %}

#### Function Name:

```javascript
setRiskLimit()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function setRiskLimit(exchange, options) {
    try {
        let result = await exchange.setRiskLimit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setRiskLimit(myPhemexExchange, {
         symbol: "BTCUSD",
         riskLimit: "10"
     });
```

## Assign position balance in isolated marign mode

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#assign-position-balance-in-isolated-marign-mode](https://phemex-docs.github.io/#assign-position-balance-in-isolated-marign-mode)
{% endhint %}

#### Function Name:

```javascript
assignPositionBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function assignPositionBalance(exchange, options) {
    try {
        let result = await exchange.assignPositionBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await assignPositionBalance(myPhemexExchange, {
         symbol: "BTCUSD",
         posbalance: "10"
     });
```

## Query open orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-open-orders-by-symbol](https://phemex-docs.github.io/#query-open-orders-by-symbol)
{% endhint %}

#### Function Name:

```javascript
getOpenOrdersPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOpenOrdersPerp(exchange, options) {
    try {
        let result = await exchange.getOpenOrdersPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query closed orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-closed-orders-by-symbol](https://phemex-docs.github.io/#query-closed-orders-by-symbol)
{% endhint %}

#### Function Name:

```javascript
getClosedOrdersPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getClosedOrdersPerp(exchange, options) {
    try {
        let result = await exchange.getClosedOrdersPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getClosedOrdersPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query user order by order ID or client order ID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-user-order-by-order-id-or-client-order-id](https://phemex-docs.github.io/#query-user-order-by-order-id-or-client-order-id)
{% endhint %}

#### Function Name:

```javascript
getUserOrderPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getUserOrderPerp(exchange, options) {
    try {
        let result = await exchange.getUserOrderPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserOrderPerp(myPhemexExchange, {
         symbol: "BTCUSD",
         orderID: "987515a0-3b56-4a9a-9f2e-48ecdd674f4a"
     });
```

## Query user trade

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-user-trade](https://phemex-docs.github.io/#query-user-trade)
{% endhint %}

#### Function Name:

```javascript
getUserTradePerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getUserTradePerp(exchange, options) {
    try {
        let result = await exchange.getUserTradePerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserTradePerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query order book

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-order-book](https://phemex-docs.github.io/#query-order-book)
{% endhint %}

#### Function Name:

```javascript
getOrderBook()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderBook(exchange, options) {
    try {
        let result = await exchange.getOrderBook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBook(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query full order book

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-full-order-book](https://phemex-docs.github.io/#query-full-order-book)
{% endhint %}

#### Function Name:

```javascript
getOrderBookFull()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderBookFull(exchange, options) {
    try {
        let result = await exchange.getOrderBookFull(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookFull(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query kline

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-kline](https://phemex-docs.github.io/#query-kline)
{% endhint %}

#### Function Name:

```javascript
getKline()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getKline(exchange, options) {
    try {
        let result = await exchange.getKline(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKline(myPhemexExchange, {
         symbol: "BTCUSD",
         resolution: "60"
     });
```

## Query recent trades

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-recent-trades](https://phemex-docs.github.io/#query-recent-trades)
{% endhint %}

#### Function Name:

```javascript
getRecentTrades()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getRecentTrades(exchange, options) {
    try {
        let result = await exchange.getRecentTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRecentTrades(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query 24 hours ticker

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-24-hours-ticker](https://phemex-docs.github.io/#query-24-hours-ticker)
{% endhint %}

#### Function Name:

```javascript
get24HourTickerPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTickerPerp(exchange, options) {
    try {
        let result = await exchange.get24HourTickerPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerPerp(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query 24 hours ticker for all symbols

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-24-hours-ticker-for-all-symbols](https://phemex-docs.github.io/#query-24-hours-ticker-for-all-symbols)
{% endhint %}

#### Function Name:

```javascript
get24HourTickerAllSymbolsPerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTickerAllSymbolsPerp(exchange, options) {
    try {
        let result = await exchange.get24HourTickerAllSymbolsPerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerAllSymbolsPerp(myPhemexExchange);
```

## Query history trades by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-history-trades-by-symbol](https://phemex-docs.github.io/#query-history-trades-by-symbol)
{% endhint %}

#### Function Name:

```javascript
getHistoryTradePerp()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getHistoryTradePerp(exchange, options) {
    try {
        let result = await exchange.getHistoryTradePerp(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoryTradePerp(myPhemexExchange, {
         market: "BTCUSD"
     });
```

## Query funding rate history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-funding-rate-history](https://phemex-docs.github.io/#query-funding-rate-history)
{% endhint %}

#### Function Name:

```javascript
getFundingRateHistoryHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundingRateHistoryHedged(exchange, options) {
    try {
        let result = await exchange.getFundingRateHistoryHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingRateHistoryHedged(myPhemexExchange, {symbol: ".ETHUSDTFR8H"});
```

## Query funding fee history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-funding-fee-history](https://phemex-docs.github.io/#query-funding-fee-history)
{% endhint %}

#### Function Name:

```javascript
getFundingFeeHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundingFeeHistory(exchange, options) {
    try {
        let result = await exchange.getFundingFeeHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingFeeHistory(myPhemexExchange, {
         symbol: "BTCUSD"
     });
```

## Query contract fee rate

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-contract-fee-rate](https://phemex-docs.github.io/#query-contract-fee-rate)
{% endhint %}

#### Function Name:

```javascript
getContractFeeRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getContractFeeRate(exchange, options) {
    try {
        let result = await exchange.getContractFeeRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractFeeRate(myPhemexExchange, {
         settleCurrency: "BTC"
     });
```

## Query Funds Detail

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

[https://phemex-docs.github.io#query-funds-detail](https://phemex-docs.github.io/#query-funds-detail)
{% endhint %}

#### Function Name:

```javascript
getFundsDetail()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundsDetail(exchange, options) {
    try {
        let result = await exchange.getFundsDetail(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundsDetail(myMainPhemexExchange);
```


# Hedged Contract

## Query product information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-product-information-2>
{% endhint %}

#### Function Name:

```javascript
getProductInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getProductInfo(exchange, options) {
    try {
        let result = await exchange.getProductInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getProductInfo(myMainPhemexExchange);
```

### Place order <a href="#place-order-http-put-prefered-2" id="place-order-http-put-prefered-2"></a>

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io/#place-order-http-put-prefered-2>
{% endhint %}

#### Function Name:

```javascript
placeOrderHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function placeOrderHedged(exchange, options) {
    try {
        let result = await exchange.placeOrderHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderHedged(myPhemexExchange, {
        symbol: "BTCUSDT", 
        side: "Buy", 
        posSide: "Long",
        orderQtyRq: "0.01",
        ordType: "Limit",
        priceRp: "20000"
    });
```

## Amend order by orderID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#amend-order-by-orderid>
{% endhint %}

#### Function Name:

```javascript
amendOrderHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function amendOrderHedged(exchange, options) {
    try {
        let result = await exchange.amendOrderHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await amendOrderHedged(myPhemexExchange, {
         symbol: "BTCUSDT", 
         orderID: "9839ae8f-88e7-431f-94a4-dd8d3312b382",
         priceRp: "21000",
         posSide: "Buy",
         orderQtyRq: "0.02"

     });
```

## Cancel Single Order by orderID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-single-order-by-orderid>
{% endhint %}

#### Function Name:

```javascript
cancelOrderHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelOrderHedged(exchange, options) {
    try {
        let result = await exchange.cancelOrderHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderHedged(myPhemexExchange, {
         symbol: "BTCUSDT",
         posSide: "Sell",
         orderID: "9839ae8f-88e7-431f-94a4-dd8d3312b382"
     });
```

## Bulk Cancel Orders

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#bulk-cancel-orders-2>
{% endhint %}

#### Function Name:

```javascript
cancelBatchOrderHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelBatchOrderHedged(exchange, options) {
    try {
        let result = await exchange.cancelBatchOrderHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelBatchOrderHedged(myMainPhemexExchange, {
        symbol: "BTCUSDT",
        orderID: "234fsfs3,d2123dada2",
        posSide: "Buy"
     });
```

## Cancel All Orders

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-all-orders-2>
{% endhint %}

#### Function Name:

```javascript
cancelAllOrdersHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelAllOrdersHedged(exchange, options) {
    try {
        let result = await exchange.cancelAllOrdersHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOrdersHedged(myPhemexExchange, {});
```

## Query Account Positions

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-account-positions>
{% endhint %}

#### Function Name:

```javascript
getAccountPositionsHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getAccountPositionsHedged(exchange, options) {
    try {
        let result = await exchange.getAccountPositionsHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountPositionsHedged(myMainPhemexExchange, {
         currency: "USDT"
     });
```

## Query Account Positions with unrealized PNL

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-account-positions-with-unrealized-pnl>
{% endhint %}

#### Function Name:

```javascript
getAccountPositionsUnPnLHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getAccountPositionsUnPnLHedged(exchange, options) {
    try {
        let result = await exchange.getAccountPositionsUnPnLHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountPositionsUnPnLHedged(myPhemexExchange, {
         currency: "BTC"
     });
```

## Switch Position Mode Synchronously

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#switch-position-mode-synchronously>
{% endhint %}

#### Function Name:

```javascript
switchPositionModeSynchronously()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function switchPositionModeSynchronously(exchange, options) {
    try {
        let result = await exchange.switchPositionModeSynchronously(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await switchPositionModeSynchronously(myPhemexExchange, {
         symbol: "BTCUSDT",
         targetPosMode: "Hedged"
     });
```

## Set Leverage

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#set-leverage-2>
{% endhint %}

#### Function Name:

```javascript
setLeverageHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function setLeverageHedged(exchange, options) {
    try {
        let result = await exchange.setLeverageHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setLeverageHedged(myPhemexExchange, {
         symbol: "BTCUSDT",
         leverageRr: "-10"
     });
```

## Set RiskLimit

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#set-risklimit>
{% endhint %}

#### Function Name:

```javascript
setRiskLimitHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function setRiskLimitHedged(exchange, options) {
    try {
        let result = await exchange.setRiskLimitHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setRiskLimitHedged(myPhemexExchange, {
         symbol: "BTCUSDT",
         riskLimitRv: "10",
         posSide: "Buy"
     });
```

## Query open orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-open-orders-by-symbol-2>
{% endhint %}

#### Function Name:

```javascript
getOpenOrdersHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOpenOrdersHedged(exchange, options) {
    try {
        let result = await exchange.getOpenOrdersHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrdersHedged(myPhemexExchange, {
         symbol: "BTCUSDT"
     });
```

## Query closed orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-closed-orders-by-symbol-2>
{% endhint %}

#### Function Name:

```javascript
getClosedOrdersHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getClosedOrdersHedged(exchange, options) {
    try {
        let result = await exchange.getClosedOrdersHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getClosedOrdersHedged(myPhemexExchange, {
         currency: "USDT"
     });
```

## Query user trade

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-user-trade-2>
{% endhint %}

#### Function Name:

```javascript
getUserTradeHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getUserTradeHedged(exchange, options) {
    try {
        let result = await exchange.getUserTradeHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUserTradeHedged(myPhemexExchange, {
         currency: "USDT",
         offset: "0",
         limit: "10"
     });
```

## Query Order Book

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-order-book-2>
{% endhint %}

#### Function Name:

```javascript
getOrderBookHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderBookHedged(exchange, options) {
    try {
        let result = await exchange.getOrderBookHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookHedged(myPhemexExchange, {
         symbol: "BTCUSDT"
     });
```

## Query kline

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-kline-2>
{% endhint %}

#### Function Name:

```javascript
getKlineHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getKlineHedged(exchange, options) {
    try {
        let result = await exchange.getKlineHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKlineHedged(myPhemexExchange, {
         symbol: "BTCUSDT",
         resolution: "60"
     });
```

## Query Trade

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-trade>
{% endhint %}

#### Function Name:

```javascript
getTradeHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getTradeHedged(exchange, options) {
    try {
        let result = await exchange.getTradeHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradeHedged(myPhemexExchange, {
         symbol: "BTCUSDT"
     });
```

## Query 24 ticker

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-24-ticker>
{% endhint %}

#### Function Name:

```javascript
get24HourTickerHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTickerHedged(exchange, options) {
    try {
        let result = await exchange.get24HourTickerHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerHedged(myPhemexExchange, {
         symbol: "BTCUSDT"
     });
```

## Query 24 ticker for all symbols

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-24-ticker-for-all-symbols>
{% endhint %}

#### Function Name:

```javascript
get24HourTickerAllSymbolsHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTickerAllSymbolsHedged(exchange, options) {
    try {
        let result = await exchange.get24HourTickerAllSymbolsHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerAllSymbolsHedged(myPhemexExchange);
```

## Query Orders History

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-orders-history>
{% endhint %}

#### Function Name:

```javascript
getOrdersHistoryHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrdersHistoryHedged(exchange, options) {
    try {
        let result = await exchange.getOrdersHistoryHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrdersHistoryHedged(myPhemexExchange, {
         symbol: "BTCUSDT"
     });
```

## Query Orders By Ids

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-orders-by-ids>
{% endhint %}

#### Function Name:

```javascript
getOrdersByIdHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrdersByIdHedged(exchange, options) {
    try {
        let result = await exchange.getOrdersByIdHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrdersByIdHedged(myPhemexExchange, {
         symbol: "BTCUSDT",
         orderID: "9839ae8f-88e7-431f-94a4-dd8d3312b382"
     });
```

## Query Trades History

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-trades-history>
{% endhint %}

#### Function Name:

```javascript
getTradeHistoryHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getTradeHistoryHedged(exchange, options) {
    try {
        let result = await exchange.getTradeHistoryHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradeHistoryHedged(myPhemexExchange, {currency:"BTC", symbol: "BTCUSDT"});
```

## Query funding rate history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-funding-rate-history-2>
{% endhint %}

#### Function Name:

```javascript
getFundingRateHistoryHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundingRateHistoryHedged(exchange, options) {
    try {
        let result = await exchange.getFundingRateHistoryHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingRateHistoryHedged(myPhemexExchange, {symbol: ".ETHUSDTFR8H"});
```

## Query funding fee history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-funding-fee-history-2>
{% endhint %}

#### Function Name:

```javascript
getFundingFeeHistoryHedged()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundingFeeHistoryHedged(exchange, options) {
    try {
        let result = await exchange.getFundingFeeHistoryHedged(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingFeeHistoryHedged(myPhemexExchange, {symbol: "BTCUSDT"});
```


# Spot

## Query product information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-product-information-3>
{% endhint %}

#### Function Name:

```javascript
getProductInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getProductInfo(exchange, options) {
    try {
        let result = await exchange.getProductInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getProductInfo(myMainPhemexExchange);
```

## Query server time

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-server-time-2>
{% endhint %}

#### Function Name:

```javascript
getServerTime()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getServerTime(exchange, options) {
    try {
        let result = await exchange.getServerTime(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getServerTime(myPhemexExchange);
```

### Place order <a href="#place-order-http-put-prefered-3" id="place-order-http-put-prefered-3"></a>

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io/#place-order-http-put-prefered-3>
{% endhint %}

#### Function Name:

```javascript
placeOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function amendOrder(exchange, options) {
    try {
        let result = await exchange.amendOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}
let result = await placeOrder(myPhemexExchange, {
            symbol: "sBTCUSDT",
            side: "Buy",
            qtyType:"ByBase",
            baseQtyEv: "1000000000",
            ordType: "Limit",
            priceEp: "2000000000"
    });
```

## Amend order

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#amend-order>
{% endhint %}

#### Function Name:

```javascript
amendOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function amendOrder(exchange, options) {
    try {
        let result = await exchange.amendOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await amendOrder(myPhemexExchange, {
             symbol: "sBTCUSDT",
             orderID: "abb9f72f-2b97-4e96-acaa-2a2a6f9453a4",
             priceRp: "200",

     });
```

## Cancel order

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-order>
{% endhint %}

#### Function Name:

```javascript
cancelOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelOrder(exchange, options) {
    try {
        let result = await exchange.cancelOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrder(myPhemexExchange, {
             symbol: "sBTCUSDT",
             orderID: "abb9f72f-2b97-4e96-acaa-2a2a6f9453a4"

     });
```

## Cancel all order by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-all-order-by-symbol>
{% endhint %}

#### Function Name:

```javascript
cancelAllOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelAllOrders(exchange, options) {
    try {
        let result = await exchange.cancelAllOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOrders(myPhemexExchange);
```

## Query open order by order ID or client order ID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-open-order-by-order-id-or-client-order-id>
{% endhint %}

#### Function Name:

```javascript
getOpenOrderActive()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOpenOrderActive(exchange, options) {
    try {
        let result = await exchange.getOpenOrderActive(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrderActive(myPhemexExchange, {
             orderID: "c3cf42ee-49ac-41a3-b092-1905062e813a",
             symbol: "sBTCUSDT"
     });
```

## Query all open orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-all-open-orders-by-symbol>
{% endhint %}

#### Function Name:

```javascript
getOpenOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOpenOrders(exchange, options) {
    try {
        let result = await exchange.getOpenOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrders(myPhemexExchange, {
             symbol: "sBTCUSDT"
     });
```

## Query wallets

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-wallets>
{% endhint %}

#### Function Name:

```javascript
getWallets()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getWallets(exchange, options) {
    try {
        let result = await exchange.getWallets(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWallets(myMainPhemexExchange, {
     });
```

## Query orders by order ID or client order ID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-orders-by-order-id-or-client-order-id>
{% endhint %}

#### Function Name:

```javascript
getOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrder(exchange, options) {
    try {
        let result = await exchange.getOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderHistory(myPhemexExchange, {
             symbol: "sBTCUSDT"
     });
```

## Query order history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-order-history>
{% endhint %}

#### Function Name:

```javascript
getOrderHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderHistory(exchange, options) {
    try {
        let result = await exchange.getOrderHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderHistory(myPhemexExchange, {
             symbol: "sBTCUSDT"
     });
```

## Query trade history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-trade-history>
{% endhint %}

#### Function Name:

```javascript
getTradesHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getTradesHistory(exchange, options) {
    try {
        let result = await exchange.getTradesHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradesHistory(myPhemexExchange, {
             symbol: "sBTCUSDT"
     });
```

## Query PnL

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-pnl>
{% endhint %}

#### Function Name:

```javascript
getPnL()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getPnL(exchange, options) {
    try {
        let result = await exchange.getPnL(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPnL(myPhemexExchange);
```

## Query chain information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-chain-information>
{% endhint %}

#### Function Name:

```javascript
getChainInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getChainInfo(exchange, options) {
    try {
        let result = await exchange.getChainInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getChainInfo(myPhemexExchange, {currency: "BTC"});
```

## Query deposit address by currency

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-deposit-address-by-currency>
{% endhint %}

#### Function Name:

```javascript
getDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getDepositAddress(exchange, options) {
    try {
        let result = await exchange.getDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositAddress(myPhemexExchange, {
         currency: "BTC",
         chainName: "BTC"
     });
```

## Query recent deposit history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-recent-deposit-history>
{% endhint %}

#### Function Name:

```javascript
getDepositHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getDepositHistory(exchange, options) {
    try {
        let result = await exchange.getDepositHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositHistory(myPhemexExchange, {
         currency: "BTC"
     });
```

## Query recent withdraw history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-recent-withdraw-history>
{% endhint %}

#### Function Name:

```javascript
getWithdrawHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getWithdrawHistory(exchange, options) {
    try {
        let result = await exchange.getWithdrawHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawHistory(myPhemexExchange, {
         currency: "BTC"
     });
```

## Query funds history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-funds-history>
{% endhint %}

#### Function Name:

```javascript
getFundsHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFundsHistory(exchange, options) {
    try {
        let result = await exchange.getFundsHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundsHistory(myPhemexExchange, {
         currency: "USDT"
     });
```

## Query fee rate by quote currency

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-fee-rate-by-quote-currency>
{% endhint %}

#### Function Name:

```javascript
getFeeRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getFeeRate(exchange, options) {
    try {
        let result = await exchange.getFeeRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFeeRate(myPhemexExchange, {
         quoteCurrency: "USDT"
     });
```

## Query order book

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-order-book-3>
{% endhint %}

#### Function Name:

```javascript
getOrderBook()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderBook(exchange, options) {
    try {
        let result = await exchange.getOrderBook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBook(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query full order book

{% hint style="info" %}
Please refer to the official Phemex  API Docs for the Required parameters.

<https://phemex-docs.github.io#query-full-order-book-2>
{% endhint %}

#### Function Name:

```javascript
getOrderBookFull()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOrderBookFull(exchange, options) {
    try {
        let result = await exchange.getOrderBookFull(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookFull(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query recent trades

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-recent-trades-2>
{% endhint %}

#### Function Name:

```javascript
getRecentTrades()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getRecentTrades(exchange, options) {
    try {
        let result = await exchange.getRecentTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRecentTrades(myPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query 24 hours ticker for all symbols

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-24-hours-ticker-for-all-symbols-2>
{% endhint %}

#### Function Name:

```javascript
get24HourTickerAllSymbols()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTickerAllSymbols(exchange, options) {
    try {
        let result = await exchange.get24HourTickerAllSymbols(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerAllSymbols(myPhemexExchange);
```

## Query 24 hours ticker

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-24-hours-ticker-2>
{% endhint %}

#### Function Name:

```javascript
get24HourTicker()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function get24HourTicker(exchange, options) {
    try {
        let result = await exchange.get24HourTicker(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HourTickerAllSymbols(myPhemexExchange);
```


# Margin Trading

## Query product information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-product-information-4>
{% endhint %}

#### Function Name:

```javascript
getProductInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getProductInfo(exchange, options) {
    try {
        let result = await exchange.getProductInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getProductInfo(myMainPhemexExchange);
```

### Place order <a href="#place-order-http-put-prefered-4" id="place-order-http-put-prefered-4"></a>

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io/#place-order-http-put-prefered-4>
{% endhint %}

#### Function Name:

```javascript
placeOrderMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function placeOrderMargin(exchange, options) {
    try {
        let result = await exchange.placeOrderMarginrderMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderMargin(myMainPhemexExchange, {
        symbol: "sBTCUSDT",
        side: "Buy",
        qtyType: "ByBase",
        baseQtyRq: "1",
        priceRp: "1000",
        ordType: "Limit"
    });

```

## Cancel order

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-order-2>
{% endhint %}

#### Function Name:

```javascript
cancelOrderMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelOrderMargin(exchange, options) {
    try {
        let result = await exchange.cancelOrderMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderMargin(myMainPhemexExchange, {
         symbol: "sBTCUSDT",
         orderID: "jwkndqwklqkdw"
     });
```

## Cancel all order by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-all-order-by-symbol-2>
{% endhint %}

#### Function Name:

```javascript
cancelAllOrdersMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelAllOrdersMargin(exchange, options) {
    try {
        let result = await exchange.cancelAllOrdersMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOrdersMargin(myMainPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query open order by order ID or client order ID

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-open-order-by-order-id-or-client-order-id-2>
{% endhint %}

#### Function Name:

```javascript
getOpenOrderMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getOpenOrderMargin(exchange, options) {
    try {
        let result = await exchange.getOpenOrderMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrderMargin(myMainPhemexExchange, {
         symbol: "sBTCUSDT",
         orderID: "swjndklwndwdkmn"
     });
```

## Query all open orders by symbol

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-all-open-orders-by-symbol-2>
{% endhint %}

#### Function Name:

```javascript
getAllOpenOrdersMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getAllOpenOrdersMargin(exchange, options) {
    try {
        let result = await exchange.getAllOpenOrdersMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllOpenOrdersMargin(myMainPhemexExchange, {
         symbol: "sBTCUSDT"
     });
```

## Query margin orders details

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-margin-orders-details>
{% endhint %}

#### Function Name:

```javascript
getMarginOrdersDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getMarginOrdersDetails(exchange, options) {
    try {
        let result = await exchange.getMarginOrdersDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginOrdersDetails(myMainPhemexExchange, {
     });
```

## Query margin order trades details

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-margin-order-trades-details>
{% endhint %}

#### Function Name:

```javascript
getMarginOrderTradesDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getMarginOrderTradesDetails(exchange, options) {
    try {
        let result = await exchange.getMarginOrderTradesDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginOrderTradesDetails(myMainPhemexExchange, {
     });
```

## Query margin borrow interest history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-margin-borrow-interest-history>
{% endhint %}

#### Function Name:

```javascript
getMarginBorrowInterestHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getMarginBorrowInterestHistory(exchange, options) {
    try {
        let result = await exchange.getMarginBorrowInterestHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginBorrowInterestHistory(myMainPhemexExchange, {
     });
```

## Query margin borrow history records

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-margin-borrow-history-records>
{% endhint %}

#### Function Name:

```javascript
getMarginBorrowHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getMarginBorrowHistory(exchange, options) {
    try {
        let result = await exchange.getMarginBorrowHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginBorrowHistory(myMainPhemexExchange, {
     });
```

## Query margin payback history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-margin-payback-history>
{% endhint %}

#### Function Name:

```javascript
getMarginPaybackHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getMarginPaybackHistory(exchange, options) {
    try {
        let result = await exchange.getMarginPaybackHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginPaybackHistory(myMainPhemexExchange, {
     });
```

## Post margin borrow request

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#post-margin-borrow-request>
{% endhint %}

#### Function Name:

```javascript
marginBorrow()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function marginBorrow(exchange, options) {
    try {
        let result = await exchange.marginBorrow(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await marginBorrow(myMainPhemexExchange, {
        currency: "USDT",
        amountRv: "100"
     });
```

## Post margin payback history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#post-margin-payback-history>
{% endhint %}

#### Function Name:

```javascript
marginPayback()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function marginPayback(exchange, options) {
    try {
        let result = await exchange.marginPayback(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await marginPayback(myMainPhemexExchange, {
        currency: "USDT",
        amountRv: "1"
     });
```

## Query wallets

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-wallets-2>
{% endhint %}

#### Function Name:

```javascript
getWalletsMargin()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getWalletsMargin(exchange, options) {
    try {
        let result = await exchange.getWalletsMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWalletsMargin(myMainPhemexExchange, {

     });
```


# Transfer

{% hint style="danger" %}
This section currently under construction
{% endhint %}


# Convert

## RFQ quote

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#rfq-quote>
{% endhint %}

#### Function Name:

```javascript
rfqQuote()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function rfqQuote(exchange, options) {
    try {
        let result = await exchange.rfqQuote(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await rfqQuote(myMainPhemexExchange, {
        fromCurrency: "BTC",
        toCurrency: "USD",
        fromAmountEv: "1"
     });
```

## Convert

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#convert>
{% endhint %}

#### Function Name:

```javascript
convert()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function convert(exchange, options) {
    try {
        let result = await exchange.convert(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await convert(myMainPhemexExchange, {
        fromCurrency: "BTC",
        toCurrency: "USD",
        fromAmountEv: "1",
         code: "GK5LG755LVQYCJUWL3MESRZF3D7T67JIZJEOPNY3RBBCOF2W65DFIJXSEOT3EJTHE33NIN2XE4TFNZRXSIR2EJBFIQZCFQRHI32DOVZHEZLOMN4SEORCKVJUIIRMEJXXE2LHNFXCEORRFQRHA4TJMNSSEORCGAXDAMBQGAYDAMBQEIWCE4DSNFRWKUZYEI5DALBCOBZGSY3FIZXXEQ3BNRRSEORQIUWTEMRMEJYHE33DMVSWI4ZCHIRDALRQGAYDAMBQGAYCELBCOBZG6Y3FMVSHGRLWEI5DALBCMNXW45TFOJZWS33OIZSWKSLUMVWXGIR2PMRGG33OOZSXE43JN5XEMZLFKJ2WYZLTEI5FWISEIVDECVKMKRPUMRKFL5LUQRKOL5HE6X2NIFKEGSBCLUWCE5DPORQWYRTFMVJGC5DFEI5DALRQGAZSYITUN52GC3CGMVSUK5RCHIYSYITCMFZWKRTFMVJGC5DFEI5DALRQGAYTKMBQFQRGEYLTMVDGKZKFOYRDUMBMEJTXEYLEOVQWYRTFMVJGC5DFEI5G45LMNQWCEZ3SMFSHKYLMIZSWKRLWEI5DALBCOBSW4YLMOR4UMZLFKJQXIZJCHJXHK3DMFQRHAZLOMFWHI6KGMVSUK5RCHIYCYITXNBUXIZKMNFZXIRTFMVJGC5DFEI5G45LMNQWCE53INF2GKTDJON2EMZLFIV3CEORQFQRGIZLGMF2WY5CGMVSVEYLUMURDUMBOGAYDGLBCMRSWMYLVNR2EMZLFIV3CEORQFQRHI2DJOJSFAYLSOR4UMZLFKJQXIZJCHJXHK3DMFQRHI2DJOJSFAYLSOR4UMZLFIV3CEORQPUWCE5DJMNVUS3TGN4RDU6ZCOBZGSY3FEI5DGMBYHE3TKOBQGQWCE43DMFWGKIR2GQWCE5DJNVSXG5DBNVYCEORRGY4TQMBXGYZDINZZHA4TQMBSHAZTOLBCORXUEYLTMVBXK4TSMVXGG6JCHJ2HE5LFPUWCE3LPOZSU64BCHIYCYITFPBYGS4TFIF2CEORRGY4TQMBXGYZDKNZQGAZSYITSMVYXKZLTORAXIIR2GE3DSOBQG43DENBZGAYDGLBCOF2W65DFIF2CEORRGY4TQMBXGYZDINZZHA4SYITROVXXIZKJMQRDUMJWHE4DANZWGI2DOOJYHEWCE4LVN52GKUDSNFRWKUZUEI5DGMBYHE3TKOBQGR6SYITVONSXESLEEI5DIOBQG44TSNZMEJRGSZBCHIRCELBCOF2W65DFJNSXSIR2EJRTEMLEGA4DENBNMQYDSNJNGRRGGYZNMFTDIZRNGI3TCYJTHFSWCOBWGM3SE7ML347V3CYBAAAA"
     });
```

## Query convert history

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-convert-history>
{% endhint %}

#### Function Name:

```javascript
getConvertHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getConvertHistory(exchange, options) {
    try {
        let result = await exchange.getConvertHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getConvertHistory(myMainPhemexExchange, {
 });
```


# Deposit And Withdraw

## Query deposit address information

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-deposit-address-information>
{% endhint %}

#### Function Name:

```javascript
getDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getDepositAddress(exchange, options) {
    try {
        let result = await exchange.getDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositAddress(myPhemexExchange, {
         currency: "BTC",
         chainName: "BTC"
     });
```

## Query deposit history records

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-deposit-history-records>
{% endhint %}

#### Function Name:

```javascript
getDepositHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getDepositHistory(exchange, options) {
    try {
        let result = await exchange.getDepositHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositHistory(myPhemexExchange, {
         currency: "BTC"
     });
```

## Query deposit chain settings

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-deposit-chain-settings>
{% endhint %}

#### Function Name:

```javascript
getDepositChainSettings()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getDepositChainSettings(exchange, options) {
    try {
        let result = await exchange.getDepositChainSettings(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositChainSettings(myMainPhemexExchange, {
         currency: "USDT"
     });
```

## Query withdraw history records

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-withdraw-history-records>
{% endhint %}

#### Function Name:

```javascript
getWithdrawHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getWithdrawHistory(exchange, options) {
    try {
        let result = await exchange.getWithdrawHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawHistory(myPhemexExchange, {
         currency: "BTC"
     });
```

## Create withdraw request

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#create-withdraw-request>
{% endhint %}

#### Function Name:

```javascript
withdraw()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function withdraw(exchange, options) {
    try {
        let result = await exchange.withdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await withdraw(myMainPhemexExchange, {
        currency: "USDT",
        address: "dalwkdmn55ownd22n",
        amount: "1",
        chainName: "ETH"
     });
```

## Cancel withdraw request

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#cancel-withdraw-request>
{% endhint %}

#### Function Name:

```javascript
cancelWithdraw()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function cancelWithdraw(exchange, options) {
    try {
        let result = await exchange.cancelWithdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelWithdraw(myMainPhemexExchange, {
        id: "fkjnklnlnm3mnpinpio3333"
     });
```

## Query withdraw chain settings

{% hint style="info" %}
Please refer to the official Phemex API Docs for the Required parameters.

<https://phemex-docs.github.io#query-withdraw-chain-settings>
{% endhint %}

#### Function Name:

```javascript
getWithdrawChainSettings()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myPhemexExchange  = createExchange({
      exchange: "phemex",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "phemex"
  });

async function getWithdrawChainSettings(exchange, options) {
    try {
        let result = await exchange.getWithdrawChainSettings(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawChainSettings(myMainPhemexExchange, {
        currency: "USDT"
     });
```


# BloFin Functions

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let blofin_exchange = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
});


```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myMexcAccount= createExchange({
      exchange: "blofin",
      authenticate: "false",
      label: "blofin"
});
```

## All Available Blofin Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% content-ref url="/pages/bI7wJmIDLEdIlXXoXZSY" %}
[Account](/pendax/using-pendax-sdk/blofin-functions/account)
{% endcontent-ref %}

{% content-ref url="/pages/8EESpJEcXUcRW2ltfyL3" %}
[Affiliate](/pendax/using-pendax-sdk/blofin-functions/affiliate)
{% endcontent-ref %}

{% content-ref url="/pages/ZsF8FSmC2SCIx0TBOkPN" %}
[Public Data](/pendax/using-pendax-sdk/blofin-functions/public-data)
{% endcontent-ref %}

{% content-ref url="/pages/WX2hnAQzjGYyN966wb8j" %}
[Trading](/pendax/using-pendax-sdk/blofin-functions/trading)
{% endcontent-ref %}

{% content-ref url="/pages/A0IIwKmgh5BC2GHf2SWS" %}
[User](/pendax/using-pendax-sdk/blofin-functions/user)
{% endcontent-ref %}

{% content-ref url="/pages/bc8ECoQF3NV8yc14wR59" %}
[Websocket](/pendax/using-pendax-sdk/blofin-functions/websocket)
{% endcontent-ref %}


# Websocket

## BlofinSocket Object

#### Constructor:

```javascript
 let myBlofinSocket = new BlofinSocket(options);
```

#### Usage:

```javascript
import { BlofinSocket } from "./dev-package/sockets/blofinsocket.js";

  let onOpen = (options) => {
  	console.log("Hello World");
  }

  const exampleOpts = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: "true",
    clientOnOpen: onOpen
  });

  let myBlofinSocket = new BlofinSocket(exampleOpts);


```

#### Options:

* apiKey: String
  * Given on creation of API key. Required
* secret: String
  * Secret Key. Required if using private channels
* passphrase: String
  * Passphrased created by user. Required if using private channels
* isPrivate: Boolean
  * Indicates whether to use private channels. False by default
* clientOnOpen: Function(options)
  * Function that takes the options given in the constructor as a parameter and should execute on creation of the websocket once finished opening
* clientOnMessage: Function(options, msg)
  * Function that takes the options given in the constructor and an incoming message as parameters and should execute on reception of said message
* clientOnError: Function(options, msg)
  * Function that takes the options given in the constructor and an incoming error as parameters and should execute on reception of said error
* clientOnClose: Function(code, msg, options)
  * Function that takes a closing code, a message, and the options given in the constructor as parameters and should execute on close

## Login

{% hint style="info" %}
Please refer to the official BloFin API Docs for additional info.

<https://docs.blofin.com/index.html#login>
{% endhint %}

#### Function name:

```javascript
login()
```

#### Usage:

```javascript
let onOpen = (options) => {
  options.socket.login();
}

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: true,
    clientOnOpen: onOpen
  });

```

## Subscribe

{% hint style="info" %}
Please refer to the official BloFin API Docs for additional info.

<https://docs.blofin.com/index.html#subscribe>
{% endhint %}

#### Function name:

```javascript
subscribe(subscriptions)
```

#### Usage:

```javascript
let onOpen = (options) => {
  options.socket.login();
}


let onMessage = (options, msg) => {
  if (msg.event == 'login'){
    options.socket.subscribe({
                    args:
                        [{ channel: 'account'}]
                });
  }
}

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: true,
    clientOnOpen: onOpen,
    clientOnMessage: onMessage
  });

```

## Unsubscribe

{% hint style="info" %}
Please refer to the official BloFin API Docs for additional info.

<https://docs.blofin.com/index.html#unsubscribe>
{% endhint %}

#### Function name:

```javascript
unsubscribe(subscriptions)
```

#### Usage:

```javascript
let onOpen = (options) => {
  options.socket.subscribe({

    args:
        [{ 
          channel: 'tickers',
          instId: 'BTC-USDT'
        }]
  });
  }
  
  
  let onMessage = (options, msg) => {
    
    if(msg.event == 'subscribe'){ 
        options.socket.unsubscribe([{ 
          channel: 'tickers',
          instId: 'BTC-USDT'
        }])
    

  }
  

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: false,
    clientOnOpen: onOpen,
    clientOnMessage: onMessage
  });



```


# Account

## GET Balance

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-balance>
{% endhint %}

#### Function Name:

```javascript
getBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getBalance(exchange, options) {
    try {
        let result = await exchange.getBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getBalance(myBlofinExchange, {
	accountType: "<String>"
});
```

## GET Funds Transfer History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-funds-transfer-history>
{% endhint %}

#### Function Name:

```javascript
getFundsTranferHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getFundsTranferHistory(exchange, options) {
    try {
        let result = await exchange.getFundsTranferHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundsTranferHistory(myBlofinExchange, 
});
```

## GET Withdraw History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-withdraw-history>
{% endhint %}

#### Function Name:

```javascript
getWithdrawHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getWithdrawHistory(exchange, options) {
    try {
        let result = await exchange.getWithdrawHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawHistory(myBlofinExchange, 
});
```

## GET Deposit History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-deposit-history>
{% endhint %}

#### Function Name:

```javascript
getDepositHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getDepositHistory(exchange, options) {
    try {
        let result = await exchange.getDepositHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositHistory(myBlofinExchange, 
});
```


# Affiliate

## GET Affiliate Info

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-affiliate-info>
{% endhint %}

#### Function Name:

```javascript
getAffiliateInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getAffiliateInfo(exchange, options) {
    try {
        let result = await exchange.getAffiliateInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAffiliateInfo(myBlofinExchange, 
});
```

## GET Referral Code

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-referral-code>
{% endhint %}

#### Function Name:

```javascript
getReferralCode()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getReferralCode(exchange, options) {
    try {
        let result = await exchange.getReferralCode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getReferralCode(myBlofinExchange, 
});
```

## GET Direct Invitees

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-direct-invitees>
{% endhint %}

#### Function Name:

```javascript
getDirectInvites()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getDirectInvites(exchange, options) {
    try {
        let result = await exchange.getDirectInvites(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDirectInvites(myBlofinExchange, 
});
```

## GET Sub Invitees

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-sub-invitees>
{% endhint %}

#### Function Name:

```javascript
getSubInvitees()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getSubInvitees(exchange, options) {
    try {
        let result = await exchange.getSubInvitees(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubInvitees(myBlofinExchange, 
});
```

## GET Sub Affiliates

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-sub-affiliates>
{% endhint %}

#### Function Name:

```javascript
getSubAffiliates()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getSubAffiliates(exchange, options) {
    try {
        let result = await exchange.getSubAffiliates(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubAffiliates(myBlofinExchange, 
});
```


# Public Data

## GET Instruments

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-instruments>
{% endhint %}

#### Function Name:

```javascript
getInstruments()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getInstruments(exchange, options) {
    try {
        let result = await exchange.getInstruments(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getInstruments(myBlofinExchange, 
});
```

## GET Tickers

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-tickers>
{% endhint %}

#### Function Name:

```javascript
getTickers()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getTickers(exchange, options) {
    try {
        let result = await exchange.getTickers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTickers(myBlofinExchange, 
});
```

## GET Order Book

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-order-book>
{% endhint %}

#### Function Name:

```javascript
getOrderBook()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getOrderBook(exchange, options) {
    try {
        let result = await exchange.getOrderBook(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBook(myBlofinExchange, 
});
```

## GET Trades

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-trades>
{% endhint %}

#### Function Name:

```javascript
getTrades()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getTrades(exchange, options) {
    try {
        let result = await exchange.getTrades(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTrades(myBlofinExchange, {
	instId: "<String>"
});
```

## GET Mark Price

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-mark-price>
{% endhint %}

#### Function Name:

```javascript
getMarkPrice()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getMarkPrice(exchange, options) {
    try {
        let result = await exchange.getMarkPrice(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarkPrice(myBlofinExchange, {
	instId: "<String>"
});
```

## GET Funding Rate

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-funding-rate>
{% endhint %}

#### Function Name:

```javascript
getFundingRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getFundingRate(exchange, options) {
    try {
        let result = await exchange.getFundingRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingRate(myBlofinExchange, {
	instId: "<String>"
});
```

## GET Funding Rate History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-funding-rate-history>
{% endhint %}

#### Function Name:

```javascript
getFundingRateHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getFundingRateHistory(exchange, options) {
    try {
        let result = await exchange.getFundingRateHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingRateHistory(myBlofinExchange, {
	instId: "<String>"
});
```

## GET Candlesticks

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-candlesticks>
{% endhint %}

#### Function Name:

```javascript
getCandleSticks()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getCandleSticks(exchange, options) {
    try {
        let result = await exchange.getCandleSticks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getCandleSticks(myBlofinExchange, {
	instId: "<String>"
});
```


# Trading

## GET Futures Account Balance

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-futures-account-balance>
{% endhint %}

#### Function Name:

```javascript
getFuturesAccountBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getFuturesAccountBalance(exchange, options) {
    try {
        let result = await exchange.getFuturesAccountBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFuturesAccountBalance(myBlofinExchange, 
});
```

## GET Positions

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-positions>
{% endhint %}

#### Function Name:

```javascript
getPositions()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getPositions(exchange, options) {
    try {
        let result = await exchange.getPositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositions(myBlofinExchange, 
});
```

## GET Margin Mode

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-margin-mode>
{% endhint %}

#### Function Name:

```javascript
getMarginMode()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getMarginMode(exchange, options) {
    try {
        let result = await exchange.getMarginMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginMode(myBlofinExchange, 
});
```

## GET Multiple Leverage

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-multiple-leverage>
{% endhint %}

#### Function Name:

```javascript
getMultipleLeverage()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getMultipleLeverage(exchange, options) {
    try {
        let result = await exchange.getMultipleLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMultipleLeverage(myBlofinExchange, 
});
```

## Set Leverage

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#set-leverage>
{% endhint %}

#### Function Name:

```javascript
setLeverage()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setLeverage(myBlofinExchange, 
});
```

## Place Order

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#place-order>
{% endhint %}

#### Function Name:

```javascript
placeOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function placeOrder(exchange, options) {
    try {
        let result = await exchange.placeOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrder(myBlofinExchange, {
	instId: "<String>",
	marginMode: "<String>",
	side: "<String>",
	orderType: "<String>",
	price: "<String>",
	size: "<String>"
});
```

## Place Multiple Orders

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#place-multiple-orders>
{% endhint %}

#### Function Name:

```javascript
placeMultipleOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function placeMultipleOrders(exchange, options) {
    try {
        let result = await exchange.placeMultipleOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeMultipleOrders(myBlofinExchange, 
});
```

## Place TPSL Order

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#place-tpsl-order>
{% endhint %}

#### Function Name:

```javascript
placeTPSLOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function placeTPSLOrder(exchange, options) {
    try {
        let result = await exchange.placeTPSLOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeTPSLOrder(myBlofinExchange, {
	instId: "<String>",
	marginMode: "<String>",
	positionSide: "<String>",
	side: "<String>",
	tpTriggerPrice: "<String>"
});
```

## Cancel Order

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#cancel-order>
{% endhint %}

#### Function Name:

```javascript
cancelOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function cancelOrder(exchange, options) {
    try {
        let result = await exchange.cancelOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrder(myBlofinExchange, 
});
```

## Cancel Multiple Orders

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#cancel-multiple-orders>
{% endhint %}

#### Function Name:

```javascript
cancelMultipleOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function cancelMultipleOrders(exchange, options) {
    try {
        let result = await exchange.cancelMultipleOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelMultipleOrders(myBlofinExchange, 
});
```

## Cancel TPSL Order

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#cancel-tpsl-order>
{% endhint %}

#### Function Name:

```javascript
cancelTPSLOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function cancelTPSLOrder(exchange, options) {
    try {
        let result = await exchange.cancelTPSLOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelTPSLOrder(myBlofinExchange, 
});
```

## GET Active Orders

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-active-orders>
{% endhint %}

#### Function Name:

```javascript
getActiveOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getActiveOrders(exchange, options) {
    try {
        let result = await exchange.getActiveOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getActiveOrders(myBlofinExchange, 
});
```

## GET Active TPSL Orders

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-active-tpsl-orders>
{% endhint %}

#### Function Name:

```javascript
getActiveTPSLOrders()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getActiveTPSLOrders(exchange, options) {
    try {
        let result = await exchange.getActiveTPSLOrders(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getActiveTPSLOrders(myBlofinExchange, 
});
```

## Close Positions

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#close-positions>
{% endhint %}

#### Function Name:

```javascript
closePositions()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function closePositions(exchange, options) {
    try {
        let result = await exchange.closePositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await closePositions(myBlofinExchange, {
	instId: "<String>",
	marginMode: "<String>"
});
```

## GET TPSL Order History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-tpsl-order-history>
{% endhint %}

#### Function Name:

```javascript
getTPSLOrderHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getTPSLOrderHistory(exchange, options) {
    try {
        let result = await exchange.getTPSLOrderHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTPSLOrderHistory(myBlofinExchange, 
});
```

## GET Trade History

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-trade-history>
{% endhint %}

#### Function Name:

```javascript
getTradeHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getTradeHistory(exchange, options) {
    try {
        let result = await exchange.getTradeHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradeHistory(myBlofinExchange, 
});
```


# User

## GET API Key Info

{% hint style="info" %}
Please refer to the official BloFin API Docs for the Required parameters.

<https://docs.blofin.com/index.html#get-api-key-info>
{% endhint %}

### Function Name:

```javascript
getApiKeyInfo()
```

### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBlofinExchange  = createExchange({
      exchange: "blofin",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "blofin"
  });

async function getApiKeyInfo(exchange, options) {
    try {
        let result = await exchange.getApiKeyInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getApiKeyInfo(myBlofinExchange, 
});
```


# BingX Functions

Documentation for interacting with BingX functions and API endpoints through the PENDAX Javascript SDK.

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object. This exchange object will allow you to interact with PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let bitget_exchange = createExchange({
  exchange: "bingx",
  key: "key",
  secret: "secret",
  authenticate: true,
  label: "bingx",
});
```

#### Unauthenticated Exchange Objects

If you are just calling public API endpoints on the exchange and you don't need any authentication to protected endpoints, simply create your exchange object with authenticate set to false and omit the key, secret, passphrase.

{% hint style="info" %}
Authenticated Exchange objects can call private and public endpoints, however, unauthenticated exchange objects may only call public endpoints.
{% endhint %}

#### Example Unauthenticated Exchange Object:

```javascript
import { createExchange } from "./exchanges/exchange.js";

let myBitgetAccount = createExchange({
  exchange: "bingx",
  authenticate: false,
  label: "bingx",
});
```

{% hint style="warning" %}
These documents are under development and will be updated shortly with all finalized functions
{% endhint %}

## All Available BingX Functions

Documentation for each category of functions is broken down into its own subpage in order to make navigating pages simpler and faster. Please use the side navigation to access these sub-pages or click on one of the links below.

{% hint style="info" %}
BingX Spot, USDT-M futures, and Coin-M futures markets functions are split into different sections of the documentation. Please ensure you are trying to interact with the right section when implementing functions.
{% endhint %}

### BingX Common Functions

Documented PENDAX functions applicable to Bitget spot markets.

{% content-ref url="/pages/wjmQUiytqP7gT92YZgBw" %}
[CopyTrader](/pendax/using-pendax-sdk/bingx-functions/copytrader)
{% endcontent-ref %}

{% content-ref url="/pages/oSjZESq2lbb57PB3aiDN" %}
[Fund Account](/pendax/using-pendax-sdk/bingx-functions/fund-account)
{% endcontent-ref %}

{% content-ref url="/pages/TyuKO8XYvZrFiB51HXtg" %}
[Sub-Account Managenent](/pendax/using-pendax-sdk/bingx-functions/sub-account-managenent)
{% endcontent-ref %}

{% content-ref url="/pages/GPhwNrl0HKHL8QLB2j0p" %}
[Wallet Deposits and Withdrawals](/pendax/using-pendax-sdk/bingx-functions/wallet-deposits-and-withdrawals)
{% endcontent-ref %}

### BingX Spot Market Functions

Documented PENDAX functions applicable to Bitget spot markets.

{% content-ref url="/pages/OdeAayJTbDZ61f2ZQQpV" %}
[Market Data (Spot)](/pendax/using-pendax-sdk/bingx-functions/market-data-spot)
{% endcontent-ref %}

{% content-ref url="/pages/o4e4q8BW4IzYSRffM5M0" %}
[Trades (Spot)](/pendax/using-pendax-sdk/bingx-functions/trades-spot)
{% endcontent-ref %}

### BingX USDT-M Futures Market Functions

Documented PENDAX functions applicable to Bitget futures markets.

{% content-ref url="/pages/ekUcGvNNM5xRN2rDLqeU" %}
[Market Data (USDT-M)](/pendax/using-pendax-sdk/bingx-functions/market-data-usdt-m)
{% endcontent-ref %}

{% content-ref url="/pages/OouB6wB5tyAHbE5kfr1T" %}
[Trades (USDT-M)](/pendax/using-pendax-sdk/bingx-functions/trades-usdt-m)
{% endcontent-ref %}

{% content-ref url="/pages/QfEU1ZwvpBlQo5Ryk7K0" %}
[Account (USDT-M)](/pendax/using-pendax-sdk/bingx-functions/account-usdt-m)
{% endcontent-ref %}

### Bitget Coin-M Futures Market Functions

Documented PENDAX functions applicable to Bitget futures markets.

{% content-ref url="/pages/lARjSXtZYQFnGFikoNKa" %}
[Market Data (Coin-M)](/pendax/using-pendax-sdk/bingx-functions/market-data-coin-m)
{% endcontent-ref %}

{% content-ref url="/pages/ykAMiqevsGqKFZziqyNI" %}
[Trades (Coin-M)](/pendax/using-pendax-sdk/bingx-functions/trades-coin-m)
{% endcontent-ref %}


# Fund Account

## Query Assets

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Query+Assets>
{% endhint %}

#### Function Name:

```javascript
getAssets()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAssets(exchange, options) {
    try {
        let result = await exchange.getAssets(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAssets(myBingxExchange);
```

## Asset Transfer

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset+Transfer>
{% endhint %}

#### Function Name:

```javascript
transferAssets()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function transferAssets(exchange, options) {
    try {
        let result = await exchange.transferAssets(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await transferAssets(myBingxExchange, {
	type: "<ENUM>",
	asset: "<string>",
	amount: "<DECIMAL>"
});
```

## Asset transfer records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset+transfer+records>
{% endhint %}

#### Function Name:

```javascript
getAssetTransferRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAssetTransferRecords(exchange, options) {
    try {
        let result = await exchange.getAssetTransferRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAssetTransferRecords(myBingxExchange, {
	type: "<ENUM>"
});
```

## Main Accoun internal transfer

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Main+Accoun+internal+transfer>
{% endhint %}

#### Function Name:

```javascript
mainAccountInternalTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function mainAccountInternalTransfer(exchange, options) {
    try {
        let result = await exchange.mainAccountInternalTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await mainAccountInternalTransfer(myBingxExchange);
```

## Main account internal transfer records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Main+account+internal+transfer+records>
{% endhint %}

#### Function Name:

```javascript
getMainAccountInternalTransferRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getMainAccountInternalTransferRecords(exchange, options) {
    try {
        let result = await exchange.getMainAccountInternalTransferRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMainAccountInternalTransferRecords(myBingxExchange);
```

## Query Assets

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/account-api.html#Query+Assets>
{% endhint %}

#### Function Name:

```javascript
getAssetsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAssetsSpot(exchange, options) {
    try {
        let result = await exchange.getAssetsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAssetsSpot(myBingxExchange);
```

## Asset Transfer

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/account-api.html#Asset+Transfer>
{% endhint %}

#### Function Name:

```javascript
assetTransferSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function assetTransferSpot(exchange, options) {
    try {
        let result = await exchange.assetTransferSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await assetTransferSpot(myBingxExchange, {
	type: "<ENUM>",
	asset: "<string>",
	amount: "<DECIMAL>"
});
```

## Asset transfer records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/account-api.html#Asset+transfer+records>
{% endhint %}

#### Function Name:

```javascript
getAssetTransferRecordsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAssetTransferRecordsSpot(exchange, options) {
    try {
        let result = await exchange.getAssetTransferRecordsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAssetTransferRecordsSpot(myBingxExchange, {
	type: "<ENUM>"
});
```


# Wallet Deposits and Withdrawals

## Deposit records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Deposit+records>
{% endhint %}

#### Function Name:

```javascript
getDepositRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getDepositRecords(exchange, options) {
    try {
        let result = await exchange.getDepositRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositRecords(myBingxExchange);
```

## Withdraw records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Withdraw+records>
{% endhint %}

#### Function Name:

```javascript
getWithdrawRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getWithdrawRecords(exchange, options) {
    try {
        let result = await exchange.getWithdrawRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWithdrawRecords(myBingxExchange);
```

## Query currency deposit and withdrawal data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query+currency+deposit+and+withdrawal+data>
{% endhint %}

#### Function Name:

```javascript
getCurrencyDepositAndWithdrawalData()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getCurrencyDepositAndWithdrawalData(exchange, options) {
    try {
        let result = await exchange.getCurrencyDepositAndWithdrawalData(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getCurrencyDepositAndWithdrawalData(myBingxExchange);
```

## Withdraw

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Withdraw>
{% endhint %}

#### Function Name:

```javascript
withdraw()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function withdraw(exchange, options) {
    try {
        let result = await exchange.withdraw(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await withdraw(myBingxExchange, {
	coin: "<string>",
	address: "<string>",
	amount: "<float64>",
	walletType: "<int64>"
});
```

## Main Account Deposit Address

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Main+Account+Deposit+Address>
{% endhint %}

#### Function Name:

```javascript
getMainAccountDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getMainAccountDepositAddress(exchange, options) {
    try {
        let result = await exchange.getMainAccountDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMainAccountDepositAddress(myBingxExchange);
```

## Deposit risk control records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Deposit+risk+control+records>
{% endhint %}

#### Function Name:

```javascript
getDepositRiskControlRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getDepositRiskControlRecords(exchange, options) {
    try {
        let result = await exchange.getDepositRiskControlRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepositRiskControlRecords(myBingxExchange);
```


# Sub-Account Managenent

## Create sub-account

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Create+sub-account>
{% endhint %}

#### Function Name:

```javascript
createSubaccount()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function createSubaccount(exchange, options) {
    try {
        let result = await exchange.createSubaccount(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await createSubaccount(myBingxExchange, {
	subAccountString: "<string>",
	recvWindow: "<long>"
});
```

## Query account uid

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+account+uid>
{% endhint %}

#### Function Name:

```javascript
getAccountUid()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAccountUid(exchange, options) {
    try {
        let result = await exchange.getAccountUid(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountUid(myBingxExchange);
```

## Get sub-account list

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Get+sub-account+list>
{% endhint %}

#### Function Name:

```javascript
getSubAccountList()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubAccountList(exchange, options) {
    try {
        let result = await exchange.getSubAccountList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubAccountList(myBingxExchange, {
	page: "<int>",
	limit: "<int>"
});
```

## Query sub-account spot assets

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+sub-account+spot+assets>
{% endhint %}

#### Function Name:

```javascript
getSubaccountSpotAssets()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountSpotAssets(exchange, options) {
    try {
        let result = await exchange.getSubaccountSpotAssets(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountSpotAssets(myBingxExchange, {
	subUid: "<long>"
});
```

## Create an API Key for a sub-account

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Create+an+API+Key+for+a+sub-account>
{% endhint %}

#### Function Name:

```javascript
createSubaccountApikey()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function createSubaccountApikey(exchange, options) {
    try {
        let result = await exchange.createSubaccountApikey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await createSubaccountApikey(myBingxExchange, {
	subUid: "<long>",
	note: "<string>",
	permissions: "<Array>"
});
```

## Query the API Key of a sub-account

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+the+API+Key+of+a+sub-account>
{% endhint %}

#### Function Name:

```javascript
getSubaccountApikey()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountApikey(exchange, options) {
    try {
        let result = await exchange.getSubaccountApikey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountApikey(myBingxExchange, {
	uid: "<long>"
});
```

## Reset the API Key of a sub-account

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Reset+the+API+Key+of+a+sub-account>
{% endhint %}

#### Function Name:

```javascript
resetSubaccountApikey()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function resetSubaccountApikey(exchange, options) {
    try {
        let result = await exchange.resetSubaccountApikey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await resetSubaccountApikey(myBingxExchange, {
	subUid: "<long>",
	apiKey: "<string>",
	note: "<string>",
	permissions: "<Array>"
});
```

## Delete the API Key of sub-accounts

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Delete+the+API+Key+of+sub-accounts>
{% endhint %}

#### Function Name:

```javascript
deleteSubaccountApikey()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function deleteSubaccountApikey(exchange, options) {
    try {
        let result = await exchange.deleteSubaccountApikey(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await deleteSubaccountApikey(myBingxExchange, {
	subUid: "<long>",
	apiKey: "<string>"
});
```

## Freeze and unfreeze sub-accounts

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Freeze+and+unfreeze+sub-accounts>
{% endhint %}

#### Function Name:

```javascript
setSubaccountFrozen()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function setSubaccountFrozen(exchange, options) {
    try {
        let result = await exchange.setSubaccountFrozen(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setSubaccountFrozen(myBingxExchange, {
	subUid: "<long>",
	freeze: "<bool>"
});
```

## Authorize sub-account internal transfers

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Authorize+sub-account+internal+transfers>
{% endhint %}

#### Function Name:

```javascript
authorizeSubaccountInternalTransfers()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function authorizeSubaccountInternalTransfers(exchange, options) {
    try {
        let result = await exchange.authorizeSubaccountInternalTransfers(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await authorizeSubaccountInternalTransfers(myBingxExchange, {
	subUids: "<string>",
	transferable: "<boolean>"
});
```

## Sub-account internal transfer

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Sub-account+internal+transfer>
{% endhint %}

#### Function Name:

```javascript
subaccountInternalTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function subaccountInternalTransfer(exchange, options) {
    try {
        let result = await exchange.subaccountInternalTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await subaccountInternalTransfer(myBingxExchange, {
	coin: "<string>",
	userAccountType: "<int>",
	userAccount: "<string>",
	amount: "<float64>",
	walletType: "<int>"
});
```

## Create deposit address for sub-account

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Create+deposit+address+for+sub-account>
{% endhint %}

#### Function Name:

```javascript
createSubaccountDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function createSubaccountDepositAddress(exchange, options) {
    try {
        let result = await exchange.createSubaccountDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await createSubaccountDepositAddress(myBingxExchange);
```

## Get sub-account deposit address

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Get+sub-account+deposit+address>
{% endhint %}

#### Function Name:

```javascript
getSubaccountDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountDepositAddress(exchange, options) {
    try {
        let result = await exchange.getSubaccountDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountDepositAddress(myBingxExchange);
```

## Get sub-account deposit records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Get+sub-account+deposit+records>
{% endhint %}

#### Function Name:

```javascript
getSubaccountDepositRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountDepositRecords(exchange, options) {
    try {
        let result = await exchange.getSubaccountDepositRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountDepositRecords(myBingxExchange);
```

## Query sub-account internal transfer records

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+sub-account+internal+transfer+records>
{% endhint %}

#### Function Name:

```javascript
getSubaccountInternalTransferRecords()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountInternalTransferRecords(exchange, options) {
    try {
        let result = await exchange.getSubaccountInternalTransferRecords(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountInternalTransferRecords(myBingxExchange, {
	coin: "<string>"
});
```

## Query Sub-Account Transfer History (For Master Account Operations Only)

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+Sub-Account+Transfer+History+(For+Master+Account+Operations+Only)>
{% endhint %}

#### Function Name:

```javascript
getSubaccsferHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccsferHistory(exchange, options) {
    try {
        let result = await exchange.getSubaccsferHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccsferHistory(myBingxExchange);
```

## Query the transferable amount of funds in the parent-child account (only for parent account operations).

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Query+the+transferable+amount+of+funds+in+the+parent-child+account+(only+for+parent+account+operations).>
{% endhint %}

#### Function Name:

```javascript
getTransferableParentChildFunds()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getTransferableParentChildFunds(exchange, options) {
    try {
        let result = await exchange.getTransferableParentChildFunds(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTransferableParentChildFunds(myBingxExchange);
```

## Sub-Account Asset Transfer Interface (For Master Account Operations Only)

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Sub-Account+Asset+Transfer+Interface+(For+Master+Account+Operations+Only)>
{% endhint %}

#### Function Name:

```javascript
subaccountAssetTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function subaccountAssetTransfer(exchange, options) {
    try {
        let result = await exchange.subaccountAssetTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await subaccountAssetTransfer(myBingxExchange);
```

## Asset overview

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Asset+overview>
{% endhint %}

#### Function Name:

```javascript
getAssetOverview()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAssetOverview(exchange, options) {
    try {
        let result = await exchange.getAssetOverview(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAssetOverview(myBingxExchange);
```

## Batch inquiry of sub account asset overview

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/common/sub-account#Batch+inquiry+of+sub+account+asset+overview>
{% endhint %}

#### Function Name:

```javascript
getSubaccountAssetOverviewBatchInquiry()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getSubaccountAssetOverviewBatchInquiry(exchange, options) {
    try {
        let result = await exchange.getSubaccountAssetOverviewBatchInquiry(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSubaccountAssetOverviewBatchInquiry(myBingxExchange);
```


# Market Data (USDT-M)

## USDT-M Perp Futures symbols

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#USDT-M+Perp+Futures+symbols>
{% endhint %}

#### Function Name:

```javascript
getSymbolsUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSymbolsUM(exchange, options) {
    try {
        let result = await exchange.getSymbolsUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSymbolsUM(myBingxExchange);
```

## Order Book

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Order+Book>
{% endhint %}

#### Function Name:

```javascript
getOrderBookUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getOrderBookUM(exchange, options) {
    try {
        let result = await exchange.getOrderBookUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Recent Trades List

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Recent+Trades+List>
{% endhint %}

#### Function Name:

```javascript
getRecentTradesUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getRecentTradesUM(exchange, options) {
    try {
        let result = await exchange.getRecentTradesUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRecentTradesUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Mark Price and Funding Rate

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark+Price+and+Funding+Rate>
{% endhint %}

#### Function Name:

```javascript
getMarkPriceAndFundingRateUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getMarkPriceAndFundingRateUM(exchange, options) {
    try {
        let result = await exchange.getMarkPriceAndFundingRateUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarkPriceAndFundingRateUM(myBingxExchange);
```

## Get Funding Rate History

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get+Funding+Rate+History>
{% endhint %}

#### Function Name:

```javascript
getFundingRateHistoryUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getFundingRateHistoryUM(exchange, options) {
    try {
        let result = await exchange.getFundingRateHistoryUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getFundingRateHistoryUM(myBingxExchange);
```

## Kline/Candlestick Data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Kline/Candlestick+Data>
{% endhint %}

#### Function Name:

```javascript
getKlineCandlestickInfoUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getKlineCandlestickInfoUM(exchange, options) {
    try {
        let result = await exchange.getKlineCandlestickInfoUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKlineCandlestickInfoUM(myBingxExchange, {
	symbol: "<string>",
	interval: "<string>"
});
```

## Open Interest Statistics

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Open+Interest+Statistics>
{% endhint %}

#### Function Name:

```javascript
getOpenInterestStatisticsUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getOpenInterestStatisticsUM(exchange, options) {
    try {
        let result = await exchange.getOpenInterestStatisticsUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenInterestStatisticsUM(myBingxExchange, {
	symbol: "<string>"
});
```

## 24hr Ticker Price Change Statistics

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#24hr+Ticker+Price+Change+Statistics>
{% endhint %}

#### Function Name:

```javascript
get24HrTickerPriceChangeInfoUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function get24HrTickerPriceChangeInfoUM(exchange, options) {
    try {
        let result = await exchange.get24HrTickerPriceChangeInfoUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HrTickerPriceChangeInfoUM(myBingxExchange);
```

## Query historical transaction orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Query+historical+transaction+orders>
{% endhint %}

#### Function Name:

```javascript
getHistoricalTransactionOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getHistoricalTransactionOrdersUM(exchange, options) {
    try {
        let result = await exchange.getHistoricalTransactionOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoricalTransactionOrdersUM(myBingxExchange);
```

## Symbol Order Book Ticker

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Symbol+Order+Book+Ticker>
{% endhint %}

#### Function Name:

```javascript
getSymbolOrderBookTickerUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSymbolOrderBookTickerUM(exchange, options) {
    try {
        let result = await exchange.getSymbolOrderBookTickerUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSymbolOrderBookTickerUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Mark Price Kline/Candlestick Data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark+Price+Kline/Candlestick+Data>
{% endhint %}

#### Function Name:

```javascript
getMarkPriceKlineCandlestickInfoUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getMarkPriceKlineCandlestickInfoUM(exchange, options) {
    try {
        let result = await exchange.getMarkPriceKlineCandlestickInfoUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarkPriceKlineCandlestickInfoUM(myBingxExchange, {
	symbol: "<string>",
	interval: "<string>"
});
```

## Symbol Price Ticker

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Symbol+Price+Ticker>
{% endhint %}

#### Function Name:

```javascript
getSymbolPriceTickerUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSymbolPriceTickerUM(exchange, options) {
    try {
        let result = await exchange.getSymbolPriceTickerUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSymbolPriceTickerUM(myBingxExchange);
```


# Account (USDT-M)

## Query account data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query+account+data>
{% endhint %}

#### Function Name:

```javascript
getAccountDataUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAccountDataUM(exchange, options) {
    try {
        let result = await exchange.getAccountDataUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountDataUM(myBingxExchange);
```

## Query position data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query+position+data>
{% endhint %}

#### Function Name:

```javascript
getPositionDataUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPositionDataUM(exchange, options) {
    try {
        let result = await exchange.getPositionDataUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositionDataUM(myBingxExchange);
```

## Get Account Profit and Loss Fund Flow

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Get+Account+Profit+and+Loss+Fund+Flow>
{% endhint %}

#### Function Name:

```javascript
getAccountPLFundFlowUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAccountPLFundFlowUM(exchange, options) {
    try {
        let result = await exchange.getAccountPLFundFlowUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountPLFundFlowUM(myBingxExchange);
```

## Export fund flow

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Export+fund+flow>
{% endhint %}

#### Function Name:

```javascript
exportFundFlowUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function exportFundFlowUM(exchange, options) {
    try {
        let result = await exchange.exportFundFlowUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await exportFundFlowUM(myBingxExchange);
```

## Query Trading Commission Rate

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query+Trading+Commission+Rate>
{% endhint %}

#### Function Name:

```javascript
getTradingCommissionRateUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getTradingCommissionRateUM(exchange, options) {
    try {
        let result = await exchange.getTradingCommissionRateUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradingCommissionRateUM(myBingxExchange);
```


# Trades (USDT-M)

## Test Order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Test+Order>
{% endhint %}

#### Function Name:

```javascript
testOrderUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function testOrderUM(exchange, options) {
    try {
        let result = await exchange.testOrderUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await testOrderUM(myBingxExchange, {
	symbol: "<string>",
	type: "<string>",
	side: "<string>"
});
```

## Place order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place+order>
{% endhint %}

#### Function Name:

```javascript
placeOrderUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeOrderUM(exchange, options) {
    try {
        let result = await exchange.placeOrderUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderUM(myBingxExchange, {
	symbol: "<string>",
	type: "<string>",
	side: "<string>"
});
```

## Place order in demo trading

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place+order+in+demo+trading>
{% endhint %}

#### Function Name:

```javascript
placeOrderDemoTradingUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeOrderDemoTradingUM(exchange, options) {
    try {
        let result = await exchange.placeOrderDemoTradingUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderDemoTradingUM(myBingxExchange, {
	symbol: "<string>",
	type: "<string>",
	side: "<string>"
});
```

## Place multiple orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place+multiple+orders>
{% endhint %}

#### Function Name:

```javascript
placeBatchOrderUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeBatchOrderUM(exchange, options) {
    try {
        let result = await exchange.placeBatchOrderUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeBatchOrderUM(myBingxExchange, {
	batchOrders: "<LIST<Order>>"
});
```

## Close All Positions

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Close+All+Positions>
{% endhint %}

#### Function Name:

```javascript
closeAllPositionsUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function closeAllPositionsUM(exchange, options) {
    try {
        let result = await exchange.closeAllPositionsUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await closeAllPositionsUM(myBingxExchange);
```

## Cancel Order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+Order>
{% endhint %}

#### Function Name:

```javascript
cancelOrderUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelOrderUM(exchange, options) {
    try {
        let result = await exchange.cancelOrderUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Cancel multiple orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+multiple+orders>
{% endhint %}

#### Function Name:

```javascript
batchCancelOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function batchCancelOrdersUM(exchange, options) {
    try {
        let result = await exchange.batchCancelOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await batchCancelOrdersUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Cancel All Open Orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+All+Open+Orders>
{% endhint %}

#### Function Name:

```javascript
cancelAllOpenOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelAllOpenOrdersUM(exchange, options) {
    try {
        let result = await exchange.cancelAllOpenOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOpenOrdersUM(myBingxExchange);
```

## Current All Open Orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current+All+Open+Orders>
{% endhint %}

#### Function Name:

```javascript
getAllOpenOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAllOpenOrdersUM(exchange, options) {
    try {
        let result = await exchange.getAllOpenOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllOpenOrdersUM(myBingxExchange);
```

## Query pending order status

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+pending+order+status>
{% endhint %}

#### Function Name:

```javascript
getPendingOrderStatusUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPendingOrderStatusUM(exchange, options) {
    try {
        let result = await exchange.getPendingOrderStatusUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPendingOrderStatusUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Query Order details

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+Order+details>
{% endhint %}

#### Function Name:

```javascript
getOrderDetailsUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderDetailsUM(exchange, options) {
    try {
        let result = await exchange.getOrderDetailsUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderDetailsUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Query Margin Type

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+Margin+Type>
{% endhint %}

#### Function Name:

```javascript
getMarginTypeUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getMarginTypeUM(exchange, options) {
    try {
        let result = await exchange.getMarginTypeUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginTypeUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Change Margin Type

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Change+Margin+Type>
{% endhint %}

#### Function Name:

```javascript
changeMarginTypeUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function changeMarginTypeUM(exchange, options) {
    try {
        let result = await exchange.changeMarginTypeUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await changeMarginTypeUM(myBingxExchange, {
	symbol: "<string>",
	marginType: "<string>"
});
```

## Query Leverage

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+Leverage>
{% endhint %}

#### Function Name:

```javascript
getLeverageUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getLeverageUM(exchange, options) {
    try {
        let result = await exchange.getLeverageUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getLeverageUM(myBingxExchange, {
	symbol: "<string>"
});
```

## Set Leverage

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set+Leverage>
{% endhint %}

#### Function Name:

```javascript
setLeverageUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function setLeverageUM(exchange, options) {
    try {
        let result = await exchange.setLeverageUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setLeverageUM(myBingxExchange, {
	symbol: "<string>",
	side: "<string>",
	leverage: "<int64>"
});
```

## Users Force Orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#User's+Force+Orders>
{% endhint %}

#### Function Name:

```javascript
getUsersForceOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getUsersForceOrdersUM(exchange, options) {
    try {
        let result = await exchange.getUsersForceOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUsersForceOrdersUM(myBingxExchange);
```

## Query Order history

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+Order+history>
{% endhint %}

#### Function Name:

```javascript
getOrderHistoryUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderHistoryUM(exchange, options) {
    try {
        let result = await exchange.getOrderHistoryUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderHistoryUM(myBingxExchange, {
	limit: "<int>"
});
```

## Modify Isolated Position Margin

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Modify+Isolated+Position+Margin>
{% endhint %}

#### Function Name:

```javascript
modifyIsolatedPositionMarginUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function modifyIsolatedPositionMarginUM(exchange, options) {
    try {
        let result = await exchange.modifyIsolatedPositionMarginUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await modifyIsolatedPositionMarginUM(myBingxExchange, {
	symbol: "<string>",
	amount: "<float64>",
	type: "<int>",
	positionSide: "<string>"
});
```

## Query historical transaction orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+historical+transaction+orders>
{% endhint %}

#### Function Name:

```javascript
getHistoricalTransactionOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getHistoricalTransactionOrdersUM(exchange, options) {
    try {
        let result = await exchange.getHistoricalTransactionOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoricalTransactionOrdersUM(myBingxExchange, {
	tradingUnit: "<string>",
	startTs: "<int64>",
	endTs: "<int64>"
});
```

## Set Position Mode

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Set+Position+Mode>
{% endhint %}

#### Function Name:

```javascript
setPositionModeUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function setPositionModeUM(exchange, options) {
    try {
        let result = await exchange.setPositionModeUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setPositionModeUM(myBingxExchange);
```

## Query position mode

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+position+mode>
{% endhint %}

#### Function Name:

```javascript
getPositionModeUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPositionModeUM(exchange, options) {
    try {
        let result = await exchange.getPositionModeUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositionModeUM(myBingxExchange);
```

## Cancel an Existing Order and Send a New Orde

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+an+Existing+Order+and+Send+a+New+Orde>
{% endhint %}

#### Function Name:

```javascript
cancelExistingOrderAndPlaceOrderUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelExistingOrderAndPlaceOrderUM(exchange, options) {
    try {
        let result = await exchange.cancelExistingOrderAndPlaceOrderUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelExistingOrderAndPlaceOrderUM(myBingxExchange, {
	cancelReplaceMode: "<string>",
	symbol: "<string>",
	type: "<string>",
	side: "<string>"
});
```

## Cancel orders in batches and place orders in batches

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+orders+in+batches+and+place+orders+in+batches>
{% endhint %}

#### Function Name:

```javascript
cancelOrdersInBatchesAndPlaceOrdersInBatchesUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelOrdersInBatchesAndPlaceOrdersInBatchesUM(exchange, options) {
    try {
        let result = await exchange.cancelOrdersInBatchesAndPlaceOrdersInBatchesUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrdersInBatchesAndPlaceOrdersInBatchesUM(myBingxExchange, {
	batchOrders: "<string>"
});
```

## Cancel All After

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel+All+After>
{% endhint %}

#### Function Name:

```javascript
cancelAllAfterUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelAllAfterUM(exchange, options) {
    try {
        let result = await exchange.cancelAllAfterUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllAfterUM(myBingxExchange);
```

## Close position by position ID

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Close+position+by+position+ID>
{% endhint %}

#### Function Name:

```javascript
closePositionByPositionIDUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function closePositionByPositionIDUM(exchange, options) {
    try {
        let result = await exchange.closePositionByPositionIDUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await closePositionByPositionIDUM(myBingxExchange, {
	positionId: "<string>"
});
```

## All Orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All+Orders>
{% endhint %}

#### Function Name:

```javascript
getAllOrdersUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAllOrdersUM(exchange, options) {
    try {
        let result = await exchange.getAllOrdersUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAllOrdersUM(myBingxExchange, {
	limit: "<int>"
});
```

## Position and Maintenance Margin Ratio

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Position+and+Maintenance+Margin+Ratio>
{% endhint %}

#### Function Name:

```javascript
getPositionMaintenanceMarginRatioUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPositionMaintenanceMarginRatioUM(exchange, options) {
    try {
        let result = await exchange.getPositionMaintenanceMarginRatioUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositionMaintenanceMarginRatioUM(myBingxExchange);
```

## Query historical transaction details

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+historical+transaction+details>
{% endhint %}

#### Function Name:

```javascript
getHistoricalTransactionDetailsUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getHistoricalTransactionDetailsUM(exchange, options) {
    try {
        let result = await exchange.getHistoricalTransactionDetailsUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoricalTransactionDetailsUM(myBingxExchange, {
	startTs: "<int64>",
	endTs: "<int64>"
});
```

## Query Position History

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query+Position+History>
{% endhint %}

#### Function Name:

```javascript
getPositionHistoryUM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPositionHistoryUM(exchange, options) {
    try {
        let result = await exchange.getPositionHistoryUM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPositionHistoryUM(myBingxExchange);
```


# Market Data (Coin-M)

## Contract Information

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Contract+Information>
{% endhint %}

#### Function Name:

```javascript
getContractInfoCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getContractInfoCM(exchange, options) {
    try {
        let result = await exchange.getContractInfoCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getContractInfoCM(myBingxExchange);
```

## Price & Current Funding Rate

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price+&+Current+Funding+Rate>
{% endhint %}

#### Function Name:

```javascript
getPriceAndCurrentFundingRateCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getPriceAndCurrentFundingRateCM(exchange, options) {
    try {
        let result = await exchange.getPriceAndCurrentFundingRateCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPriceAndCurrentFundingRateCM(myBingxExchange);
```

## Get Swap Open Positions

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get+Swap+Open+Positions>
{% endhint %}

#### Function Name:

```javascript
getSwapOpenPositionsCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSwapOpenPositionsCM(exchange, options) {
    try {
        let result = await exchange.getSwapOpenPositionsCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSwapOpenPositionsCM(myBingxExchange);
```

## Get K-line Data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get+K-line+Data>
{% endhint %}

#### Function Name:

```javascript
getKlineCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getKlineCM(exchange, options) {
    try {
        let result = await exchange.getKlineCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKlineCM(myBingxExchange, {
	symbol: "<string>",
	interval: "<string>"
});
```

## Query Depth Data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query+Depth+Data>
{% endhint %}

#### Function Name:

```javascript
getDepthCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getDepthCM(exchange, options) {
    try {
        let result = await exchange.getDepthCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getDepthCM(myBingxExchange, {
	symbol: "<string>"
});
```

## Query 24-Hour Price Change

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query+24-Hour+Price+Change>
{% endhint %}

#### Function Name:

```javascript
get24HrPriceChangeCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function get24HrPriceChangeCM(exchange, options) {
    try {
        let result = await exchange.get24HrPriceChangeCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HrPriceChangeCM(myBingxExchange);
```


# Trades (Coin-M)

## Trade order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade+order>
{% endhint %}

#### Function Name:

```javascript
placeTradeOrderCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeTradeOrderCM(exchange, options) {
    try {
        let result = await exchange.placeTradeOrderCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeTradeOrderCM(myBingxExchange, {
	symbol: "<string>",
	type: "<string>",
	side: "<string>"
});
```

## Query Trade Commission Rate

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Trade+Commission+Rate>
{% endhint %}

#### Function Name:

```javascript
getComissionRateCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getComissionRateCM(exchange, options) {
    try {
        let result = await exchange.getComissionRateCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getComissionRateCM(myBingxExchange);
```

## Query Leverage

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Leverage>
{% endhint %}

#### Function Name:

```javascript
getLeverageCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getLeverageCM(exchange, options) {
    try {
        let result = await exchange.getLeverageCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getLeverageCM(myBingxExchange);
```

## Modify Leverage

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Modify+Leverage>
{% endhint %}

#### Function Name:

```javascript
modifyLeverageCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function modifyLeverageCM(exchange, options) {
    try {
        let result = await exchange.modifyLeverageCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await modifyLeverageCM(myBingxExchange);
```

## Cancel all orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel+all+orders>
{% endhint %}

#### Function Name:

```javascript
cancelAllOrdersCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelAllOrdersCM(exchange, options) {
    try {
        let result = await exchange.cancelAllOrdersCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllOrdersCM(myBingxExchange);
```

## Close all positions in bulk

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close+all+positions+in+bulk>
{% endhint %}

#### Function Name:

```javascript
closeAllPositionsInBulkCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function closeAllPositionsInBulkCM(exchange, options) {
    try {
        let result = await exchange.closeAllPositionsInBulkCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await closeAllPositionsInBulkCM(myBingxExchange);
```

## Query warehouse

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+warehouse>
{% endhint %}

#### Function Name:

```javascript
getWarehouseCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getWarehouseCM(exchange, options) {
    try {
        let result = await exchange.getWarehouseCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getWarehouseCM(myBingxExchange);
```

## Query Account Assets

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Account+Assets>
{% endhint %}

#### Function Name:

```javascript
getAccountAssetsCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getAccountAssetsCM(exchange, options) {
    try {
        let result = await exchange.getAccountAssetsCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getAccountAssetsCM(myBingxExchange);
```

## Query force orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+force+orders>
{% endhint %}

#### Function Name:

```javascript
getForceOrdersCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getForceOrdersCM(exchange, options) {
    try {
        let result = await exchange.getForceOrdersCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getForceOrdersCM(myBingxExchange);
```

## Query Order Trade Detail

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Order+Trade+Detail>
{% endhint %}

#### Function Name:

```javascript
getOrderTradeDetailCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderTradeDetailCM(exchange, options) {
    try {
        let result = await exchange.getOrderTradeDetailCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderTradeDetailCM(myBingxExchange);
```

## Cancel an Order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel+an+Order>
{% endhint %}

#### Function Name:

```javascript
cancelOrderCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelOrderCM(exchange, options) {
    try {
        let result = await exchange.cancelOrderCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderCM(myBingxExchange, {
	symbol: "<string>"
});
```

## Query all current pending orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+all+current+pending+orders>
{% endhint %}

#### Function Name:

```javascript
getPendingOrdersCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getPendingOrdersCM(exchange, options) {
    try {
        let result = await exchange.getPendingOrdersCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getPendingOrdersCM(myBingxExchange);
```

## Query Order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Order>
{% endhint %}

#### Function Name:

```javascript
getOrderCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderCM(exchange, options) {
    try {
        let result = await exchange.getOrderCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderCM(myBingxExchange, {
	symbol: "<string>"
});
```

## " Users History Orders "

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's+History+Orders>
{% endhint %}

#### Function Name:

```javascript
getUsersHistoryOrdersCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getUsersHistoryOrdersCM(exchange, options) {
    try {
        let result = await exchange.getUsersHistoryOrdersCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getUsersHistoryOrdersCM(myBingxExchange, {
	limit: "<int>"
});
```

## Query Margin Type

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query+Margin+Type>
{% endhint %}

#### Function Name:

```javascript
getMarginTypeCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getMarginTypeCM(exchange, options) {
    try {
        let result = await exchange.getMarginTypeCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getMarginTypeCM(myBingxExchange, {
	symbol: "<string>"
});
```

## Set Margin Type

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Set+Margin+Type>
{% endhint %}

#### Function Name:

```javascript
setMarginTypeCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function setMarginTypeCM(exchange, options) {
    try {
        let result = await exchange.setMarginTypeCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await setMarginTypeCM(myBingxExchange, {
	symbol: "<string>",
	marginType: "<string>"
});
```

## Adjust Isolated Margin

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Adjust+Isolated+Margin>
{% endhint %}

#### Function Name:

```javascript
adjustIsolatedMarginCM()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function adjustIsolatedMarginCM(exchange, options) {
    try {
        let result = await exchange.adjustIsolatedMarginCM(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await adjustIsolatedMarginCM(myBingxExchange, {
	symbol: "<string>",
	amount: "<float64>",
	type: "<int>",
	positionSide: "<string>"
});
```


# Market Data (Spot)

## Spot trading symbols

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Spot+trading+symbols>
{% endhint %}

#### Function Name:

```javascript
getTradingSymbolsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getTradingSymbolsSpot(exchange, options) {
    try {
        let result = await exchange.getTradingSymbolsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradingSymbolsSpot(myBingxExchange);
```

## Recent Trades List

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Recent+Trades+List>
{% endhint %}

#### Function Name:

```javascript
getRecentTradesListSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getRecentTradesListSpot(exchange, options) {
    try {
        let result = await exchange.getRecentTradesListSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getRecentTradesListSpot(myBingxExchange, {
	symbol: "<string>"
});
```

## Order Book

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Order+Book>
{% endhint %}

#### Function Name:

```javascript
getOrderBookSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getOrderBookSpot(exchange, options) {
    try {
        let result = await exchange.getOrderBookSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookSpot(myBingxExchange, {
	symbol: "<string>"
});
```

## Kline/Candlestick Data

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Kline/Candlestick+Data>
{% endhint %}

#### Function Name:

```javascript
getKlineCandlestickInfoSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getKlineCandlestickInfoSpot(exchange, options) {
    try {
        let result = await exchange.getKlineCandlestickInfoSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getKlineCandlestickInfoSpot(myBingxExchange);
```

## 24hr Ticker Price Change Statistics

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24hr+Ticker+Price+Change+Statistics>
{% endhint %}

#### Function Name:

```javascript
get24HrPriceChangeInfoSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function get24HrPriceChangeInfoSpot(exchange, options) {
    try {
        let result = await exchange.get24HrPriceChangeInfoSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await get24HrPriceChangeInfoSpot(myBingxExchange);
```

## Order Book aggregation

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Order+Book+aggregation>
{% endhint %}

#### Function Name:

```javascript
getOrderBookAggregationSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getOrderBookAggregationSpot(exchange, options) {
    try {
        let result = await exchange.getOrderBookAggregationSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderBookAggregationSpot(myBingxExchange);
```

## Symbol Price Ticker

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Symbol+Price+Ticker>
{% endhint %}

#### Function Name:

```javascript
getSymbolPriceTickerSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSymbolPriceTickerSpot(exchange, options) {
    try {
        let result = await exchange.getSymbolPriceTickerSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSymbolPriceTickerSpot(myBingxExchange);
```

## Symbol Order Book Ticker

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Symbol+Order+Book+Ticker>
{% endhint %}

#### Function Name:

```javascript
getSymbolOrderBookTickerSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getSymbolOrderBookTickerSpot(exchange, options) {
    try {
        let result = await exchange.getSymbolOrderBookTickerSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getSymbolOrderBookTickerSpot(myBingxExchange);
```

## Historical K-line

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Historical+K-line>
{% endhint %}

#### Function Name:

```javascript
getHistoricalKlineSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getHistoricalKlineSpot(exchange, options) {
    try {
        let result = await exchange.getHistoricalKlineSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getHistoricalKlineSpot(myBingxExchange);
```

## Old Trade Lookup

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#Old+Trade+Lookup>
{% endhint %}

#### Function Name:

```javascript
getOldTradeSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "false",
      label: "bingx"
  });

async function getOldTradeSpot(exchange, options) {
    try {
        let result = await exchange.getOldTradeSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOldTradeSpot(myBingxExchange, {
	symbol: "<string>"
});
```


# Fund Account (Spot)


# Trades (Spot)

## Place order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Place+order>
{% endhint %}

#### Function Name:

```javascript
placeOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeOrderSpot(exchange, options) {
    try {
        let result = await exchange.placeOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeOrderSpot(myBingxExchange, {
	symbol: "<string>",
	side: "<string>",
	type: "<string>"
});
```

## Place multiple orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Place+multiple+orders>
{% endhint %}

#### Function Name:

```javascript
placeBatchOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function placeBatchOrderSpot(exchange, options) {
    try {
        let result = await exchange.placeBatchOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await placeBatchOrderSpot(myBingxExchange);
```

## Cancel Order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel+Order>
{% endhint %}

#### Function Name:

```javascript
cancelOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelOrderSpot(exchange, options) {
    try {
        let result = await exchange.cancelOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderSpot(myBingxExchange, {
	symbol: "<string>"
});
```

## Cancel multiple orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel+multiple+orders>
{% endhint %}

#### Function Name:

```javascript
batchCancelOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function batchCancelOrderSpot(exchange, options) {
    try {
        let result = await exchange.batchCancelOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await batchCancelOrderSpot(myBingxExchange, {
	symbol: "<string>",
	orderIds: "<string>"
});
```

## Cancel all Open Orders on a Symbol

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel+all+Open+Orders+on+a+Symbol>
{% endhint %}

#### Function Name:

```javascript
cancelAllSymbolOrdersSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelAllSymbolOrdersSpot(exchange, options) {
    try {
        let result = await exchange.cancelAllSymbolOrdersSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllSymbolOrdersSpot(myBingxExchange);
```

## Cancel an Existing Order and Send a New Orde

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel+an+Existing+Order+and+Send+a+New+Orde>
{% endhint %}

#### Function Name:

```javascript
cancelOrderAndPlaceOrderSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelOrderAndPlaceOrderSpot(exchange, options) {
    try {
        let result = await exchange.cancelOrderAndPlaceOrderSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelOrderAndPlaceOrderSpot(myBingxExchange, {
	symbol: "<string>",
	CancelReplaceMode: "<string>",
	side: "<string>",
	type: "<string>",
	stopPrice: "<string>"
});
```

## Query Order details

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query+Order+details>
{% endhint %}

#### Function Name:

```javascript
getOrderDetailsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderDetailsSpot(exchange, options) {
    try {
        let result = await exchange.getOrderDetailsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderDetailsSpot(myBingxExchange, {
	symbol: "<string>"
});
```

## Current Open Orders

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current+Open+Orders>
{% endhint %}

#### Function Name:

```javascript
getOpenOrdersSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOpenOrdersSpot(exchange, options) {
    try {
        let result = await exchange.getOpenOrdersSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOpenOrdersSpot(myBingxExchange);
```

## Query Order history

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query+Order+history>
{% endhint %}

#### Function Name:

```javascript
getOrderHistorySpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getOrderHistorySpot(exchange, options) {
    try {
        let result = await exchange.getOrderHistorySpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getOrderHistorySpot(myBingxExchange);
```

## Query transaction details

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query+transaction+details>
{% endhint %}

#### Function Name:

```javascript
getTransactionDetailsSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getTransactionDetailsSpot(exchange, options) {
    try {
        let result = await exchange.getTransactionDetailsSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTransactionDetailsSpot(myBingxExchange, {
	orderId: "<long>"
});
```

## Query Trading Commission Rate

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query+Trading+Commission+Rate>
{% endhint %}

#### Function Name:

```javascript
getTradingCommissionRateSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getTradingCommissionRateSpot(exchange, options) {
    try {
        let result = await exchange.getTradingCommissionRateSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradingCommissionRateSpot(myBingxExchange);
```

## Cancel All After

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel+All+After>
{% endhint %}

#### Function Name:

```javascript
cancelAllAfterSpot()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function cancelAllAfterSpot(exchange, options) {
    try {
        let result = await exchange.cancelAllAfterSpot(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await cancelAllAfterSpot(myBingxExchange);
```


# CopyTrader

## Trader’s current order

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/copyTrade/trader-interface.html#Trader’s+current+order>
{% endhint %}

#### Function Name:

```javascript
getTradersCurrentOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function getTradersCurrentOrder(exchange, options) {
    try {
        let result = await exchange.getTradersCurrentOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await getTradersCurrentOrder(myBingxExchange);
```

## Traders close positions according to the order number

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/copyTrade/trader-interface.html#Traders+close+positions+according+to+the+order+number>
{% endhint %}

#### Function Name:

```javascript
tradersClosePositionsByOrderNumber()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function tradersClosePositionsByOrderNumber(exchange, options) {
    try {
        let result = await exchange.tradersClosePositionsByOrderNumber(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await tradersClosePositionsByOrderNumber(myBingxExchange, {
	positionId: "<int64>",
	recvWindow: "<int64>"
});
```

## Traders set take profit and stop loss based on order numbers

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/copyTrade/trader-interface.html#Traders+set+take+profit+and+stop+loss+based+on+order+numbers>
{% endhint %}

#### Function Name:

```javascript
tradersSetTPSLByOrderNumber()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function tradersSetTPSLByOrderNumber(exchange, options) {
    try {
        let result = await exchange.tradersSetTPSLByOrderNumber(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await tradersSetTPSLByOrderNumber(myBingxExchange, {
	positionId: "<int64>",
	takeProfitMarkPrice: "<float64>",
	stopLossMarkPrice: "<float64>",
	recvWindow: "<int64>"
});
```

## Trader sells spot assets based on buy order number

{% hint style="info" %}
Please refer to the official BingX API Docs for the Required parameters.

<https://bingx-api.github.io/docs/#/en-us/copyTrade/trader-interface.html#Trader+sells+spot+assets+based+on+buy+order+number>
{% endhint %}

#### Function Name:

```javascript
traderSellsSpotAssetsBasedOnBuyOrder()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

   let myBingxExchange  = createExchange({
      exchange: "bingx",
      authenticate: "true",
      key: "myKey",
      secret: "mySecret",
      label: "bingx"
  });

async function traderSellsSpotAssetsBasedOnBuyOrder(exchange, options) {
    try {
        let result = await exchange.traderSellsSpotAssetsBasedOnBuyOrder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

let result = await traderSellsSpotAssetsBasedOnBuyOrder(myBingxExchange, {
	orderId: "<int64>"
});
```


# FTX Functions

Documentation for functions available for FTX through the PENDAX SDK

{% hint style="danger" %}
Due to recent events related to FTX.com - We have decided to stop the development and documentation of FTX capabilities. They will remain in the PENDAX SDK for documentation purposes only. **Please use all FTX functions and integrations with caution.  Current events may result in failure of FTX servers to respond.**
{% endhint %}

## Create an Exchange Object

Before you can interact with PENDAX functions, you must first create an Exchange object with which to use when using PENDAX. You can create one or multiple, and reference them together or individually throughout your code.

#### Example Exchange Object Creation:

<pre class="language-javascript"><code class="lang-javascript"><strong>import { createExchange } from "./exchanges/exchange.js";
</strong>
let myFtxAccount = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "myKeys",
  secret: "mySecret",
  subaccount: "mySubaccountName",
  label: "ftx",
});
</code></pre>

Once an Exchange object has been created you may use any of the available functions allowed by that exchange by referencing the name of the Exchange object you created.

#### Example using multiple Exchange Objects for executing PENDAX functions:

<pre class="language-javascript"><code class="lang-javascript">import { createExchange } from "./exchanges/exchange.js";

<strong>let myFtxAccount = createExchange({
</strong>  exchange: "ftx",
  authenticate: true,
  key: "myKeys",
  secret: "mySecret",
  subaccount: "mySubaccountName",
  label: "ftx",
});

let myOtherFtxAccount = createExchange({
  exchange: "ftx",
  authenticate: true,
  key: "myOtherKeys",
  secret: "myOtherSecret",
  subaccount: "myOtherSubaccountName",
  label: "ftx",
});

async function getAllSubaccounts() {
  try {
    const subaccounts = await myFtxAccount.getAllSubaccounts();
    const subaccounts2 = await myOtherFtxAccount.getAllSubaccounts();
    console.log(subaccounts);
    console.log(subaccounts2);
  } catch (error) {
    console.log(error.message);
  }
}
</code></pre>

{% hint style="info" %}
This code would create two separate FTX exchange objects, then query each account for a list of subaccounts attached to that FTX account.&#x20;
{% endhint %}

## Subaccounts

### Get All Subaccounts

```javascript
getAllSubaccounts()
```

{% hint style="info" %}

#### You must use api keys from a main account, you cannot use this passing a subaccount api keys

{% endhint %}

#### Example usage:

```javascript
async function getAllSubaccounts() {
  try {
    const accts = await myFtxAccount.getAllSubaccounts();
    console.log(accts);
  } catch (error) {
    console.log(error.message);
  }
}
```

### Create Subaccount

```javascript
createSubaccount(options)
```

{% hint style="info" %}
This function takes in an options object. Optional and required parameters are listed below.
{% endhint %}

#### Required Parameters:

```javascript
nickname: "mySubaccount"
```

#### Available Parameters:

```javascript
nickname: "mySubaccount"
```

#### Example Usage:

```javascript
async function createSubaccount() {
  myFtxAccount.createSubaccount({
    nickname: "myNewSubaccount",
  });
}
```

### Change Subaccount Name

```javascript
changeSubaccountName(options)
```

{% hint style="info" %}
This function takes in an options object. Optional and required parameters are listed below.
{% endhint %}

#### Required Parameters:

```javascript
 nickname: "mySubaccount"
 newNickname: "new name"
```

#### Available Parameters:

```javascript
 nickname: "mySubaccount"
 newNickname: "new name"
```

{% hint style="info" %}
`nickname` is the current subaccount name
{% endhint %}

#### Example Usage:

```javascript
async function changeSubaccountName() {
  myFtxAccount.changeSubaccountName({
    nickname: "currentName",
    newNickname: "newName",
  });
}
```

### Delete Subaccount

```javascript
deleteSubaccount(options)
```

{% hint style="info" %}
This function takes in an options object. Optional and required parameters are listed below.
{% endhint %}

#### Required Parameters:

```
nickname: "mySubaccount"
```

#### Available Parameters:

```
nickname: "mySubaccount"
```

#### Example Usage:

```javascript
async function deleteSubaccount() {
  myFtxAccount.deleteSubaccount({
    nickname: "myUnwantedSubaccount",
  });
}
```

### Get Subaccount Balances

```javascript
getSubaccountBalances(options)
```

{% hint style="info" %}
This function takes in an options object. Optional and required parameters are listed below.
{% endhint %}

#### Required Parameters:

```
nickname: "my subaccount"
```

#### Available Parameters:

```
nickname: "my subaccount"
```

#### Example Usage:

```javascript
async function getSubaccountBalances(options) {
  try {
    let result = await myFtxAccount.getSubaccountBalances(options);
    console.log(result.data.result);
  } catch (error) {
    console.log(error.message);
  }
}

getSubaccountBalances({
nickname: "my subaccount"
});
```

### Transfer Between Subaccounts

```javascript
transferBetweenSubaccounts(options)
```

{% hint style="info" %}
This function takes in an options object. Optional and required parameters are listed below.
{% endhint %}

#### Required Parameters:

```javascript
     "coin": "BTC",
     "size": 10,
     "source": null, 
     //null or "main" denotes the use of main account for source of funds. else supply the subaccount you want to transfer from
     "destination": "sub1"
```

#### Available Parameters:

```javascript
     "coin": "BTC",
     "size": 10,
     "source": null, 
     //null or "main" denotes the use of main account for source of funds. else supply the subaccount you want to transfer from
     "destination": "sub1"
```

#### Example Usage:

```javascript
async function transferBetweenSubaccounts(options) {
  try {
    let result = await myFtxAccount.transferBetweenSubaccounts(options);
    console.log(result.data.result);
  } catch (error) {
    console.log(error.message);
    console.log(error.response.data.error);
  }
}

transferBetweenSubaccounts({
     "coin": "BTC",
     "size": 10,
     "source": null, 
     "destination": "sub1"
});
```


# License Agreement

Usage License Agreement regarding PENDAX SDK and hosted API service.

*Last updated on October 30th, 2022.*

**IMPORTANT:** This PENDAX SDK & API license agreement ("Agreement") is a legally binding contract between you, as Licensee ("You or "Licensee") and Compendium and applies to your use of the PENDAX SDK or API, as defined herein, available through <https://docs.compendium.finance> (collectively the "Service"). The Service includes an Application Programming Interface ("API" or "Program") and a Software Development Kit ("SDK"), which is further discussed and defined below. If you do not agree to be bound by the terms and conditions of this Agreement, please do not proceed with the use of Service, the API, or the PENDAX SDK.

In this Agreement, the terms "you" or "your" mean any person or entity using the Service ("Users"). Unless otherwise states, the terms "PENDAX", "we" or "our" will collectively refer to Compendium and its representatives.

This Agreement becomes effective as of the date you first access, download, or use the API or SDK ("Effective Date"). This Agreement shall continue until terminated either by us or by you. Even after termination of this Agreement, certain provisions will survive, as discussed herein. This Agreement also incorporates Compendium's Terms of Service and Privacy Policy which terms shall also govern your use of the Service.

You are entering a legally binding contract: by copying, downloading, or otherwise using the PENDAX API or SDK you are expressly agreeing to be bound by all terms of this agreement. If you do not agree to all of the terms of this agreement, you are not authorized to copy, download, install , or otherwise use the PENDAX API or SDK.

The API and SDK are protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The API and SDK are licensed to you, and their use is subject to the terms of this Agreement.

### 1) Definitions

**1.1.** "Application Programming Interfaces" or "API" or "Program" or "PENDAX API" means PENDAX technology, an aggregated library of simplified cryptocurrency exchange and financial institution interface commands which is an informational service that provides trading capabilities (most distinctively for products like Compendium), which may include object code, software libraries, software tools, sample source code, published specifications, and documentation. PENDAX API shall include any future, updated, or otherwise modified version(s) thereof furnished by Compendium (in its sole discretion) to Licensee.

**1.2.** "Software Development Kit" or "SDK" or "PENDAX SDK" means PENDAX technology,  an aggregated library of simplified cryptocurrency exchange and financial institution interface commands which is an informational service that provides trading capabilities (most distinctively for products like Compendium), which may include object code, software libraries, software tools, sample source code, published specifications, and documentation. PENDAX SDK shall include any future, updated, or otherwise modified version(s) thereof furnished by Compendium (in its sole discretion) to Licensee.

**1.3.** "Documentation" includes, but is not limited to programmer guides, manuals, materials, and information appropriate or necessary for use in connection with the API and other products.

### 2) Grant of License

**2.1.** Subject to the terms of this Agreement, Compendium hereby grants Licensee a limited, non-exclusive, non-transferable, royalty-free license (without the right to sublicense) to use the API or SDK solely for the purpose of Licensee's internal development efforts to develop applications to work in conjunction with the products referenced in the API or SDK and for which the API or SDK was provided.

**2.2.** Licensee shall have no right to distribute, license (whether or not through multiple tiers) or otherwise transfer the API or SDK to any third party or use it for commercial resale/redistribution reasons without a separate agreement entered upon by both parties.

**2.3.** In case of potential other API or SDK use that is not prescribed by this Agreement please write at *<support@compendium.finance>*.

**2.4.** Representations. Both parties to this Agreement are duly organized and validly exist in good standing with all requisite power and authority to enter into this Agreement and conduct its business as is now being conducted. It is observed that neither party is identified on, or engages in any transactions with anyone listed on any sanctions lists maintained by the U.S. Department of the Treasury's Office of Foreign Asset Control ("OFAC") and can produce Articles of Incorporation and Significant Shareholder List on demand in case of investigation. Any party in sanctioned jurisdictions, or on specific sanction lists, shall not receive a valid license to use any Compendium or PENDAX-related products, APIs, or SDKs.

**2.5.** Independent Contractor Relationship. The relationship between the parties is that of independent contractors. Nothing in this agreement shall be manipulated to create a representation of a relationship like a joint venture, partnership, or joint association.

### 3) Other Rights And Limitations&#x20;

**3.1.** Copies. Licensee may copy the API or SDK only as necessary to exercise its rights hereunder.

**3.2.** No Reverse Engineering. Licensee shall have no rights to any source code for any of the software in the SDK or API, except for the explicit rights to use the source code as provided to Licensee hereunder. Licensee may not reverse engineer, decompile, modify, disassemble or otherwise alter the SDK or API or any part thereof or otherwise reduce the SDK or API to human-perceivable form in whole or in part, except and only to the extent that such activity is expressly permitted by this Agreement or applicable laws.

**3.3.** No assertion by Licensee. Licensee agrees not to assert any patent rights related to the API/SDK or applications developed using the API/SDK against Compendium, Compendium / PENDAX participants, or other licensees of the API/SDK for making, using, selling, offering for sale, or importing any products or technology developed using the API/SDK.

**3.4.** Transfer and Processing Data. Licensees understand and agree to the fact that data may be transferred through servers in multiple jurisdictions *(where you may not have the same rights and protections as you do under local law)* while utilizing the PENDAX-hosted API and related services.

**3.5.** Third-Party Software. Licensee acknowledges that effective utilization of the API and/or PENDAX SDK may require the use of a development tool, compiler, and other software or technology of third-party providers ("Third-Party Software"). Licensee is solely responsible for supplying and procuring any necessary complimentary software and their necessary licenses for use thereof. Compendium makes no representation or warranty concerning Third-Party Software and shall have no obligation or liability with respect to Third-Party Software.

**3.6.** Ecosystem Integration Terms of Service. PENDAX and Compendium products link together several different platforms. Any Licensee also accepts the terms of service and usage agreements for any and all platforms they may interact with through the Compendium or PENDAX API/SDK. Licensee will be required to stop all utilization of all products for illegal or implementations that break these terms of service agreements.

**3.7.** No right is granted to Licensee to sublicense its rights hereunder. All rights not expressly granted are reserved by Compendium and, except as expressly set forth herein, no license is granted by Compendium under this Agreement directly, by implication, estoppel or otherwise, under any patent, copyright, trade secret or trademark, or other intellectual property rights of Compendium. Nothing herein shall be deemed to authorize Licensee to use Compendium\`s trademarks or trade names in Licensee's advertising, marketing, promotional, sales, or related materials unless otherwise agreed upon separately through official communication channels. Compendium reserves all rights not otherwise expressly granted in this Agreement.

### 4) Ownership

**4.1.** As between Compendium and Licensee, Compendium and/or its licensors shall own and retain all proprietary rights, including all patent, copyright, graphics, images, trade secrets, trademarks, and other intellectual property rights, in and to the PENDAX API and SDK. This also includes ownership of any corrections, bug fixes, enhancements, updates, improvements, or modifications thereto and Licensee hereby irrevocably transfers, conveys and assigns to Compendium all of its right, title, and interest therein. Compendium shall have the exclusive right to apply for or register any patents, mask work rights, copyrights, and such other proprietary protections with respect thereto. Licensee acknowledges that the license granted under this Agreement does not provide Licensee with title or ownership to the PENDAX API or SDK, but only a right of limited use under the terms and conditions of this Agreement.

### 5) Confidentiality

**5.1.** The PENDAX API and SDK contain valuable proprietary information and trade secrets that will remain the property of Compendium. You shall protect the confidentiality of, and avoid disclosure and unauthorized use of, the PENDAX API or SDK.

### 6) Fees, Payments, And Access

**6.1.** Compendium may charge for usage of our hosted PENDAX APIs to pay for underlying infrastructure costs and other related company expenses. Compendium reserves the right to change the charge fee for use or access to the PENDAX API. Access to the hosted PENDAX API is determined through authorization keys documented alongside the hosted PENDAX API literature.&#x20;

*Compendium also reserves the right to charge fees for all other PENDAX products in the future. If Compendium decides to charge for access to related PENDAX products, you do not have any obligation to continue to use such products.*

**6.2.** Compendium reserves the right to change the method of access to the PENDAX API or SDK at any time to ensure the safety and security of the encompassing ecosystem environment. In the event of degradation or instability of Compendium's systems or in an emergency, you acknowledge and agree that Compendium may, in its sole discretion, temporarily suspend your access to the API or SDK in order to minimize threats and to protect the operational stability/security of the PENDAX and Compendium system.

**6.3.** Users may need to register with integrated exchanges, and pass all necessary KYC/AML procedures, in order to take full advantage of trading capabilities provided by the PENDAX API and SDK. Compendium has no control over the decisions of integrated exchanges and third-party platforms. Usage of PENDAX does not guarantee a valid account status on integrated exchanges and third-party platforms.

### 7) No Warranties

**7.1.** The hosted PENDAX API, SDK, Github examples, and documentation are provided "AS-IS" without any warranty whatsoever, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement to the full extent allowed by law, all of which are expressly disclaimed.

**7.2.** No advice, information, or examples, whether oral or written, are obtained by you from Compendium or through, or from, the PENDAX API/SDK shall create any warranty not expressly stated in this agreement. Compendium does not warrant that the API, SDK, Examples, or Documentation are suitable for licensee's use, that the API, SDK, Examples, or Documentation are without defect or error, that operation will be uninterrupted, or that defects will be corrected. Furthermore, Compendium makes no warranty regarding the results of the use of the PENDAX API, SDK, Examples, and Documentation.

### 8) Support

**8.1.** Compendium will not provide any dedicated support for the hosted PENDAX API or SDK under this Agreement. Nothing herein shall be construed to required Compendium to provide consultations, support services or updates, upgrades, bug fixes, or modifications to the PENDAX API or SDK. Public discussion channels are currently provided on our official Discord server, however, we do reserve the right to change communication channels at any time. Compendium will promptly respond to inquiries from you, or any user, with respect to the hosted API services and will continue to implement systems that ensure any user of the API is treated with the same fairness and good faith as any other user of the API.

### 9) Limitations of Liability

**9.1.** IN NO EVENT SHALL LICENSOR OR ITS LICENSORS, BE LIABLE TO LICENSEE OR ANY THIRD PARTY FOR ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, INDIRECT, SPECIAL, PUNITIVE, OR EXEMPLARY DAMAGES FOR LOSS OF BUSINESS, LOSS OF PROFITS, BUSINESS INTERRUPTION, BREACH OF SECURITY, OR LOST OR DAMAGED DATA) ARISING OUT OF OR CONNECTED IN ANY WAY WITH THIS AGREEMENT, THE LICENSED SOFTWARE, OR ANY SERVICES RENDERED BY LICENSOR, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. EXCLUDING LICENSOR’S INDEMNIFICATION OBLIGATIONS, THE TOTAL LIABILITY OF LICENSOR TO LICENSEE FOR ALL DAMAGES, LOSSES, AND CAUSES OF ACTION (WHETHER IN CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE) SHALL NOT EXCEED THE AMOUNT OF $100. THE FOREGOING LIMITATIONS, EXCLUSIONS, AND DISCLAIMERS SHALL APPLY TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, EVEN IF ANY REMEDY FAILS ITS ESSENTIAL PURPOSE.

### 10) Indemnity

**10.1.** You agree to indemnify and hold harmless Compendium and its contributors, subsidiaries, affiliates, officers, agents, Intellectual Property service providers, co-branders, customers, suppliers or other partners, and employees, from any loss, claim or demand, including reasonable attorneys' fees, made by any third party due to or arising out of your negligence, error, omissions, or failure to perform relating to your use of the API/SDK, your connection to the API, or your violation of the Agreement.

### 11) Disclaimer of Warranty

**11.1.** Unless separately stated in a written express limited warranty, all API and SDK provided by Compendium / PENDAX is provided "AS IS" and on an "AS AVAILABLE" basis, without warranties of any kind from Compendium / PENDAX, either expressed or implied. To the fullest extent possible pursuant to applicable law, Compendium disclaims all warranties express, implied, or statutory, including, but not limited to implied warranties of merchantability, satisfactory quality or workmanship like effort, fitness for a particular purpose, reliability or availability, accuracy, lack of viruses, quiet enjoyment, non-infringement of third-party rights or other violations of rights. Some jurisdictions do not allow exclusions or limitations of implied warranties, so the above exclusions or limitations may not apply to you. No advice or information, whether oral or written, obtained by you from Compendium or its affiliates shall be deemed to alter this disclaimer by Compendium of warranty regarding the API or SDK or the agreement, or to create any warranty of any sort from Compendium and/or related parties.

**11.2.** Compendium disclaims any responsibility for any disclosure of information or any other practices of any third-party API provider. Compendium expressly disclaims any warranty regarding whether your personal information is captured by any third-party API provider or the use to which such personal information may be put by such third-party API providers.

### 12) Term Of Agreement & Termination

**12.1.** The effective date of this Agreement is the start of use of the API or SDK by the Licensee.&#x20;

**12.2.** This Agreement will terminate automatically if you fail to comply with any of the terms and conditions of this Agreement and you will be liable to Compendium / PENDAX and its suppliers for damages or losses caused by your non-compliance. The waiver by Compendium of a specific breach or default shall not constitute the waiver of any subsequent breach or default.&#x20;

**12.3.** Either party shall have the right to terminate the Agreement, immediately or upon thirty (30) days written notice to <support@compendium.finance>.&#x20;

**12.4.** Upon termination of this Agreement, Licensee will immediately cease using the API and the SDK, and Licensee agrees to destroy all adaptations or copies of the API, SDK, and Documentation or return them to the Compendium team upon the termination of this License.&#x20;

**12.5.** Compendium shall have the unlimited right to audit your use of the API or SDK in conjunction with this Agreement, and you will provide reasonable assistance for this purpose.&#x20;

**12.6.** The rights of Compendium and your obligations contained in this Agreement survive any expiration or termination of this Agreement.

### 13) Applicable Law & Arbitration

**13.1.** Licensee and Compendium agree to arbitrate any dispute arising from this Agreement, except for disputes in which either party seeks equitable and other relief for the alleged unlawful use of copyrights, trademarks, trade names, logos, **trade secrets,** or patents. ARBITRATION PREVENTS THE LICENSEE FROM SUING IN COURT OR FROM HAVING A JURY TRIAL.&#x20;

**13.2.** Licensee and Compendium agree to notify each other in writing of any dispute within thirty (30) days of when it arises. Notice to Compendium shall be sent to <support@compendium.finance>.

**13.3.** The Licensee and Compendium shall cooperate in good faith to resolve any dispute, controversy or claim arising out of, relating to, or in connection with this Agreement, including with respect to the formation, applicability, breach, termination, validity, or enforceability thereof (a “Dispute”) shall be settled in accordance with the laws of the state of Saint Vincent & The Grenadines. The parties undertake to carry out any award without delay and waive their right to any form of recourse insofar as such waiver can validly be made. Judgment upon the award may be entered by any court having jurisdiction thereof or having jurisdiction over the relevant party or its assets. Compendium and the Licensee will each pay their respective attorneys’ fees and expenses. Any dispute arising out of or related to this Agreement is personal to the Licensee and Compendium and will not be brought as a class arbitration, class action, or any other type of representative proceeding. There will be no class arbitration or arbitration in which a person attempts to resolve a dispute as a representative of another person or group of persons. Further, a dispute cannot be brought as a class or other type of representative action, whether within or outside of arbitration, or on behalf of any other person or group of persons.

**13.4.** Any dispute between the parties will be governed by this Agreement and the laws of the state of Saint Vincent & The Grenadines, without giving effect to any conflict of laws principles that may provide for the application of the law of another jurisdiction. Whether the dispute is heard in arbitration or in court, Licensee and Compendium will not commence against the other a class action, class arbitration, or representative action or proceeding.

### 14) Changes To The Agreement

**14.1.** We may amend any portion of this Agreement at any time by posting the revised version of this Agreement with an updated revision date. The changes will become effective and shall be deemed accepted by you, the first time you use or access the SDK or API after the initial posting of the revised Agreement and shall apply on a going-forward basis with respect to your use of the SDK or API. In the event that you do not agree with any such modification, your sole and exclusive remedy are to terminate your use of the SDK or API&#x20;

**14.2.** We will post a notice to the official [Compendium Trading Tools Discord Server](https://discord.gg/64r2xtqczs) at least 5 days prior to posting any revision to this Agreement and give you an opportunity to provide us with any feedback you may have.

### 15) Miscellaneous

**15.1.** **Assignment.** Licensee may not assign this Agreement or any interest or rights granted hereunder to any third party without the prior written consent of Compendium. A change of control or reorganization of Licensee pursuant to a merger, sale of assets or stock shall be deemed to be an assignment under this Agreement. This Agreement shall terminate immediately upon the occurrence of any prohibited assignment.&#x20;

**15.2.** **Waiver.** No failure by either party to exercise or enforce any of its rights under this Agreement will act as a waiver of such rights and no waiver of a breach in a particular situation shall be held to be a waiver of any other or subsequent breach.&#x20;

**15.3. Severability.** If any provision of this Agreement is found invalid or unenforceable, that provision will be enforced to the maximum extent possible and the other provisions of this Agreement will remain in force.&#x20;

**15.4. Entire agreement.** This Agreement represents the complete agreement concerning the API, SDK and oral amendments are void. If any provision of this Agreement is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.&#x20;

**15.5.** By installing, copying, or otherwise using this API or SDK, you acknowledge that you have read, understand, and agree to be bound by the terms and conditions indicated above.


# Compendium Trading Tools

A full suite of products to make crypto investing simpler and smarter. Subscribe to or create your very own trading bots, copy trading groups, or signal provider services in just a few clicks.

<figure><img src="/files/z1wctrHsezHCQd8AL30z" alt=""><figcaption><p>The Compendium platform offers a wide variety of customizable automated strategies and social trading for multiple exchanges.</p></figcaption></figure>

{% embed url="<https://compendium.finance>" %}
Our Automation Terminal and Compendium trading tools are located at <https://compendium.finance&#x20>;
{% endembed %}

This side of our consumer-facing application offers the ability to create or subscribe to several different forms of [verified trading bots](/automation-terminal/verified-trading-bots), [automated trading signal providers](/automation-terminal/signal-provider-groups), [copy trading groups](/automation-terminal/copy-trading-groups), and more.&#x20;

{% hint style="success" %}
Access and registration for our automation terminal and trading tool platform are **COMPLETELY FREE** for all users, group leaders, and strategy authors.&#x20;

*Some third-party strategies featured may require a separate monthly subscription which is paid to the author of that strategy.*
{% endhint %}

We currently provide support and integrations for a growing list of what we internally consider "deeply liquid" centralized cryptocurrency exchanges like [OKX,](https://www.okx.com/join/COMPENDIUM) Binance, Bybit, Kucoin, Huobi, MEXC, and more. Our automation terminal is powered [PENDAX](/pendax/what-is-pendax) combined with a state-of-the-art load-balancing system to ensure industry-leading performance.

## Integrated Exchanges & Platforms

The following list of exchanges is currently available within the Compendium Automation Terminal and Trading Tool suite. Exchanges are often added after they have been integrated into the [PENDAX SDK](/pendax/what-is-pendax). You can view current SDK integrations that may come shortly to Compendium [here](/pendax/what-is-pendax#supported-platform-integrations).

{% tabs %}
{% tab title="Currently Integrated" %}

<table><thead><tr><th width="156">Exchange</th><th width="165" data-type="checkbox">Trading Bots</th><th width="188" data-type="checkbox">Signal Provider</th><th width="178" data-type="checkbox">Copy Trading</th><th data-hidden>Hosted API</th></tr></thead><tbody><tr><td>OKX</td><td>true</td><td>true</td><td>true</td><td></td></tr></tbody></table>
{% endtab %}

{% tab title="Staged For Deployment" %}
The following exchange platforms are currently undergoing full integration and debugging tests for deployment to the Compendium application.

* [x] Full Bybit Integration
* [x] Full Bitget Integration
  {% endtab %}

{% tab title="Planned" %}
The following exchanges are currently undergoing development integration for availability within the PENDAX SDK. This list is provided in alphabetical order and not by integration availability.<br>

| Exchange     | Status         |
| ------------ | -------------- |
| Binance      | In Development |
| Binance US   | In Development |
| Bitmex       | In Development |
| Deribit      | In Development |
| Gate         | In Development |
| Huobi        | In Development |
| Kucoin       | In Development |
| MEXC         | In Development |
| {% endtab %} |                |

{% tab title="Deprecated" %}
The following exchanges are deprecated from future PENDAX npm pushes and the Compendium application.<br>

| Exchange      | SDK Status     |
| ------------- | -------------- |
| FTX           | ⚠️ Deprecating |
| FTX US        | ⚠️ Deprecating |
| {% endtab %}  |                |
| {% endtabs %} |                |

{% hint style="danger" %}
⚠️ FTX connections and tools are currently being deprecated due to recent events.
{% endhint %}

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

## A Powerful Suite Of Tools, Simplified

### Verified Trading Bot Marketplace

Our [marketplace](https://compendium.finance/marketplace) features a wide variety of verified trading bots from a growing list of authors. All verified bots undergo strict due diligence and transparent result-reporting processes to ensure the longevity of the included strategies throughout multiple different market sentiments.

{% content-ref url="/pages/hIMYKWCaGzgJGqly69d7" %}
[Verified Trading Bots](/automation-terminal/verified-trading-bots)
{% endcontent-ref %}

### Cross-Exchange Copy Trading Groups

With our scalable trading routers, copy traders can follow historically profitable traders and automatically duplicate their trade signals. Our system dynamically sets risk management thresholds for each trade a group leader takes and ensures the correct post to every subscriber's account. Our system works across several exchanges and aggregates markets so that leaders and followers can use the exchange of their choice.

{% content-ref url="/pages/4iHFBdFzLxB7R1KXnzyG" %}
[Copy Trading Groups](/automation-terminal/copy-trading-groups)
{% endcontent-ref %}

### Signal Provider Groups

Trading signal groups powered by signals from [TradingView](https://tradingview.com/) or more advanced custom scripts. Create your own public or private signal provider group for others to follow or easily subscribe to a [growing list](https://compendium.finance/signalgroup) of community-created and managed groups of all levels.

{% content-ref url="/pages/00VzoTrTi8iJAKHEd5ZP" %}
[Signal Provider Groups](/automation-terminal/signal-provider-groups)
{% endcontent-ref %}

### Multiple Account Management

Users can easily manage multiple crypto exchange accounts, both automatically and manually through several products. When creating a trading strategy, you can choose several connected exchange accounts from the same platform and trade on all of them concurrently.

### Instant Portfolio Management

Managing balances of connected exchange accounts have never been easier. Our simple interface brings the simplicity of "Uniswap Style" swaps to all supported centralized exchanges. Converting balances is as easy as pressing one button without the need to browse over order books.

### Preselected Baskets & Indexes

Instantly rebalancing a full portfolio has never been easier. Our one-click interface allows traders to select from a wide variety of community-selected baskets with customizable percentage allocation breakdowns. Our system takes this one step further with the ability to auto-convert new collateral into preset percentage allocations.


# Connect An Exchange Account

The automation terminal links to supported cryptocurrency exchange accounts via a secure API connection. This segment reviews how to set up a new connection in order to utilize our tools.

## Step 1: Navigate To Connections Menu

<figure><img src="/files/X3fsqBXvm5iCXWu59FLk" alt=""><figcaption><p>Access the user dashboard at https://compendium.finance/dashboard and navigate to the "Connections" tab.</p></figcaption></figure>

After navigating to the correct "Exchange Connections" tab in the "Portfolio" drop down, you will then see the "Connect A New Exchange Account" form.

<figure><img src="/files/VcIWnKQV0pPi4Nlzo9GY" alt=""><figcaption></figcaption></figure>

## Step 2: Fetch And Enter Exchange API Keys

You can use the form pictured above. Depending on where you are accessing the ability to add a new connection from, a popup may then display allowing you to enter your exchange API keys in order to interact with our trading tools. Both of these forms (the main form, and the popup) will allow you to manage the addition of new exchange keys.

Before you enter the keys into our platform, it's important to understand how to create the API keys from your supported exchange account. Please follow the links below to ensure the correct creation of these API keys.&#x20;

{% hint style="warning" %}
It is important that your API keys have the ability to post trades. Some exchanges allow you to toggle the "Read Only" setting. If the "Read Only" setting is set to true then this account will not be able to follow signals sent by our variety of trading tools.
{% endhint %}

### Currently Supported Exchanges

Learn how to create and connect API keys from supported cryptocurrency exchanges.

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>OKX (Formerly Okex)</td><td>Learn how to create and connect API keys from OKX</td><td></td><td><a href="/files/aYL6GwKVrotysExHCfCB">/files/aYL6GwKVrotysExHCfCB</a></td><td><a href="/pages/88kz18laBzn0PJVJK031">/pages/88kz18laBzn0PJVJK031</a></td></tr></tbody></table>

### Exchanges Coming Soon To The Automation Terminal

These exchanges are in no exact order. To view integration schedules visit [here](/automation-terminal/compendium-trading-tools#integrated-exchanges-and-platforms).

* Binance
* Binance US
* BitMex
* BitGet
* Bybit
* Kucoin
* Huobi
* MEXC

{% hint style="info" %}
**Integrations:** Most exchanges integrated with our open-source PENDAX engine will automatically appear in our consumer-facing automation terminal after the confirmation and debugging stage.
{% endhint %}

## Step 3: Enter API Keys Into The Compendium App

![A visual representation of the Exchange API Credential pop-up](/files/lRJfWTHNWjgbOtj28IMi)

It is now time to enter your newly created keys after following the instructions for your selected exchange above.&#x20;

* **Select Exchange:** Ensure you select the correct exchange for your API keys from the "Exchange" dropdown menu.
* **API Key:** Enter the "Key" or "API Key" delivered by the exchange for your account or subaccount. This must be an exact match.
* **API Secret:** Enter the "Secret" or "API Secret" delivered by the exchange for your account or subaccount. This must be an exact match.
* **Subaccount Name:** This field is optional but required if you generated an API key for a specific subaccount on an exchange that supports this feature.
* **Nickname**: This nickname is for the Compendium automation terminal only and is used to distinguish this API key connection from others on your dashboard. It can be labeled however you see fit.

After you have entered these details correctly and confirmed their accuracy you can now click on the "Save" button. Once you click on the save button please allow the page a few seconds to load the "Health Check Confirmation".&#x20;

<figure><img src="/files/vqSlwG2rVISvCNt5H0qZ" alt=""><figcaption><p>The <strong>Successful Test</strong> parameter should read <strong>PASSED</strong> in order for the automation terminal tooling to post trades to your connected accounts.</p></figcaption></figure>

### Successful Health Check

If the "Successful Test" parameter retrieves a **"Passed"** signal during the exchange API credential health check then your connected account is now ready to be utilized on our platform. You can continue by pressing the close button.

### Failed Health Check

If the "Successful Test" parameter retrieves a **"Fail"** signal during the exchange API credential health check then you will need to press the **"Edit Details"** button and ensure that the entered information is correct.

{% hint style="warning" %}
Please Note: It has been documented in rare instances that exchanges may encounter problems verifying API keys that have been recently created. If for some reason you can not confirm newly created API keys then we recommend users return to the exchange and generate a new API key for their account.
{% endhint %}


# OKX.com API Keys

The following documentation will help provide instructions for creating an API key on OKX.com

<figure><img src="/files/USi6FIG6SRTojNH4VB2w" alt=""><figcaption><p>OKX is available for trading tool integrations and exchange connections on the Compendium platform.</p></figcaption></figure>

## Getting Started

Go to <https://www.okx.com/account/my-api> to access the API dashboard on OKX.

{% hint style="warning" %}
To create API keys on OKX you are required to do it from your PC. This process will not work on a mobile device.
{% endhint %}

![](https://lh4.googleusercontent.com/AElUERbMlPGevGZivYrxlivGaSCvZrLPwrnpnw8fISfzYWzDL-YzeMEvKYOqkOLvuiBvgRMVXLdd4QgBGFd6F8DXxM0YXbNnsk5148OZAlUIuWU34iLMkddIl-NgS6PEifxmeYYpGMzUcXc4Mw)

## Creating API Keys

On <https://www.okx.com/account/my-api> select “Create V5 API Key.”

Your browser will redirect you to the following page below.

![](https://lh5.googleusercontent.com/PVaJYdxwqyvLwA2IMf6PMkR5q8bwR0JG40ovGsuSivNC18xqA2pQR1ZlZNBZfTZXm_k5Hpa255k0BGpC7P0qTpdqs1qZXsw585BPRQYbEZYssIpT7dRV7P1EB5M4j3veS86j8muZJS9OpZ4-AA)

**Here you are required to provide the following details:**

* **API Name** - A case-sensitive name for 3rd party applications to interact with.&#x20;
* **Passphrase** - A password that allows you to connect to the OKX API infrastructure.&#x20;
* **IP Address** - *This step is optional for you*. This allows you to whitelist an IP address to interact with this pair of API keys. This significantly improves your API security.&#x20;
* **Permissions** - When creating a pair of API keys you have THREE options to choose from. These options determine what function can be carried out by the pair of API keys. You can choose one or all of the following options:&#x20;
  * Read&#x20;
  * Withdraw&#x20;
  * Trade (Necessary for utilization of Automated Trading Terminal Tools)

{% hint style="warning" %}
IP Address whitelisting may interfere with traditional Compendium Automation Terminal tools, as our IP address may rotate depending on server usage and load balancing.
{% endhint %}

Once you have provided the basic account information above you will be required to authorize your credentials.

After you have authorized your credentials, click confirm and you will receive a display similar to this below:

![An Example of furnished API Keys created on OKX.com](https://lh4.googleusercontent.com/j7o_YSuFmrAhpaAfjctgs8mbXk2biFbc5t-PdSlNjIQTgr3jermw7Dvx_RIBR96ZyGiNYzbuj9FG_Si6HixjSJgJ12E4Z2OGbgaDNJR9mAtv0QnM5uXlV0uw2JcAPMA9bccb4OWcK6t_IbckBw)

Click “Confirm” and you have successfully created a pair of API Keys on OKX.

Remember API rules and tips:&#x20;

* You can create up to 50 API keys.&#x20;
* For higher security, link IP addresses to your API keys and don’t share your API keys with anyone. Be aware that your API key can be exposed by using it on third-party platforms.&#x20;
* You can link up to 20 IP addresses to each API key. Use commas to separate them.&#x20;
* <mark style="color:red;">**For even higher security, API keys without IP addresses are automatically deleted if you don’t use them for 30 days. You’ll need to create a new API key if the old one was deleted. API keys with IP addresses don’t expire at all.**</mark>

{% hint style="danger" %}
Please remember OKX's API security rule highlighted above if you utilize trading strategies or tools that may not post trades within 30-day time frames. If an API key becomes invalid, then your trading bot or strategy may fail to post a trade.
{% endhint %}

### Which type of API keys are right for me?

On OKX there are three different types of API Keys you can create depending on the way you want to use them.

* Read - Fetching account balances.&#x20;
* Withdraw - Allowing a 3rd party to authorize withdrawals.&#x20;
* Trade - Allowing trading platforms like Compendium to authorize trades.

When connecting your API Keys to a platform, they will specify what type of API Keys are required.

## Deleting API Keys

You can remove a pair of API Keys by visiting <https://www.okx.com/account/my-api>.

![](https://lh4.googleusercontent.com/SAFJtL3bcRzAky0x7u_h6iXyvI4DexL_KP8VYSLassapUd9L8Ysbj_5xgRYcZABJ5K1ObgyEu3AUvDmlYe7UEB_yNkVCk96OZZTA0Ia-a0X8T0BiQkdmQP6SpzLBgntOYMMH7LO-NofyuCrF-w)

On this dashboard, you will see all current API Keys.

![](https://lh6.googleusercontent.com/1fXswUdvdzEKVaSBqoOotvZDLrS28F0owDQgdsILZBp-6d8v6THvi4tzvwvROoEHa6ys4tgREsDsumivLgFp3aSxxYcG02w9bai5lE2F3glonbimNg-EaOXUYGRacJVDkPiyHu13IDGKWsObVw)

Simply go to below the action category on the right-hand side and click “Delete” and “Confirm” this action.

This will remove the selected API Key from your OKX account.


# Verified Trading Bots

Learn more about our Verified Trading Bot program on Compendium. This documentation explains the bot listing and verification process as well as user-based subscription abilities and setup.

## Automated Trading Bot Strategy Marketplace

Automated cryptocurrency trading bots are software programs that use algorithms to analyze market data and make trades on behalf of a user. These bots can be programmed to follow a specific trading strategy or to react to certain market conditions, such as changes in the price of a particular cryptocurrency.

The goal of using an automated trading bot is to make trades faster and more efficiently than a human trader could, and to potentially increase profits by taking advantage of market opportunities that may be missed by a manual trader.

There are many different types of automated cryptocurrency trading bots available, ranging from simple bots that execute predetermined trades to more complex bots that use machine learning algorithms to make decisions.

Our trading strategy marketplace features a wide variety of verified trading bot strategies. These strategies are published by vetted third-party authors and also feature our own propriety CompendiuML products.&#x20;

{% content-ref url="/pages/8LhB13cfm7FViIOkEI5D" %}
[Explore The Marketplace](/automation-terminal/verified-trading-bots/explore-the-marketplace)
{% endcontent-ref %}

<figure><img src="/files/7A8l0tPdCjQ2U9jL5aLD" alt=""><figcaption><p>The Trading Bot Marketplace can be accessed from the "Trading Bots" dropdown on the main dashboard navigation bar.</p></figcaption></figure>

Detailed information on strategy setup, historical statistics, and more are available. Our system also tracks up-to-date data on all verified strategies and runs these strategies through our proprietary statistical tracking system to include all fees and slippage that a user may experience. This ensures that our main focus of data transparency within our trading systems remains an industry-leading experience, unlike our competitors that only display paper traded estimates.

## Listing And Running Your Bot On Compendium

Verified trading bots are different than our signal provider groups and other products. They also provide monetization opportunities for successful algorithmic authors. All authors and strategies are vetted through a time-controlled verification process. This process usually lasts 30-60 days on a Compendium-controlled subaccount to ensure that test results are not corrupted and that the strategy functions as planned in a live testing environment.

You can explore the listing process, how the platform is monetized, protected intellectual property notes, and more by visiting the "For Algo & Strategy Authors" Page.

{% content-ref url="/pages/EZQCRNIhMfSUNmqO2MzM" %}
[For Algo & Strategy Authors](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors)
{% endcontent-ref %}

## Automating Your Portfolio With Verified Bots

Verified bot details are available on the [marketplace page](https://compendium.finance/marketplace) and [user dashboard](https://compendium.finance/dashboard). If a strategy fits your overall trading goals you can choose to subscribe to this strategy.&#x20;

There are several potential benefits to using automated cryptocurrency trading bots, including:

* **Increased Efficiency:** Automated trading bots can make trades faster and more consistently than human traders, which can be especially useful in fast-moving markets.
* **The Ability to Execute Complex Strategies:** Some trading strategies may be too complex for a human trader to execute manually, but can be easily implemented by a bot.
* **The Potential to Increase Profits:** By analyzing market data and making trades based on predetermined strategies, bots may be able to identify and take advantage of trading opportunities that a human trader might miss.
* **Reduced Emotion:** Automated trading can help to remove emotion from the trading process, as bots don't experience fear, greed, or other emotions that can influence a trader's decisions.

You can explore how to subscribe to a strategy and have trading signals automated to your connected exchange account on the "For Users & Subscribers" page.

{% content-ref url="/pages/DAr2kWM9HlH9o4FVDpDO" %}
[For Users & Subscribers](/automation-terminal/verified-trading-bots/for-users-and-subscribers)
{% endcontent-ref %}


# Explore The Marketplace

The Compendium automated strategy marketplace displays a full list of live tested cryptocurrency trading bots and strategies.

You can also view our strategy marketplace's public page here *(Does not require login)* :

{% embed url="<https://compendium.finance/marketplace>" %}
Public Marketplace URL to view and browse trading bots located at <https://compendium.finance/marketplace>
{% endembed %}

### Available Marketplace Filtering

Our marketplace provides several different filtering options to help find the correct strategy for everyone while giving equal free-market-based visibility to all verified trading bots. The following filtering options are available from the dropdown at the top of the marketplace grid.

* **All Trading Bots:** Displays all trading bots on the marketplace with no parameter filtering.
* **Paid Subscription Trading Bots:** Displays all trading bots that require a monthly subscription which can be paid via PayPal, USDC, or CMFI on a rolling monthly basis.
* **Free Trading Bots:** Displays all trading bots available for free with no subscription payment needed.
* **Invite-Only Trading Bots:** Displays trading bots that require users to meet certain parameters in order to receive an invite from the author. These strategies are private and can not be openly subscribed to.
* **Token & NFT Gated Access:** Displays trading bots that require the user to have an eligible connected wallet to access.

{% hint style="info" %}
Trading bots can also be filtered by strategy type as well which is explained below. A strategy type will determine what kind of collateral and market the trading bot utilizes to make and post trades on connected accounts.
{% endhint %}

## Trading Bot Subscription Types

Our marketplace features a wide variety of strategies by different algorithmic authors and funds. There are currently four different types of subscription models available depending on the strategy.

* **Paid Monthly Subscriptions:** These trading bots are most often the most sophisticated and are offered by third-party authors who set the price individually for access to their own strategies. All monthly subscription payments are made through our automated systems and send a large percentage of the payment to the author to help support the further development of these strategies. Our payment systems are non-recurring and will require users to purchase a set amount of monthly credits. Users can then purchase more credits before their subscription time is up in order to continue utilizing this strategy.
* **Free Access:** These trading bots are provided for **FREE** to all users on Compendium with no strings attached. Users can subscribe to this strategy for free in 3-month increments. To continue using this strategy after the 3-month subscription is over, a user just needs to renew their subscription for free. This helps to cut down on unused subscription allocations.
* **Invite-Only Trading Bots:** These trading bots require users to meet certain parameters set by the author in order to receive an invite. Subscriptions are managed by the author who will have control over which users gain and retain access. Users can visit our Discord or reach out to the author with an invite request if they wish to utilize one of these strategies.
* **NFT & Tokenized Access:** Trading bots offered under this program are available for members or holders of the [Compendi-Pigs NFT](https://compendium.finance/piggies) and [CMFI token](https://compendium.finance/token) ecosystems. Users can subscribe to these strategies after linking a Phantom Wallet or Discord account that meets the minimum criteria requirements. The subscription will remain active as long as this account continues to meet the minimum holder requirements.

{% hint style="info" %}
Looking to further support a trading bot author? Up to 90% of subscription payments are sent to the author each month, however, 100% of payments made in $CMFI are sent directly to the author on subscription payment.
{% endhint %}

## Understanding Strategies With Analytics

Our system hosts a wide variety of strategies with verifiable historical results. In addition to traditional data, we also include a list of data and analytics points on each trading bot's page to ensure subscribers can make a decision that best fits their overall trading strategy.

### **Strategy Types**

Our verified strategy marketplace hosts two different main versions of retail-facing strategies. The two main types differ in the related markets that they may trade on.

#### Spot Markets / Auto Hedge Strategies

These strategies trade spot markets based on a user's collateral in order to take advantage of changing market sentiment, DCA into a spot position, or attempt to hedge a user's portfolio. A user **MUST** hold one of the underlying assets of this strategy's main trading pair in their attached exchange portfolio for the strategy to work correctly.\
\
*For example: If a user is utilizing a spot market bot that trades SOL/USD, then a user must either have Solana or USD in the attached underlying exchange portfolio. Otherwise***,** *this strategy will fail to correctly post trades*

#### &#x20;Perpetual Futures Strategies

These strategies trade perpetual futures (or futures SWAP markets) on supported centralized exchanges. The strategy will either long or short the perpetual futures market instead of buying or selling an underlying asset.\
\
To correctly utilize these strategies a user must have the correct collateral available in the connected account. Most exchanges support a variety of underlying assets with different collateral basis percentages, although USDT and USDC are the most popular.\
\
*For example: If a user attaches a perpetual futures market strategy to an OKX account, then OKX will calculate the total collateral available for the specific margin asset on the traded market. If the market is BTC-USDT-SWAP then the user must have USDT as collateral for margin in their connected account.*

{% hint style="warning" %}
Although not required, we do recommend utilizing stable coins for underlying collateral on perpetual futures strategies in order to prevent collateral minimalization during market shifts. It is also recommended to research exactly how leverage and liquidations work to prevent any possible loss of funds and stay within responsible risk thresholds.
{% endhint %}

### Historical Strategy Analytics

Upon viewing each strategy a user will be greeted with a list of historical data points to help understand if the trading bot fits their goal.

<figure><img src="/files/RUgmxHDEOFvmz2ShC6m2" alt=""><figcaption><p>An example of what a trading bot details page may look like.</p></figcaption></figure>

Each of the following data points is available for each bot. Users can also hover over the "?" next to each point for a tooltip explainer that matches the explainers below.

**Traded Asset:** Verified strategies only trade on one specific market. This market can either be Spot (USD) or specialized markets like perpetual futures (PERP or USDT-SWAP, etc).

**Default Equity:** The default amount of equity used from the attached account collateral in each posted trade signal. This may differ slightly with each trade post dependent on individual call details.

**Default Leverage:** The default amount of leverage used in conjunction with the equity settings in each trade signal post. This may differ slightly with each trade post dependent on individual call details.

**Candle Time Frame:** Estimated time frame that this strategy may observe. Shorter time frames lead to quicker more frequent trades.

**Trade Frequency:** Insight into how many trades this strategy has taken within the verified listing timeframe.

**Strategy Logic:** The main strategy type that this verified trading bot will employ in trade signals.

**Trade Amount Cap:** The total amount of collateral that can be utilized in one single trade signal post under this strategy. This is mainly utilized to prevent slippage on less liquid pairs. This does not apply while closing trades that with profit may include a higher order size.

**Started Trading On:** The day this strategy began the verification process and live trading on the Compendium platform.

**Compounding Discount:** Compounding discounts apply to monthly subscriptions for this strategy and multiply with each new month added at the same time in order to give users the best deals! This is solely applicable to strategies that require a monthly subscription fee.

### Trading Bot Performance Data

<figure><img src="/files/e5WkuH5XLKyNdIOUaXv7" alt=""><figcaption><p>Performance chart and recent trades example from a trading bot on our test environment to display what a user may see.</p></figcaption></figure>

{% hint style="success" %}
Performance is based on live trade data with no backtest results. Trade posts are calculated using the default settings and data is pulled via API from an exchange account.
{% endhint %}

The attached graph for each bot displays the trading bot's historical lifetime return from the start of the verification process until the current date and time. It is important to note that this performance chart also is affected by variables like slippage, funding, and fees just as a real subscriber's account would be affected! There will always be slight variations between each subscriber, however, this graph best portrays applicable historical results.

The recent trades table pulls data through API from our live trading account to show actual entries and exits a subscriber can expect when utilizing this verified strategy.

{% hint style="warning" %}
When subscribing to or selecting a strategy it is important to remember that historical results can never guarantee future outcomes and all trades are solely at the user's discretion.
{% endhint %}

It is important to understand how the trading routers and strategy subscription settings work in conjunction with posting orders for each user.

Each verified trading strategy features a default set of parameters for the following:\
\
**Traded Market:** This is the market that the trading strategy will focus on. Verified trading strategies are limited to one single market.\
\
**Default Leverage:** This is the standard leverage setting for trades posted to subscribers. It is calculated in conjunction with "Default Equity" to form the order amount for each individual trade signal a user may receive.\
\
**Default Equity:** This is the standard equity setting that the strategy will utilize. For example: A 100% equity means that the strategy has access to the full collateral of the attached exchange account.\
\
*Formulating trade posts for each user is dependent on the factors above. Both the default leverage and equity are also customizable but we recommend this feature for advanced users only.*


# For Algo & Strategy Authors

Documentation explaining the Verified Trading Bots product on Compendium for strategy and bot authors wishing to utilize our platform.

## Getting Started And Understanding The System

This section of the documentation covers our Signal Provider Groups system from a verified bot author perspective. The sections outlined below define the basics you should know and learn before getting started in order to harness the full potential of this system.

{% content-ref url="/pages/mANJfazXrWsNUKjoNmNG" %}
[Get Listed & Verified](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors/get-listed-and-verified)
{% endcontent-ref %}

{% content-ref url="/pages/V9eLtg7trJvGzF8Tdggh" %}
[Strategy Monetization](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors/strategy-monetization)
{% endcontent-ref %}

{% content-ref url="/pages/41olsi0VWObqAkwIAOX2" %}
[Sending Trading Signals](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors/sending-trading-signals)
{% endcontent-ref %}

## Other Automated Trading Options

Our Copy Trading & Signal Provider Groups do not require strategies to be verified like strategies within the Verified Trading Bots Marketplace. If you are looking to explore the capabilities of our system then we advise checking these open-access listing products.

{% content-ref url="/pages/00VzoTrTi8iJAKHEd5ZP" %}
[Signal Provider Groups](/automation-terminal/signal-provider-groups)
{% endcontent-ref %}

{% content-ref url="/pages/4iHFBdFzLxB7R1KXnzyG" %}
[Copy Trading Groups](/automation-terminal/copy-trading-groups)
{% endcontent-ref %}

## Useful External Resources

Although our system supports commands from any platform or system, most group leaders choose to communicate signals via platforms like TradingView through their native webhook systems. We've gathered some information and tutorials for creating your own trading study or strategy via their `pinescript` coding language.&#x20;

{% embed url="<https://www.tradingview.com/pine-script-docs/en/v5/index.html>" %}

{% embed url="<https://www.tradingview.com/pine-script-reference/v5/>" %}

{% embed url="<https://www.tradingview.com/pine-script-docs/en/v4/index.html>" %}


# Get Listed & Verified

Looking to monetize your automated trading bot or strategy? Compendium offers a wide variety of support to help make the most of your intellectual property.

## How To Get Your Strategy Verified

Verified trading bots are different than our signal provider groups and other products. They also provide monetization opportunities for successful algorithmic authors. All authors and strategies are vetted through a time-controlled verification process. This process usually lasts 30-60 days on a Compendium-controlled subaccount to ensure that test results are not corrupted and that the strategy functions as planned in a live testing environment.

**Please fill out the form below if you are an algorithmic strategy author looking to monetize your creations.**&#x20;

{% embed url="<https://forms.gle/KHegEVcWRdd8r7CNA>" %}
**Please fill out the attached Google Form to start your verified listing process.**
{% endembed %}

{% hint style="info" %}
We will process your application and reach out shortly if we feel it is a great fit for our ecosystem! We greatly recommend joining our Discord server in the meantime so that communication processes are seamless.
{% endhint %}

## **Why You Should List With Us**

### Intellectual Property Protection

The author remains in complete control of all intellectual property and sends signals to a designated webhook, which in turn issues trade posts for all subscribers.

There are also no restrictions to listing your strategy on other marketplaces, as the strategy is your property. We believe in free markets and realize that different platforms may offer variably different services. Extending strategies to other marketplaces can help an author increase their visibility.

Our designated author panel gives strategy owners complete control over their listings. Our focus is on the simplicity and automation of these practices in order to make things seamless, unlike our major competitors.

### Platform Performance Like No Other

Our automated systems are designed on the [PENDAX SDK](/pendax/what-is-pendax) and provide the ability to meet any trading integration needs an author may need to effectively automate their strategies or indicators for the community. Support for high-frequency trading strategies is included natively for both spot and leveraged futures markets.

### Freedom To Monetize

We work with strategy owners to correctly price their strategies based on offerings and performance. Strategies can also be marked as "invite" or "affiliate link" only. Users pay for your strategy on a monthly basis. All payments are made under "Net-30" terms and conditions. The monetization options for verified trading strategies include the following:

* Receive **80%** of monthly subscription revenue paid out in USDC-SPL to a Solana-compatible address when a user pays with PayPal or USDC.
* Receive **100%** of monthly subscription revenue paid out in CMFI-SPL to a Solana-compatible address when a user pays with [CMFI](/cmfi-token/tokenomics-breakdown).
* Mark strategy as "Invite Only" and manage subscriptions off the platform or through unique terms. The author must manage their subscriptions manually in this aspect. "Invite Only" strategies can also be utilized for requiring a subscriber to register under the attached referral link if an author wishes to monetize volume for a strategy instead of monthly subscriptions. Referral-based volume monetization is always marked on the terms of that specific exchange and may differ dependent on exchange referral systems.

**Please Read More On Monetization Options & Terms in the Strategy Monetization section.**

{% content-ref url="/pages/V9eLtg7trJvGzF8Tdggh" %}
[Strategy Monetization](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors/strategy-monetization)
{% endcontent-ref %}

{% hint style="info" %}
Refer users for extra income! Strategy authors can also utilize our referral system to capture an additional 5-10% of monthly subscription revenue for all subscription and feature purchases a user may make. Our referral system is lifetime-based which means you continue to collect referral revenue for as long as that user utilized our platform! The referral system is only applicable to purchases made with PayPal or USDC and does not currently carry over to the 100% CMFI payouts.
{% endhint %}

### Joint Marketing Opportunities

We also focus on joint marketing opportunities in order to increase the visibility of all listed strategies.&#x20;

* Social Media Marketing and Social Proof / Rapport Campaigns.
* Interviews and AMA's on the web application, [Twitter](https://twitter.com/CompendiumFi), & Youtube Channels
* Inclusion in cross-marketing efforts with partnered platforms and exchanges.
* Designated Discord roles for further visibility within the Compendium chat channels.
* Press Releases and [partnered guest educational](https://compendium.finance/trading-education) posts are available.
* Public page for each strategy to increase SEO capabilities and organic traffic.
* Author profile pages to show all social channels and on-platform posts/strategies.

### Direct Communication And Support

Communication and relationships are important to us!  We provide constant updates as our platform is updated with subscriber and author feedback to ensure the best user experience possible.

Verified strategy authors also have direct lines to our team and their subscribers at all times. Designated Discord roles also provide access to private channels for both team and joint-author communications.

### Current Author Testimonial

> I personally use several different tools offered by the CEX suite for algo-trading. I usually set up new strategies as signal groups for forward testing, and once enough data is gathered, I can share that group with a selected few with ease - no hassle with handling complicated invite systems, or the need to send my signals to different webhooks managed by others. Once I'm happy with how the algo is performing, it's a smooth process to transition to an actual bot and offer the strategy in the marketplace.
>
> The team has been very reactive and helpful from the beginning, always took feedback into account, fixed issues in very short periods, and been around to support and implement specific requirements I had through the past 1+ year I've worked with them. I think Compendium will easily dominate the automated trading industry with its flexibility and offering of a wide range of products.
>
> From A Verified Bot Author Featured On Compendium - [Overhead Gains](https://twitter.com/OverheadGains)


# Strategy Monetization

Explore monetization options for verified trading bot listings and earn income by offering your protected intellectual property on our marketplace.

## Freedom To Monetize

Our company collaborates with strategy owners to determine an appropriate pricing model based on offerings and performance metrics.&#x20;

The strategies can also be designated as either "invite-only" or "affiliate link-only". Subscriptions to these strategies are billed monthly to users.&#x20;

Payment terms are established as "Net-30" unless otherwise specified and paid in CMFI or alternative payment methods.

## Available Monetization Methods

{% tabs %}
{% tab title="🟡 PayPal" %}
**Payment Type:** Debit/Credit Card or PayPal account through PayPal Connection at checkout.

**Payment Cut:** `80%` of monthly subscription payment revenue

**Payment Terms:** All payments received through this method are made under "Net-30" terms and conditions.

**Payout Type:** The bot author can choose to be paid via PayPal or USDC (Solana) under the payment terms above.
{% endtab %}

{% tab title="🔵 USDC (SPL)" %}
**Payment Type:** USDC (USD Coin) via user payment through Phantom wallet connection.

**Payment Cut:** `80%` of monthly subscription payment revenue

**Payment Terms:** All payments received through this method are made under "Net-30" terms and conditions.

**Payout Type:** Bot author receives cut in USDC (Solana) under payment terms above
{% endtab %}

{% tab title="🟣 CMFI (SPL)" %}
**Payment Type:** CMFI token via user payment through Phantom wallet connection.

**Payment Cut:** `100%` of monthly subscription payment revenue

**Payment Terms:** All payments received through this method are instantly forwarded to the bot author's connected Solana wallet.

**Payout Type:** The bot author receives `100%` in CMFI (Solana) under the payment terms above.
{% endtab %}

{% tab title="🔒 Invite Only" %}
{% hint style="info" %}
This system requires special permission from the team to access.
{% endhint %}

Mark strategy as "Invite Only" and manage subscriptions off the platform or through unique terms. The author must manage their subscriptions manually in this aspect. "Invite Only" strategies can also be utilized for requiring a subscriber to register under the attached referral link if an author wishes to monetize volume for a strategy instead of monthly subscriptions. Referral-based volume monetization is always marked on the terms of that specific exchange and may differ dependent on exchange referral systems.&#x20;
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Our current payment system is non-recurring, users buy an allotment of time at once and can choose to renew and add more credits at any time. We feel this way is more transparent and helps to cut down on monthly charges and unused products. Strategy authors can provide discounts to prompt users to buy multiple-month credit allotments in one purchase.
{% endhint %}

## Referral System

Utilize our referral system to augment your revenue streams as a strategy author. By referring users, you are entitled to an additional 5-10% of monthly subscription revenue from all purchases made by the referred user, including subscriptions and feature purchases. Additionally, you can still collect referral revenue even if the referred user subscribes to a verified trading bot created by another author. Our referral system operates on a lifetime basis, enabling you to continuously collect referral revenue as long as the referred user remains active on our platform.

{% hint style="info" %}
The referral system is only applicable to purchases made with PayPal or USDC and does not currently carry over to the 100% CMFI payouts.
{% endhint %}


# Sending Trading Signals

Documentation for creating and formatting Verified Trading Bot trade notifications on the Compendium application.

## How To Obtain An API Key

To link your trading strategy with Compendium, head back to the admin page of your Verified Trading Bot. Scroll down until you see the "View This Bot's Alert API Key" section, then click the "View My Bot API Key" button. This will reveal your private API key, which you can then input into the Compendium WebHook.

{% hint style="warning" %}
It's crucial to keep your API key confidential as it's used to identify calls. Sharing your API key can result in unauthorized signals being sent and potentially compromise the security of your group. If you suspect that your API key has been compromised, we recommend clicking the "Reroll API Key" button. Don't forget to update the API key in your webhooks to ensure that your strategy continues to post trades successfully.
{% endhint %}

## Formatting WebHook Signals

Now that you have your API key it is time to learn how signals can be sent!

All signals should be sent to the following webhook URL as POST. If you are using TradingView it will automatically format webhook + JSON in the correct method.

### Understanding JSON Formatting

You can learn more about specific JSON formatting at the link below.

{% embed url="<https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON>" %}

### Posting Webhooks From TradingView

Please follow TradingView's internal documentation for educational resources on posting Webhook orders from their system.

{% embed url="<https://www.tradingview.com/support/solutions/43000529348-about-webhooks/>" %}
Official documentation provided by TradingView on interacting with their webhooks system.
{% endembed %}

### **Webhook URL**

The webhook URL for our verified trading bots router is different from our regular Signal Provider webhook. The webhook information is available on request through your designated representative channel in our official discord server.

{% hint style="warning" %}
A "success" return from the provided Webhook means that the URL was successfully pinged in your workflow. It does not mean that the `signal` or `orderchain` was formatted correctly and still may result in a trade post error.&#x20;
{% endhint %}

### **Webhook JSON Format**

```json
{
  "apiKey": "insertGroupAPIKeyHere",  
  "orderchain" : [
        {
          "signal" : "place",
          "orderType" : "limit",
          "symbol" : "BTC-USDT-SWAP",
          "marketType" : "linear",
          "side" : "buy",
          "risk" : "100",
          "mode" : "cross",
          "reduceOnly" : "false",
          "postOnly" : "false",
          "ioc" : "false",
          "fok" : "false",
          "price" : "20000",
          "tpTrigger" : "21000",
          "tpPrice" : "21500",
          "tpType" : "last",
          "tpOrderType" : "limit",
          "slTrigger" : "19900",
          "slPrice" : "19500",
          "slType" : "last",
          "slOrderType" : "limit"
        }
    ]
}
```

The above JSON example shows a single signal in the `orderchain` array. Please read the next section to understand how to fully utilize this new integration.

## Understanding the `orderchain` Array

Our new signal system requires signal commands to be sent in the `orderchain` array, even if you are only sending a single command. We can now offer supremely advanced capabilities by offering the capability to chain orders together. We have provided some simple examples below.

{% hint style="info" %}
The `orderchain` array has a capacity of accommodating a **maximum of 5 signal types in a stacked manner** and mandates the presence of **at least one signal type** to effectively transmit a trade notification signal. It is imperative to acknowledge that the execution of Orderchain commands is dependent on the sequence of WebHook post in which they are transmitted, thus dictating their placement order.
{% endhint %}

### Single Signal Post Example

The following example shows the user sending a single signal in the `orderchain` array to close all open positions.

```json
{
  "apiKey": "insertGroupAPIKeyHere",  
  "orderchain" : [
        {
            "signal" : "closeall"
        }
    ]
}
```

### Sending Multiple Signals At Once

The following example shows the user sending multiple signals in the `orderchain` array. This specific example shows the user closing all open positions and then opening a new trade. This code snippet should be helpful if your trading strategy is always in a trade and needs to flip sides from "short" to "long" or vice-versa.

```json
{
  "apiKey": "insertGroupAPIKeyHere",  
  "orderchain" : [
        {
            "signal" : "closeall"
        },
        {
            "signal" : "place",
            "orderType" : "limit",
            "symbol" : "BTC-USDT-SWAP",
            "marketType" : "linear",
            "side" : "buy",
            "risk" : "100",
            "mode" : "cross",
            "reduceOnly" : "false",
            "postOnly" : "false",
            "ioc" : "false",
            "fok" : "false",
            "price" : "20000",
            "tpTrigger" : "21000",
            "tpPrice" : "21500",
            "tpType" : "last",
            "tpOrderType" : "limit",
            "slTrigger" : "19900",
            "slPrice" : "19500",
            "slType" : "last",
            "slOrderType" : "limit"
        }
    ]
}
```

## All Available Signal Parameters

{% hint style="info" %}
All parameters should be sent as a "string" from your POST API call. This is to simplify connections from platforms like TradingView while normalizing our structure. It is also important to note that if you are passing a number, it should be treated as an `integer` within the "string".
{% endhint %}

<table><thead><tr><th width="178">Parameter</th><th width="98.33333333333331">Type</th><th>Requirements &#x26; Description</th></tr></thead><tbody><tr><td>signal</td><td><em>String</em></td><td><strong>ALWAYS</strong> <em><strong>REQUIRED</strong></em> - See valid values below</td></tr><tr><td>orderId</td><td><em>String</em></td><td>Required if <code>signal</code> = cancel</td></tr><tr><td>orderType</td><td><em>String</em></td><td>Required if <code>signal</code> = place. See valid values below</td></tr><tr><td>symbol</td><td><em>String</em></td><td>Required if <code>signal</code> parameter requires.</td></tr><tr><td>marketType</td><td><em>String</em></td><td>Optional - if <code>signal</code> is <code>cancel</code> type, the orders canceled will be of <code>marketType</code>.</td></tr><tr><td>side</td><td><em>String</em></td><td>Required if <code>signal</code> = place</td></tr><tr><td>risk</td><td><em>String</em></td><td>Required if <code>signal</code> = place</td></tr><tr><td>price</td><td><em>String</em></td><td>Required if <code>orderType</code> requires it (eg limit)</td></tr><tr><td>mode</td><td><em>String</em></td><td>Optional - default value = <code>cross</code></td></tr><tr><td>reduceOnly</td><td><em>String</em></td><td>Optional - default is <code>false</code></td></tr><tr><td>postOnly</td><td><em>String</em></td><td>Optional - default value is <code>false</code></td></tr><tr><td>ioc</td><td><em>String</em></td><td>Optional - default = <code>false</code></td></tr><tr><td>fok</td><td><em>String</em></td><td>Optional - default = <code>false</code></td></tr><tr><td>tpTrigger</td><td><em>String</em></td><td>Optional</td></tr><tr><td>tpPrice</td><td><em>String</em></td><td>Required if <code>tpTrigger</code> submitted and <code>tpOrderType</code> = <code>limit</code></td></tr><tr><td>tpType</td><td><em>String</em></td><td>Optional - default = <code>last</code></td></tr><tr><td>tpOrderType</td><td><em>String</em></td><td>Required if <code>tpTrigger</code> submitted</td></tr><tr><td>slTrigger</td><td><em>String</em></td><td>Optional</td></tr><tr><td>slPrice</td><td><em>String</em></td><td>Required if <code>slTrigger</code> submitted and <code>slOrderType</code> = <code>limit</code></td></tr><tr><td>slType</td><td><em>String</em></td><td>Optional - default = <code>last</code></td></tr><tr><td>slOrderType</td><td><em>String</em></td><td>Required if <code>slTrigger</code> submitted</td></tr></tbody></table>

## Understanding Each Parameter

The following breakdown includes **JSON Type**, **Required Conditions**, & **Valid Values** for all available `signal` parameters.

<details>

<summary>signal</summary>

**JSON type:** "String"

**Required:** Always

**Valid Values:**

* `place` : used to place orders
* `cancel` : cancels ONE specific order, must provide `orderid`&#x20;
* `cancelall` : cancels ALL open orders without regard to market or complexity
* `cancelbuys` : cancels all open buy orders
* `cancelsells` : cancels all open sell orders
* `canceltps` : cancel all take profit orders (including embedded TP orders)
* `cancelsls` : cancels all stop loss orders (including embedded SL orders)
* `canceltriggers` : cancels all orders having TP or SL orders embedded but not both
* `close` : if submitted with a symbol (e.g. symbol: `BTC-USDT-SWAP`), then closes all current positions on that symbol. Otherwise closes all positions on all tokens (same behavior as `closeall`)
* `closeall` : closes all positions on all token markets
* `closelongs` : closes all long positions on any token market
* `closeshorts` : closes all short positions on any token

</details>

<details>

<summary>orderID</summary>

**JSON type:** "String"

**Required:** required if `signal` = cancel (specifies order to cancel)

**Valid Values:** insert `orderid` from exchange to cancel.

</details>

<details>

<summary>orderType</summary>

**JSON type:** "String"

**Required:** required if `signal` = place.

**Valid Values:** `limit` or `market`

</details>

<details>

<summary>symbol</summary>

**JSON type:** "String"

**Required:** Required if `signal` parameter requires.

**Valid Values:** must be a VALID symbol on native exchange. (e.g. symbol: `BTC-USDT-SWAP`)

</details>

<details>

<summary>marketType</summary>

**JSON type:** "String"

**Required:** Optional - if `signal` is cancel type, the orders canceled will be of `marketType`. if omitted and `signal` is cancel type then spot and perpetual orders will be canceled.

**Valid Values:** `linear, inverse,` or `spot`

**Deprecated Values:** `perpetual`

</details>

<details>

<summary>side</summary>

**JSON Type:** "String"

**Required:** Required if `signal` = place

**Valid Values:** `buy` or `sell`

</details>

<details>

<summary>risk</summary>

**JSON Type:** "String"

**Required:** Required if `signal` = place

**Valid Values:**

* Risk is limited from 1 - 100 for spot markets.&#x20;
* Risk can be above 100 for perpetual swap markets.

**Explanation:** Risk is our system's version of trade size.

**Examples of `risk` utilization:**

* 50 = 50% of the connected exchange account balance
* 100 = 100% of the connected exchange account balance
* 150 = 150% of the connected exchange account balance (1.5x Leverage)
* 200 = 200% of the connected exchange account balance (2x Leverage)

</details>

<details>

<summary>price</summary>

**JSON Type:** Integer within "String"

**Required:** Required if `orderType` requires it (eg limit)

**Valid Values:** Insert price to initiate order as a "string"

**Example:** `"21000"` (must be formatted as an integer within the string)

</details>

<details>

<summary>mode</summary>

**JSON Type:** "String"

**Required:** Optional, default value = `cross`

**Trade Mode Explanation:** Trade Mode, when placing an order, you need to specify the trade mode. (Notes taken specifically from OKX documentation)\
\
**Valid Values:**

* `cash` for spot markets
* `cross` for perpetual markets

</details>

<details>

<summary>reduceOnly</summary>

**JSON Type:** "String"

**Required:** Optional - default is `false`

**Valid Values:** `true` or `false` (passed in a "string"). The default value is `false`.\
Only applicable to `MARGIN` orders, and `FUTURES/SWAP` orders in `net` mode\
Only applicable to `Single-currency margin` and `Multi-currency margin`

</details>

<details>

<summary>postOnly</summary>

**JSON type:** "String"

**Required:** Optional - default value is `false`

**Valid Values:** `true` or `false` (passed as "string")&#x20;

</details>

<details>

<summary>ioc</summary>

**JSON Type:** "String"

**Required:** Optional - default = `false`

**Valid Values:** `true` or `false` (passed as "string")

</details>

<details>

<summary>fok</summary>

**JSON Type:** "String"

**Required:**  Optional - default = `false`

**Valid Values:** `true` or `false` (passed as a "string")

</details>

<details>

<summary>tpTrigger</summary>

**JSON Type:** Integer within a "String"

**Required:** Optional

**Valid Values:** Insert price to initiate order as a "string"

**Example:** `"21000"` (must be formatted as an integer within the string)

</details>

<details>

<summary>tpPrice</summary>

**JSON Type:** Integer within "String"

**Required:** Required if `tpTrigger` submitted and `tpOrderType` = `limit`

**Valid Values:** Insert price to initiate order as a "string"

**Example:** `"21000"` (must be formatted as an integer within the string)

</details>

<details>

<summary>tpType</summary>

**JSON Type:** "String"

**Required:** Optional - default = `last`

**Valid Values:**

* `last` : last price
* `index` : index price
* `mark` : mark price

</details>

<details>

<summary>tpOrderType</summary>

**JSON Type:** "String"

**Required:** Required if `tpTrigger` is submitted

**Valid Values:** `limit` or `market`

</details>

<details>

<summary>slTrigger</summary>

**JSON Type:** Integer within a "String"

**Required:** Optional

**Valid Values:** Insert price integer to initiate order as a "string"

**Example:** `"21000"` (must be formatted as an integer within the string)

</details>

<details>

<summary>slPrice</summary>

**JSON Type:** Integer within a "String"

**Required:** Required if `slTrigger` submitted and `slOrderType` = `limit`

**Valid Values:** Insert price integer to initiate order as a "string"

**Example:** `"21000"` (must be formatted as an integer within the string)

</details>

<details>

<summary>slType</summary>

**JSON Type:** "String"

**Required:** Optional - default = `last`

**Valid Values:**

* `last` : last price
* `index` : index price
* `mark` : mark price

</details>

<details>

<summary>slOrderType</summary>

**JSON Type:** "String"

**Required:** Required if `tpTrigger` is submitted

**Valid Values:** `limit` or `market`

</details>


# Simplified Signal Program

Documentation for utilizing the simplified Verified Trading Bot trade router notifications on the Compendium application.

## What is the Simplified Signal Program?

The "Simplified Signal Program" is part of Compendium's no-code/low-code initiative to expand greater functionality to strategies and implementations dependent on a non-traditional or simplified notification system. It is essentially an extension of the first version of our trading notification systems to work on top of our current, more complex systems.

Our new advanced systems provide ultimate control over each strategy trade notification, however, some authors find it simpler to have the trading notification routers built into Compendium to handle the brunt of the calculations and complete a workflow or task.

### Program Prerequisites

* You will still need an API key which is found on your trading bot strategy admin panel
* You will still need to understand simple JSON structures but unlike the `orderchain` initiative documented in [Sending Trading Signals](/automation-terminal/verified-trading-bots/for-algo-and-strategy-authors/sending-trading-signals), there are no built-in arrays.
* You must request the specific webhook URL for the simplified program router you wish to utilize for your strategy. All verified trading bot routers are by request only to verified bot authors in order to protect the integrity and speed of our priority workflow programs.

{% hint style="info" %}
The Simplified Signal Program is also available for Signal Provider Groups as a hosted webhook URL and downloadable n8n instance for ultimate customization options. Don't hesitate to contact your representative to request a customized router program for any specific needs concerning the verified trading bot system.
{% endhint %}

## Simplified Trading Router Options

The following documentation lists all available Simplified Signal Program trading routers and how to potentially interact with these programs.

### Easy 3 Command Perpetual

This trading bot router employs a straightforward three-command system without `stop losses` or `take profits`.

<figure><img src="/files/x3DUNtusESOWjOvTnHzY" alt=""><figcaption><p>The "Easy 3 Command Perpetual" Simplified Signal Program is built in n8n for compatability and customization options.</p></figcaption></figure>

#### Webhook Information

```
Method: POST
Webhook URL: Contact your account representative
```

```json
{
  "apiKey": "insertApiKeyHere", 
  "symbol": "DASH-USDT-SWAP", // Must be a valid market on your selected exchange
  "signal": "openlong" // "openlong" , "openshort", or "closeall"
}
```

* `"openlong"` will open a long position on all subscriber accounts for the selected market with a single market trade at maximum set default leverage.
* `"openshort"` will open a short position on all subscriber accounts for the selected market with a single market trade at maximum set default leverage.
* `"closeall"` can be used to close an open long or short position and should be used before entering an opposing position.

### Ten Level Take Profit With SL

This trading bot router was built for dedicated purposes regarding currently listed trading bots but can be utilized by a similar trading bot or Signal Provider strategies if needed. This router adds ten different take-profit orders for long and short positions with 10% increments in either direction. The router also adds a stop loss of 26% to each order to prevent *black swan* events.

<figure><img src="/files/8paVDx8x9qdjG7crXuM3" alt=""><figcaption><p>The "Ten Level Take Profit With SL" Simplified Signal Program is built in n8n for compatability and customization options.</p></figcaption></figure>

#### Webhook Information

```
Method: POST
Webhook URL: Contact your account representative
```

```json
{
  "apiKey": "insertApiKeyHere", 
  "symbol": "BTC-USDT-SWAP", // Must be a valid market on your selected exchange
  "signal": "openlong" // "openlong" , "openshort", or "closeall"
}
```

* `"openlong"` : Closes all open trades and cancels standing orders. It will then open a long position on all subscriber accounts for the selected market with a single market trade at maximum set default leverage. Ten levels of take-profit orders are added at 10% increments. A stop-loss order set at 26% is also added to the original trade execution price.
* `"openshort"` : Closes all open trades and cancels standing orders. It will then open a short position on all subscriber accounts for the selected market with a single market trade at maximum set default leverage. Ten levels of take-profit orders are added at 10% increments. A stop-loss order set at 26% is also added to the original trade execution price.
* `"closeall"` : Closes all open trades and cancels all standing orders.


# For Users & Subscribers

Documentation explaining how to setup and utilize the verified trading bots feature on Compendium to automate a user's connected portfolio.

## Getting Started And Understanding The System

This section of the documentation covers our Verified Trading Bot system from the perspective of a user looking to follow trading signals on their exchange from a subscription to a bot available in the verified marketplace. The sections outlined below define the basics you should know and learn before getting started in order to harness the full potential of this system.

{% content-ref url="/pages/0tyqU9HBavDRfRcUM5OG" %}
[Subscribing To Bots](/automation-terminal/verified-trading-bots/for-users-and-subscribers/subscribing-to-bots)
{% endcontent-ref %}

{% content-ref url="/pages/kNhdnSoYjwfSuPYB1F0i" %}
[Managing A Subscription](/automation-terminal/verified-trading-bots/for-users-and-subscribers/managing-a-subscription)
{% endcontent-ref %}

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

{% hint style="success" %}
Users agree to our Terms and Conditions and Risk Disclosures when they connect an exchange or subscribe to any product on our system. Please do your own research before continuing to conclude if this product is right for you!
{% endhint %}


# Subscribing To Bots

Instructions on how to subscribe to a Verified Trading Bot on Compendium and receive trading notifications to a connected exchange account.

## Subscribing To A Verified Bot

Verified bot details are available on the [marketplace page](https://compendium.finance/marketplace) and [user dashboard](https://compendium.finance/dashboard). If a strategy fits your overall trading goals you can choose to subscribe to this strategy. Some bots are free while others require payments.&#x20;

{% hint style="info" %}
Our payment system is non-recurring, users buy an allotment of time at once and can choose to renew and add more credits at any time. We feel this way is more transparent and helps to cut down on monthly charges and unused products. Free strategies are available in increments of 3-month subscriptions and can be added onto at any time.
{% endhint %}

### Subscribing To A Free Strategy

Subscribing to a strategy without a monthly cost is simple.&#x20;

* Go to that trading bot's details page and click the "Activate Free Strategy" button.&#x20;
* Upon confirming the activation on the following popup your trading bot subscription will then be available on the Subscriptions tab to connect an exchange account and manage.

### Subscribing To A Monetized Strategy

We have made the payment workflow for subscribing to monetized trading bots simple. Upon visiting a trading bot's details page click the "Add Subscription For X/Mo" button. This will forward you to the new version of our checkout page.

<figure><img src="/files/4hhj7h9tDGBXLr73NLpy" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
After being redirected to this page, please ensure the URL is correct and verify that it starts with: [https://compendium.finance/checkout2/](https://compendium.finance/version-test/checkout2/)\[Followed by the trading bot's unique identifier]
{% endhint %}

* You will be prompted to select the total amount of time credits you wish to add for the selected monetized trading bot.&#x20;
* After selecting the credentials you will see your "Total Order Amount" and the "New End Date". The end date determines when you should add more credits to your subscription by visiting this page again.

Payments can be made via our integration with **PayPal** or by utilizing our native CMFI token through "SolanaPay". The Solana options are currently only available by connecting your **PHANTOM** wallet.

{% hint style="success" %}
Did you know? Paying for a trading bot subscription with CMFI may provide further discounts and ensure that the author of the trading strategy receives 100% of the proceeds!
{% endhint %}

*Our team plans to include more payment methods shortly such as other highly liquid tokens and even the inclusion of Ethereum-native tokens with MetaMask support on the checkout page.*

## Subscription Ending Details

You will receive an email if your subscription is close to expiring or has expired reminding you to add time in order to keep receiving trades.  You can view your subscription ending date on the subscription management panel for that specific trading bot under the connect account options.

<figure><img src="/files/guK3dpdvCdDCsisLFMLW" alt=""><figcaption><p>The example subscription above will stop posting trades on March 9th, 2023 unless subscription credits are added beforehand.</p></figcaption></figure>

{% hint style="danger" %}
Our system WILL NOT close orders if a subscription ends and your account currently has open trades open. Please ensure you check connected exchange accounts!
{% endhint %}


# Managing A Subscription

Managing and editing settings for your subscription to a Verified Trading Bot on the Compendium application.

## Managing A Trading Bot Subscription

Users also have the option to manage their subscriptions as well and change connected exchange accounts and certain parameters. These features are accessible from the "Subscriptions" panel of the "Trading Bot" page on the user dashboard. You can view certain metrics and options about each subscription from this panel.

<figure><img src="/files/fsx2aRkswfGyKt3WHYzj" alt=""><figcaption><p>An example of what the new tabbed interface on each product page looks like and where to access your trading bot subscriptions.</p></figcaption></figure>

## Connecting An Account To The Trading Bot

After subscribing to a strategy it is then important to link a centralized exchange trading account using your API keys. Make sure that the API keys have access to modify or post trades. These API keys do not need access for deposits and withdrawals while utilizing our platform. Instructions for linking exchange accounts can be found [here](/automation-terminal/connect-an-exchange-account).

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

* Visit the "Subscriptions" panel in the "Trading Bots" section of the user dashboard.&#x20;
* You can now connect an exchange account by clicking the "Manage" button next to that trading bot's details.
* Upon clicking the "Manage" button the following page may appear:

<figure><img src="/files/8Mhlzm0Bl4ygrPuHXZWt" alt=""><figcaption></figcaption></figure>

You will be able to select an exchange account currently in good health check standing to connect to this trading bot strategy. Select an account, and then save your changes using the green button when the conditional button status changes.

{% hint style="info" %}
Always make sure that the connection passes health checks and is promptly funded with the correct underlying collateral to ensure trading commences. Please note that one exchange account API connection can not be used in multiple Trading Bot or Signal Provider Groups at the same time. Please create a newly funded subaccount or exchange account to use if you are utilizing multiple products or tools.
{% endhint %}

## Checking Your Subscription Status

After linking your exchange account and passing the health check, it is then important to view the current status of your subscription on the main subscription pages.&#x20;

Users will see one of the following "Subscription Status" monikers:\
\
**✅ Currently Trading Signals:** This status means that the trading bot subscription is in good standing and that you currently have the account connection set to "active". Trades will be posted to a connected exchange account.\
\
**❌ Currently Not Active:** This status means that the trading bot subscription may still be in good standing but that you currently do not have an exchange account connected or that you have set the active status to "inactive". Trades will not be posted to a connected exchange account.\
\
**⚠️ Requires Subscription Credits:** This notification in the Subscription Status column means that the underlying subscription requires credits to be added in order to facilitate trades again. *Refer to Subscribing To A Verified Bot above.*

## Customizing Your Subscription

Parameters for each subscription are customizable by pressing the "View/Edit" button for that specific group from the main subscriptions table.

* **Configure Account:** Make changes to the connected exchange account API keys, add a new API key connection, or select another exchange to utilize this strategy on. &#x20;
* **Perform Account Health Check:** Pressing this button will perform a backup health check on the connected exchange account to ensure our system is still capable of communicating while utilizing your connected API keys.
* **Strategy Details:** View the connected strategy details, historical statistics, recent trading history, and more.
* **Billing Details:** Some verified trading bots require a monthly subscription charge to access. Users can view historical billing payments or add subscription time on this panel.
* **Receive Email Notifications:** You will not receive email notifications if this option is toggled "OFF"

## Trade Post Error Handling

Internal error handling is built into our platform, however, there may be very distinct circumstances for a trade's failure to post that a user may be responsible for.

* **Failure To Pass Health Check:** Our system cannot post trades to an exchange account connection that has not been set up correctly. Please ensure all linked exchange accounts are set up correctly.
* **Lack Of Available Collateral:** A user must have a sufficient amount of available underlying collateral for the trading strategy to utilize. We recommend only running one strategy on each subaccount so there is no overlap of collateral usage. All manual trading should also be done on another subaccount as well.
* **Strategy Subscription Ended:** Your subscription to the strategy may have ended. In this case, you will need to add more time allocation to that strategy in order for trades to keep posting. If a subscription runs out of time while a trade is open, then our system will not close the open order.
* **Max Leverage Settings:** We recommend settings your maximum leverage settings to **at least** twice what your subscription's settings are based on. This ensures that trade will correctly post if the connected exchanges system fails to immediately update your collateral used.
* **Exchange Unavailability:** In some rare circumstances, an exchange's systems may go offline making it impossible to access your account credentials. Our system does implement dynamic retries but if a system is offline for an extended period of time or signals continue to time out then a trade may not correctly post.

{% hint style="info" %}
Users will receive an email to their registered address if an error can be immediately diagnosed by our automated systems
{% endhint %}


# Copy Trading Groups

Our Copy Trading Groups allow any trader to create their own private or public group trading integrations through Compendium with no setup or subscription fees.

<figure><img src="/files/uOYmJKBHfJctJ3yTkH75" alt=""><figcaption><p>Learn more about our copy trading group platform by visiting: <a href="https://compendium.finance/version-test/copy-trading-platform">https://compendium.finance/copy-trading-platform</a></p></figcaption></figure>

## Getting Started With Copy Trading

Documentation for our Copy Trading Groups is organized into a few key sections depending on your specific need or role within the ecosystem.

1. **Developers & Group Leaders**: Instructions on creating a group, managing your subscribers, and ensuring you meet supported trade requirements.
2. **Users & Group Subscribers:** Instructions for users wishing to subscribe to Copy Trading Groups and utilize these tools to help automate their trading portfolios.

{% tabs %}
{% tab title="For Copy Group Leaders" %}
{% content-ref url="/pages/w18wa9q4LaZIoaClAN7n" %}
[For Copy Group Leaders](/automation-terminal/copy-trading-groups/for-copy-group-leaders)
{% endcontent-ref %}

\
The following documentation pages can be extremely helpful while creating and managing your own Copy Trading Groups on Compendium.<br>

{% content-ref url="/pages/DakXbsL04mrQEdGizdQK" %}
[Creating A Copy Group](/automation-terminal/copy-trading-groups/for-copy-group-leaders/creating-a-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/9u6YSLIvd8OX1ClEijXs" %}
[Linking Leader Account](/automation-terminal/copy-trading-groups/for-copy-group-leaders/linking-leader-account)
{% endcontent-ref %}

{% content-ref url="/pages/ZE7BLGwBrT2eYMffDRRM" %}
[Important Trading Notes](/automation-terminal/copy-trading-groups/for-copy-group-leaders/important-trading-notes)
{% endcontent-ref %}

{% content-ref url="/pages/qKv3SgE8WfxpjXoSrNUA" %}
[Manage A Copy Group](/automation-terminal/copy-trading-groups/for-copy-group-leaders/manage-a-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/RUkNrDSKh4dZKFQko77d" %}
[Discord Webhooks Setup](/automation-terminal/copy-trading-groups/for-copy-group-leaders/discord-webhooks-setup)
{% endcontent-ref %}
{% endtab %}

{% tab title="For Copy Group Subscribers" %}
{% content-ref url="/pages/WBqfHrkAoZuGhLbsAnba" %}
[For Users & Subscribers](/automation-terminal/copy-trading-groups/for-users-and-subscribers)
{% endcontent-ref %}

The following documentation pages can be extremely helpful in utilizing our Copy Trading Group tools from a subscriber perspective.<br>

{% content-ref url="/pages/eHvblgxaPX2W69urlsmQ" %}
[Subscribe To Copy Group](/automation-terminal/copy-trading-groups/for-users-and-subscribers/subscribe-to-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

{% content-ref url="/pages/2FYNZN1pFr0nunf2qXm0" %}
[Link Account To Group](/automation-terminal/copy-trading-groups/for-users-and-subscribers/link-account-to-group)
{% endcontent-ref %}
{% endtab %}
{% endtabs %}

This system works differently than our verified bots or signal providers. Group leaders can link subaccount or account API keys to create a live connection subscription to trade naturally from the exchange interface *(and not a special terminal like most other systems)*. This system was built from the ground up by traders for traders with efficiency in mind.

{% hint style="success" %}
**Free To Use:** Just like most of our products, the Copy Trading Group systems are free to use for both group leaders and group subscribers. Managing larger groups on other platforms can easily cost hundreds or thousands of dollars per month. With us, it's FREE.
{% endhint %}

> For nearly a year now, I've had the upmost privilege of working with the team at Compendium and the multitude of tools and products the team offers. While the copy trading system has been a core part of the features I use, the Compendium platform offers a wide range of products and features.&#x20;
>
> Whether the latest and cutting edge DEX, NFT platform, trading strategies and bots, or simply copy trading systems, the Compendium platform is hands down the best and by far ahead of any of its competitors when it comes to offering like features and products. However, and most importantly, the team itself sets the bar extremely high when it comes to delivering a quality product. Take the copy trading system for example, there's none like out there that exists today, yet it offers all of the features the perfect copy trading system should offer. Real time execution of copied trades directly within the exchange, not from some third party platform. And best of all, risk management is tied directly into the copy trading system so if/when the trader executes a trade with 1% risk, that same 1% risk applies across to all users connected to the copy trader, regardless of their account size and value. With the sound risk management functionality, copy traders are also in complete control of the trade (ability to exit/close trade if desired) and their funds as well.&#x20;
>
> Lastly, the team themselves are down to earth, helpful, and some of the most genuine people in the space. The team is quick to respond and address any issues that may arise, which is not many or often, but they are "one of us" when it comes to trading and they know what traders want and look for when it comes to trading tools. I can't recommend enough the team and tools they have built within Compendium platform and I know I'll personally be using for the years to come. Thank you to the team at Compendium for what they have built for the traders of today.
>
> — From a Copy Trading Group Leader - [SatoshiScalper](https://twitter.com/SatoshiScalper)

## The Main Benefits Of Copy Trading

The main benefit of copy trading for retail clients is that it allows them to benefit from the expertise and experience of successful traders. With copy trading, retail clients can automatically copy the trades of these successful traders, allowing them to potentially achieve similar returns on their own investments. This can be particularly useful for retail clients who are new to trading or who do not have the time or expertise to conduct their own research and analysis.

Overall, the benefits of copy trading for retail clients include access to a wider range of investment opportunities and the ability to potentially achieve better returns on their investments by following the proven strategies of experienced traders.

## How Does Copy Trading Work?

* A WebSocket connection is made with the group leader’s connected exchange trading account.&#x20;
* Subscribers can then link their trading API keys to our system when actively subscribed to a Copy Trading Group.
* The Copy Group leader trades natively from the regular exchange interface without the need for a special terminal or further integrations. This helps to provide a better user experience and an optimal trading experience.
* WebSocket connections from the main account then parse trades through our backend and [PENDAX](/pendax/what-is-pendax) to ensure trades are posted correctly and at blazing-fast speed for each group subscriber.
* Our system uses dynamic risk management thresholds for each individual subscriber by calculating the Copy Group leader’s risk management on position entry or exit. It then algorithmically associates that calculated risk management percentage to each copy trader’s total collateral balance to ensure users remain within the leader’s set risk threshold. These thresholds can also be dynamically adjusted by each user if they wish to enter with slightly different risk management settings. We recommend that only advanced users change their risk management setting from group default.
* Our Copy Trading integrations also will also soon feature the ability for both leaders and group followers to trade across different exchanges. Internal systems normalize available markets and make sure that trades are posted to the correct markets if a subscriber is trading on a different exchange platform than the group leader.

{% hint style="warning" %}
Please note that the use of all Copy Trading Group systems for both leaders and subscribers is at your own discretion and falls in line with our Risk Disclosures. Compendium has no formal relationship with leaders or authors of Copy Groups. We recommend keeping "tabs" on your exchange account to ensure trades are posting correctly and are within reason.
{% endhint %}


# For Copy Group Leaders

Documentation explaining the Copy Trading Groups product on Compendium for traders wishing to create and manage a group on our platform.

{% hint style="success" %}
**Free To Use:** Just like most of our products, the Copy Trading Group systems are free to use for both group leaders and group subscribers. Managing larger groups on other platforms can easily cost hundreds or thousands of dollars per month. With us, it's FREE.
{% endhint %}

## Getting Started And Understanding The System

This section of the documentation covers our Copy Trading Groups system from an author or group leader perspective. The sections outlined below define the basics you should know and learn before getting started in order to harness the full potential of this system.

{% content-ref url="/pages/DakXbsL04mrQEdGizdQK" %}
[Creating A Copy Group](/automation-terminal/copy-trading-groups/for-copy-group-leaders/creating-a-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/9u6YSLIvd8OX1ClEijXs" %}
[Linking Leader Account](/automation-terminal/copy-trading-groups/for-copy-group-leaders/linking-leader-account)
{% endcontent-ref %}

{% content-ref url="/pages/ZE7BLGwBrT2eYMffDRRM" %}
[Important Trading Notes](/automation-terminal/copy-trading-groups/for-copy-group-leaders/important-trading-notes)
{% endcontent-ref %}

{% content-ref url="/pages/qKv3SgE8WfxpjXoSrNUA" %}
[Manage A Copy Group](/automation-terminal/copy-trading-groups/for-copy-group-leaders/manage-a-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/RUkNrDSKh4dZKFQko77d" %}
[Discord Webhooks Setup](/automation-terminal/copy-trading-groups/for-copy-group-leaders/discord-webhooks-setup)
{% endcontent-ref %}


# Creating A Copy Group

Documentation outlining how to create and manage your own FREE Copy Trading Group within the Compendium application.

## Creating A Copy Trading Group

After [registering for a Compendium account](https://compendium.finance/login), you can then proceed to the user dashboard. Click on "Copy Trading" on the top navigation bar and then click on the "My Groups" tab. You will then see the green "Create New Trading Group" button.

<figure><img src="/files/z2o1DGBfYhQjuihMbYZ3" alt=""><figcaption><p>The Copy Trading page provides the ability to explore all groups, manage your own groups, or manage your subscriptions to other copy trading groups.</p></figcaption></figure>

Clicking the "Create New Trading Group" button above will display a pop-up full of information that you will need to fill out in order to continue.

<figure><img src="/files/LxwnWl7ZRffMLhDTKWrJ" alt=""><figcaption><p>A preview of the "Create New Trading Group" popup</p></figcaption></figure>

* **Trading Group Type:** The type of social trading group you wish to create. For this purpose we will select "Copy Trading Group"
* **Trading Group Name:** What would you like your copy trading group to be called? Please follow our terms and conditions and stray away from profane content.
* **Strategy’s Description:** Give the public details on how the copy trading group is run. Details on how to obtain a private subscription and more can also be entered here. Please make this description as thorough as possible and also include snippets on your trading style, risk thresholds, and other important variables to help other users make informed decisions.
* **Private Group Checkbox:** You will also notice a check box for public and private group settings. Marking this checkbox will mark the group as private which means that the public can see that the group exists and read the group description but can not subscribe to the group or see details of recent trade posts. Private groups require members to be invited from that group’s admin page.&#x20;

{% hint style="warning" %}
Please keep in mind that a private group cannot \*currently\* be marked as public after creation and vice versa. This helps to prevent problems with group subscriptions. We recommend making a new or separate group in this case.
{% endhint %}

After filling in the information, you can then press the "Save" button. This group will then become available on the "My Groups" tab of the Copy Trading page. To access group management and connect an exchange account, click on the "Manage" button in the table for that group.

<figure><img src="/files/gp7vAcmJrIZfOVYlhNBJ" alt=""><figcaption><p>An example of the copy group management table. You can also see a total count of your copy groups in the table header.</p></figcaption></figure>

After clicking the manage button, you will be forwarded to the group management page for that specific copy trading group.

<figure><img src="/files/D0A5CkhnlITnfSyurYWU" alt=""><figcaption><p>An example of the copy group management page can be seen above.</p></figcaption></figure>

On this page you can edit existing information or add the following group information parameters:

* **Strategy Visible Icon:** Upload a 500x500 image to act as your group’s visible icon. Make sure that your uploaded graphic meets our community standards.
* **Telegram:** You can input the URL parameters of your telegram group here. Please do not insert the whole URL. *An example of this format is given in the pop-up.*
* **Twitter:** You can input the Twitter page username of your group here. Please do not insert an @ sign or input the whole URL.
* **Discord:** You can enter the invite code for your own group discord server here. Please do not input the whole URL. Users will also be prompted to join our official Discord server for technical support if needed.

{% hint style="info" %}
Inputting social links can help possible subscribers research further about your trading group offerings or contact you with potential questions.
{% endhint %}

### **Recommended Minimum Subscriber Account Size**

Our copy trading group system is built on top of the PENDAX SDK. Our system takes a unique risk-based approach to support the most intuitive trading experience for group leaders and followers.

It is important to understand the intricacies of this platform while placing trades and subscribing. When posting a trade our system will look at the total percentage of available equity used and post this as the "risk" or "equity" factor while copying trades.

For example: If you are currently trading with an available connected balance of $100,000 and post a $1000 trade then the equity variable passed to subscribers would equate to 1%. If 1% of the connected subscriber's portfolio does not meet minimum order requirements for the traded market then the exchange in use may not allow that subscriber to post trades.

You should communicate "Minimum Balance Recommendation" with subscribers in the available dropdown below to provide insight into your equity strategy. Some traders may use smaller accounts with higher equity trades and other traders may use larger accounts with smaller equity trades.

{% hint style="success" %}
Please make sure to save all information changes. These changes are not automatically saved.
{% endhint %}


# Linking Leader Account

Documentation outlining how to link a connected exchange account for other users to copy within our Copy Trading Groups systems on Compendium.

### Linking A Trading Account For Users To Copy Trade

Now that you have successfully created your Copy Trading Group it is now time to link the main account you want trades to duplicate from to your subscriber base. You will see the following component asking which currently connected exchange account you wish to allow users to copy trades from.

<figure><img src="/files/uYpkD6yoKpOjNkg5ri8D" alt=""><figcaption></figcaption></figure>

Please note that you must connect an exchange account to Compendium before it becomes accessible for the copy trading groups feature. The "Connected Account" dropdown will display all available (and applicable) exchange accounts that our platform can interact with.&#x20;

{% hint style="info" %}
Make sure this account has passed the health check procedures and is currently in good standing on both our platform and the exchange of origination. If you need to connect an exchange account via API's to the platform before continuing then please go to [Connect An Exchange Account](/automation-terminal/connect-an-exchange-account).
{% endhint %}

After selecting your copy-trading exchange account you can then <mark style="color:green;">**PRESS THE GREEN ATTACH ACCOUNT BUTTON**</mark>. This will save the account connected to your copy trading group. You **ONLY** need to save account settings again if the connected group is changed.

Afterward, marking the group as "active" using the toggle pictured in the image above will change the status. Copy trades will only be posted for subscribers when the group is marked as "active".&#x20;

{% hint style="info" %}
Pressing the toggle to change the status of your copy trading group does not require a user to press the green attach/save button again. The status is automatically saved as the toggle is clicked!
{% endhint %}

If you "deactivate" a copy trading connection then trades will not be copied and current trades may be left open for subscribers!

{% hint style="warning" %}
Some exchanges allow a limited number of WebSocket connections per account or subaccount. Make sure that this account or subaccount is not connected to any other system that may interfere with our connection if your selected exchange imposes limits on WebSockets.
{% endhint %}

### Changing A Linked Trading Account

Changing the trading account linked to the copy trading platform is simple. You must first deactivate the group temporarily by using the toggle above. After the group is marked as inactive you can then select an applicable exchange connection. After connecting a new account you must mark the group as "active" again for copy trading to persist for subscribers.

{% hint style="danger" %}
Please close out all positions before deactivating or changing the connected exchange account. Failure to do so may cause some issues for subscribers.
{% endhint %}


# Important Trading Notes

Important Notes For Copy Group Leaders on understanding risk management, minimum trade sizing, and specific exchange setup requirements.

## Important Notes For Copy Group Leaders

**Please read these important notes before taking on subscribers or posting your first trade.**

All group subscribers should ensure their maximum account leverage positions are set high enough according to their trading style. If a user hits their maximum leverage availability then new trades will fail to post. We recommend advising a cushion percentage for emergency cases. Our system will automatically adjust leverage settings for connected accounts dependent on group needs, however, this automated process is not available for all supported platforms.

{% hint style="info" %}
For example: If you usually trade at a maximum of 3x leverage available then advise your group members to adjust their maximum leverage bar to 5x in order to provide a "cushion" and avoid trade interference.
{% endhint %}

Understand the risk management threshold calculations and minimum order requirements for certain trading pairs. Most trading pairs have a minimum trading post requirement to enter a position. If a Copy Group leader has a larger balance and enters a new position at a lower risk threshold, this trade may not meet the minimum order requirement for a subscriber with a low collateral balance. After testing we recommend that subscribers try to have anywhere between $700-$1000 in minimum collateral available for the Copy Trading infrastructure to correctly work for them on medium to high-risk threshold posts. A lower-risk group may require subscribers to have a higher overall balance to meet minimum order requirements.

Our system essentially supports all available order types on multiple different supported exchanges besides those noted in [Unsupported Order Types](#undefined). The upgraded Copy Trading Systems (Built on [PENDAX](/pendax/what-is-pendax)) will automatically copy a multitude of different order types for a true copy trading experience. This ensures that all users can exit and enter a trade depending on slippage and protects accounts from multiple order posts through essential filtering requests.

When closing a position please make sure to always try and select the “Reduce Only” toggle or press the “Market Close” button if these parameters are available on that exchange.

Advise your followers to always closely watch their accounts. Our Copy Trading Group solution provides a great way to automate your trading group but no system is always perfect. Please tell your subscribers to leave their notifications on so that they can monitor trade entries and exits.&#x20;

{% hint style="warning" %}
In the rare occurrence that API or data information fetches from a connected exchange is unavailable or out of the available threshold a trade may fail to post. Our system will automatically retry trade entries within a set time threshold. Any orders that encounter an error may send an automated email to the affected user describing the problem.
{% endhint %}

### OKX Account Setup

Copy trading on OKX requires both leaders and subscribers to set their accounts up in a certain way. The following settings should be used for all services when an OKX account is attached.

* Account Mode Should Be Set To **Single Currency Margin**
* Futures & Perpetual Contract Units Should Be Set To **Contracts**
* Order Placement Mode Should Be Set To **Buy/Sell Mode**

{% hint style="info" %}
We also recommend ensuring that you set ample maximum leverage on OKX accounts to ensure there are no issues with account balances during trade posts.
{% endhint %}

### Unsupported Order Types

* **Best Bid Orders "BBO"** are *unreliable* for most copy-trading instances. We highly advise against using this order type as a group leader. Due to the nature of this order, it may not act as planned on subscriber accounts and will lead to some issues.

{% hint style="danger" %}
Using unsupported order types may result in issues with orders being posted for followers.&#x20;
{% endhint %}


# Manage A Copy Group

Documentation on how to manage specific details and user access to your Copy Trading Group on the Compendium application.

## Managing Copy Trading Group Subscribers

Managing subscribers is important to copy trading groups marked as private. The only way for a user to access a private copy trading group is to receive a direct invite from the group admin. Our management portal also makes it easy to edit subscriber information after they have accepted the invite and leave notes.

Group leaders may mark groups as private if they plan to monetize the group off the platform through direct payments or by using our CMFI token access payments which are planned to launch shortly.

{% hint style="info" %}
Public copy trading groups have limited group management features.
{% endhint %}

### Sending A Copy Group Invite

As mentioned, copy trading groups marked as private will require the group admin/leader to send an invite to the group. Scrolling down the group management page will reveal the "Send Group Invite" component.

<figure><img src="/files/Oh9GL3ovVRFdI5I4Y1BI" alt=""><figcaption></figcaption></figure>

The invite system works via a Compendium user's "Username" / "Nickname". Upon entering a valid username, the green "Send Invite" button will then appear. Clicking on this will send the invite to the user which they can then accept on the copy trading group section of their "Subscriptions" tab.

### Manage Individual Member Subscription

Private trading groups allow the ability to change the status of a user's subscription and set a note in our system table.&#x20;

For example, if a group leader is monetizing their group off the platform and a user has missed their payment window then the group leader may set the subscription to "inactive". This will send an email to the user from our system that there has been a status change. The notes section for each user can also be used to keep track of recent payments and other details.

Managing members is simple and can be done from the table pictured below that becomes available when scrolling down the page. Clicking on the "Manage" button will display a popup allowing you to make these changes.

<figure><img src="/files/L7oIGorQKR70JfWqGukH" alt=""><figcaption></figcaption></figure>

## Deleting A Copy Trading Group

Ready to move on? Deleting a Copy Trading Group is easy. This option is found at the bottom of that group’s admin page. You will be asked to confirm before deleting the group. Once the group is deleted we will automatically send out email notifications to all group subscribers. Group deletion is permanent in our database. The ability to pause and resume copy trading connections can also be found on the same admin page.


# Discord Webhooks Setup

Documentation outlining the setup and integration of Discord Webhooks attached to a Copy Trading Group. Useful for community notifications and trade tracking systems.

Discord Webhooks provide a simple way to integrate notifications for each copy trade to your community. These notifications can help ensure subscribers stay up to date with their accounts and can report or fix any issues as they occur. Automating your alerts with Webhooks can save group leaders ample amounts of time by not dealing with micro-management of their infrastructure.

## Creating A Discord Webhook

You can create a Discord webhook using either the graphical user interface (GUI) or the Discord API. The most straightforward way to add a webhook to your Discord account is through the user interface. It is the recommended option if you plan to manage your Discord webhooks in automated workflows.

<figure><img src="/files/oLDrn3n0crM4ExrokOiA" alt=""><figcaption><p>A preview of the Discord create Webhook panel found in the Integrations page of your Discord server.</p></figcaption></figure>

To add a webhook to your server:

* Navigate to the Integrations page on your Discord server
* Click on Create Webhook
* Give your webhook an appropriate name
* Choose the destination channel
* Save the changes made to your webhook configuration.

{% hint style="info" %}
Make sure not to share your Webhook URL for security reasons.
{% endhint %}

## Webhook ID And Token

The Discord Webhook created in the previous step can be dissected into three different sections. Understanding these different sections is necessary for connecting the Webhook to your Copy Trading Group in order to receive notifications.

### Example Of Discord Webhook

{% code overflow="wrap" %}

```
https://discord.com/api/webhooks/1076532801734452871/OTAFbsHZT-33XzMlb0eCZnkt7bXKGqHU3EdeVaPCji-UvoDyK_j9ve0HjxQDCltaTREC
```

{% endcode %}

### Dissected Discord Webhook

{% code overflow="wrap" %}

```
https://discord.com/api/webhooks/[WEBHOOK ID]/[WEBHOOK TOKEN]
```

{% endcode %}

In this example, the following would be true:

* Webhook ID: 1076532801734452871
* Webhook Token: OTAFbsHZT-33XzMlb0eCZnkt7bXKGqHU3EdeVaPCji-UvoDyK\_j9ve0HjxQDCltaTREC

## Set Webhook For Group

Visit the group management panel for your designated Copy Trading Group. Scroll down to the "Discord Webhook" section and press the down arrow to display the full component.

<figure><img src="/files/5peFlyCZu3E5SkUyokeB" alt=""><figcaption></figcaption></figure>

Using what we've learned in the previous section, enter the correct Discord Webhook ID and Webhook Token in the appropriate input fields. After entering the correct information press "Save Webhook Information" and a test webhook entry will be sent to your designated Webhook URL.

In order to clear any information or deactivate the Webhook, just simply save empty input fields for both inputs.

## Example Webhook Info

The following image shows an example of what a group leader can expect from Webhook integrations.

<figure><img src="/files/tFSNwr4uLusDR2TKWfTJ" alt=""><figcaption><p>A Preview of a Discord Webhook Example forwarded from the Compendium Application.</p></figcaption></figure>

We highly recommend saving a custom Group Icon in your management panel to avoid any complications with empty data fields while using the Webhook.


# For Users & Subscribers

Information for subscribing to copy trading groups for cryptocurrency exchanges like OKX and more on the Compendium application.

## Getting Started And Understanding The System

This section of the documentation covers our Copy Trading Group system from the perspective of a user looking to follow trades on their exchange from groups in the marketplace. The sections outlined below define the basics you should know and learn before getting started in order to harness the full potential of this system.

{% content-ref url="/pages/eHvblgxaPX2W69urlsmQ" %}
[Subscribe To Copy Group](/automation-terminal/copy-trading-groups/for-users-and-subscribers/subscribe-to-copy-group)
{% endcontent-ref %}

{% content-ref url="/pages/GU6m3yMVKxkAyzvxPMyn" %}
[Connect An Exchange Account](/automation-terminal/connect-an-exchange-account)
{% endcontent-ref %}

{% content-ref url="/pages/2FYNZN1pFr0nunf2qXm0" %}
[Link Account To Group](/automation-terminal/copy-trading-groups/for-users-and-subscribers/link-account-to-group)
{% endcontent-ref %}

Interested in running your own trading group instead and having users copy your trades on the platform? Check out the section for Group Leaders & Authors.

{% content-ref url="/pages/w18wa9q4LaZIoaClAN7n" %}
[For Copy Group Leaders](/automation-terminal/copy-trading-groups/for-copy-group-leaders)
{% endcontent-ref %}


# Subscribe To Copy Group

Instructions on how to subscribe to a Copy Trading group and receive trading notifications to a connected exchange account.

## Subscribing To A Copy Trading Group

Joining a public Copy Trading Group is easy and straightforward. Users can browse available groups on the [dashboard](https://compendium.finance/dashboard) or on the public Copy Trading Group page.&#x20;

<figure><img src="/files/TSz5jZt6nnrsYNQ4oA24" alt=""><figcaption><p>Copy Trading Groups can be accessed from the Social Trading dropdown on the top navigation on desktop view.</p></figcaption></figure>

When viewing public groups you can also see all related information in order to make an educated decision. Specific group statistics and recent trade posts will be available to view on each group's page. If a Copy Group is marked as private the recent trade posts will be hidden from public view. Due to data limitations and some high-frequency trading groups, our system currently saves the last 100 trades for analytics purposes.

{% hint style="info" %}
Invitations for private groups can be found on the Subscriptions panel of the regular user dashboard by scrolling to the "Copy Trading Subscriptions" table and clicking on the "View Copy Invites" button.
{% endhint %}

If a Copy Trading Group is marked as public then a user can freely subscribe to this group by clicking the "Subscribe" button located at the top right above the social sharing button.

After subscribing to a copy group it is now time to select an exchange account to initiate copy trades through.

{% content-ref url="/pages/2FYNZN1pFr0nunf2qXm0" %}
[Link Account To Group](/automation-terminal/copy-trading-groups/for-users-and-subscribers/link-account-to-group)
{% endcontent-ref %}

## Customizing Your Copy Trading Group Subscription

Parameters for each subscription are customizable by pressing the "Manage" button for that specific group from the main subscriptions table.

<figure><img src="/files/y4cX6oE7vaW3Gui8t68t" alt=""><figcaption></figcaption></figure>

The ability to perform a health check on your connected account appears here along with the ability to toggle email notifications. Due to the high-frequency output of some groups we have recently changed email notifications from single trades to historical trade reminders and error handling notifications.

## Unsubscribing From A Copy Group

If a user wishes to delete their copy subscription or no longer utilize that specific group then they can delete the subscription from the subscription management screen.

{% hint style="warning" %}
Deleting a copy subscription is permanent and will require the user to re-subscribe to the group, or receive another invitation if the group is marked as private.
{% endhint %}


# Link Account To Group

Instructions on how to link a connected exchange account to follow trades from your Copy Trading Subscriptions on the Compendium Application.

## Attaching An Account To Your Subscription

The ability to manage your group on the subscriptions tab will appear after subscribing to a group or accepting a copy trading group invite.

<figure><img src="/files/OSgTbj07pmhg2TK1uQ6S" alt=""><figcaption><p>An example of a newly subscribed copy group waiting for an exchange connection to be added.</p></figcaption></figure>

Visit your "Subscriptions" tab of the regular dashboard and click the "Manage" button after activation in order to begin the process of linking your supported exchange account. Our system gives users the ability to connect a currently active exchange account which are managed and added on the Connections page of the dashboard. Please read our [Connect An Exchange](/automation-terminal/connect-an-exchange-account) documentation if you are having issues completing this last step.&#x20;

{% hint style="info" %}
The system currently only allows exchange accounts to be connected that match the copy group leader's selected exchange. This limitation will be removed when cross-exchange copy trading is activated shortly.
{% endhint %}

<figure><img src="/files/G8zfU9MRKfOe9UaR6GKL" alt=""><figcaption><p>Connecting an exchange account can be done from the "Connected Account Settings" component on that copy group's management page.</p></figcaption></figure>

{% hint style="warning" %}
It is important to remember that the linked exchange account will need to pass the "Health Check" process in order for copied trades to post to a user's account. Accounts also require deposited collateral in the connected exchange account. We recommend collateral in line with the minimum recommended balance of each group.
{% endhint %}

### OKX Specific Notes

Copy trading on OKX requires both leaders and subscribers to set their accounts up in a certain way. The following settings should be used for all services when an OKX account is attached.

* Account Mode Should Be Set To **Single Currency Margin**
* Futures & Perpetual Contract Units Should Be Set To **Contracts**
* Order Placement Mode Should Be Set To **Buy/Sell Mode**

We also recommend ensuring that you set ample maximum leverage on OKX accounts to ensure there are no issues with account balances during trade posts. OKX recently introduced "Trade Clearance Settings" as a master leverage control on the main account which will need to be set high enough in certain instances so as to not interfere with leverage calculations. This setting also carries over to all subaccounts associated with the main account.

To change or turn off this new setting please follow the instructions below:

1\) Access your OKX.com account. Make sure you are on the main account and not a subaccount.

2\) Hover over the profile icon and click on the "Security" tab.

3\) Scroll down to the "Enabled Security Features" section

4\) Make sure that "Trading Clearance Settings" are turned off.

{% hint style="warning" %}
If you choose to leave the setting on, please ensure that leverage is set to at least 50x or is in conjunction with the settings your copy group leader is using per trade post. Your trades may fail to post or post with the incorrect leverage and risk management settings if these settings do not match or cause leverage to be restricted.
{% endhint %}

### Changing the Connected Exchange Account

Changing the connected exchange account is simple.&#x20;

* **Users MUST deactivate the subscription before changing the connected account.**&#x20;
* After temporarily deactivating the subscription you can then choose from applicable connected exchange accounts.&#x20;
* Choose the new account, save the account connection, and then click the toggle to activate the strategy on your connected account again.

{% hint style="info" %}
Applicable exchange accounts are connected accounts in good standing from the same exchange as the current copy group leader's exchange account. This feature will be opened up for cross-exchange shortly.
{% endhint %}

## Activating The Copy Trading Connection

After linking your exchange account and passing the health check, it is then important to activate the subscription. The "Activate Copy Trading For Account" toggle will be clickable after an exchange connection has been established. By clicking this toggle to active, trades will begin posting to the connected account when observed by the group leader.

### Deactivating The Copy Trading Connection

Deactivating the connection is simple. Just click the toggle to inactive and copy trading posts will seize on the connected account until the subscription is activated again.

## Trade Post Error Handling

Internal error handling is built into our platform, however, there may be very distinct circumstances for a trade's failure to post that a user may be responsible for.

* **Failure To Pass Health Check:** Our system cannot post trades to an exchange account connection that has not been set up correctly. Please ensure all linked exchange accounts are set up correctly.
* **Lack Of Available Collateral:** A user must have a sufficient amount of available underlying collateral for the trading strategy to utilize. We recommend only running one strategy on each subaccount so there is no overlap of collateral usage. All manual trading should also be done on another subaccount as well.
* **Strategy Subscription Ended:** Your subscription to the strategy may have ended. In this case, you will need to add more time allocation to that strategy in order for trades to keep posting. If a subscription runs out of time while a trade is open, then our system will not close the open order.
* **Max Leverage Settings:** We recommend settings your maximum leverage settings to at least twice what your subscription's settings are based on. This ensures that trade will correctly post if the connected exchanges system fails to immediately update your collateral used.
* **Exchange Unavailability:** In some rare circumstances an exchange's systems may go offline making it impossible to access your account credentials. Our system does implement dynamic retries but if a system is offline for an extended period of time or signals continue to time out then a trade may not correctly post.




---

[Next Page](/llms-full.txt/1)

