← BingX

BingX Custom Calculate Leveraged Position with BingX API

Pipedream makes it easy to connect APIs for BingX and 1400+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
BingX Custom Calculate Leveraged Position with the BingX API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 500,000+ developers from startups to Fortune 500 companies

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

Create a workflow to BingX Custom Calculate Leveraged Position with the BingX API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the BingX Custom Calculate Leveraged Position action
    1. Connect your BingX account
    2. Select a Symbol
    3. Optional- Select a Currency
    4. Select a Trade Type
    5. Optional- Configure Limit Price
    6. Configure Stop Loss Price
    7. Configure Take Profit Loss Price
    8. Configure Risk
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger


BingX Custom CalculateLeveragedPosition with BingX API on New Requests (Payload Only) from HTTP / Webhook API
HTTP / Webhook + BingX
Try it
BingX Custom CalculateLeveragedPosition with BingX API on New Item in Feed from RSS API
RSS + BingX
Try it
BingX Custom CalculateLeveragedPosition with BingX API on New Message in Channel from Discord Bot API
Discord Bot + BingX
Try it
BingX Custom CalculateLeveragedPosition with BingX API on New Submission from Typeform API
Typeform + BingX
Try it
BingX Custom CalculateLeveragedPosition with BingX API on Custom Events from Zoom API
Zoom + BingX
Try it


This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

BingX Custom Calculate Leveraged Position on BingX
Description:Calculate leveraged position based on entry, stop price and account balance


import bingx from "../../bingx.app.mjs";

export default {
  name: "BingX Custom Calculate Leveraged Position",
  version: "0.0.3",
  key: "bingx-custom-calculate-leveraged-position",
  description: "Calculate leveraged position based on entry, stop price and account balance",
  props: {
    symbol: {
      propDefinition: [
    currency: {
      propDefinition: [
    tradeType: {
      propDefinition: [
    limitPrice: {
      label: "Limit Price",
      description: "Limit Price (Applicable only for limit orders)",
      type: "string",
      optional: true,
    stopPrice: {
      label: "Stop Loss Price",
      description: "Stop Loss Price for trade",
      type: "string",
      optional: false,
    profitPrice: {
      label: "Take Profit Loss Price",
      description: "Take Profit Price for trade",
      type: "string",
      optional: false,
    riskOnCapital: {
      label: "Risk",
      description: "Risk Percentage of capital",
      type: "string",
      default: "2",
      optional: false,
  type: "action",
  methods: {
    async getBalance() {
      const API_METHOD = "POST";
      const API_PATH = "/api/v1/user/getBalance";
      const parameters = {
        "currency": this.currency,
      return this.bingx.makeRequest(API_METHOD, API_PATH, parameters);
    async getLatestPrice() {
      const API_METHOD = "GET";
      const API_PATH = "/api/v1/market/getLatestPrice";
      const parameters = {
        "symbol": this.symbol,
      let returnValue = await this.bingx.makeRequest(API_METHOD, API_PATH, parameters);
      return returnValue.data.indexPrice;
  async run({ $ }) {
    let entryPrice = this.limitPrice;
    if (!entryPrice)
      entryPrice = await this.getLatestPrice();
    let tradeDirection = entryPrice > this.stopPrice
      ? "Bid"
      : "Ask";
    let tpDirection = entryPrice > this.stopPrice
      ? "Ask"
      : "Bid";
    const balanceQuery = await this.getBalance();
    if (balanceQuery.code) {
      throw new Error(balanceQuery.msg);
    const balance = balanceQuery.data.account.balance;
    const risk = this.bingx.convertToFloat(this.riskOnCapital) * balance / 100;

    const stopDiff = Math.abs(entryPrice - this.stopPrice);
    const profitDiff = Math.abs(entryPrice - this.profitPrice);

    const leverage = Math.floor(entryPrice * 0.9 / stopDiff);
    const qty = risk / stopDiff;
    const profit = qty * profitDiff;
    const returnValue = {
      "entryPrice": entryPrice,
      "stopPrice": this.stopPrice,
      "targetPrice": this.profitPrice,
      "entryDirection": tradeDirection,
      "exitDirection": tpDirection,
      "leverage": leverage,
      "quantity": qty,
      "riskAmount": risk,
      "profitAmount": profit,
      "riskReward": profit / risk,
    $.export("$summary", `Calculate bracket order for ${this.symbol}`);
    return returnValue;


This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
BingXbingxappThis component uses the BingX app.
SymbolsymbolstringSelect a value from the drop down menu.
CurrencycurrencystringSelect a value from the drop down menu.
Trade TypetradeTypestringSelect a value from the drop down menu:MarketLimit
Limit PricelimitPricestring

Limit Price (Applicable only for limit orders)

Stop Loss PricestopPricestring

Stop Loss Price for trade

Take Profit Loss PriceprofitPricestring

Take Profit Price for trade


Risk Percentage of capital


BingX uses API keys for authentication. When you connect your BingX account, Pipedream securely stores the keys so you can easily authenticate to BingX APIs in both code and no-code steps.

You must create an API Key at the API Management page on BingX to connect to Pipedream.

About BingX

Connect with Elite Traders, Discover Smarter Investing

More Ways to Use BingX


BingX Account Get Balance with the BingX API

Get Perpetual Swap Account Asset Information reference.

Try it
BingX Account Get Positions with the BingX API

Perpetual Swap Positions reference.

Try it
BingX Custom Bracket Order with the BingX API

Place bracket order

Try it
BingX Generic API Call with the BingX API

Make any API call for Bingx Futures as per the documentation. See docs here

Try it
BingX Market Get All Contracts with the BingX API

Contract Information reference.

Try it

Explore Other Apps

apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Trigger workflows on an interval or cron schedule.
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Data Stores
Data Stores
Use Pipedream Data Stores to manage state throughout your workflows.
Telegram Bot
Telegram Bot
Telegram is a cloud-based instant messaging and voice over IP service
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular apps like ChatGPT and DALL·E 2.
Google Sheets
Google Sheets
With Google Sheets, you can create, edit, and collaborate wherever you are
Use this app to create a Discord source that emits messages from your guild to a Pipedream workflow.
Where the world builds software. Millions of developers and companies build, ship, and maintain their software on GitHub—the largest and most advanced development platform in the world.
Pre-built actions to make formatting and manipulating data within your workflows easier.
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.