Static
v1Static
v2取得指定的 Bifinex 設定檔。
設定檔名稱的陣列。
Bifinex 設定檔的內容。
const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2Config(['pub:spec:site:maintenance', 'pub:list:category:securities']))
/* Expected output:
{
'pub:spec:site:maintenance': {
id: 'maintenance-march-06-2023',
start: '2023-03-06 09:00:00',
duration: 6,
url: 'https://blog.bitfinex.com/?p=21173'
},
'pub:list:category:securities': [
[
'aifc',
'AIFC',
'ALT2612:USD',
'AIFC',
'Bitfinex Securities Ltd.'
],
[
'el_salvador',
'El Salvador',
'USTBL:UST',
'El-Salvador',
'Bitfinex Securities El Salvador, S.A. de C.V.'
]
]
}
*/
Static
v2取得目前 IP 位址的 GeoIp 資訊。
1
if the country is a member state of the European Union, 0
otherwise.Static
v2取得目前 Bitfinex 平台的運作狀態。維護狀態通常會持續幾分鐘到幾小時,並且在基礎設施升級期間也有可能進入維護狀態。
當平台標記為維護模式時,機器人應停止所有交易活動。在維護模式時可能會無法取消訂單和下單。
Static
v2取得指定交易對目前的行情概覽。它會回傳當前最佳買入價和賣出價、最近成交價,以及昨日至今的每日成交量和價格變動資訊。
參數說明
const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2Ticker({ pair: 'BTCUSD' }))
/* Expected output:
{
symbol: 'tBTCUSD',
bidPrice: 82388,
bidSize: 10.16663748,
askPrice: 82389,
askSize: 4.73069672,
dailyChange: -1154,
dailyChangeRelative: -0.01381821,
lastPrice: 82359,
volume: 715.62902556,
high: 83697,
low: 81481,
pair: 'BTCUSD'
}
*/
取得指定融資貨幣目前的行情概覽。它會回傳當前最佳買入價和賣出價、最近成交價,以及昨日至今的每日成交量和價格變動資訊。
參數說明
frr * 100
計算產生frr * 100 * 365
計算產生const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2Ticker({ currency: 'USD' }))
/* Expected output:
{
symbol: 'fUSD',
frr: 0.0003347671232876712,
bidPrice: 0.0003347671232876712,
bidPeriod: 30,
bidSize: 33194024.88639909,
askPrice: 0.0001639,
askPeriod: 2,
askSize: 42436.36607463,
dailyChange: -9.1e-7,
dailyChangePerc: -0.0061,
lastPrice: 0.00014799,
volume: 143727499.90044996,
high: 0.00059907,
low: 0.00007945,
frrAmountAvailable: 45904.65709059,
currency: 'USD',
dpr: 0.03347671,
apr: 12.219
}
*/
取得指定交易對或融資貨幣目前的行情概覽。它會回傳當前最佳買入價和賣出價、最近成交價,以及昨日至今的每日成交量和價格變動資訊。
參數說明
frr * 100
計算產生frr * 100 * 365
計算產生Static
v2取得交易對以及融資目前的行情概覽。它會回傳當前最佳買入價和賣出價、最近成交價,以及昨日至今的每日成交量和價格變動資訊。這個 API 允許同時取得多個交易對及融資的行情資訊。
參數說明
ALL
。frr * 100
計算產生frr * 100 * 365
計算產生const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2Tickers()) // default: ALL symbols
console.log(await Bitfinex.v2Tickers({ symbols: 'fUSD' }))
console.log(await Bitfinex.v2Tickers({ symbols: ['tBTCUSD', 'fUSD'] }))
/* Expected output:
[
{
symbol: 'tBTCUSD',
bidPrice: 82254,
bidSize: 8.81387677,
askPrice: 82255,
askSize: 7.91928646,
dailyChange: -1272,
dailyChangeRelative: -0.01523116,
lastPrice: 82241,
volume: 716.48201682,
high: 83697,
low: 81481,
pair: 'BTCUSD'
},
{
symbol: 'fUSD',
frr: 0.0003347671232876712,
bidPrice: 0.0003347671232876712,
bidPeriod: 30,
bidSize: 33193866.53816909,
askPrice: 0.00035676,
askPeriod: 4,
askSize: 442678.99810842,
dailyChange: 0.0002188,
dailyChangePerc: 1.4694,
lastPrice: 0.0003677,
volume: 144225957.2861548,
high: 0.00059907,
low: 0.00007945,
frrAmountAvailable: 0,
currency: 'USD',
dpr: 0.03347671,
apr: 12.219
}
]
*/
Static
v2取得指定交易對行情概覽的歷史記錄,它會回傳以小時為單位的最佳買入價及賣出價。
const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2TickersHist()) // default: ALL symbols
console.log(await Bitfinex.v2TickersHist({ symbols: ['tBTCUSD', 'tETHUSD'], limit: 2 }))
console.log(await Bitfinex.v2TickersHist({ symbols: 'tBTCUSD', limit: 2 }))
/* Expected output:
[
{
symbol: 'tBTCUSD',
bidPrice: 82201,
askPrice: 82202,
mts: 2025-03-31T07:00:03.000Z,
pair: 'BTCUSD'
},
{
symbol: 'tBTCUSD',
bidPrice: 82345,
askPrice: 82346,
mts: 2025-03-31T06:00:03.000Z,
pair: 'BTCUSD'
}
]
*/
Static
v2取得指定交易對 pair
的歷史 K 棒。
參數說明
1h
BTCUSD
10000
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值取得指定融資貨幣 currency
的歷史 K 棒。
參數說明
1h
USD
10000
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2CandlesHist({ currency: 'USD', timeframe: '1h', period: 2, limit: 1 }))
/* Expected output:
[
{
mts: 2025-03-31T08:00:00.000Z,
open: 0.00025,
close: 0.00042729,
high: 0.00042729,
low: 0.00025,
volume: 79474.06069641
}
]
*/
取得指定融資貨幣 currency
的歷史 K 棒。
參數說明
1h
USD
10
或 30
,預設為 30
10000
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2CandlesHist({ currency: 'USD', timeframe: '1h', periodStart: 2, periodEnd: 30, aggregation: 30, limit: 1 }))
/* Expected output:
[
{
mts: 2025-03-31T08:00:00.000Z,
open: 0.00025,
close: 0.0004273,
high: 0.0004273,
low: 0.00025,
volume: 255358.55160453
}
]
*/
Static
v2取得指定交易對 pair
的最新 K 棒。
參數說明
1h
BTCUSD
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值取得指定融資貨幣 currency
的最新 K 棒。
參數說明
1h
USD
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值取得指定融資貨幣 currency
的最新 K 棒。
參數說明
1h
USD
10
或 30
,預設為 30
mts
欄位將交易記錄以指定的方式進行排序,預設為 BitfinexSort.DESC
mts
欄位不小於此值mts
欄位不大於此值const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2CandlesLast({ currency: 'USD', timeframe: '1h', periodStart: 2, periodEnd: 30, aggregation: 30 }))
/* Expected output:
{
mts: 2025-03-31T08:00:00.000Z,
open: 0.00025,
close: 0.0004273,
high: 0.0004273,
low: 0.00025,
volume: 255358.55160453
}
*/
Static
v2取得指定貨幣最近的融資統計記錄
frr * 365
計算產生0.75%
的融資貨幣掛單數量const { Bitfinex } = require('@taichunmin/bitfinex')
console.log(await Bitfinex.v2FundingStatsHist({ currency: 'USD', limit: 1 }))
/* Expected output:
[
{
mts: 2025-03-31T08:05:00.000Z,
frrDiv365: 9.2e-7,
avgPeriod: 76.12,
amount: 3401493724.8104763,
amountUsed: 3268364679.8992467,
belowThreshold: 126893437.13542865,
frr: 0.0003358,
apr: 0.122567
}
]
*/
Static
v2取得指定交易對或融資的成交記錄。
取得目前 apiKey 或 token 的權限。
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const util = require('node:util')
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
const perms = await bitfinex.v2AuthReadPermissions()
console.log(util.inspect(perms))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{
account: { read: false, write: false },
history: { read: true, write: false },
orders: { read: false, write: false },
positions: { read: false, write: false },
funding: { read: true, write: true },
settings: { read: false, write: false },
wallets: { read: true, write: false },
withdraw: { read: false, write: false },
ui_withdraw: { read: false, write: false },
bfxpay: { read: false, write: false },
eaas_agreement: { read: false, write: false },
eaas_withdraw: { read: false, write: false },
eaas_deposit: { read: false, write: false },
eaas_brokerage: { read: false, write: false }
}
*/
取得錢包的資訊。
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log((await bitfinex.v2AuthReadWallets())?.[0])
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{
availableBalance: 0.00001,
balance: 0.00001,
currency: 'TRX',
lastChange: {},
type: 'exchange',
unsettledInterest: 0
}
*/
取得指定融資貨幣的自動借出設定
參數說明
0
代表無限制若回傳 null
代表沒有啟用自動借出。
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthReadFundingAutoStatus({ currency: 'USD' }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{ amount: 0, currency: 'USD', period: 5, rate: 0.00034405 }
*/
取得目前出借中或是借入中的融資記錄。
參數說明
1
代表為貸方,0
代表同時為貸方與借款人,-1
代表為借款人ACTIVE
FIXED
代表固定利率,VAR
代表基於 FRR 浮動利率apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log((await bitfinex.v2AuthReadFundingCredits())?.[0])
} catch (err) {
console.log(err)
}
})()
/* Expected output:
[
{
amount: 1027.10723507,
flags: 0,
hidden: false,
id: 402617569,
mtsCreate: 2025-03-31T08:50:47.000Z,
mtsLastPayout: 1970-01-01T00:00:00.000Z,
mtsOpening: 2025-03-31T08:50:47.000Z,
mtsUpdate: 2025-03-31T08:50:47.000Z,
noClose: false,
notify: false,
period: 2,
positionPair: 'tBTCUST',
rate: 0.00019958,
rateType: 'FIXED',
renew: false,
side: 1,
status: 'ACTIVE',
symbol: 'fUST',
currency: 'UST'
}
]
*/
取得已結束的融資記錄。
1
代表為貸方,0
代表同時為貸方與借款人,-1
代表為借款人CLOSED (expired)
FIXED
代表固定利率,VAR
代表基於 FRR 浮動利率apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthReadFundingCreditsHist({ limit: 1 }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
[
{
amount: 850.29527051,
flags: null,
hidden: false,
id: 402392161,
mtsCreate: 2025-03-27T00:50:47.000Z,
mtsLastPayout: 2025-03-31T00:51:03.000Z,
mtsOpening: 2025-03-27T00:50:47.000Z,
mtsUpdate: 2025-03-30T19:28:55.000Z,
noClose: false,
notify: false,
period: 4,
positionPair: 'tBTCUST',
rate: 0.00031771,
rateType: 'FIXED',
renew: false,
side: 1,
status: 'CLOSED (expired)',
symbol: 'fUST',
currency: 'UST'
}
]
*/
取得融資目前的掛單,如果有指定 currency
,則只會回傳該融資代碼的掛單。如果沒有指定 currency
,則會回傳全部的掛單。
參數說明
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log((await bitfinex.v2AuthReadFundingOffers())?.[0])
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{
amount: 1010.5521123,
amountOrig: 1010.5521123,
flags: null,
hidden: false,
id: 3854301834,
mtsCreate: '2025-04-03T04:58:08.000Z',
mtsUpdate: '2025-04-03T04:58:08.000Z',
notify: false,
period: 6,
rate: 0.00039459,
renew: false,
status: 'ACTIVE',
symbol: 'fUSD',
type: 'LIMIT',
currency: 'USD'
}
*/
取得已掛單融資的交易記錄。可以用來查詢特定貨幣的融資交易記錄,或是一次取得所有貨幣的融資交易記錄。
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthReadFundingTradesHist({ limit: 1 }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
[
{
amount: 1027.10723507,
id: 356904509,
mtsCreate: 2025-03-31T08:50:47.000Z,
offerId: 3850654061,
period: 2,
rate: 0.00019958,
symbol: 'fUST',
currency: 'UST'
}
]
*/
更新融資貨幣的自動借出設定
參數說明
1
代表啟用、0
代表停用0
代表無上限2
0
代表套用 FRR 浮動利率fa-req
0
代表無上限SUCCESS
、ERROR
、FAILURE
…apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex, FundingAutoStatus } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
// activate with 0.1% rate
console.log(await bitfinex.v2AuthWriteFundingAuto({ currency: 'BTC', rate: 0.1, period: 2, amount: 0, status: FundingAutoStatus.activate }))
/* Expected output:
{
mts: '2025-03-31T09:06:27.737Z',
type: 'fa-req',
msgId: null,
offer: { currency: 'BTC', period: 2, rate: 0.001, threshold: 0 },
code: null,
status: 'SUCCESS',
text: 'Auto-renew of BTC offers activated at 0.1% a day for 2 days periods'
}
*/
// activate with FRR
console.log(await bitfinex.v2AuthWriteFundingAuto({ currency: 'BTC', period: 2, amount: 0, status: FundingAutoStatus.activate }))
/* Expected output:
{
mts: '2025-03-31T09:01:56.969Z',
type: 'fa-req',
msgId: null,
offer: { currency: 'BTC', period: 2, rate: 0, threshold: 0 },
code: null,
status: 'SUCCESS',
text: 'Auto-renew of BTC offers activated at FRR for 2 days periods'
}
*/
// deactivate
console.log(await bitfinex.v2AuthWriteFundingAuto({ currency: 'BTC', status: FundingAutoStatus.deactivate }))
/* Expected output:
{
mts: '2025-03-31T09:01:57.423Z',
type: 'fa-req',
msgId: null,
offer: { currency: 'BTC', period: 2, rate: 0, threshold: 0 },
code: null,
status: 'SUCCESS',
text: 'Auto-renew deactivated for BTC offers'
}
*/
} catch (err) {
console.log(err)
}
})()
取消全部的融資掛單,如果有指定貨幣時,則只取消該貨幣全部的融資掛單。
參數說明
foc_all-req
(funding offer cancel all request)SUCCESS
、ERROR
、FAILURE
…apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthWriteFundingOfferCancelAll({ currency: 'BTC' }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{
mts: 2025-03-31T09:13:21.649Z,
type: 'foc_all-req',
status: 'SUCCESS',
text: 'None to cancel'
}
*/
取得帳戶指定貨幣的融資資訊
參數說明
USD
apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthReadInfoFunding({ currency: 'USD' }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
{
symbol: 'fUSD',
yieldLoan: 0,
yieldLend: 0.00022886,
durationLoan: 0,
durationLend: 0.5785416666666667,
currency: 'USD'
}
*/
取得重要的帳戶資訊
"individual"
或 "corporate"
)查看過去的分類帳記錄。預設會返回最近的記錄,但可以使用時間戳來檢索特定時間的數據,最長可以取得六年內的記錄。
參數說明
2500
mts
欄位不小於此值mts
欄位不大於此值apiKey = 'apiKey'
apiSecret = 'apiSecret'
await (async () => {
try {
const { Bitfinex, LedgersHistCategory } = require('@taichunmin/bitfinex')
const bitfinex = new Bitfinex({ apiKey, apiSecret })
console.log(await bitfinex.v2AuthReadLedgersHist({ category: LedgersHistCategory.MarginSwapInterestPayment, limit: 1 }))
} catch (err) {
console.log(err)
}
})()
/* Expected output:
[
{
amount: 0.20089545,
balance: 1009.89393076,
currency: 'USD',
description: 'Margin Funding Payment on wallet funding',
id: 9784673670,
mts: 2025-03-31T01:30:13.000Z,
wallet: 'funding'
}
]
*/
取得 Bitfinex 所有交易對的詳細資訊。