Comment on page
⚠
FTX Functions
Documentation for functions available for FTX through the PENDAX SDK
Due to recent events related to FTX.com - We have decided to stop the development and documentation of FTX capabilities. They will remain in the PENDAX SDK for documentation purposes only. Please use all FTX functions and integrations with caution. Current events may result in failure of FTX servers to respond.
Before you can interact with PENDAX functions, you must first create an Exchange object with which to use when using PENDAX. You can create one or multiple, and reference them together or individually throughout your code.
import { createExchange } from "./exchanges/exchange.js";
let myFtxAccount = createExchange({
exchange: "ftx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
subaccount: "mySubaccountName",
label: "ftx",
});
Once an Exchange object has been created you may use any of the available functions allowed by that exchange by referencing the name of the Exchange object you created.
import { createExchange } from "./exchanges/exchange.js";
let myFtxAccount = createExchange({
exchange: "ftx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
subaccount: "mySubaccountName",
label: "ftx",
});
let myOtherFtxAccount = createExchange({
exchange: "ftx",
authenticate: true,
key: "myOtherKeys",
secret: "myOtherSecret",
subaccount: "myOtherSubaccountName",
label: "ftx",
});
async function getAllSubaccounts() {
try {
const subaccounts = await myFtxAccount.getAllSubaccounts();
const subaccounts2 = await myOtherFtxAccount.getAllSubaccounts();
console.log(subaccounts);
console.log(subaccounts2);
} catch (error) {
console.log(error.message);
}
}
This code would create two separate FTX exchange objects, then query each account for a list of subaccounts attached to that FTX account.
getAllSubaccounts()
async function getAllSubaccounts() {
try {
const accts = await myFtxAccount.getAllSubaccounts();
console.log(accts);
} catch (error) {
console.log(error.message);
}
}
createSubaccount(options)
This function takes in an options object. Optional and required parameters are listed below.
nickname: "mySubaccount"
nickname: "mySubaccount"
async function createSubaccount() {
myFtxAccount.createSubaccount({
nickname: "myNewSubaccount",
});
}
changeSubaccountName(options)
This function takes in an options object. Optional and required parameters are listed below.
nickname: "mySubaccount"
newNickname: "new name"
nickname: "mySubaccount"
newNickname: "new name"
nickname
is the current subaccount nameasync function changeSubaccountName() {
myFtxAccount.changeSubaccountName({
nickname: "currentName",
newNickname: "newName",
});
}
deleteSubaccount(options)
This function takes in an options object. Optional and required parameters are listed below.
nickname: "mySubaccount"
nickname: "mySubaccount"
async function deleteSubaccount() {
myFtxAccount.deleteSubaccount({
nickname: "myUnwantedSubaccount",
});
}
getSubaccountBalances(options)
This function takes in an options object. Optional and required parameters are listed below.
nickname: "my subaccount"
nickname: "my subaccount"
async function getSubaccountBalances(options) {
try {
let result = await myFtxAccount.getSubaccountBalances(options);
console.log(result.data.result);
} catch (error) {
console.log(error.message);
}
}
getSubaccountBalances({
nickname: "my subaccount"
});
transferBetweenSubaccounts(options)
This function takes in an options object. Optional and required parameters are listed below.
"coin": "BTC",
"size": 10,
"source": null,
//null or "main" denotes the use of main account for source of funds. else supply the subaccount you want to transfer from
"destination": "sub1"
"coin": "BTC",
"size": 10,
"source": null,
//null or "main" denotes the use of main account for source of funds. else supply the subaccount you want to transfer from
"destination": "sub1"
async function transferBetweenSubaccounts(options) {
try {
let result = await myFtxAccount.transferBetweenSubaccounts(options);
console.log(result.data.result);
} catch (error) {
console.log(error.message);
console.log(error.response.data.error);
}
}
transferBetweenSubaccounts({
"coin": "BTC",
"size": 10,
"source": null,
"destination": "sub1"
});
Last modified 1yr ago