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);
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 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
Function Name:
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
Function Name:
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
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
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
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
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
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
Function Name:
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
Function Name:
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
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
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
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
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
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
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
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
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:
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"});
Last updated