
    ":hk                         d dl Zd dlmZmZmZ d dlZd dlmZm	Z	m
Z
mZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ  G d
 dej4                  j6                        Zy)    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheByTimestamp)AnyBalancesIntOrder	OrderBookStrTickerTrade)Client)List)ExchangeError)AuthenticationError)ChecksumError)Precisec            
           e Zd Zdef fdZi fdZd Zdddi fdeded	ede	e
   fd
ZdefdZddi fdeded	ede	e   fdZdddi fdeded	ede	e   fdZi fdedefdZi fdefdZdefdZd$dZdefdZd$dZdi fded	edefdZdefdZdefdZi fdefdZdefdZd Z defdZ!defdZ"i fdZ#defdZ$dddi fdeded	ede	e%   fdZ&defd Z'd! Z(d$d"Z)defd#Z* xZ+S )%bitfinexreturnc                     | j                  t        t        |          ddddddddddd
dddddiid	d
ddddd      S )NTF)
wswatchTickerwatchTickerswatchOrderBookwatchTradeswatchTradesForSymbolswatchMyTradeswatchBalance
watchOHLCVwatchOrdersapir   zwss://api-pub.bitfinex.com/ws/2zwss://api.bitfinex.com/ws/2)publicprivateP0F0)precfreqchecksum  )r   ordersLimit)hasurlsoptions)deep_extendsuperr   describe)self	__class__s    K/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/pro/bitfinex.pyr1   zbitfinex.describe   s    h > @# %"&#).!% $"# "C#@ !  $#
  $+C
  	    c                   K   | j                          d {    | j                  |      }|d   }| j                  d   d   d   }| j                  |      }|dz   |z   }d||d}	| j	                  ||| j                  |	|      |dd	i       d {   }
| j                  | j                  dd
      }|rE|j                  |   d   s3|dk(  r.d
|j                  |   d<   |j                  ddd       d {    |
S 7 7 l7 
w)Nidr"   r   r#   :	subscribe)eventchannelsymbolr)   FTbookconfi   )r:   flags)
load_marketsmarketr-   clientwatchr/   	safe_boolr.   subscriptionssend)r2   r;   r<   paramsrA   marketIdurlrB   messageHashrequestresultr)   s               r4   r9   zbitfinex.subscribe4   s%    !!!V$$<iit$X.S!mh. 

 zz#{D4D4DWf4UWbeoqvdwxx>>$,,
DAF00=jIwZ`O`<@F  -j9++    ' 	" ys5   D C:A8D C<A#D 3C>4D <D >D c                    K   | j                          d {    | j                          d {    | j                  d   d   d   }| j                  ||d d       d {   S 7 M7 77 w)Nr"   r   r$      )r@   authenticater-   rC   )r2   rJ   rI   s      r4   subscribe_privatezbitfinex.subscribe_privateJ   sg     !!!!!!iit$Y/ZZ[$::: 	"!:s1   A*A$A*A&0A*A( A*&A*(A*1mNr<   sincelimitc                   K   | j                          d{    | j                  |      }|d   }| j                  | j                  ||      }d}d|z   dz   |d   z   }	|dz   |z   dz   |d   z   }
d||	d}| j                  d	   d
   d   }| j                  ||
| j                  ||      |
       d{   }| j                  r|j                  ||      }| j                  |||dd      S 7 7 9w)aQ  
        watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr<   candlestrade:r8   r7   r9   )r:   r;   keyr"   r   r#   r   T)
r@   rA   safe_string
timeframesr-   rC   r/   
newUpdatesgetLimitfilter_by_since_limit)r2   r<   	timeframerR   rS   rG   rA   intervalr;   rW   rJ   rK   rI   ohlcvs                 r4   watch_ohlcvzbitfinex.watch_ohlcvP   s     !!!V$!##DOOY	J!C'&,6mh.4vd|C 

 iit$X.jjk43C3CGV3TVabb??NN651E))%q$GG# 	" cs"   C-C)BC-1C+28C-+C-rB   c                    | j                  |dg       }d }| j                  |d      }t        |t              r|}n|g}| j                  |d      }| j                  |d      }|j	                  d      }	| j                  |	d      }
|}|j                  dd      }|j                  |
dz   d      }| j                  |      }| j                  |
      }|d   }|dz   |
z   dz   |z   }| j                  | j                  |i       | j                  |<   | j                  | j                  |   |      }|:| j                  | j                  d	d
      }t        |      }|| j                  |   |<   t        |      }t        d|      D ]0  }|||z
  dz
     }| j                  ||      }|j                  |       2 |j!                  ||       y )NrN   r   r;   rW   r8   rV    r<   
OHLCVLimitr*   )
safe_value
isinstancelistrX   splitreplacesafe_marketfind_timeframeohlcvssafe_integerr.   r   lenrangeparse_ohlcvappendresolve)r2   rB   messagesubscriptiondatark   firstr;   rW   keyPartsr^   rH   rA   r]   r<   rJ   storedrS   ohlcvsLengthir_   parseds                         r4   handle_ohlcvzbitfinex.handle_ohlcvm   s   \ w2.a(eT"F VF//,	:|U399S>##Ha0##Hb1##HsNB7!!(+''1	!mh.4x?"oodkk62FFV!4i@>%%dllL$GE*51F-3DKK	*6{q,' 	"A<!+a/0E%%eV4FMM&!	" 	v{+r5   c                    K   | j                  d||       d{   }| j                  r|j                  ||      }| j                  |||dd      S 7 7w)a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        tradesN	timestampT)r9   rZ   r[   r\   )r2   r<   rR   rS   rG   r}   s         r4   watch_tradeszbitfinex.watch_trades   sS      ~~h????OOFE2E))&%TRR @s   AA8Ac                   K   | j                          d{    d}|| j                  |      }|d|d   z   z  }| j                  |       d{   }| j                  r|j	                  ||      }| j                  ||||d      S 7 p7 9w)a  
        watches information on multiple trades made by the user
        :param str symbol: unified market symbol of the market trades were made in
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NmyTrader8   r7   Tr@   rA   rP   rZ   r[   filter_by_symbol_since_limit)r2   r<   rR   rS   rG   rJ   rA   r}   s           r4   watch_my_tradeszbitfinex.watch_my_trades   s      !!![[(F3--K--k::??OOFE2E00tTT 	"
 ;!   BB8BB	8B	Bc                 D   K   | j                  d||       d{   S 7 w)a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        tickerN)r9   )r2   r<   rG   s      r4   watch_tickerzbitfinex.watch_ticker   s!      ^^Hff====s     c                    d}| j                  |d      }| j                  |      }|d   }| j                  |      }|dz   |d   z   }	| j                  -| j	                  | j
                  dd      }
t        |
      | _        | j                  }|j                  |       || _        |j                  ||       |j                  ||	       y )Nr      r<   r8   r7   tradesLimitr*   )	rd   parse_ws_traderA   myTradesrl   r.   r   rp   rq   )r2   rB   rr   rs   namert   trader<   rA   rJ   rS   tradesArrays               r4   handle_my_tradezbitfinex.handle_my_trade   s    , w*##D)xV$Sj6$</== %%dllM4HE259DMmm5!#{D){K0r5   c                    | j                  |d      }| j                  |d      }| j                  |      }|dz   |z   }| j                  | j                  dd      }|d   }	| j                  | j
                  |	      }
|
t        |      }
|
| j
                  |	<   t        |      }|dk(  r^| j                  |dg       }t        |      }t        d|      D ]0  }||z
  dz
  }| j                  ||   |      }|
j                  |       2 nN| j                  |d      }|d	k(  ry | j                  |dg       }| j                  ||      }|
j                  |       |j                  |
|       y )
Nr;   r<   r8   r   r*   r   rN   r   tu)rd   rX   ri   rl   r.   r}   r   rm   	safe_listrn   r   rp   rq   )r2   rB   rr   rs   r;   rH   rA   rJ   r   r<   rw   messageLengthr}   lengthry   indexrz   typer   s                      r4   handle_tradeszbitfinex.handle_trades  sf   > //,	:##L(;!!(+mh.''mTJ!f5>,F"(DKKGA^^GQ3F[F1f% &
Q,,VE]FCf%& ##GQ/Dt| OOGQ3E((7FMM&!v{+r5   c                    t        |      }|dk  }|s| j                  |d      nd }| j                  ||      }|rdnd}|rdnd}|rdnd}|d   }| j                  |d      }	|	-|	j                  d	      d
kD  rd}	n|	j                  d      d
kD  rd}	|s| j                  |d      nd }
| j                  |d      }| j	                  ||      }| j                  ||      }| j                  ||      }| j                  t        j                  |            }d }|t        j                  |d      rdnd}| j                  ||      }| j                  |d      }d }|(| j                  |d      }| j                  |      }||d}| j	                  |d      }d }|	|d
k(  rdnd}| j                  ||| j                  |      |||
|	||||d |d|      S )N   rN   r            r7      LIMITrS   MARKETrA   r   0buysell	   
   )costcurrencytakermaker)infor~   datetimer<   r7   orderr   takerOrMakersidepriceamountr   fee)rm   rX   ri   findrl   parse_numberr   
string_abs	string_gtsafe_symbolsafe_currency_code
safe_tradeiso8601)r2   r   rA   	numFieldsisPublicrH   
createdKeypriceKey	amountKeyr   orderIdr7   r~   r   amountStringr   r   r<   feeValuer   
currencyIdcoder   r   s                           r4   r   zbitfinex.parse_ws_tradeL  s   V J	>6>4##E1-T!!(F3"Q
 1a!Aq	$<q)yy!B&8$r)5=$""5!,DeQ'%%eZ8	  1''y9""7#5#5l#CD#--lC@5fD!!(F3##E1-))%4J**:6D  C !!%+',{7L"Y/( 
  	r5   c                 
   | j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j	                  ||      }d}	|	dz   |z   }
|| j
                  |<   |j                  ||
       y )NrN   r<   r   r8   )rd   rX   ri   r   parse_ws_tickertickersrq   )r2   rB   rr   rs   r   rH   rA   r<   rz   r;   rJ   s              r4   handle_tickerzbitfinex.handle_ticker  s    $ !,##L(;!!(+!!(+%%ff5mh.%Vv{+r5   c                    | j                  d |      }|d   }| j                  |d      }| j                  |d      }| j                  i d|dd dd d| j                  |d      d| j                  |d	      d
| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      dd dd d|d|dd d|d| j                  |d      dd | j                  |d      d |d|      S )Nr<   r   r   r~   r   highr   lowr   bidr   	bidVolumerN   askr   	askVolumer   vwapopencloselastpreviousClosechange
percentager   average   )
baseVolumequoteVolumer   )ri   rX   safe_ticker)r2   r   rA   r<   r   r   s         r4   r   zbitfinex.parse_ws_ticker  s    !!$/!*!!&!, !
f!
!
 !
 D$$VQ/	!

 4##FA.!
 4##FA.!
 ))&!4!
 4##FA.!
 ))&!4!
 D!
 D!
 T!
 D!
 T!
 f!
  $**615!!
" t#!
$ **615)!
* + 	r5   c                 j  K   |"|dk7  r|dk7  rt        | j                  dz         | j                  | j                  di       }| j	                  |dd      }| j	                  |dd	      }||d
}|||d<   | j                  d|| j                  ||             d{   }|j                         S 7 w)a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        N   d   z6 watchOrderBook limit argument must be None, 25 or 100r   r'   r%   r(   r&   )r'   r(   rm   r=   )r   r7   rd   r.   rX   r9   r/   rS   )	r2   r<   rS   rG   r.   r'   r(   rK   	orderbooks	            r4   watch_order_bookzbitfinex.watch_order_book  s      %3,#DGG.f$fgg//$,,0@"E66
 "GEN..9I9I'SY9Z[[	   \s   BB3B1B3c                    | j                  |d      }| j                  |      }d}|dz   |z   }| j                  |dd      }|dk(  }	|| j                  vr|| j                  |d      }
|	r | j	                  i |
      | j                  |<   n| j                  i |
      | j                  |<   | j                  |   }|	rz|d   }t        d	t        |            D ]\  }||   }|d
   }|d	k  r| n|}|d	k  rdnd}||   }| j                  |d	      }| j                  |d      }|j                  |||g       ^ n|d   }t        d	t        |            D ]i  }||   }| j                  |d
      }| j                  |d      }| j                  |d	      }|d	k  r| n|}|d	k  rdnd}||   }|j                  |||g       k ||d<   |j                  ||       y | j                  |   }|d   }| j                  |   }|	r| j                  |d      }|d
   }|d	k  r| n|}|d	k  rdnd}||   }t        j                  |d      r|nd}| j                  |d	      }|j                  | j                  |      | j                  |      |g       n| j                  |d
      }| j                  |d      }| j                  |d	      }t        j                  |d      rt        j                   |      n|}t        j                  |d      rdnd}||   }|j                  | j                  |      | j                  |      | j                  |      g       |j                  ||       y )Nr<   r=   r8   r'   r%   R0rm   rN   r   r   asksbidsr   )rX   r   
orderbooksrl   indexed_order_bookcounted_order_bookrn   rm   
safe_float
storeArraysafe_numberrq   r   r   r   	string_lt
string_neg)r2   rB   rr   rs   rH   r<   r;   rJ   r'   isRawrS   r   deltasry   deltadelta2sizer   booksideidStringr   r   counterorderbookItemdeltas2s                            r4   handle_order_bookzbitfinex.handle_order_book	  s   6 ##L(;!!(+mh.fd;$//)%%lE:E*.*A*A"e*L' +/*A*A"e*L'/I q#f+. AA"1IE"1XF'-zF7D&,qj6vD(H#//q9H OOE15E''h(?@A !q#f+. @A"1IE!--eQ7F"..ua8G ,,UA6E'-zF7D&,qj6vD(H''g(>?@ #)IhNN9k2/IQZF OOF3M((3 )$+aKxg")A+vF(.!(!2!25#!>C++FA6##T%6%6u%=t?P?PQW?XZb$cd))&!4**615((35<5F5Fvs5Sw))&1Y_!(!2!263!?vV(.##T%6%6u%=t?P?PQU?VX\XiXijqXr$stNN9k2r5   c                    | j                  |d      }| j                  |      }d}|dz   |z   }| j                  | j                  |      }|y d}	g }
|d   }|d   }| j                  |dd      }|d	k(  }|rd
nd}t	        d|	      D ]  }| j                  ||      }| j                  ||      }|L|
j                  | j                  ||   |                |
j                  | j                  ||   d                |x|
j                  | j                  ||   |                ||   d   }|
j                  | j                  |               dj                  |
      }| j                  |d      }| j                  |d
      }||k7  rm|j                  |= | j                  |= | j                  ddd      }|r=t        | j                  dz   | j                  |      z         }|j                  ||       y y y )Nr<   r=   r8   r   r   r   r'   r%   r   r   r   rN   Tr   r)    )rX   r   rd   r   rn   rp   number_to_stringjoincrc32rl   rE   handle_optionr   r7   orderbook_checksum_messagereject)r2   rB   rr   rs   rH   r<   r;   rJ   r=   depthstringArrayr   r   r'   r   	idToCheckry   r   r   aski1payloadlocalChecksumresponseChecksumr)   errors                            r4   handle_checksumzbitfinex.handle_checksumd  s    ##L(;!!(+mh.t7<F|F|fd;AA	q% 		BA//$*C//$*C""4#8#8a9K#LM""4#8#8a#DE""4#8#8a9K#LMQ
""4#8#8%#@A		B ((;'

7D1,,Wa8},$$[1'))*:JMH%dggmd6U6UV\6]&]^e[1 	 -r5   c                    K   | j                          d{    | j                  |dd      }| j                  |d      }d|z   }| j                  |       d{   S 7 G7 w)a  
        watch balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: spot or contract if not provided self.options['defaultType'] is used
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nwalletexchangebalance:)r@   rX   omitrP   )r2   rG   balanceTyperJ   s       r4   watch_balancezbitfinex.watch_balance  sg      !!!&&vxD68, ;.++K888	 	" 9s"   A"AAA"A A" A"c                    | j                  |d      }d }|dk(  r| j                  |d      }n| j                  |d      g}i }t        dt        |            D ]  }||   }| j                  |d      }	| j	                  |	      }
| j                  |      }| j                  |d      }| j                  | j                  |i       }|||
<   ||d<   | j                  |      | j                  |<   d||<    t        |j                               }t        dt        |            D ]+  }||   }d|z   }|j                  | j                  |   |       - y )NrN   r   r   r   r   Tr  )rd   rn   rm   rX   r   parse_ws_balancebalancesafe_balancerf   keysrq   )r2   rB   rr   rs   
updateTypert   updatedTypesry   
rawBalancer   r   r  r  
oldBalanceupdatesKeysr   rJ   s                    r4   handle_balancezbitfinex.handle_balance  sX   ~ __Wa0
??7A.DOOGQ/0Dq#d)$ 
	-AaJ))*a8J**:6D++J7G**:q9K{BGJ&Jt!(Jv(,(9(9*(EDLL%(,L%
	- <,,./q#k*+ 	<Aq>D$t+KNN4<<-{;	<r5   c                     | j                  |d      }| j                  |d      }| j                         }|||d<   ||d<   |S )Nr   r   freetotal)rX   account)r2   r  totalBalanceavailableBalancer  s        r4   r  zbitfinex.parse_ws_balance  sR     ''3++GQ7,,.'.GFO'r5   c                     |S N )r2   rB   rr   s      r4   handle_system_statuszbitfinex.handle_system_status  s	     r5   c                 H    | j                  |d      }||j                  |<   |S )NchanId)rX   rE   )r2   rB   rr   	channelIds       r4   handle_subscription_statusz#bitfinex.handle_subscription_status  s+     $$Wh7	*1Y'r5   c                   K   | j                   d   d   d   }| j                  |      }d}|j                  |      }| j                  |j                  |      }|| j                         }dt        |      z   }| j                  | j                  |      | j                  | j                        t        j                  d      }	d}
| j                  |	|||
d}| j                  ||      }| j                  ||||       | d {   S 7 w)	Nr"   r   r$   authenticatedAUTHhexauth)apiKeyauthSig	authNonceauthPayloadr:   )r-   rB   futurerd   rE   millisecondsstrhmacencodesecrethashlibsha384r/  extendrC   )r2   rG   rI   rB   rJ   r3  r+  noncer  	signaturer:   rK   rr   s                r4   rO   zbitfinex.authenticate   s     iit$Y/S!%{+(<(<kJ %%'Es5z)G		$++g"6DKK8PRYR`R`bghIE++$"&G kk'62GJJsK+>||s   C?DDDc                 "   d}| j                  |d      }|dk(  r.| j                  |j                  |      }|j                  d       y t	        | j                  |            }|j                  ||       ||j                  v r|j                  |= y y )Nr+  statusOKT)rX   rd   futuresrq   r   jsonr   rE   )r2   rB   rr   rJ   r?  r3  r  s          r4   handle_authentication_messagez&bitfinex.handle_authentication_message6  s    %!!'84T>__V^^[AFNN4 '		'(:;EMM%-f222((5 3r5   c                   K   | j                          d{    d}|| j                  |      }|d|d   z   z  }| j                  |       d{   }| j                  r|j	                  ||      }| j                  ||||d      S 7 p7 9w)a  
        watches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nordersr8   r7   Tr   )r2   r<   rR   rS   rG   rJ   rA   rE  s           r4   watch_orderszbitfinex.watch_ordersD  s      !!![[(F3--K--k::??OOFE2E00tTT 	"
 ;r   c                    | j                  |dg       }| j                  |d      }| j                  -| j                  | j                  dd      }t        |      | _        | j                  }i }|dk(  r]t        |      }	|	dk(  ry t        dt        |            D ]3  }
||
   }| j                  |      }|d   }d||<   |j                  |       5 n,| j                  |      }|j                  |       |d   }d||<   d	}|j                  | j                  |       t        |j                               }t        dt        |            D ]?  }
||
   }| j                  |      }|d
z   |d   z   }|j                  | j                  |       A y )Nr   rN   r+   r*   osr   r<   TrE  r8   r7   )rd   rX   rE  rl   r.   r   rm   rn   parse_ws_orderrp   rq   rf   r  rA   )r2   rB   rr   rs   rt   messageTyperS   rE  	symbolIdssnapshotLengthry   valuerz   r<   r   r  rA   rJ   s                     r4   handle_orderszbitfinex.handle_ordersW  s   R w2.&&w2;;%%dllM4HE07DK	$ YN"1c$i( &Q,,U3)$(	&!f%& ((.FMM&!H%F $Ift{{D)INN$%q#d)$ 	5A!WF[[(F*vd|3KNN4;;4		5r5   c                 6    ddddd}| j                  |||      S )Nr   canceledclosed)ACTIVECANCELEDEXECUTED	PARTIALLY)rX   )r2   r?  statusess      r4   parse_ws_order_statuszbitfinex.parse_ws_order_status  s,    " 	
 &&99r5   c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j                  |d      }d}t        j                  |d      rt        j
                  |      }d}t        j
                  | j                  |d            }	| j                  |d	      }
|
j                  d
      dkD  rd}
n|
j                  d      dkD  rd}
| j                  |d      }|j                  d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |dd      }| j                  |d      }| j                  | j                  |d            }| j                  i d|d|d|d|d| j                  |      dd d|d|
d|d|d |d!|d"|d#|d$|	d%d d&|d d d d'|      S )(Nr   rN   r   r   r   r   r   r   r   r   r   rS   r   rA      r      r   r         r   r7   clientOrderIdr~   r   lastTradeTimestampr<   r   r   r   	stopPricetriggerPricer   r   	remainingfilledr?  )r   r   r}   )rX   r   ri   r   r   r   r   rg   rW  safe_integer_2	omit_zero
safe_orderr   )r2   r   rA   r7   r]  rH   r<   r   r   ra  r   rawState
statePartstrimmedStatusr?  r   r~   r   r_  s                      r4   rI  zbitfinex.parse_ws_order  s   J eQ'((2##E1-!!(+!!&)!!%+VS)''/FD&&t'7'7q'AB	q)99W"DYYx 2%D##E2.^^C(
((Q7++M:  +''q!4	""5"-NN4#3#3E2#>?	  
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 f 
 D 
 D 
 U 
  
 I 
 w 
 f 
  
  d! 
" f# 
$ ) 
* + 	r5   c                    | j                  |d      }t        |t              r|d   dk(  ry | j                  |j                  |i       }| j                  |d      }| j                  |d      }| j
                  | j                  | j                  | j                  | j                  d}| j                  | j                  | j                  | j                  | j                  | j                  | j                  d}d }	|dk(  r| j                  ||      }	n| j                  |||      }	|	 |	|||       y y | j                  |d      }
|
C| j                  | j                  | j                   d	}| j                  ||
      }	|	
 |	||       y y y )
Nr   rN   hbr;   )r=   csrU   r   r}   )rH  ouonocwur   r   r   r:   )r   
subscribedr.  )rX   re   rf   rd   rE   r   r	  r{   r   r   rN  r  r   safe_value_2r%  r)  rC  )r2   rB   rr   r(  rs   r;   r   publicMethodsprivateMethodsmethodr:   methodss               r4   handle_messagezbitfinex.handle_message  s   $$Wa0	4 gt$qzT!??6+?+?BOL&&|Y?G##GQ/D..**,,,,,,#M (((((((())))**$N FC>**=$H!vw5 " $$Wg6E  55"&"A"A >>!
 %8%67+ & !r5   r#  ),__name__
__module____qualname__r   r1   r9   rP   r5  r   r   rf   r`   r   r{   r   r   r   r   r   r   r   r   r   r   r   r
   r   r   r	  r   r  r  r  r%  r)  rO   rC  r	   rF  rN  rW  rI  rv  __classcell__)r3   s   @r4   r   r      s$   # @ 79 ,; 8<$]ajl H HC HWZ Hquvzq{ H:M,6 M,^ <@d[] S SS S Sbfglbm S 37TX\eg UC Us URU Ulpqvlw U& 68 > >F > EG %1f %1N=,F =,~^@,F ,8(T @DB !S ! !S\ !.Y3 Y3v&2f &2P *, 9 9U<V U<n(	6 	 " )+ ,6F 6 04$UYbd U UC Us Uimnsit U&F5F F5P:RhB,V B,r5   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   r9  ccxt.base.typesr   r   r   r	   r
   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   ccxt.base.preciser   async_supportr   r$  r5   r4   <module>r     sH     f f  T T T 4  * 0 * %l,t!!** l,r5   