> For the complete documentation index, see [llms.txt](https://docs.compendium.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.compendium.finance/pendax/using-pendax-sdk/blofin-functions/trading.md).

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.compendium.finance/pendax/using-pendax-sdk/blofin-functions/trading.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
