This document describes the set of functions found in the rFTX package and how to use them. Helper functions such as ftx_send_request are used by all functions to connect to the API.

Package Functionality

Coin Balances

This function returns balances coin balances of all accounts if accounts argument is left empty or returns the balances of the specified accounts. The data element in the response list will contain a column with the subaccount names. The main account values will appear under the name main.

# Loading the library
library(rFTX)

# Example API key and secret
key <- "LR0RQT6bKjrUNh38eCw9jYC89VDAbRkCogAc_XAm"
secret <- "T4lPid48QtjNxjLUFOcUZghD7CUJ7sTVsfuvQZF2"

obj <- ftx_coin_balances(key, secret, accounts = c())

Positions

This function returns the account positions and takes subaccount as an optional argument.

obj <- ftx_positions(key, secret, subaccount=NA)

Coin Markets

This function returns information on all types of markets on FTX: spot, perpetual futures, expiring futures, and MOVE contracts. For futures that expired in 2019, prepend a 2019 to the date, like so: BTC-20190628 or BTC-MOVE-20190923.

obj <- ftx_coin_markets(key, secret)

Orderbook

This function returns the orderbook for the market specified. The name of the market is required. The maximum depth is 100.

obj <- ftx_orderbook(key, secret, market = NA, depth = 10)

Trades

This function returns the trades that have taken place for a particular market. Start and end time arguments are optional.

obj <- ftx_trades(key, secret, market, start_time = NA, end_time = NA)

Historical Prices

This function returns historical prices of expired futures. Start and end time arguments are optional.

obj <- ftx_historical_prices(key, secret, market, resolution = 14400, start_time = NA, end_time = NA)

Future Markets

This function returns all types of futures on FTX: perpetual, expiring, and MOVE. Examples for each type are BTC-PERP, BTC-0626, and BTC-MOVE-1005. For futures that expired in 2019, prepend a 2019 to the date, like so: BTC-20190628.

obj <- ftx_future_markets(key, secret, market = NA)

Future Stats

This function returns stats on futures such as volume which is quantity traded in the last 24 hours.

obj <- ftx_future_stat(key, secret, market) 

Future Funding Rates

This function returns the funding rates of futures.

obj <- ftx_future_funding_rates(key, secret, markets=c(), start_time, end_time)

Open Orders

This function returns information on the account or subaccount if specified open orders along with their statuses such as new (accepted but not processed yet), open, or closed (filled or cancelled).

obj <- ftx_open_orders(key, secret, subaccount, markets=c())

Orders History

This function returns the history of orders for the account or subaccount if specified.

obj <- ftx_orders_history(key, secret, subaccount, markets=c())

Place Order

This function places an order based on the information provided. Market, side, price, type and size are required arguments. It returns information on the order along with their statuses such as new (accepted but not processed yet), open, or closed (filled or cancelled).

obj <- ftx_place_order(key, secret, subaccount, market=NA, side=NA, price=NA, type=NA, size=NA, 
                       reduceOnly=FALSE, ioc=FALSE, postOnly=FALSE, clientId=NA)

Modify Order

This function modifies an order based on size and price. Either price or size must be specified. The order's queue priority will be reset, and the order ID of the modified order will be different from that of the original order. Also, this is implemented as cancelling and replacing your order. There's a chance that the order meant to be cancelled gets filled and its replacement still gets placed.

obj <- ftx_modify_order(key, secret, subaccount, order_id, size, price)

Modify order by clientID

This function modifies an order using the client ID instead of the order ID.

obj <- ftx_modify_order_clientid(key, secret, subaccount, client_id, size, price)

Order Status

This function returns the status of orders such as new (accepted but not processed yet), open, or closed (filled or cancelled).

obj <- ftx_order_status(key, secret, subaccount, order_id)

Order Status by clientID

This function returns the status of orders using the client ID instead of the order ID.

obj <- ftx_order_status_clientid(key, secret, subaccount, client_id)

Cancel Order

This function queues an order for cancellation.

obj <- ftx_cancel_order(key, secret, subaccount, order_id)

Cancel Order by clientID

This function queues an order for cancellation using the client ID instead of the order ID.

obj <- ftx_cancel_order_clientid(key, secret, subaccount, client_id)

Order Fills

This function returns market fills. The markets argument can take in more than one value. Fills generated by Converts will show up as 'type': 'otc'.

obj <- ftx_order_fills(key, secret, subaccount, markets=c(), start_time=NA, end_time=NA)

Funding Payments

This function returns the funding payments for futures.

obj <- ftx_funding_payments(key, secret, subaccount, start_time = NA, end_time = NA)

Spot Lending History

This function returns the lending history for coins in rate and size.

obj <- ftx_spot_lending_history(key, secret, start_time=NA, end_time=NA)

Spot Margin Borrow Rates

This function returns the estimated hourly borrow rate for the next spot margin cycle and the hourly borrow rate in the previous spot margin cycle for coins.

obj <- ftx_spot_margin_borrow_rates(key, secret, subaccount)

Spot Borrow History

This functions returns the coin borrow history for the user.

obj <- ftx_my_spot_borrow_history(key, secret, subaccount, start_time, end_time)


andreskull/rFTX documentation built on Nov. 8, 2022, 2:27 p.m.