Compendium Trading Tools Documentation
CompendiumPENDAXCompendexOfficial Links
  • ⭐Platform Overview
  • ⚫PENDAX
    • 🌐What is PENDAX?
    • 🖱️PENDAX Capabilities
    • 💾Installing PENDAX modules
    • 💡Using PENDAX SDK
      • 💻Common Functions
      • 💻OKX Functions
        • Trading & Orders
        • Funding
        • Convert
        • Account & Subaccount
        • Grid Trading
        • Market Data
        • Public Data
        • Trading Data
      • 💻Bitget Functions
        • Public (Spot)
        • Market (Spot)
        • Wallet (Spot)
        • Account (Spot)
        • Trade (Spot)
        • Market (Futures)
        • Account (Futures)
        • Trade (Futures)
        • CopyTrade (Futures)
        • Sub Account Interface (Broker)
        • Sub API Interface (Broker)
      • 💻ByBit Functions
        • Market
        • Trading
        • Position
        • Account
        • Asset
        • User
        • Spot Leverage Token
        • Spot Margin Trade (UTA)
        • Spot Margin Trade (Normal)
        • Institutional Lending
      • 💻Mexc Functions
        • Market
        • Sub-Account
        • Spot Account/Trade
        • Wallet
        • ETF
        • Rebate
        • Futures Market
        • Futures Account and Trading
      • 💻Phemex Functions
        • Contract
        • Hedged Contract
        • Spot
        • Margin Trading
        • Transfer
        • Convert
        • Deposit And Withdraw
      • 💻BloFin Functions
        • Websocket
        • Account
        • Affiliate
        • Public Data
        • Trading
        • User
      • 💻BingX Functions
        • Fund Account
        • Wallet Deposits and Withdrawals
        • Sub-Account Managenent
        • Market Data (USDT-M)
        • Account (USDT-M)
        • Trades (USDT-M)
        • Market Data (Coin-M)
        • Trades (Coin-M)
        • Market Data (Spot)
        • Fund Account (Spot)
        • Trades (Spot)
        • CopyTrader
      • ⚠️FTX Functions
    • 📜License Agreement
  • 🟣Compendium App
    • 📈Compendium Trading Tools
    • 🔗Connect An Exchange Account
      • 🗝️OKX.com API Keys
    • 🤖Verified Trading Bots
      • Explore The Marketplace
      • For Algo & Strategy Authors
        • Get Listed & Verified
        • Strategy Monetization
        • Sending Trading Signals
        • Simplified Signal Program
      • For Users & Subscribers
        • Subscribing To Bots
        • Managing A Subscription
    • 💫Copy Trading Groups
      • For Copy Group Leaders
        • Creating A Copy Group
        • Linking Leader Account
        • Important Trading Notes
        • Manage A Copy Group
        • Discord Webhooks Setup
      • For Users & Subscribers
        • Subscribe To Copy Group
        • Link Account To Group
    • 📶Signal Provider Groups
      • For Group Leaders
        • Creating A Signal Group
        • Managing A Signal Group
        • Sending Trading Signals
      • For Users & Subscribers
        • Subscribing To Signal Groups
        • Manage Signal Group Subscription
  • 🔵Compendex Suite
    • 🔮DeFi With Compendex
    • ☀️Solana Integrations
      • Supported Solana Wallets
      • Overview And News
      • Openbook Spot Markets
      • Smart Swap Aggregator
      • NFT Metaverse Markets
      • Solana DeFi Analytics Portal
      • Community Tools List
  • 🪙The CMFI Token Ecosystem
    • 📊Tokenomics Breakdown
    • 🍎Trade Incentive Program
    • 🌊Staking And Liquidity Pools
      • ✨Raydium Liquidity Pools
      • 🐳Orca Liquidity Whirlpools
      • 🐋Orca Liquidity Pools
    • 🐷Compendi-Pigs NFT
  • 👥Community Info
    • ✅Links And Social Pages
    • 🎨Branding Guidelines
Powered by GitBook
On this page
  • Query product information
  • Place order
  • Amend order by orderID
  • Cancel Single Order by orderID
  • Bulk Cancel Orders
  • Cancel All Orders
  • Query Account Positions
  • Query Account Positions with unrealized PNL
  • Switch Position Mode Synchronously
  • Set Leverage
  • Set RiskLimit
  • Query open orders by symbol
  • Query closed orders by symbol
  • Query user trade
  • Query Order Book
  • Query kline
  • Query Trade
  • Query 24 ticker
  • Query 24 ticker for all symbols
  • Query Orders History
  • Query Orders By Ids
  • Query Trades History
  • Query funding rate history
  • Query funding fee history
  1. PENDAX
  2. Using PENDAX SDK
  3. Phemex Functions

Hedged Contract

PreviousContractNextSpot

Last updated 1 year ago

Query product information

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getProductInfo()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

placeOrderHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

amendOrderHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

cancelOrderHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

cancelBatchOrderHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

cancelAllOrdersHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getAccountPositionsHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getAccountPositionsUnPnLHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

switchPositionModeSynchronously()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

setLeverageHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

setRiskLimitHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getOpenOrdersHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getClosedOrdersHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getUserTradeHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getOrderBookHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getKlineHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getTradeHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

get24HourTickerHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

get24HourTickerAllSymbolsHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getOrdersHistoryHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getOrdersByIdHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getTradeHistoryHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getFundingRateHistoryHedged()

Usage:

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

Please refer to the official Phemex API Docs for the Required parameters.

Function Name:

getFundingFeeHistoryHedged()

Usage:

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"});

⚫
💡
💻
https://phemex-docs.github.io#query-product-information-2
https://phemex-docs.github.io/#place-order-http-put-prefered-2
https://phemex-docs.github.io#amend-order-by-orderid
https://phemex-docs.github.io#cancel-single-order-by-orderid
https://phemex-docs.github.io#bulk-cancel-orders-2
https://phemex-docs.github.io#cancel-all-orders-2
https://phemex-docs.github.io#query-account-positions
https://phemex-docs.github.io#query-account-positions-with-unrealized-pnl
https://phemex-docs.github.io#switch-position-mode-synchronously
https://phemex-docs.github.io#set-leverage-2
https://phemex-docs.github.io#set-risklimit
https://phemex-docs.github.io#query-open-orders-by-symbol-2
https://phemex-docs.github.io#query-closed-orders-by-symbol-2
https://phemex-docs.github.io#query-user-trade-2
https://phemex-docs.github.io#query-order-book-2
https://phemex-docs.github.io#query-kline-2
https://phemex-docs.github.io#query-trade
https://phemex-docs.github.io#query-24-ticker
https://phemex-docs.github.io#query-24-ticker-for-all-symbols
https://phemex-docs.github.io#query-orders-history
https://phemex-docs.github.io#query-orders-by-ids
https://phemex-docs.github.io#query-trades-history
https://phemex-docs.github.io#query-funding-rate-history-2
https://phemex-docs.github.io#query-funding-fee-history-2