restv2¶
-
class
Client
(key=None, secret=None, nonce_multiplier=1.0)[source]¶ Client for the bitfinex.com API REST V2. Link for official bitfinex documentation :
Parameters: Examples
bfx_client = Client(key,secret) bfx_client = Client(key,secret,2.0)
-
platform_status
()[source]¶ Bitfinex platform_status reference
Get the current status of the platform. Maintenance periods last for just few minutes and might be necessary from time to time during upgrades of core components of our infrastructure. Even if rare it is important to have a way to notify users. For a real-time notification we suggest to use websockets and listen to events 20060/20061
Returns: - 1 = operative
- 0 = maintenance
Return type: int Example
bfx_client.platform_status()
-
tickers
(symbol_list)[source]¶ -
The ticker is a high level overview of the state of the market. It shows you the current best bid and ask, as well as the last trade price.It also includes information such as daily volume and how much the price has moved over the last day.
Parameters: symbol_list (list) – The symbols you want information about as a comma separated list, or ALL for every symbol. Returns: [ # on trading pairs (ex. tBTCUSD) [ SYMBOL, BID, BID_SIZE, ASK, ASK_SIZE, DAILY_CHANGE, DAILY_CHANGE_PERC, LAST_PRICE, VOLUME, HIGH, LOW ], # on funding currencies (ex. fUSD) [ SYMBOL, FRR, BID, BID_SIZE, BID_PERIOD, ASK, ASK_SIZE, ASK_PERIOD, DAILY_CHANGE, DAILY_CHANGE_PERC, LAST_PRICE, VOLUME, HIGH, LOW ], ... ]
Return type: list Note
Field Type Description FRR float Flash Return Rate - average of all fixed rate funding over the last hour BID float Price of last highest bid BID_PERIOD int Bid period covered in days BID_SIZE float Sum of the 25 highest bid sizes ASK float Price of last lowest ask ASK_PERIOD int Ask period covered in days ASK_SIZE float Sum of the 25 lowest ask sizes DAILY_CHANGE float Amount that the last price has changed since yesterday DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms LAST_PRICE float Price of the last trade VOLUME float Daily volume HIGH float Daily high LOW float Daily low Examples
bfx_client.tickers(['tIOTUSD', 'fIOT']) bfx_client.tickers(['tBTCUSD']) bfx_client.tickers(['ALL'])
-
ticker
(symbol)[source]¶ -
The ticker is a high level overview of the state of the market.It shows you the current best bid and ask, as well as the last trade price.It also includes information such as daily volume and how much the price has moved over the last day.
Parameters: symbol (str) – The symbol you want information about. You can find the list of valid symbols by calling the symbols method Returns: # on trading pairs (ex. tBTCUSD) [ SYMBOL, BID, BID_SIZE, ASK, ASK_SIZE, DAILY_CHANGE, DAILY_CHANGE_PERC, LAST_PRICE, VOLUME, HIGH, LOW ] # on funding currencies (ex. fUSD) [ SYMBOL, FRR, BID, BID_SIZE, BID_PERIOD, ASK, ASK_SIZE, ASK_PERIOD, DAILY_CHANGE, DAILY_CHANGE_PERC, LAST_PRICE, VOLUME, HIGH, LOW ]
Return type: list Examples
bfx_client.ticker('tIOTUSD') bfx_client.ticker('fIOT') bfx_client.ticker('tBTCUSD')
-
trades
(symbol)[source]¶ -
Trades endpoint includes all the pertinent details of the trade, such as price, size and time.
Parameters: symbol (str) – The symbol you want information about. You can find the list of valid symbols by calling the symbols method
Returns: # on trading pairs (ex. tBTCUSD) [ [ ID, MTS, AMOUNT, PRICE ] ] # on funding currencies (ex. fUSD) [ [ ID, MTS, AMOUNT, RATE, PERIOD ] ]
Return type: list Examples
bfx_client.trades('tIOTUSD') bfx_client.trades('fIOT') bfx_client.trades('tBTCUSD')
-
books
(symbol, precision='P0')[source]¶ -
The Order Books channel allow you to keep track of the state of the Bitfinex order book. It is provided on a price aggregated basis, with customizable precision.
Parameters: Returns: # on trading pairs (ex. tBTCUSD) [ [ PRICE, COUNT, AMOUNT ] ] # on funding currencies (ex. fUSD) [ [ RATE, PERIOD, COUNT, AMOUNT ] ]
Return type: Examples
bfx_client.books('tIOTUSD') bfx_client.books('fIOT') bfx_client.books('tBTCUSD')
-
stats
(**kwargs)[source]¶ -
Various statistics about the requested pair.
Parameters: - Key (str) – Allowed values: “funding.size”, “credits.size”, “credits.size.sym”, “pos.size”
- Size (str) – Available values: ‘1m’
- Symbol (str) – The symbol you want information about.
- Symbol2 (str) – The symbol you want information about.
- Side (str) – Available values: “long”, “short”
- Section (str) – Available values: “last”, “hist”
- sort (str) – if = 1 it sorts results returned with old > new
Returns: # response with Section = "last" [ MTS, VALUE ] # response with Section = "hist" [ [ MTS, VALUE ], ... ]
Return type: Examples
PARAMS = { 'key': 'funding.size', 'size': '1m', 'symbol': 'fUSD', 'section': 'hist', 'sort': '0' } bfx_client.stats(**PARAMS) # statistics PARAMS = { 'key': 'credits.size', 'size': '1m', 'symbol': 'fUSD', 'section': 'hist', 'sort': '0' } bfx_client.stats(**PARAMS) # statistics PARAMS = { 'key': 'pos.size', 'size': '1m', 'symbol': 'tIOTUSD', 'side': 'short', 'section': 'hist', 'sort': '0' } bfx_client.stats(**PARAMS) # statistics PARAMS = { 'key': 'credits.size.sym', 'size': '1m', 'symbol': 'fUSD', 'symbol2': 'tBTCUSD', 'section': 'hist', 'sort': '0' }
-
candles
(*args, **kwargs)[source]¶ -
Provides a way to access charting candle info
Parameters: - timeFrame (str) – Available values: ‘1m’, ‘5m’, ‘15m’, ‘30m’, ‘1h’, ‘3h’, ‘6h’, ‘12h’, ‘1D’, ‘7D’, ‘14D’, ‘1M’
- symbol (str) – The symbol you want information about.
- section (str) – Available values: “last”, “hist”
- limit (int) – Number of candles requested
- start (str) – Filter start (ms)
- end (str) – Filter end (ms)
- sort (int) – if = 1 it sorts results returned with old > new
Returns: # response with Section = "last" [ MTS, OPEN, CLOSE, HIGH, LOW, VOLUME ] # response with Section = "hist" [ [ MTS, OPEN, CLOSE, HIGH, LOW, VOLUME ], ... ]
Return type: Examples
# 1 minute candles bfx_client.candles("1m", "tBTCUSD", "hist") # 1 hour candles , limit to 1 candle bfx_client.candles("1h", "tBTCUSD", "hist", limit='1') bfx_client.candles("1h", "tBTCUSD", "last")
-
market_average_price
(**kwargs)[source]¶ Bitfinex market average price reference
Calculate the average execution rate for Trading or Margin funding.
Parameters: Returns: [RATE_AVG, AMOUNT]
Return type: Example
bfx_client.market_average_price(symbol="tBTCUSD", amount="100", period="1m")
-
foreign_exchange_rate
(**kwargs)[source]¶ Bitfinex foreign exchange rate reference
Parameters: Returns: [ CURRENT_RATE ]
Return type: Example
bfx_client.foreign_exchange_rate(ccy1="IOT", ccy2="USD")
-
wallets_balance
()[source]¶ Bitfinex wallets balance reference
Get account wallets
Returns: [ [ WALLET_TYPE, CURRENCY, BALANCE, UNSETTLED_INTEREST, BALANCE_AVAILABLE, ... ], ... ]
Return type: list Example
bfx_client.wallets_balance()
-
active_orders
(trade_pair='')[source]¶ Bitfinex active orders reference
Fetch active orders using rest api v2
Parameters: symbol (Optional str) – The symbol you want information about.
Returns: [ [ ID, GID, CID, SYMBOL, MTS_CREATE, MTS_UPDATE, AMOUNT, AMOUNT_ORIG, TYPE, TYPE_PREV, _PLACEHOLDER, _PLACEHOLDER, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, PRICE, PRICE_AVG, PRICE_TRAILING, PRICE_AUX_LIMIT, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, HIDDEN, PLACED_ID, ... ], ... ]
Return type: list Examples
bfx_client.active_orders("tIOTUSD") bfx_client.active_orders()
-
orders_history
(trade_pair, **kwargs)[source]¶ Bitfinex orders history reference
Returns the most recent closed or canceled orders up to circa two weeks ago
Parameters: Returns: [ [ ID, GID, CID, SYMBOL, MTS_CREATE, MTS_UPDATE, AMOUNT, AMOUNT_ORIG, TYPE, TYPE_PREV, _PLACEHOLDER, _PLACEHOLDER, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, PRICE, PRICE_AVG, PRICE_TRAILING, PRICE_AUX_LIMIT, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, NOTIFY, HIDDEN, PLACED_ID, ... ], ... ]
Return type: Example
bfx_client.orders_history("tIOTUSD")
-
order_trades
(trade_pair, order_id)[source]¶ Bitfinex order trades reference
Get Trades generated by an Order
Parameters: Returns: [ [ ID, PAIR, MTS_CREATE, ORDER_ID, EXEC_AMOUNT, EXEC_PRICE, _PLACEHOLDER, _PLACEHOLDER, MAKER, FEE, FEE_CURRENCY, ... ], ... ]
Return type: Example
bfx_client.order_trades("tIOTUSD", 14395751815)
-
trades_history
(trade_pair, **kwargs)[source]¶ Bitfinex trades history reference
List of trades
Parameters: Returns: [ [ ID, PAIR, MTS_CREATE, ORDER_ID, EXEC_AMOUNT, EXEC_PRICE, ORDER_TYPE, ORDER_PRICE, MAKER, FEE, FEE_CURRENCY, ... ], ... ]
Return type: Examples
bfx_client.trades_history('tIOTUSD', limit=10) TH = BTFXCLIENT.trades_history("tIOTUSD") for trade in TH: print(trade)
-
active_positions
()[source]¶ -
Get active positions
Returns: [ [ SYMBOL, STATUS, AMOUNT, BASE_PRICE, MARGIN_FUNDING, MARGIN_FUNDING_TYPE, PL, PL_PERC, PRICE_LIQ, LEVERAGE ... ], ... ]
Return type: list Example
bfx_client.active_positions()
-
funding_offers
(symbol='')[source]¶ Bitfinex funding offers reference
Get active funding offers.
Parameters: symbol (str) – The symbol you want information about.
Returns: [ [ ID, SYMBOL, MTS_CREATED, MTS_UPDATED, AMOUNT, AMOUNT_ORIG, TYPE, _PLACEHOLDER, _PLACEHOLDER, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, ... ], ... ]
Return type: list Examples
bfx_client.funding_offers() bfx_client.funding_offers("fIOT")
-
funding_offers_history
(symbol='', **kwargs)[source]¶ Bitfinex funding offers hist reference
Get past inactive funding offers. Limited to last 3 days.
Parameters: Returns: [ [ ID, SYMBOL, MTS_CREATED, MTS_UPDATED, AMOUNT, AMOUNT_ORIG, TYPE, _PLACEHOLDER, _PLACEHOLDER, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, ... ], ... ]
Return type: Examples
bfx_client.funding_offers_history() bfx_client.funding_offers_history('fOMG')
-
funding_loans
(symbol='')[source]¶ Bitfinex funding loans reference
Funds not used in active positions
Parameters: symbol (str) – The symbol you want information about.
Returns: [ [ ID, SYMBOL, SIDE, MTS_CREATE, MTS_UPDATE, AMOUNT, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, MTS_OPENING, MTS_LAST_PAYOUT, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, _PLACEHOLDER, NO_CLOSE, ... ], ... ]
Return type: list Example
bfx_client.funding_loans('fOMG')
-
funding_loans_history
(symbol='', **kwargs)[source]¶ Bitfinex funding loans history reference
Inactive funds not used in positions. Limited to last 3 days.
Parameters: Returns: [ [ ID, SYMBOL, SIDE, MTS_CREATE, MTS_UPDATE, AMOUNT, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, MTS_OPENING, MTS_LAST_PAYOUT, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, _PLACEHOLDER, NO_CLOSE, ... ], ... ]
Return type: Example
bfx_client.funding_loans_history('fOMG')
-
funding_credits
(symbol='')[source]¶ Bitfinex funding credits reference
Funds used in active positions
Parameters: symbol (str) – The symbol you want information about.
Returns: [ [ ID, SYMBOL, SIDE, MTS_CREATE, MTS_UPDATE, AMOUNT, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, MTS_OPENING, MTS_LAST_PAYOUT, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, _PLACEHOLDER, NO_CLOSE, ... ], ... ]
Return type: list Example
bfx_client.funding_credits('fUSD')
-
funding_credits_history
(symbol='', **kwargs)[source]¶ Bitfinex funding credits history reference
Inactive funds used in positions. Limited to last 3 days.
Parameters: Returns: [ [ ID, SYMBOL, SYMBOL, MTS_CREATE, MTS_UPDATE, AMOUNT, FLAGS, STATUS, _PLACEHOLDER, _PLACEHOLDER, _PLACEHOLDER, RATE, PERIOD, MTS_OPENING, MTS_LAST_PAYOUT, NOTIFY, HIDDEN, _PLACEHOLDER, RENEW, _PLACEHOLDER, NO_CLOSE, POSITION_PAIR, ... ], ... ]
Return type: Example
bfx_client.funding_credits_history('fUSD')
-
funding_trades
(symbol='', **kwargs)[source]¶ Bitfinex funding trades hitory reference
Get funding trades
Parameters: Returns: [ [ ID, CURRENCY, MTS_CREATE, OFFER_ID, AMOUNT, RATE, PERIOD, MAKER, ... ], ... ]
Return type: Example
bfx_client.funding_trades('fUSD')
-
margin_info
(tradepair='base')[source]¶ Bitfinex margin info reference
Get account margin info
Parameters: key (str) – “base” | SYMBOL Returns: # margin base [ "base", [ USER_PL, USER_SWAPS, MARGIN_BALANCE, MARGIN_NET, ... ] ] # margin symbol [ SYMBOL, [ TRADABLE_BALANCE, GROSS_BALANCE, BUY, SELL, ... ] ]
Return type: list Examples
bfx_client.margin_info() bfx_client.margin_info('base') bfx_client.margin_info('tIOTUSD')
-
funding_info
(tradepair)[source]¶ Bitfinex funding info reference
Get account funding info
Parameters: symbol (str) – The symbol you want information about.
Returns: [ "sym", SYMBOL, [ YIELD_LOAN, YIELD_LEND, DURATION_LOAN, DURATION_LEND, ... ], ... ]
Return type: list Example
bfx_client.funding_info('fIOT')
-
movements
(currency='')[source]¶ -
View your past deposits/withdrawals.
Parameters: Currency (str) – Currency (BTC, …) Returns: [ [ ID, CURRENCY, CURRENCY_NAME, null, null, MTS_STARTED, MTS_UPDATED, null, null, STATUS, null, null, AMOUNT, FEES, null, null, DESTINATION_ADDRESS, null, null, null, TRANSACTION_ID, null ], ... ]
Return type: list Example
bfx_client.movements() bfx_client.movements("BTC")
-
performance
(period='1D')[source]¶ Bitfinex performance reference
Get account historical daily performance (work in progress on Bitfinex side)
This endpoint is still under active development so you might experience unexpected behavior from it.
Currently not working : bitfinex.rest.restv2.BitfinexException: (500, ‘Internal Server Error’, [‘error’, 10020, ‘method: invalid’])
Returns: The list contains the following information: [ CURRENT_RATE ]
Return type: list Example
bfx_client.performance()
-
alert_list
()[source]¶ Bitfinex list alerts reference
List of active alerts
Returns: [ [ 'price:tBTCUSD:560.92', 'price', 'tBTCUSD', 560.92, 91 ], ... ]
Return type: list Example
bfx_client.alert_list()
-
alert_set
(alert_type, symbol, price)[source]¶ Bitfinex auth alert set reference
Sets up a price alert at the given value
Parameters: Returns: [ 'price:tBTCUSD:600', 'price', 'tBTCUSD', 600, 100 ]
Return type: Example
bfx_client.alert_set('price', 'tIOTUSD', 3)
-
alert_delete
(symbol, price)[source]¶ Bitfinex auth alert delete reference
Bitfinex always returns [True] no matter if the request deleted an alert or not
Parameters: Returns: [ True ]
Return type: Example
bfx_client.alert_delete('tIOTUSD', 1)
-
calc_available_balance
(symbol, direction, rate, order_type)[source]¶ Bitfinex calc balance available reference
Calculate available balance for order/offer example : calc_available_balance(“tIOTUSD”,”1”,”1.13”,”EXCHANGE”)
Parameters: Returns: [AMOUNT_AVAIL]
Return type: Example
bfx_client.calc_available_balance('tIOTUSD', 1, 0.02, 'EXCHANGE')
-
ledgers
(currency='')[source]¶ -
View your past ledger entries.
Parameters: Currency (str) – Currency (BTC, …) Returns: [ [ ID, CURRENCY, null, TIMESTAMP_MILLI, null, AMOUNT, BALANCE, null, DESCRIPTION ], ... ]
Return type: list Example
bfx_client.ledgers('IOT')
-
user_settings_read
(pkey)[source]¶ Bitfinex user settings read reference
Read user settings
Parameters: pkey (str) – Requested Key Returns: [ [ KEY VALUE ], ... ]
Return type: list Example
none available
-
user_settings_write
(pkey)[source]¶ Bitfinex user settings write reference
Write user settings
Warning
Not Implemented
-
user_settings_delete
(pkey)[source]¶ Bitfinex user settings delete reference
Delete user settings
Warning
Not Implemented
-