Giter Club home page Giter Club logo

ftx-cli's Introduction

FTX CLI

๐Ÿ’ธ Supercharged FTX lending from the command line.

Version Node.js License Total downloads Twitter

Demo

Contents

Divider

Features

๐ŸŒ 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

Divider

Prerequisites

  • Node.js v14.13.0+

The quickest and easiest way to install or update Node.js is via nvm.

Divider

Installation

Try it out

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

Global package (recommended)

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

Build from source

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

Divider

Getting started

Obtain API credentials

  1. Create a new account (5% fees discount) on FTX or FTX US
  2. Settings > Margin > 'ENABLE SPOT MARGIN TRADING'
  3. Settings > Api > 'CREATE API KEY'
  4. Note credentials down temporarily

Secure API credentials

  1. Edit API key permissions to the minimum required for this package to function properly
    • Disable 'Read-only'
    • Disable 'Withdrawals enabled'
    • Disable 'Internal transfers enabled'
  2. If you know the static IP address(es) you will be using, you can further improve security by whitelisting them via 'WHITELIST IP'

Resources

Divider

Usage

If you need a quick reminder or link back here in future, try ftx --help.

Global options

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

Login

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

Logout

Remove stored FTX API credentials.

ftx logout

Config

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

Rates

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

Earnings

Display my lending earnings.

๐Ÿ” Requires authentication

ftx earnings

Offers

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

Lend

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

Stop

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.

Spot

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

Futures

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 the currency and type filters, and by avoiding repeating the command too quickly.

Divider

Examples

Using subaccounts

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).

Repeating commands and auto-compounding

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).

Divider

FAQ

Why is this open-source/self-hosted?

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.

Why did I get rate-limited?

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.

Why did I receive 'Size too large' error?

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.

Why did I receive X error?

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.

Why would I want to auto-compound my lending offers?

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

Divider

Disclaimer

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.

Contact

Website โ€ข Twitter โ€ข Email

Donate

BTC: bc1q5f323q4399s3plle9t33j7czv5knj90ujyg3ys
ETH/ERC-20: 0x07324D924CA0C9Fbe933AE7E958e47Dd7d040C4d
SOL/SPL: 32Jwe936XEN5NEvbWusapYeqwFcuPQkSgCuzduQEkfCV

License

MIT ยฉ Dusk

ftx-cli's People

Contributors

duskcodes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.