mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
websocket: support events pu, pc, pn
This commit is contained in:
@@ -368,7 +368,17 @@ class BfxRest:
|
|||||||
async def get_ledgers(self, symbol, start, end, limit=25, category=None):
|
async def get_ledgers(self, symbol, start, end, limit=25, category=None):
|
||||||
"""
|
"""
|
||||||
Get all ledgers on account associated with API_KEY - Requires authentication.
|
Get all ledgers on account associated with API_KEY - Requires authentication.
|
||||||
|
|
||||||
|
You can emit the symbol param in order to receive ledger entries for all symbols.
|
||||||
See category filters here: https://docs.bitfinex.com/reference#rest-auth-ledgers
|
See category filters here: https://docs.bitfinex.com/reference#rest-auth-ledgers
|
||||||
|
|
||||||
|
# Attributes
|
||||||
|
@param symbol string: pair symbol i.e tBTCUSD - can be omitted to receive all entries
|
||||||
|
@param start int: start of window
|
||||||
|
@param end int: end of window
|
||||||
|
@param limit int: max number of entries
|
||||||
|
@param category int: filter category to receive specific ledger entries
|
||||||
|
|
||||||
@return Array <models.Ledger>
|
@return Array <models.Ledger>
|
||||||
"""
|
"""
|
||||||
endpoint = ("auth/r/ledgers/{}/hist".format(symbol)
|
endpoint = ("auth/r/ledgers/{}/hist".format(symbol)
|
||||||
|
|||||||
@@ -126,26 +126,29 @@ class BfxWebsocket(GenericWebsocket):
|
|||||||
- `wallet_snapshot` (array[Wallet]): Initial wallet balances (Fired once)
|
- `wallet_snapshot` (array[Wallet]): Initial wallet balances (Fired once)
|
||||||
- `order_snapshot` (array[Order]): Initial open orders (Fired once)
|
- `order_snapshot` (array[Order]): Initial open orders (Fired once)
|
||||||
- `positions_snapshot` (array): Initial open positions (Fired once)
|
- `positions_snapshot` (array): Initial open positions (Fired once)
|
||||||
- `wallet_update` (Wallet): changes to the balance of wallets
|
- `positions_new` (array): Initial open positions (Fired once)
|
||||||
- `status_update` (Object): new platform status info
|
- `positions_update` (array): An active position has been updated
|
||||||
- `seed_candle` (Object): initial past candle to prime strategy
|
- `positions_close` (array): An active position has closed
|
||||||
- `seed_trade` (Object): initial past trade to prime strategy
|
- `wallet_update` (Wallet): Changes to the balance of wallets
|
||||||
- `funding_offer_snapshot` (array): opening funding offer balances
|
- `status_update` (Object): New platform status info
|
||||||
- `funding_loan_snapshot` (array): opening funding loan balances
|
- `seed_candle` (Object): Initial past candle to prime strategy
|
||||||
- `funding_credit_snapshot` (array): opening funding credit balances
|
- `seed_trade` (Object): Initial past trade to prime strategy
|
||||||
- `balance_update` (array): when the state of a balance is changed
|
- `funding_offer_snapshot` (array): Opening funding offer balances
|
||||||
- `new_trade` (array): a new trade on the market has been executed
|
- `funding_loan_snapshot` (array): Opening funding loan balances
|
||||||
- `new_ticker` (Ticker|FundingTicker): a new ticker update has been published
|
- `funding_credit_snapshot` (array): Opening funding credit balances
|
||||||
- `new_funding_ticker` (FundingTicker): a new funding ticker update has been published
|
- `balance_update` (array): When the state of a balance is changed
|
||||||
- `new_trading_ticker` (Ticker): a new trading ticker update has been published
|
- `new_trade` (array): A new trade on the market has been executed
|
||||||
- `trade_update` (array): a trade on the market has been updated
|
- `new_ticker` (Ticker|FundingTicker): A new ticker update has been published
|
||||||
- `new_candle` (array): a new candle has been produced
|
- `new_funding_ticker` (FundingTicker): A new funding ticker update has been published
|
||||||
- `margin_info_updates` (array): new margin information has been broadcasted
|
- `new_trading_ticker` (Ticker): A new trading ticker update has been published
|
||||||
- `funding_info_updates` (array): new funding information has been broadcasted
|
- `trade_update` (array): A trade on the market has been updated
|
||||||
- `order_book_snapshot` (array): initial snapshot of the order book on connection
|
- `new_candle` (array): A new candle has been produced
|
||||||
- `order_book_update` (array): a new order has been placed into the ordebrook
|
- `margin_info_updates` (array): New margin information has been broadcasted
|
||||||
- `subscribed` (Subscription): a new channel has been subscribed to
|
- `funding_info_updates` (array): New funding information has been broadcasted
|
||||||
- `unsubscribed` (Subscription): a channel has been un-subscribed
|
- `order_book_snapshot` (array): Initial snapshot of the order book on connection
|
||||||
|
- `order_book_update` (array): A new order has been placed into the ordebrook
|
||||||
|
- `subscribed` (Subscription): A new channel has been subscribed to
|
||||||
|
- `unsubscribed` (Subscription): A channel has been un-subscribed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, API_KEY=None, API_SECRET=None, host='wss://api-pub.bitfinex.com/ws/2',
|
def __init__(self, API_KEY=None, API_SECRET=None, host='wss://api-pub.bitfinex.com/ws/2',
|
||||||
@@ -178,6 +181,9 @@ class BfxWebsocket(GenericWebsocket):
|
|||||||
'os': self._order_snapshot_handler,
|
'os': self._order_snapshot_handler,
|
||||||
'ws': self._wallet_snapshot_handler,
|
'ws': self._wallet_snapshot_handler,
|
||||||
'ps': self._position_snapshot_handler,
|
'ps': self._position_snapshot_handler,
|
||||||
|
'pu': self._position_update_handler,
|
||||||
|
'pn': self._position_new_handler,
|
||||||
|
'pc': self._position_close_handler,
|
||||||
'fos': self._funding_offer_snapshot_handler,
|
'fos': self._funding_offer_snapshot_handler,
|
||||||
'fcs': self._funding_credit_snapshot_handler,
|
'fcs': self._funding_credit_snapshot_handler,
|
||||||
'fls': self._funding_load_snapshot_handler,
|
'fls': self._funding_load_snapshot_handler,
|
||||||
@@ -339,6 +345,18 @@ class BfxWebsocket(GenericWebsocket):
|
|||||||
self._emit('position_snapshot', data)
|
self._emit('position_snapshot', data)
|
||||||
self.logger.info("Position snapshot: {}".format(data))
|
self.logger.info("Position snapshot: {}".format(data))
|
||||||
|
|
||||||
|
async def _position_update_handler(self, data):
|
||||||
|
self._emit('position_update', data)
|
||||||
|
self.logger.info("Position update: {}".format(data))
|
||||||
|
|
||||||
|
async def _position_close_handler(self, data):
|
||||||
|
self._emit('position_close', data)
|
||||||
|
self.logger.info("Position close: {}".format(data))
|
||||||
|
|
||||||
|
async def _position_new_handler(self, data):
|
||||||
|
self._emit('position_new', data)
|
||||||
|
self.logger.info("Position new: {}".format(data))
|
||||||
|
|
||||||
async def _funding_offer_snapshot_handler(self, data):
|
async def _funding_offer_snapshot_handler(self, data):
|
||||||
self._emit('funding_offer_snapshot', data)
|
self._emit('funding_offer_snapshot', data)
|
||||||
self.logger.info("Funding offer snapshot: {}".format(data))
|
self.logger.info("Funding offer snapshot: {}".format(data))
|
||||||
|
|||||||
@@ -63,23 +63,29 @@ https://github.com/Crypto-toolbox/btfxwss
|
|||||||
- `wallet_snapshot` (array[Wallet]): Initial wallet balances (Fired once)
|
- `wallet_snapshot` (array[Wallet]): Initial wallet balances (Fired once)
|
||||||
- `order_snapshot` (array[Order]): Initial open orders (Fired once)
|
- `order_snapshot` (array[Order]): Initial open orders (Fired once)
|
||||||
- `positions_snapshot` (array): Initial open positions (Fired once)
|
- `positions_snapshot` (array): Initial open positions (Fired once)
|
||||||
- `wallet_update` (Wallet): changes to the balance of wallets
|
- `positions_new` (array): Initial open positions (Fired once)
|
||||||
- `status_update` (Object): new platform status info
|
- `positions_update` (array): An active position has been updated
|
||||||
- `seed_candle` (Object): initial past candle to prime strategy
|
- `positions_close` (array): An active position has closed
|
||||||
- `seed_trade` (Object): initial past trade to prime strategy
|
- `wallet_update` (Wallet): Changes to the balance of wallets
|
||||||
- `funding_offer_snapshot` (array): opening funding offer balances
|
- `status_update` (Object): New platform status info
|
||||||
- `funding_loan_snapshot` (array): opening funding loan balances
|
- `seed_candle` (Object): Initial past candle to prime strategy
|
||||||
- `funding_credit_snapshot` (array): opening funding credit balances
|
- `seed_trade` (Object): Initial past trade to prime strategy
|
||||||
- `balance_update` (array): when the state of a balance is changed
|
- `funding_offer_snapshot` (array): Opening funding offer balances
|
||||||
- `new_trade` (array): a new trade on the market has been executed
|
- `funding_loan_snapshot` (array): Opening funding loan balances
|
||||||
- `trade_update` (array): a trade on the market has been updated
|
- `funding_credit_snapshot` (array): Opening funding credit balances
|
||||||
- `new_candle` (array): a new candle has been produced
|
- `balance_update` (array): When the state of a balance is changed
|
||||||
- `margin_info_updates` (array): new margin information has been broadcasted
|
- `new_trade` (array): A new trade on the market has been executed
|
||||||
- `funding_info_updates` (array): new funding information has been broadcasted
|
- `new_ticker` (Ticker|FundingTicker): A new ticker update has been published
|
||||||
- `order_book_snapshot` (array): initial snapshot of the order book on connection
|
- `new_funding_ticker` (FundingTicker): A new funding ticker update has been published
|
||||||
- `order_book_update` (array): a new order has been placed into the ordebrook
|
- `new_trading_ticker` (Ticker): A new trading ticker update has been published
|
||||||
- `subscribed` (Subscription): a new channel has been subscribed to
|
- `trade_update` (array): A trade on the market has been updated
|
||||||
- `unsubscribed` (Subscription): a channel has been un-subscribed
|
- `new_candle` (array): A new candle has been produced
|
||||||
|
- `margin_info_updates` (array): New margin information has been broadcasted
|
||||||
|
- `funding_info_updates` (array): New funding information has been broadcasted
|
||||||
|
- `order_book_snapshot` (array): Initial snapshot of the order book on connection
|
||||||
|
- `order_book_update` (array): A new order has been placed into the ordebrook
|
||||||
|
- `subscribed` (Subscription): A new channel has been subscribed to
|
||||||
|
- `unsubscribed` (Subscription): A channel has been un-subscribed
|
||||||
|
|
||||||
|
|
||||||
## enable_flag
|
## enable_flag
|
||||||
|
|||||||
Reference in New Issue
Block a user