Bitfinex
Bitfinex (Spot): Bitfinex spot trading through the Bitfinex v2 API (https://api.bitfinex.com), accessed with an API Key and Secret Key. Orders and balances use Bitfinex's exchange wallet, not the margin wallet; Bitfinex perpetual contracts are a separate exchange object, Futures_Bitfinex.
Futures_Bitfinex (Futures): Bitfinex derivatives: USDT-settled perpetual contracts through the Bitfinex v2 API (https://api.bitfinex.com), accessed with an API Key and Secret Key. Margin sits on the F0-suffixed currencies of the Bitfinex margin wallet, in cross margin with one-way positions; Bitfinex spot is a separate exchange object, Bitfinex.
Names and Configuration
exchange.GetName() | Type | Aliases |
|---|---|---|
Bitfinex | Spot | — |
Futures_Bitfinex | Futures | Bitfinex Futures |
| Field | Required | |
| - | - | |
| Access Key | Yes | |
| Secret Key | Yes |
Trading Pairs and Contract Codes
Bitfinex (Spot)
Pair examples: BTC_USD, BTC_USDT, AAVE_USD
Trading pairs are written BASE_QUOTE, matching Bitfinex's tBTCUSD and tAAVE:USD. Bitfinex writes USDT as UST; use USDT in trading pairs, and returned symbols always use USDT.
Futures_Bitfinex (Futures)
Pair examples: BTC_USDT, ETH_USDT
Trading pairs look like BTC_USDT, matching Bitfinex's tBTCF0:USTF0.
| Contract code | Description |
|---|---|
swap | Perpetual contract (the only contract code). |
Bitfinex has perpetual contracts only; other contract codes are rejected.
Exchange-specific IO Commands
Bitfinex (Spot)
| Command | Description | Returns |
|---|---|---|
version | Get the API version. | Always v2. |
For the common commands api, base and currency see exchange.IO.
Futures_Bitfinex (Futures)
| Command | Arguments | Description | Returns |
|---|---|---|---|
mbase | [url] | Query or switch the market-data (public) API base address (only http:// and https:// addresses are accepted), separate from the trading API base address (the base command); the same as the trading address when not set. | The address before the change. |
For the common commands api, base and currency see exchange.IO.
Common Usage
Send market data requests to the public API domain while trading requests stay (Futures_Bitfinex only)
javascript
function main() {
// Returns the previous market data address (the trading address when not set)
var old = exchange.IO("mbase", "https://api-pub.bitfinex.com")
Log("Previous:", old, "Market:", exchange.IO("mbase"), "Trading:", exchange.IO("base"))
Log(exchange.GetTicker("BTC_USDT.swap")) // sent to api-pub.bitfinex.com
}
Function Support
No unsupported standard functions.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 5m, 15m, 30m, 1h, 3h, 6h, 12h, 1d, 1w, 14d, 1M; other periods are synthesized by the docker.
Margin, Account and Simulation
Futures_Bitfinex (Futures)
Margin mode: Cross margin only; the margin mode in exchange.GetPositions() is always cross; exchange.IO("cross", ...) fails.
Position mode: One-way positions: each contract has a single net position, with Bitfinex expressing long and short by the sign of the amount; exchange.IO("dual", ...) fails.
Account: Futures margin sits on the F0-suffixed currencies (such as USTF0) of the Bitfinex margin wallet; exchange.GetAccount returns the currencies without the suffix (USTF0 shows as USDT). Bitfinex has no set-leverage endpoint: exchange.SetMarginLevel() only records the leverage per contract locally and sends it with each regular and conditional order (10x when not set).
Notes
All exchange objects
- Conditional orders support take-profit and stop-loss only, not OCO.
- An order
clientIdmust be a positive integer (Bitfinex'scid); other values report an error. Limit orders supporttifIOC, FOK and maker-only (postOnly); market orders do not support FOK or maker-only, and conditional orders do not support IOC or FOK; passing them reports an error. exchange.ModifyOrder()andexchange.ModifyConditionOrder()are supported (Bitfinex amends the order in place). Bitfinex amounts carry the direction as a sign, so changing the amount requires the order side.exchange.IO("api", ...)signs by default and sends the parameters of a signed request as a JSON body; paths starting with/v1/are signed the Bitfinex v1 way.
Bitfinex (Spot)
- The amount of a spot market buy order is in the base currency, not a quote-currency amount.
- Bitfinex prices have 5 significant digits and no fixed tick size; the
TickSizeandPricePrecisionreturned byexchange.GetMarketsare derived from the current last price and change when the price moves to another order of magnitude; amount precision is fixed at 8 decimals.
Futures_Bitfinex (Futures)
- Order amounts are in coins, not numbers of contracts.
- Bitfinex prices have 5 significant digits; the
TickSizeandPricePrecisionreturned byexchange.GetMarketsare derived from the current last price. - The rate from
exchange.GetFundings()is the current rate from Bitfinex's derivatives status, settled every 8 hours; without arguments it returns every perpetual of the current quote currency.