regenerate docs

This commit is contained in:
JacobPlaster
2020-04-14 16:14:48 +01:00
committed by Jacob Plaster
parent d4b0aa9eab
commit 63c7fc3d23
2 changed files with 191 additions and 56 deletions

View File

@@ -1,22 +1,45 @@
# bfxapi
This module is used to interact with the bitfinex api
# bfxapi.client
This module exposes the core bitfinex clients which includes both
a websocket client and a rest interface client
## Client
```python
Client(self, API_KEY=None, API_SECRET=None, rest_host='https://test.bitfinex.com/v2', ws_host='wss://test.bitfinex.com/ws/2', create_event_emitter=None, logLevel='INFO', dead_man_switch=False, ws_capacity=25, *args, **kwargs)
Client(self,
API_KEY=None,
API_SECRET=None,
rest_host='https://api-pub.bitfinex.com/v2',
ws_host='wss://api-pub.bitfinex.com/ws/2',
create_event_emitter=None,
logLevel='INFO',
dead_man_switch=False,
ws_capacity=25,
channel_filter=[],
*args,
**kwargs)
```
The bfx client exposes rest and websocket objects
# BfxRest
```python
BfxRest(self, API_KEY, API_SECRET, host='https://test.bitfinex.com/v2', loop=None, logLevel='INFO', parse_float=<class 'float'>, *args, **kwargs)
BfxRest(self,
API_KEY,
API_SECRET,
host='https://api-pub.bitfinex.com/v2',
loop=None,
logLevel='INFO',
parse_float=float,
*args,
**kwargs)
```
BFX rest interface contains functions which are used to interact with both the public
@@ -24,34 +47,44 @@ and private Bitfinex http api's.
To use the private api you have to set the API_KEY and API_SECRET variables to your
api key.
## fetch
```python
BfxRest.fetch(self, endpoint, params='')
BfxRest.fetch(endpoint, params='')
```
Send a GET request to the bitfinex api
@return reponse
## post
```python
BfxRest.post(self, endpoint, data={}, params='')
BfxRest.post(endpoint, data={}, params='')
```
Send a pre-signed POST request to the bitfinex api
@return response
## get_seed_candles
```python
BfxRest.get_seed_candles(self, symbol, tf='1m')
BfxRest.get_seed_candles(symbol, tf='1m')
```
Used by the honey framework, this function gets the last 4k candles.
## get_public_candles
```python
BfxRest.get_public_candles(self, symbol, start, end, section='hist', tf='1m', limit='100', sort=-1)
BfxRest.get_public_candles(symbol,
start,
end,
section='hist',
tf='1m',
limit='100',
sort=-1)
```
Get all of the public candles between the start and end period.
@@ -68,9 +101,10 @@ __Attributes__
- `@param sort int`: if = 1 it sorts results returned with old > new
@return Array [ MTS, OPEN, CLOSE, HIGH, LOW, VOLUME ]
## get_public_trades
```python
BfxRest.get_public_trades(self, symbol, start, end, limit='100', sort=-1)
BfxRest.get_public_trades(symbol, start, end, limit='100', sort=-1)
```
Get all of the public trades between the start and end period.
@@ -83,9 +117,10 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array [ ID, MTS, AMOUNT, RATE, PERIOD? ]
## get_public_books
```python
BfxRest.get_public_books(self, symbol, precision='P0', length=25)
BfxRest.get_public_books(symbol, precision='P0', length=25)
```
Get the public orderbook for a given symbol.
@@ -97,9 +132,10 @@ __Attributes__
- `@param length int`: number of price points ("25", "100")
@return Array [ PRICE, COUNT, AMOUNT ]
## get_public_ticker
```python
BfxRest.get_public_ticker(self, symbol)
BfxRest.get_public_ticker(symbol)
```
Get tickers for the given symbol. Tickers shows you the current best bid and ask,
@@ -111,9 +147,10 @@ __Attributes__
@return Array [ SYMBOL, BID, BID_SIZE, ASK, ASK_SIZE, DAILY_CHANGE,
DAILY_CHANGE_PERC, LAST_PRICE, VOLUME, HIGH, LOW ]
## get_public_tickers
```python
BfxRest.get_public_tickers(self, symbols)
BfxRest.get_public_tickers(symbols)
```
Get tickers for the given symbols. Tickers shows you the current best bid and ask,
@@ -125,9 +162,10 @@ __Attributes__
@return Array [ SYMBOL, BID, BID_SIZE, ASK, ASK_SIZE, DAILY_CHANGE, DAILY_CHANGE_PERC,
LAST_PRICE, VOLUME, HIGH, LOW ]
## get_derivative_status
```python
BfxRest.get_derivative_status(self, symbol)
BfxRest.get_derivative_status(symbol)
```
Gets platform information for derivative symbol.
@@ -138,9 +176,10 @@ __Attributes__
@return [KEY/SYMBOL, MTS, PLACEHOLDER, DERIV_PRICE, SPOT_PRICE, PLACEHOLDER, INSURANCE_FUND_BALANCE4,
PLACEHOLDER, PLACEHOLDER, FUNDING_ACCRUED, FUNDING_STEP, PLACEHOLDER]
## get_derivative_statuses
```python
BfxRest.get_derivative_statuses(self, symbols)
BfxRest.get_derivative_statuses(symbols)
```
Gets platform information for a collection of derivative symbols.
@@ -151,18 +190,20 @@ __Attributes__
@return [KEY/SYMBOL, MTS, PLACEHOLDER, DERIV_PRICE, SPOT_PRICE, PLACEHOLDER, INSURANCE_FUND_BALANCE4,
PLACEHOLDER, PLACEHOLDER, FUNDING_ACCRUED, FUNDING_STEP, PLACEHOLDER]
## get_wallets
```python
BfxRest.get_wallets(self)
BfxRest.get_wallets()
```
Get all wallets on account associated with API_KEY - Requires authentication.
@return Array <models.Wallet>
## get_active_orders
```python
BfxRest.get_active_orders(self, symbol)
BfxRest.get_active_orders(symbol)
```
Get all of the active orders associated with API_KEY - Requires authentication.
@@ -172,9 +213,10 @@ __Attributes__
- `@param symbol string`: pair symbol i.e tBTCUSD
@return Array <models.Order>
## get_order_history
```python
BfxRest.get_order_history(self, symbol, start, end, limit=25, sort=-1)
BfxRest.get_order_history(symbol, start, end, limit=25, sort=-1)
```
Get all of the orders between the start and end period associated with API_KEY
@@ -188,18 +230,20 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array <models.Order>
## get_active_position
```python
BfxRest.get_active_position(self)
BfxRest.get_active_position()
```
Get all of the active position associated with API_KEY - Requires authentication.
@return Array <models.Position>
## get_order_trades
```python
BfxRest.get_order_trades(self, symbol, order_id)
BfxRest.get_order_trades(symbol, order_id)
```
Get all of the trades that have been generated by the given order associated with API_KEY
@@ -211,9 +255,10 @@ __Attributes__
- `@param order_id string`: id of the order
@return Array <models.Trade>
## get_trades
```python
BfxRest.get_trades(self, symbol, start, end, limit=25)
BfxRest.get_trades(symbol, start, end, limit=25)
```
Get all of the trades between the start and end period associated with API_KEY
@@ -227,18 +272,20 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array <models.Trade>
## get_funding_offers
```python
BfxRest.get_funding_offers(self, symbol)
BfxRest.get_funding_offers(symbol)
```
Get all of the funding offers associated with API_KEY - Requires authentication.
@return Array <models.FundingOffer>
## get_funding_offer_history
```python
BfxRest.get_funding_offer_history(self, symbol, start, end, limit=25)
BfxRest.get_funding_offer_history(symbol, start, end, limit=25)
```
Get all of the funding offers between the start and end period associated with API_KEY
@@ -252,18 +299,20 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array <models.FundingOffer>
## get_funding_loans
```python
BfxRest.get_funding_loans(self, symbol)
BfxRest.get_funding_loans(symbol)
```
Get all of the funding loans associated with API_KEY - Requires authentication.
@return Array <models.FundingLoan>
## get_funding_loan_history
```python
BfxRest.get_funding_loan_history(self, symbol, start, end, limit=25)
BfxRest.get_funding_loan_history(symbol, start, end, limit=25)
```
Get all of the funding loans between the start and end period associated with API_KEY
@@ -277,9 +326,10 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array <models.FundingLoan>
## get_funding_credit_history
```python
BfxRest.get_funding_credit_history(self, symbol, start, end, limit=25)
BfxRest.get_funding_credit_history(symbol, start, end, limit=25)
```
Get all of the funding credits between the start and end period associated with API_KEY
@@ -293,9 +343,15 @@ __Attributes__
- `@param limit int`: max number of items in response
@return Array <models.FundingCredit>
## submit_funding_offer
```python
BfxRest.submit_funding_offer(self, symbol, amount, rate, period, funding_type='LIMIT', hidden=False)
BfxRest.submit_funding_offer(symbol,
amount,
rate,
period,
funding_type='LIMIT',
hidden=False)
```
Submits a new funding offer
@@ -307,9 +363,10 @@ __Attributes__
- `@param rate float`: percentage rate to charge per a day
- `@param period int`: number of days for funding to remain active once accepted
## submit_cancel_funding_offer
```python
BfxRest.submit_cancel_funding_offer(self, fundingId)
BfxRest.submit_cancel_funding_offer(fundingId)
```
Cancel a funding offer
@@ -318,9 +375,11 @@ __Attributes__
- `@param fundingId int`: the id of the funding offer
## submit_wallet_transfer
```python
BfxRest.submit_wallet_transfer(self, from_wallet, to_wallet, from_currency, to_currency, amount)
BfxRest.submit_wallet_transfer(from_wallet, to_wallet, from_currency,
to_currency, amount)
```
Transfer funds between wallets
@@ -333,9 +392,10 @@ __Attributes__
- `@param to_currency string`: currency symbol to transfer to i.e BTC, USD
- `@param amount float`: amount of funds to transfer
## get_wallet_deposit_address
```python
BfxRest.get_wallet_deposit_address(self, wallet, method, renew=0)
BfxRest.get_wallet_deposit_address(wallet, method, renew=0)
```
Get the deposit address for the given wallet and protocol
@@ -345,9 +405,10 @@ __Attributes__
- `@param wallet string`: wallet name i.e margin, exchange
- `@param method string`: transfer protocol i.e bitcoin
## create_wallet_deposit_address
```python
BfxRest.create_wallet_deposit_address(self, wallet, method)
BfxRest.create_wallet_deposit_address(wallet, method)
```
Creates a new deposit address for the given wallet and protocol.
@@ -358,9 +419,10 @@ __Attributes__
- `@param wallet string`: wallet name i.e margin, exchange
- `@param method string`: transfer protocol i.e bitcoin
## submit_wallet_withdraw
```python
BfxRest.submit_wallet_withdraw(self, wallet, method, amount, address)
BfxRest.submit_wallet_withdraw(wallet, method, amount, address)
```
Submits a request to withdraw crypto funds to an external wallet.
@@ -372,9 +434,25 @@ __Attributes__
- `@param amount float`: amount of funds to withdraw
- `@param address string`: external address to withdraw to
## submit_order
```python
BfxRest.submit_order(self, symbol, price, amount, market_type='LIMIT', hidden=False, price_trailing=None, price_aux_limit=None, oco_stop_price=None, close=False, reduce_only=False, post_only=False, oco=False, aff_code=None, time_in_force=None, leverage=None, gid=None)
BfxRest.submit_order(symbol,
price,
amount,
market_type='LIMIT',
hidden=False,
price_trailing=None,
price_aux_limit=None,
oco_stop_price=None,
close=False,
reduce_only=False,
post_only=False,
oco=False,
aff_code=None,
time_in_force=None,
leverage=None,
gid=None)
```
Submit a new order
@@ -402,9 +480,10 @@ __Attributes__
- `@param time_in_force`: datetime for automatic order cancellation ie. 2020-01-01 10:45:23
- `@param leverage`: the amount of leverage to apply to the order as an integer
## submit_cancel_order
```python
BfxRest.submit_cancel_order(self, orderId)
BfxRest.submit_cancel_order(orderId)
```
Cancel an existing open order
@@ -413,9 +492,21 @@ __Attributes__
- `@param orderId`: the id of the order that you want to update
## submit_update_order
```python
BfxRest.submit_update_order(self, orderId, price=None, amount=None, delta=None, price_aux_limit=None, price_trailing=None, hidden=False, close=False, reduce_only=False, post_only=False, time_in_force=None, leverage=None)
BfxRest.submit_update_order(orderId,
price=None,
amount=None,
delta=None,
price_aux_limit=None,
price_trailing=None,
hidden=False,
close=False,
reduce_only=False,
post_only=False,
time_in_force=None,
leverage=None)
```
Update an existing order
@@ -437,9 +528,10 @@ __Attributes__
- `@param time_in_force`: datetime for automatic order cancellation ie. 2020-01-01 10:45:23
- `@param leverage`: the amount of leverage to apply to the order as an integer
## set_derivative_collateral
```python
BfxRest.set_derivative_collateral(self, symbol, collateral)
BfxRest.set_derivative_collateral(symbol, collateral)
```
Update the amount of callateral used to back a derivative position.

View File

@@ -1,22 +1,48 @@
# bfxapi
This module is used to interact with the bitfinex api
# bfxapi.client
This module exposes the core bitfinex clients which includes both
a websocket client and a rest interface client
## Client
```python
Client(self, API_KEY=None, API_SECRET=None, rest_host='https://api-pub.bitfinex.com/v2', ws_host='wss://api-pub.bitfinex.com/ws/2', create_event_emitter=None, logLevel='INFO', dead_man_switch=False, ws_capacity=25, channel_filter=[], *args, **kwargs)
Client(self,
API_KEY=None,
API_SECRET=None,
rest_host='https://api-pub.bitfinex.com/v2',
ws_host='wss://api-pub.bitfinex.com/ws/2',
create_event_emitter=None,
logLevel='INFO',
dead_man_switch=False,
ws_capacity=25,
channel_filter=[],
*args,
**kwargs)
```
The bfx client exposes rest and websocket objects
# BfxWebsocket
```python
BfxWebsocket(self, API_KEY=None, API_SECRET=None, host='wss://api-pub.bitfinex.com/ws/2', manageOrderBooks=False, dead_man_switch=False, ws_capacity=25, logLevel='INFO', parse_float=<class 'float'>, channel_filter=[], *args, **kwargs)
BfxWebsocket(self,
API_KEY=None,
API_SECRET=None,
host='wss://api-pub.bitfinex.com/ws/2',
manageOrderBooks=False,
dead_man_switch=False,
ws_capacity=25,
logLevel='INFO',
parse_float=float,
channel_filter=[],
*args,
**kwargs)
```
More complex websocket that heavily relies on the btfxwss module.
@@ -55,9 +81,10 @@ https://github.com/Crypto-toolbox/btfxwss
- `subscribed` (Subscription): a new channel has been subscribed to
- `unsubscribed` (Subscription): a channel has been un-subscribed
## enable_flag
```python
BfxWebsocket.enable_flag(self, flag)
BfxWebsocket.enable_flag(flag)
```
Enable flag on websocket connection
@@ -66,9 +93,10 @@ __Attributes__
- `flag (int)`: int flag value
## subscribe_order_book
```python
BfxWebsocket.subscribe_order_book(self, symbol)
BfxWebsocket.subscribe_order_book(symbol)
```
Subscribe to an orderbook data feed
@@ -77,9 +105,10 @@ __Attributes__
- `@param symbol`: the trading symbol i.e 'tBTCUSD'
## subscribe_candles
```python
BfxWebsocket.subscribe_candles(self, symbol, timeframe)
BfxWebsocket.subscribe_candles(symbol, timeframe)
```
Subscribe to a candle data feed
@@ -89,9 +118,10 @@ __Attributes__
- `@param symbol`: the trading symbol i.e 'tBTCUSD'
- `@param timeframe`: resolution of the candle i.e 15m, 1h
## subscribe_trades
```python
BfxWebsocket.subscribe_trades(self, symbol)
BfxWebsocket.subscribe_trades(symbol)
```
Subscribe to a trades data feed
@@ -100,9 +130,10 @@ __Attributes__
- `@param symbol`: the trading symbol i.e 'tBTCUSD'
## subscribe_ticker
```python
BfxWebsocket.subscribe_ticker(self, symbol)
BfxWebsocket.subscribe_ticker(symbol)
```
Subscribe to a ticker data feed
@@ -111,9 +142,10 @@ __Attributes__
- `@param symbol`: the trading symbol i.e 'tBTCUSD'
## subscribe_derivative_status
```python
BfxWebsocket.subscribe_derivative_status(self, symbol)
BfxWebsocket.subscribe_derivative_status(symbol)
```
Subscribe to a status data feed
@@ -122,9 +154,10 @@ __Attributes__
- `@param symbol`: the trading symbol i.e 'tBTCUSD'
## subscribe
```python
BfxWebsocket.subscribe(self, *args, **kwargs)
BfxWebsocket.subscribe(*args, **kwargs)
```
Subscribe to a new channel
@@ -136,9 +169,10 @@ __Attributes__
- `@param timeframe`: sepecifies the data timeframe between each candle (only required
for the candles channel)
## unsubscribe
```python
BfxWebsocket.unsubscribe(self, *args, **kwargs)
BfxWebsocket.unsubscribe(*args, **kwargs)
```
Unsubscribe from the channel with the given chanId
@@ -148,32 +182,36 @@ __Attributes__
- `@param onComplete`: function called when the bitfinex websocket resoponds with
a signal that confirms the subscription has been unsubscribed to
## resubscribe
```python
BfxWebsocket.resubscribe(self, *args, **kwargs)
BfxWebsocket.resubscribe(*args, **kwargs)
```
Unsubscribes and then subscribes to the channel with the given Id
This function is mostly used to force the channel to produce a fresh snapshot.
## unsubscribe_all
```python
BfxWebsocket.unsubscribe_all(self, *args, **kwargs)
BfxWebsocket.unsubscribe_all(*args, **kwargs)
```
Unsubscribe from all channels.
## resubscribe_all
```python
BfxWebsocket.resubscribe_all(self, *args, **kwargs)
BfxWebsocket.resubscribe_all(*args, **kwargs)
```
Unsubscribe and then subscribe to all channels
## submit_order
```python
BfxWebsocket.submit_order(self, *args, **kwargs)
BfxWebsocket.submit_order(*args, **kwargs)
```
Submit a new order
@@ -198,16 +236,17 @@ __Attributes__
- `@param oco`: cancels other order option allows you to place a pair of orders stipulating
that if one order is executed fully or partially, then the other is automatically canceled
- `@param time_in_force`: datetime for automatic order cancellation ie. 2020-01-01 10:45:23
- `@param leverage`: the amount of leverage to apply to the order as an integer
- `@param onConfirm`: function called when the bitfinex websocket receives signal that the order
@param time_in_force: datetime for automatic order cancellation ie. 2020-01-01 10:45:23
@param leverage: the amount of leverage to apply to the order as an integer
@param onConfirm: function called when the bitfinex websocket receives signal that the order
was confirmed
- `@param onClose`: function called when the bitfinex websocket receives signal that the order
@param onClose: function called when the bitfinex websocket receives signal that the order
was closed due to being filled or cancelled
## update_order
```python
BfxWebsocket.update_order(self, *args, **kwargs)
BfxWebsocket.update_order(*args, **kwargs)
```
Update an existing order
@@ -233,9 +272,10 @@ __Attributes__
- `@param onClose`: function called when the bitfinex websocket receives signal that the order
was closed due to being filled or cancelled
## cancel_order
```python
BfxWebsocket.cancel_order(self, *args, **kwargs)
BfxWebsocket.cancel_order(*args, **kwargs)
```
Cancel an existing open order
@@ -249,25 +289,28 @@ __Attributes__
- `@param onClose`: function called when the bitfinex websocket receives signal that the order
was closed due to being filled or cancelled
## cancel_order_group
```python
BfxWebsocket.cancel_order_group(self, *args, **kwargs)
BfxWebsocket.cancel_order_group(*args, **kwargs)
```
Cancel a set of orders using a single group id.
## cancel_all_orders
```python
BfxWebsocket.cancel_all_orders(self, *args, **kwargs)
BfxWebsocket.cancel_all_orders(*args, **kwargs)
```
Cancel all existing open orders
This function closes all open orders.
## cancel_order_multi
```python
BfxWebsocket.cancel_order_multi(self, *args, **kwargs)
BfxWebsocket.cancel_order_multi(*args, **kwargs)
```
Cancel existing open orders as a batch