Query product information
Function Name:
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);
Query server time
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
cancelBatchOrderPerp()
Usage:
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
Function Name:
cancelAllOrdersPerp()
Usage:
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
Function Name:
getTradingAccountPerp()
Usage:
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
Function Name:
getTradingAccountUnPnLPerp()
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
assignPositionBalance()
Usage:
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
Function Name:
Usage:
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
Function Name:
getClosedOrdersPerp()
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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
Function Name:
get24HourTickerPerp()
Usage:
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
Function Name:
get24HourTickerAllSymbolsPerp()
Usage:
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
Function Name:
getHistoryTradePerp()
Usage:
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
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
Function Name:
getFundingFeeHistory()
Usage:
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
Function Name:
Usage:
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
Function Name:
Usage:
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);
Last updated