πΈ Supercharged FTX lending from the command line.
- Features
- Prerequisites
- Installation
- Getting started
- Usage
- Examples
- FAQ
- Disclaimer
- Contact
- Donate
- License
π Global exchange: supports FTX and FTX US
π€ Multiple logins: allows switching between API credentials and subaccounts
π Better metrics: displays all the metrics provided by FTX and more
π Repeat commands: compounds lending offers automatically via inbuilt command scheduler
β²οΈ Custom schedules: repeats commands using custom cron expressions
π Self-hosted: retains your control over your API credentials
βοΈ Close to the metal: remains faithful to FTX terminology, options, and errors
- Node.js v14.13.0+
The quickest and easiest way to install or update Node.js is via nvm.
Before you install, why not try one of the commands out? This one doesn't require authentication and will display information on lending rates.
npx ftx-cli rates
The quickest and easiest way to install is globally from npm. By default, you will be notified when an update is available.
npm install -g ftx-cli
You can also download/clone and install the package manually. You will be in charge of downloading/pulling and installing the latest source when an update is available.
git clone https://github.com/dusktrades/ftx-cli
cd ftx-cli
npm install -g
- Create a new account (5% fees discount) on FTX or FTX US
- Settings > Margin > 'ENABLE SPOT MARGIN TRADING'
- Settings > Api > 'CREATE API KEY'
- Note credentials down temporarily
- Edit API key permissions to the minimum required for this package to function properly
- Disable 'Read-only'
- Disable 'Withdrawals enabled'
- Disable 'Internal transfers enabled'
- If you know the static IP address(es) you will be using, you can further improve security by whitelisting them via 'WHITELIST IP'
- Margin Lending (UI) (FTX US)
- Spot Margin Trading Explainer (Article)
- FTX Guide: How to Borrow and Lend on FTX (Video)
If you need a quick reminder or link back here in future, try ftx --help
.
You can inline these options with any command to modify its behaviour. Inline options take priority over stored credentials/config.
Option | Description | Default | Notes |
---|---|---|---|
-e, --exchange <exchange> |
FTX exchange platform (FTX or FTX US) | ftx |
Options: ftx , ftx-us |
-k, --key <key> |
FTX API key | ||
-x, --secret <secret> |
FTX API secret | ||
-a, --subaccount <subaccount> |
FTX subaccount name | No subaccount | Learn more about using subaccounts |
--schedule <schedule> |
Schedule to run command at a specific future date and time or at every given time period | ||
-z, --repeat [cron expression] |
Repeat the command with optional schedule | false |
Learn more about repeating commands |
--colour |
Enable coloured output | true |
Disable: --no-colour |
--update-notifications |
Enable update notifications | true |
Disable: --no-update-notifications |
Store FTX API credentials locally. This provides a convenient method of remaining authenticated with FTX. Please note any previously stored credentials will be overwritten.
Option | Description | Default | Notes |
---|---|---|---|
-k, --key <key> |
FTX API key | Required | |
-x, --secret <secret> |
FTX API secret | Required | |
-a, --subaccount <subaccount> |
FTX subaccount name | No subaccount | Learn more about using subaccounts |
# Store API credentials.
ftx login --key API_KEY --secret API_SECRET
# Store API credentials and subaccount.
ftx login --key API_KEY --secret API_SECRET --subaccount SUBACCOUNT
Remove stored FTX API credentials.
ftx logout
Store option preferences locally. This lets you customise the default behaviour of the package so you don't need to continuously repeat the same options.
Option | Description | Default | Notes |
---|---|---|---|
-e, --exchange <exchange> |
FTX exchange platform (FTX or FTX US) | ftx |
Options: ftx , ftx-us |
--colour |
Enable coloured output | true |
Disable: --no-colour |
--update-notifications |
Enable update notifications | true |
Disable: --no-update-notifications |
# Store preference to use FTX US.
ftx config --exchange ftx-us
# Store preference to disable coloured output.
ftx config --no-colour
# Store preference to disable update notifications.
ftx config --no-update-notifications
Display lending rates.
Option | Description | Default | Notes |
---|---|---|---|
-c, --currency <currency> |
Currency symbol(s) | All lendable currencies | Supports comma-separated list |
--sort <sorting method> |
Sorting method | currency |
Options: currency , previous , estimated |
# Display lending rates for all currencies.
ftx rates
# Display lending rates for BTC.
ftx rates --currency btc
# Display lending rates for USD and USDT, sorted by estimated next lending rate.
ftx rates --currency usd,usdt --sort estimated
Display my lending earnings.
π Requires authentication
ftx earnings
Display my open lending offers.
π Requires authentication
Option | Description | Default | Notes |
---|---|---|---|
--sort <sorting method> |
Sorting method | currency |
Options: currency , lendable , offered , locked , min-rate |
# Display my open lending offers.
ftx offers
# Display my open lending offers, sorted by locked size.
ftx offers --sort locked
Create lending offer(s). Please note any matching existing offer(s) will be updated.
π Requires authentication
Option | Description | Default | Notes |
---|---|---|---|
-c, --currency <currency> |
Currency symbol(s) | All lendable currencies | Supports comma-separated list |
-s, --size <size> |
Currency amount | Maximum lendable size | Supports thousand (k , K ) and million (m , M ) shorthands |
-r, --min-rate <rate> |
Minimum yearly lending rate (%) | 0 |
# Offer all lendable currencies with no minimum rate.
ftx lend
# Offer all BTC with no minimum rate.
ftx lend --currency btc
# Offer all lendable currencies at a minimum rate of 5% per year.
ftx lend --min-rate 5
# Offer 100 TWTR with no minimum rate.
ftx lend --currency twtr --size 100
# Offer all USD and USDT at a minimum rate of 7.5% per year.
ftx lend --currency usd,usdt --min-rate 7.5
# Offer 10,500 USD at a minimum rate of 10% per year.
ftx lend --currency usd --size 10.5k --min-rate 10
Withdraw lending offer(s).
π Requires authentication
Option | Description | Default | Notes |
---|---|---|---|
-c, --currency <currency> |
Currency symbol(s) | All lendable currencies | Supports comma-separated list |
# Withdraw all offers.
ftx stop
# Withdraw offer for USD.
ftx stop --currency usd
# Withdraw offers for USD and USDT.
ftx stop --currency usd,usdt
β οΈ Funds will stay locked by FTX for up to 1 hour after withdrawing your offer.
Display spot stats.
Option | Description | Default | Notes |
---|---|---|---|
-c, --currency <currency> |
Currency symbol(s) | All currencies | Supports comma-separated list |
-t, --type <type> |
Spot type | All spot types | Supports comma-separated list Options: coin fiat leveraged-token (lev )volatility-token (vol )equity-token (stock ) |
-q, --quote-currency <currency> |
Quote currency symbol(s) | All currencies | Supports comma-separated list |
--token-leverage <leverage> |
Token leverage name or multiplier | All token leverages | Supports comma-separated list Options: bull (3x )half (0.5x )hedge (-1x )bear (-3x ) |
--sort <sorting method> |
Sorting method | name |
Options:name price change-1h change-24h volume |
# Display stats for all spot markets.
ftx spot
# Display stats for all BTC and ETH spot markets.
ftx spot --currency btc,eth
# Display stats for all fiat spot markets.
ftx spot --type fiat
# Display stats for all tokenised equity spot markets, sorted by 1 hour change.
ftx spot --type equity-token --sort change-1h
# Display stats for all leveraged and volatility token spot markets, sorted by volume.
ftx spot --type leveraged-token,volatility-token --sort volume
# Display stats for BEAR (-3x) leveraged token USDT spot markets.
ftx spot --quote-currency usdt --token-leverage bear
Display futures stats.
Option | Description | Default | Notes |
---|---|---|---|
-c, --currency <currency> |
Currency symbol(s) | All currencies | Supports comma-separated list |
-t, --type <type> |
Future type | All future types | Supports comma-separated list Options: perpetual (perp ), quarterly (dated ), move |
--sort <sorting method> |
Sorting method | name |
Options:name last-price mark-price change-1h change-24h volume open-interest (oi )previous-funding estimated-funding |
# Display stats for all futures.
ftx futures
# Display stats for all BTC and ETH-related futures.
ftx futures --currency btc,eth
# Display stats for all perpetual futures.
ftx futures --type perpetual
# Display stats for all perpetual futures, sorted by estimated next funding rate.
ftx futures --type perpetual --sort estimated-funding
# Display stats for BTC quarterly and move futures, sorted by open interest.
ftx futures --currency btc --type quarterly,move --sort open-interest
β οΈ This command is currently intensive on the FTX API due to the amount of data required. You can reduce load by using thecurrency
andtype
filters, and by avoiding repeating the command too quickly.
Subaccounts are fully supported. If you plan on using one subaccount most of the time, you can login
with it. If you plan on switching between subaccounts, you can use inline options.
# Store API credentials and subaccount.
ftx login --key API_KEY --secret API_SECRET --subaccount SUBACCOUNT
# Display my open lending offers on 'Idle' subaccount.
ftx offers --subaccount Idle
Notes:
- FTX subaccount names are case-sensitive
- FTX API credentials can be linked to your whole account or individual subaccounts
β οΈ It is recommended that you create and use a subaccount if you want to keep your lending funds separate. The purpose of this is to prevent conflicts with other trading activity on your account (e.g. using a subaccount when auto-compounding will prevent accidentally lending collateral from elsewhere on your account).
Any command can be easily repeated at specified intervals via the inbuilt command scheduler and will keep running until manually aborted. If you need help with cron expression syntax, we recommend reading the node-cron documentation and using crontab guru.
Command | Default repeat schedule | Notes |
---|---|---|
lend |
59 * * * * ('At 59 minutes past every hour') |
Optimised for auto-compounding (FTX lending rates and locked balances are updated hourly) |
Others | * * * * * ('At every minute') |
# Auto-compound all lendable currencies with no minimum rate.
ftx lend --repeat
# Auto-compound all USD at a minimum rate of 1% per year.
ftx lend --currency usd --min-rate 1 --repeat
# Withdraw all offers at 09:00 AM every day.
ftx stop --repeat "0 9 * * *"
β οΈ The machine you are using to run repeated commands must remain powered on and capable of communicating with FTX (e.g. PC with no downtime, local server, VM).
The popular crypto phrase 'not your keys, not your coins' holds true for your API keys, too (especially if insecure). The way this project is set up means your API credentials are only communicated between, and stored on, your own machine and FTX β and anyone can scrutinise and build from source to verify that claim.
It's possible to get rate-limited by FTX if you attempt to execute large amounts of commands in a short period of time. Learn more.
The FTX API seems to accept sizes with precision up to 8 decimal places, which you can utilise if you set size explicitly.
However, we have encountered strange behaviour when creating lending offers close to your lendable size (such as when auto-compounding), therefore we truncate lendable size to 6 decimal places before communicating with FTX. This makes the errors less common, but it remains possible to receive them while we look for a more robust solution. As a workaround, you can try the command again or wait for the next repeat scheduled run.
This package doesn't impose many artificial limitations beyond the defaults, meaning most limits and errors are relayed directly from the FTX platform. Please ensure what you're trying to do is possible on FTX before raising the issue with this package.
Auto-compounding is perfect if you want to maximise lending earnings while avoiding manually updating your lending offers to include recent payouts. It is worth the small effort to set up if you intend to lend long-term with decent size. See the table below for examples:
Average annual lending rate | Effective annual rate (with hourly compounding)* |
---|---|
5% | ~5.13% |
10% | ~10.52% |
25% | ~28.40% |
50% | ~64.87% |
*Formula: (1 + X / 8760)8760 - 1
X = Average annual lending rate
FTX CLI is not affiliated with FTX. Your account(s) and funds are your responsibility. Trading involves a high degree of risk and is not suitable for all persons.
BTC: bc1q5f323q4399s3plle9t33j7czv5knj90ujyg3ys
ETH/ERC-20: 0x07324D924CA0C9Fbe933AE7E958e47Dd7d040C4d
SOL/SPL: 32Jwe936XEN5NEvbWusapYeqwFcuPQkSgCuzduQEkfCV
MIT Β© Dusk