
    ":h-                    f   d dl Zd dlmZmZmZ d dlmZmZm	Z	m
Z
mZ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 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" 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jR                  jT                        Z*y)    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheByTimestamp)AnyBalancesIntNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)ChecksumError)Precisec                       e Zd Zdef fdZdi fdededededed	efd
Zdi fdede	de
ded	edefdZd Zddi fdedede	de
ded	edefdZdi fdee   defdZdi fdededefdZd Zdi fdefdZd Zd ZdefdZdefdZd Zi fdZi fdedefdZdi fdede fdZ!di fdede fdZ"defd Z#dEd!Z$ddi fded"e%d#e%dee&   fd$Z'ddi fdee   d"e%d#e%dee&   fd%Z(di fded#e%de)fd&Z*di fdee   d#e%de)fd'Z+d(ddi fded"e%d#e%dee,   fd)Z-d*i f fd+	Z.i fd,Z/defd-Z0defd.Z1d/ Z2dEd0Z3defd1Z4i fd2Z5dddi fded"e%d#e%fd3Z6dddi fded"e%d#e%dee&   fd4Z7dEdefd5Z8dEd6Z9dddi fded"e%d#e%dee   fd7Z:dEdefd8Z;dEd9Z<ddi fd:ed;edefd<Z=i fde>fd=Z?defd>Z@dFd?ed@edefdAZAdefdBZBdefdCZCdefdDZD xZES )Gkrakenreturnc                 <   | j                  t        t        |          i ddddddddddddddd	dd
dddddddddddddddddddddddddiidddi ddidddt        ii dt        dt
        d t        d!t        d"t        d#t
        d$t        d%t        d&t        d't        d(t        d)t        d*t        d+t        d,t        d-t        d.t        i d/t        d0t        d1t        d2t        d3t        d4t        d5t        d6t        d7t        d8t        d9t        d:t        d;t        d<t        d=t        d>t        d?t        t        t        t        t        t        t        t        t        t        t        d@
dAidB      S )CNwsTwatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderBookForSymbolswatchOrderswatchTickerwatchTickerswatchBidsAskswatchTradeswatchTradesForSymbolscreateOrderWseditOrderWscancelOrderWscancelOrdersWscancelAllOrdersWsapizwss://ws.kraken.comzwss://ws-auth.kraken.comzwss://ws-auth.kraken.com/v2zwss://beta-ws.kraken.comzwss://beta-ws-auth.kraken.com)publicprivate	privateV2betazbeta-private  checksum)tradesLimit
OHLCVLimitordersLimitsymbolsByOrderIdr,   zEvent(s) not foundzAlready subscribedz'Currency pair not in ISO 4217-A3 formatzMalformed requestzPair field must be an arrayz1Pair field unsupported for self subscription typezPair(s) not foundz*Subscription book depth must be an integerz Subscription depth not supportedz$Subscription field must be an objectzSubscription name invalidz%Subscription object unsupported fieldz-Subscription ohlc interval must be an integerz(Subscription ohlc interval not supportedz#Subscription ohlc requires intervalzEAccount:Invalid permissionsz EAuth:Account temporary disabledzEAuth:Account unconfirmedzEAuth:Rate limit exceededzEAuth:Too many requestsz+EDatabase: Internal error(to be deprecated)z EGeneral:Internal error[:<code>]zEGeneral:Invalid argumentsz$EOrder:Cannot open opposing positionzEOrder:Cannot open positionz2EOrder:Insufficient funds(insufficient user funds)z[EOrder:Insufficient margin(exchange does not have sufficient funds to allow margin trading)zEOrder:Invalid pricez EOrder:Margin allowance exceededzEOrder:Margin level too lowzaEOrder:Margin position size exceeded(client would exceed the maximum position size for self pair)z,EOrder:Order minimum not met(volume too low)zEOrder:Orders limit exceededzEOrder:Positions limit exceededzEOrder:Rate limit exceeded)
z&EOrder:Scheduled orders limit exceededzEOrder:Unknown positionzEOrder:Unknown orderzEOrder:Invalid orderzEService:Deadline elapsedz#EService:Market in cancel_only modez"EService:Market in limit_only modez!EService:Market in post_only modezEService:UnavailablezETrade:Invalid request)exactbroad)hasurlsoptions
exceptions)deep_extendsuperr%   describer   r   r   r   r   r    r   r   r   r   r!   r   )self	__class__s    I/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/pro/kraken.pyrL   zkraken.describe   s8   fd < >d   d	
 !$ +D t t    t (   t    !$!" $T#, "7#=%B :(G
  $"#$&# ,j-,j-A9- ,Z- 6z	-
 LZ- ,Y- Ej- ;J- ?
- 4Z- @- H- CJ- >z- 78H-  ;<L!-" 45H#-$ 45F%-& 23D'-( F})-* ;M+-, 5j--. ?/-0 6|1-2 MN_3-4 v  xI5-6 /7-8 ;L9-: 6|;-< |  ~J=-> G?-@ 7A-B :<C-D 56GE-F CO3@0=0<5I?K>J=I0D2<Y-	24[bA
 b b	    Nmethodsymboltyperequestamountpricec                    |j                  d      }|rA|t        | j                  dz         | j                  | j	                  ||            |d   d<   |dk(  }	d }
| j                  |	d|      \  }
}|
rd|d   d<   | j                  |d	      }|||d   d
<   | j                  |d      }|'| j                  | j                  ||            |d   d<   | j                  |di       }| j                  |di       }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }|d u}|d u}| j                  |d      }| j                  |d      }|d u}|d u}| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }|d u}|d u}|d u}|d u} | j                  |dd      }!||!| j                  |      z   nd }"||!| j                  |      z   nd }#||!| j                  |      z   nd }$||!| j                  |      z   nd }%|s| rdnd}&|dk(  r| j                  |d      }'|'rd|d   d<   | j                  |d      }(|(|(|d   d<   | j                  |ddg      }|s
|s|s|s|s| ri |d   d <   |s|ri |d   d!<   |r6d"|d   d!   d#<   | j                  | j	                  ||            |d   d!   d$<   n7|r5d%|d   d!   d#<   | j                  | j	                  ||            |d   d!   d$<   |6d&|d   d!   d#<   | j                  | j	                  ||            |d   d!   d<   n7|5d'|d   d!   d#<   | j                  | j	                  ||            |d   d!   d<   | j                  |ddg      }n#|s|r|r@| j                  | j	                  ||            |d   d    d<   |r
d&|d   d#<   nd"|d   d#<   n| j                  | j	                  ||            |d   d    d<   |r
d'|d   d#<   nd%|d   d#<   n|s|s|s| r|&|d   d    d(<   |sF|s|rBd)|d   d#<   |r| j                  |"      |d   d    d<   n]| j                  |#      |d   d    d<   nA|&|d   d*<   d+|d   d#<   |r| j                  |$      |d   d    d<   n| j                  |%      |d   d    d<   n|d,k(  r|s|rt        | j                  d-z         |s|rR|r(| j                  | j	                  ||            |d   d$<   n| j                  | j	                  ||            |d   d$<   n|s|s|s| ry|&|d   d.<   |s6|s|r2|r| j                  |"      |d   d$<   nQ| j                  |#      |d   d$<   n9|&|d   d*<   |r| j                  |$      |d   d$<   n| j                  |%      |d   d$<   | j                  |g d/      }||gS )0Nlimitz& limit orders require a price argumentparamslimit_pricemarketFT	post_onlyclientOrderId	cl_ord_idcost	order_qtystopLoss
takeProfittriggerPricerV   stopLossPricetakeProfitPricetrailingAmounttrailingPercenttrailingLimitAmounttrailingLimitPercentoffset pctquoter4   
reduceOnlyreduce_onlytimeInForcetime_in_forcetriggersconditionalz	stop-loss
order_typetrigger_priceztake-profitzstop-loss-limitztake-profit-limit
price_typeztrailing-stoplimit_price_typeztrailing-stop-limitr5   zR editing the stopLoss and takeProfit on existing orders is currently not supportedtrigger_price_type)	r]   r_   rj   rd   re   rf   rg   rh   ri   )endswithr   idparse_to_numericprice_to_precisionhandle_post_onlysafe_stringcost_to_precision	safe_dictnumber_to_string	safe_boolsafe_string_loweromitr   ))rM   rQ   rR   rS   rT   rU   rV   rY   isLimitOrderisMarketpostOnlyr]   r_   ra   rb   presetStopLosspresetTakeProfitpresetStopLossLimitpresetTakeProfitLimitisPresetStopLossisPresetTakeProfitrd   re   isStopLossPriceOrderisTakeProfitPriceOrderrf   rg   rh   ri   isTrailingAmountOrderisTrailingPercentOrderisTrailingLimitAmountOrderisTrailingLimitPercentOrderrj   trailingAmountStringtrailingPercentStringtrailingLimitAmountStringtrailingLimitPercentString	priceTypern   rp   s)                                            rO   order_request_wszkraken.order_request_ws   s   }}W-}'2Z(Z[[/3/D/DTE\E\]cejEk/lGHm,H$005&I&-1GHk*((A$-:GHk*/-1-B-B4CYCYZ`bfCg-hGHk*>>&*b9^^FL"=
))(NC++JG"..xA $ 0 0W E)5-T9((A**63DE,D8!0!<))&2BC**63DE"..v7LM#//8NO .d :!0!<%8%D"&:$&F#!!&(B7R`Rlv(=(=n(MMswTcTo)>)>)O Ovz\o\{FT-B-BCV-W$W  CG!^r^~Vd.C.CDX.Y%Y  FJ"48SEZa	_$=J37!-000GK&5@!/2YYvm'DEF#'=AVZp  uO  Sn02!*-#535!-0#EPGH%m4\BHLH]H]^b^u^uv|  M  _N  IOGH%m4_E'ERGH%m4\BHLH]H]^b^u^uv|  O  _P  IQGH%m4_E&2EVGH%m4\BFJF[F[\`\s\stz  }P  ]Q  GRGH%m4]C*6EXGH%m4\BFJF[F[\`\s\stz  }R  ]S  GTGH%m4]C6J+EF%)?'=A=R=RSWSjSjkq  tA  TB  >CGH%j1':#:K),7:E),7=A=R=RSWSjSjkq  tC  TD  >EGH%j1':#:M),7:G),7&*@D^b}>G!*-l;#)>BX6EGH%l3,AEAVAVWkAl)*5g>AEAVAVWlAm)*5g> =FGH%&896KGH%l31AEAVAVWpAq)*5g>AEAVAVWqAr)*5g>}$#5"477  .B  $B  C  C#'='9=9N9NtOfOfgmo|O}9~GH%o69=9N9NtOfOfgmo~O  :AGH%o6&*@D^b}:C!"67#)>BX,=A=R=RSg=h)/:=A=R=RSh=i)/:<EGH%&891=A=R=RSl=m)/:=A=R=RSm=n)/:6  $  @  rP   sidec           	        K   | j                          d{    | j                          d{   }| j                  |      }| j                  d   d   d   }	| j	                         }
|
}d||| j                  | j                  ||            |d   |d|
d}| j                  d	||||||      \  }}| j                  |	|| j                  ||      |       d{   S 7 7 7 w)
a  
        create a trade order

        https://docs.kraken.com/api/docs/websocket-v2/add_order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr9   r(   r<   	add_orderrR   )rt   r   r`   rR   tokenrQ   rY   req_idr4   )
load_marketsauthenticater[   rG   
request_idr{   amount_to_precisionr   watchextend)rM   rR   rS   r   rU   rV   rY   r   r[   url	requestIdmessageHashrT   s                rO   create_order_wszkraken.create_order_ws   s      !!!''))V$iit$[1OO%	!"!2243K3KFTZ3[\ *  

 //wX^`egmnZZ[$++gv2NP[\\\% 	")" ]s2   C%CC%C!B+C%C#C%!C%#C%c                     | j                  |di       }| j                  |      }| j                  |dd      }|j                  ||       y )Nresultreqidr   )r   parse_ordersafe_value_2resolve)rM   clientmessager   orderr   s         rO   handle_create_edit_orderzkraken.handle_create_edit_order  sH    6 26  (''(Cuk*rP   rz   c           	        K   | j                          d{    | j                          d{   }| j                  d   d   d   }	| j                         }
|
}d|| j	                  | j                  ||            |d|
d}| j                  d||||||      \  }}| j                  |	|| j                  ||      |       d{   S 7 7 7 w)	a  
        edit a trade order

        https://docs.kraken.com/api/docs/websocket-v2/amend_order

        :param str id: order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of the currency you want to trade in units of the base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr9   r(   r<   amend_order)order_idr`   r   r   r5   )	r   r   rG   r   r{   r   r   r   r   )rM   rz   rR   rS   r   rU   rV   rY   r   r   r   r   rT   s                rO   edit_order_wszkraken.edit_order_ws>  s      !!!''))iit$[1OO%	#!2243K3KFTZ3[\
  
 //vtWV\^ceklZZ[$++gv2NP[\\\ 	") ]s2   CC	CCBCCCCCidsc                 b  K   |t        | j                  dz         | j                          d{    | j                          d{   }| j                  d   d   d   }| j                         }|}d||d|d}| j                  ||| j                  ||      |       d{   S 7 x7 b7 w)	a  

        https://docs.kraken.com/api/docs/websocket-v1/cancelorder

        cancel multiple orders
        :param str[] ids: order ids
        :param str [symbol]: unified market symbol, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NzK cancelOrdersWs() does not support cancelling orders for a specific symbol.r9   r(   r<   cancel_orderr   r   r   r   rz   r   r   rG   r   r   r   )	rM   r   rR   rY   r   r   r   r   rT   s	            rO   cancel_orders_wszkraken.cancel_orders_ws^  s      tww)vvww!!!''))iit$[1OO%	$  
 ZZ[$++gv2NP[\\\ 	") ]s4   .B/B)B/B+	AB/$B-%B/+B/-B/c                 d  K   |t        | j                  dz         | j                          d{    | j                          d{   }| j                  d   d   d   }| j                         }|}d|g|d|d}| j                  ||| j                  ||      |       d{   S 7 y7 c7 w)	a  

        https://docs.kraken.com/api/docs/websocket-v1/cancelorder

        cancels an open order
        :param str id: order id
        :param str [symbol]: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NzJ cancelOrderWs() does not support cancelling orders for a specific symbol.r9   r(   r<   r   r   r   r   )	rM   rz   rR   rY   r   r   r   r   rT   s	            rO   cancel_order_wszkraken.cancel_order_wsz  s      tww)uuvv!!!''))iit$[1OO%	$D  
 ZZ[$++gv2NP[\\\ 	") ]s4   .B0B*B0B,	AB0%B.&B0,B0.B0c                 L    | j                  |d      }|j                  ||       y Nr   
safe_valuer   rM   r   r   reqIds       rO   handle_cancel_orderzkraken.handle_cancel_order  "     2w&rP   c                 `  K   |t        | j                  dz         | j                          d{    | j                          d{   }| j                  d   d   d   }| j                         }|}dd|i|d}| j                  ||| j                  ||      |       d{   S 7 w7 a7 w)	a  

        https://docs.kraken.com/api/docs/websocket-v1/cancelall

        cancel all open orders
        :param str [symbol]: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
        :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>`
        NzM cancelAllOrdersWs() does not support cancelling orders in a specific market.r9   r(   r<   
cancel_allr   r   r   )rM   rR   rY   r   r   r   r   rT   s           rO   cancel_all_orders_wszkraken.cancel_all_orders_ws  s      tww)xxyy!!!''))iit$[1OO%	"  
 ZZ[$++gv2NP[\\\ 	") ]s4   .B.B(B.B*	AB.#B,$B.*B.,B.c                 L    | j                  |d      }|j                  ||       y r   r   r   s       rO   handle_cancel_all_orderszkraken.handle_cancel_all_orders  r   rP   c                    |d   }| j                  | j                  d   |      }|d   }| j                  dd |      }|d   }| j                  |d   d      }	d }
| j                  |d   d      }||	t	        j
                  ||	      }
| j                  |d	   d      }| j                  i d|d
d dd d| j                  |d   d      d| j                  |d   d      d| j                  |d   d      d| j                  |d   d      d| j                  |d   d      d| j                  |d   d      d|	d| j                  |d   d      d|d|dd dd dd dd ||
|d       }|| j                  |<   |j                  ||       y )!N   marketsByWsNamerR   ticker   pr   vc	timestampdatetimehighhlowlbidb	bidVolume   aska	askVolumevwapopenocloselastpreviousClosechange
percentageaverage)
baseVolumequoteVolumeinfo)	r   rH   get_message_hashr~   r#   
string_mulsafe_tickertickersr   )rM   r   r   subscriptionwsNamer[   rR   r   r   r   r   r   r   r   s                 rO   handle_tickerzkraken.handle_ticker  s4   & .?!@&I!++HdFCsQ/%%fSk15
!d&6!,,Z>KsQ/!! #
f#
#
 #
 D$$VC[!4	#

 4##F3K3#
 4##F3K3#
 ))&+q9#
 4##F3K3#
 ))&+q9#
 D#
 D$$VC[!4#
 T#
 D#
 T#
 d#
  $!#
" t##
$ %&)#
 ,  &Vv{+rP   r   c                 .   | j                  |d      }| j                  |d      }| j                  | j                  d   |      }|d   }| j                  |d |      }| j                  | j                  |      }	|	7| j                  | j                  dd      }
t        |
      }	|	| j                  |<   | j                  |dg       }| j                  ||      }t        dt        |            D ]  }|	j                  ||           |j                  |	|       y )	Nr   r   r   rR   r@   r>   r   r   )r~   r   rH   r   tradessafe_integerr   parse_tradesrangelenappendr   )rM   r   r   r   r   namer[   rR   r   storedrX   r   parsedis                 rO   handle_tradeszkraken.handle_trades  s    !!'1-+.?!@&I!++D$?f5>%%dllM4HE&F"(DKK!R0""662q#f+& 	%AMM&)$	%v{+rP   c           	         | j                  |di       }| j                  |d      }| j                  |d      }| j                  |d      }| j                  | j                  d   |      }|d   }	| j	                  |      }
| j                  |
      }|
L| j                  |d      }|dz   |
z   dz   |z   }| j                  |d      }||z  }| j                  |d	z        }|| j                  |d
      | j                  |d      | j                  |d      | j                  |d      | j                  |d      g}| j                  | j                  |	i       | j                  |	<   | j                  | j                  |	   |
      }|:| j                  | j                  dd	      }t        |      }|| j                  |	   |
<   |j                  |       |j                  ||       y y )Nr   intervalr   r   r   rR   r   :r>   r            rA   )r   r   r~   rH   find_timeframeparse_timeframe
safe_floatparse_to_intohlcvsr   r   r   )rM   r   r   r   r   r  r   r   r[   rR   	timeframedurationcandler   r   tsr   r   rX   s                      rO   handle_ohlcvzkraken.handle_ohlcv#  s   & |^R@$$T:6f-!!'1-.?!@&I!''1	''	2 __Wa0F*y036?K2I!I""9t#34B*****F #'//$++vr"JDKK__T[[%8)DF~))$,,dK.u517F#I.MM&!NN6;/+ !rP   c                 ~    | j                  | j                  | j                  dd      d      }|| j                  d<   |S )Nr   r   r   )sumr   rH   )rM   r   s     rO   r   zkraken.request_idU  s8    **4<<!DaH %WrP   c                 X  K   | j                          d {    | j                  |      }| j                  |d   d      }|dz   |z   }| j                  d   d   d   }| j	                         }d||gd|id	}	| j                  |	|      }
| j                  |||
|       d {   S 7 7 w)
Nr   wsnamer  r9   r(   r:   	subscriber   eventr   pairr   )r   r[   r   rG   r   rJ   r   )rM   r   rR   rY   r[   r   r   r   r   r  rT   s              rO   watch_publiczkraken.watch_public[  s     !!!V$:Sj6)iit$X.OO%	  	
	 ""9f5ZZ[';GGG# 	"" Hs"   B*B&B
B*!B("B*(B*c                    K   | j                          d{    | j                  |      }| j                  |g|       d{   }||   S 7 57 w)a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.kraken.com/api/docs/websocket-v1/ticker

        :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>`
        N)r   rR   watch_tickers)rM   rR   rY   r   s       rO   watch_tickerzkraken.watch_tickero  sR      !!!V$**F8V<<v 	"<s!   AA+AA
AAsymbolsc                   K   | j                          d{    | j                  |dd      }| j                  dd|d|       d{   }| j                  ri }|||d   <   |S | j	                  | j
                  d|      S 7 i7 ;w)a  
        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.kraken.com/api/docs/websocket-v1/ticker

        :param str[] symbols:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        NFr   rR   )r   market_symbolswatch_multi_helper
newUpdatesfilter_by_arrayr   rM   r  rY   r   r   s        rO   r  zkraken.watch_tickers~  s      !!!%%gtU;..x7DRXYY??F'-F6(#$M##DLL(GDD 	"Y!   BB /BB:BBc                   K   | j                          d{    | j                  |dd      }| j                  dd|d|       d{   }| j                  ri }|||d   <   |S | j	                  | j
                  d|      S 7 i7 ;w)av  

        https://docs.kraken.com/api/docs/websocket-v1/spread

        watches best bid & ask for symbols
        :param str[] symbols: 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>`
        NFbidaskspreadrR   )r   r  r   r!  r"  bidsasksr#  s        rO   watch_bids_askszkraken.watch_bids_asks  s      !!!%%gtU;..x7DRXYY??F'-F6(#$M##DMM8WEE 	"Yr$  c                     | j                  |      }|d   }|| j                  |<   | j                  dd |      }|j                  ||       y )NrR   r&  )parse_ws_bid_askr(  r   r   )rM   r   r   r   parsedTickerrR   r   s          rO   handle_bid_askzkraken.handle_bid_ask  sN     ,,W5h' ,f++HdFC|[1rP   c                    | j                  |dg       }| j                  |d      }| j                  | j                  d   |      }| j                  |d      }| j	                  | j                  |d            dz  }| j                  ||| j                  |      | j                  |d      | j                  |d      | j                  |d      | j                  |d      |d	|      S )
Nr   r   r   rR   r   r>   r  r   )rR   r   r   r   r   r   r   r   )	safe_listr~   r   rH   r
  r   r   iso8601)rM   r   r[   datamarketIdrR   r   s          rO   r+  zkraken.parse_ws_bid_ask  s    ~~fa,##FA..?!@(K!!&(3%%d&7&7a&@ADH	"Y/##D!,))$2##D!,))$2	!
 	 		rP   sincerX   c                 H   K   | j                  |g|||       d{   S 7 w)a  
        get the list of most recent trades for a particular symbol

        https://docs.kraken.com/api/docs/websocket-v1/trade

        :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>`
        N)watch_trades_for_symbolsrM   rR   r3  rX   rY   s        rO   watch_tradeszkraken.watch_trades  s'      22F8UE6RRRR   " "c                    K   | j                  dd|d|       d{   }| j                  r6| j                  |d      }| j                  |d      }|j	                  ||      }| j                  |||dd      S 7 [w)a  

        https://docs.kraken.com/api/docs/websocket-v1/trade

        get the list of most recent trades for a list of symbols
        :param str[] symbols: 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>`
        tradeNr   rR   r   T)r   r!  r/  r~   getLimitfilter_by_since_limit)rM   r  r3  rX   rY   r   firsttradeSymbols           rO   r5  zkraken.watch_trades_for_symbols  s|      ..w$PVWW??NN61-E**5(;KOOK7E))&%TRR Xs   A9A7AA9c                 F   K   | j                  |g||       d{   S 7 w)a0  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.kraken.com/api/docs/websocket-v1/book

        :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)watch_order_book_for_symbols)rM   rR   rX   rY   s       rO   watch_order_bookzkraken.watch_order_book  s%      66xOOOOs   !!c           
         K   i }|4| j                  |g d      rd|i|d<   nt        | j                  dz         | j                  dd|d|i| j	                  ||             d{   }|j                         S 7 w)	a  
        watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.kraken.com/api/docs/websocket-v1/book

        :param str[] symbols: unified array of symbols
        :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   i  r>   depthr   zF watchOrderBook accepts limit values of 10, 25, 100, 500 and 1000 only	orderbookbookrX   )in_arrayr   rz   r   r   rX   )rM   r  rX   rY   rT   rG  s         rO   r@  z#kraken.watch_order_book_for_symbols  s      }}U$<=U+' #477-u#uvv11+vwQXZ_P`bfbmbmnuw}b~	   @s   A#A<%A:&A<1mc           	        K   | j                          d{    d}| j                  |      }|d   }| j                  |d   d      }|dz   |z   dz   |z   }	| j                  d   d   d	   }
| j	                         }d
||g|| j                  | j
                  ||      dd}| j                  ||      }| j                  |
|	||	       d{   }| j                  r|j                  ||      }| j                  |||dd      S 7 7 9w)a  
        watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.kraken.com/api/docs/websocket-v1/ohlc

        :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
        NohlcrR   r   r  r  r9   r(   r:   r  )r   r  r  r   T)r   r[   r   rG   r   
timeframesrJ   r   r!  r;  r<  )rM   rR   r  r3  rX   rY   r   r[   r   r   r   r   r  rT   ohlcvs                  rO   watch_ohlcvzkraken.watch_ohlcv  s!     !!!V$!:Sj9,s2V;iit$X.OO%	   OODOOY	R

	 ""9f5jjk7KHH??NN651E))%q$GG/ 	"( Is"   DDB3D
D8DDFc                   K   t         t        |   ||       d {   }| j                  | j                  d      }||ri }t        dt        | j                              D ]  }| j                  |   }| j                  |   }|d   r9| j                  |di       }| j                  |d      }	|	dd dz   |	dd  z   }
|||
<   _| j                  |di       }| j                  |d      }
|||
<    || j                  d<   |S 7 w)	Nr   r   darkpoolr   altnamer   /r  )
rK   r%   r   r   rH   r   r   r  marketsr~   )rM   reloadrY   rT  r   r   rR   r[   r   rR  r   rN   s              rO   r   zkraken.load_markets4  s    fd8HH//$,,8IJ# O1c$,,/0 5af-*%??662>D"..tY?G$Qq\C/'!"+=F.4OF+??662>D!--dH=F.4OF+5 />DLL*+# Is   C?C=C"C?c                    K   | j                          d {    d}| j                  d   d   d   }| j                  ||       d {   S 7 57 w)N	heartbeatr9   r(   r:   )r   rG   r   )rM   rY   r  r   s       rO   watch_heartbeatzkraken.watch_heartbeatH  sT     !!!iit$X.ZZU+++ 	" ,s!   AA0AAAAc                 L    | j                  |d      }|j                  ||       y )Nr  )r~   r   )rM   r   r   r  s       rO   handle_heartbeatzkraken.handle_heartbeatN  s$       '2w&rP   c                    t        |      }||dz
     }||dz
     }|j                  d      }| j                  |dd      }| j                  | j                  d   |      }	|	d   }
d }| j                  dd |
      }d|d   v r| j                  i |      | j                  |
<   | j                  |
   }d	d
d}t        |j                               }t        dt        |            D ]:  }||   }||   }||   }| j                  |d   |g       }| j                  |||      }< |
|d<   ||d<   | j                  |      |d<   |j                  ||       y | j                  |
   }d }d }d }|dk(  rX| j                  |d   dg       }| j                  |d   dg       }| j                  |d   d      }| j                  |d   d|      }nI| j                  |d   d      }d|d   v r| j                  |d   dg       }n| j                  |d   dg       }|d	   }|d
   }d }|%| j                  |||      }| j                  |d      }|%| j                  |||      }| j                  |d      }|j                          | j                  ddd      }|r| j!                  |d      }| j!                  |d      }|j                  d      }|j                  d      }t        |d         dz
  } t        |d         dz
  }!g }"|t        dd      D ]D  }| j#                  ||   d   |       | j#                  ||   d   |!      z   }#|"j%                  |#       F t        dd      D ]D  }| j#                  ||   d   |       | j#                  ||   d   |!      z   }#|"j%                  |#       F dj'                  |"      }$| j)                  |$d      }%|%|k7  rWt+        | j,                  dz   | j/                  |
      z         }&|j0                  |= | j                  |
= |j3                  |&|       y |
|d<   ||d<   | j                  |      |d<   |j                  ||       y )Nr   r   -rC  r   rR   rG  asasksbids)r]  bsr   r   r   r  r   r   r   r,   r?   T.rk   F )r   splitr   r   rH   r   
order_book
orderbookslistkeysr   custom_handle_deltasr0  r   rX   handle_optionr~   format_numberr   joincrc32r"   rz   orderbook_checksum_messagesubscriptionsreject)'rM   r   r   r   messageLengthr   bookDepthStringpartsrF  r[   rR   r   r   rG  sidesrg  r   keyr   booksidedeltasr   r   r   
storedAsks
storedBidsexampler?   priceStringamountString
pricePartsamountPartspriceLengthamountLengthpayloadArray	formattedpayloadlocalChecksumerrors'                                          rO   handle_order_bookzkraken.handle_order_bookW  s   R G*+!-!"34%%c*!!%B/.?!@&I!	++KvF71:&*oob%&@DOOF#/IE 

%D1c$i( S1gSz$T?S"= 55h	R	S #)Ih%.Ik"$(LL$;Ij!NN9k2/IAAA!OOGAJR8OOGAJR8%%gaj#6%%gaj#q9%%gaj#6'!*$
C<A
C<A"6*J"6*JG} 55j!YO	//!Q/} 55j!YO	//!Q/OO))*:JMH"..w:#//;(..s3
*005!*Q-014";q>2Q6!="1b\ 7$($6$6z!}Q7G$UX\XjXjkuvwkxyzk{  ~J  YK  %K	$++I67 #1b\ 7$($6$6z!}Q7G$UX\XjXjkuvwkxyzk{  ~J  YK  %K	$++I67 '',/ $

7E : A%)$''C-$:Y:YZ`:a*abE,,[9/MM%5"(Ih%.Ik"$(LL$;Ij!NN9k2rP   c                    | j                  |      }|j                  d      }| j                  |d      }| j                  |dd      }|j                  |d      }||z   }d}	||	   dk(  r|	dz  }	||	   dk(  r|	dkD  r||	d  S |S )Nra  r   r   rk   0)r   rc  r~   ljust)
rM   nlengthstringNumberrr  integerdecimalspaddedDecimalsjoinedr   s
             rO   rj  zkraken.format_number  s    ,,Q/""3'""5!,##E1b1!4>)Qi3FA Qi3q5!":MrP   c           
         t        dt        |            D ]q  }||   }| j                  |d         }| j                  |d         }|r|nd}t        || j	                  t        |d         dz              }|j                  ||       s |S )Nr   r   r   r>   )r   r   parse_numbermaxr
  floatstore)	rM   ru  rv  r   jdeltarV   rU   oldTimestamps	            rO   rh  zkraken.custom_handle_deltas  s    q#f+& 	*A1IE%%eAh/E&&uQx0F(19qLL$*;*;E%(Od<R*STINN5&)	* rP   c                     |S N )rM   r   r   s      rO   handle_system_statuszkraken.handle_system_status  s	    6 rP   c                 2  K   | j                   d   d   d   }| j                  |      }d}| j                  |j                  |      }|:| j	                  |       d {   }| j                  |d      }||j                  |<   | j                  |d      S 7 7w)Nr9   r(   r;   authenticatedr   r   )rG   r   r   rn  privatePostGetWebSocketsTokenr~   )rM   rY   r   r   r  r   responses          rO   r   zkraken.authenticate  s     iit$Y/S!'v';';]K!??GGH  ??8X>L2>F  /g66 Hs   ABB8Bc                   K   | j                          d {    | j                          d {   }|}|}|| j                  |      }|d|z   z  }| j                  d   d   d   }	| j	                         }
d|
||dd}| j                  ||      }| j                  |	|||       d {   }| j                  r|j                  ||      }| j                  ||||      S 7 7 7 :w)Nr  r9   r(   r;   r  )r   r   )r  r   r   )
r   r   rR   rG   r   rJ   r   r!  r;  filter_by_symbol_since_limit)rM   r   rR   r3  rX   rY   r   subscriptionHashr   r   r   r  rT   r   s                 rO   watch_privatezkraken.watch_private   s     !!!''))[[(F3<'Kiit$Y/OO%	 
	 ""9f5zz#{G=MNN??OOFE2E00NN+ 	")" Os2   C&C C&C"A:C&)C$*7C&"C&$C&c                 H   K   | j                  d||||       d{   S 7 w)a.  
        watches information on multiple trades made by the user

        https://docs.kraken.com/api/docs/websocket-v1/owntrades

        :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>`
        	ownTradesNr  r6  s        rO   watch_my_tradeszkraken.watch_my_trades8  s'      ''VUE6RRRRr8  c                    | j                  |dg       }t        |      }|dkD  rh| j                  -| j                  | j                  dd      }t        |      | _        | j                  }i }t        dt        |            D ]  }	| j                  ||	i       }
t        |
j                               }t        dt        |            D ]J  }||   }|
|   }| j                  | j                  d|i|            }|j                  |       |d   }d||<   L  d}|j                  | j                  |       t        |j                               }t        dt        |            D ])  }	|dz   ||	   z   }|j                  | j                  |       + y y )	Nr   r@   r>   rz   rR   Tr  r  )r   r   myTradesr   rH   r   r   rf  rg  parse_ws_trader   r   r   )rM   r   r   r   	allTradesallTradesLengthrX   r   r  r   r   r   r  rz   r:  r   rR   r   rg  r   s                       rO   handle_my_tradeszkraken.handle_my_tradesF  sv   N OOGQ3	i.Q}}$))$,,tL *5 1]]FG1c)n- 	+Ar:6;;=)q#c(+ +AQB"2JE!00dBZ1OPFMM&)#H-F&*GFO+	+ DNN4==$/'D1c$i( ;"Sj472t}}k:;' rP   c                    | j                  |d      }| j                  | j                  d   ||      }d }| j                  |d      }| j                  |dd      }| j	                  |d      }| j                  |d      }| j                  |d      }	| j                  |d	      }
| j                  |d
      }d }d }d|v rd }||d   }| j                  |d      |d}||d   }|
||
|z  }||||| j                  |      ||	|d |
|||dS )Nr  r   	ordertxidrz   postxidtimerS   	ordertyperV   volfeerm   )r_   currencyrR   )rz   r   r   r   r   rR   rS   r   takerOrMakerrV   rU   r_   r  )r~   r   rH   safe_string_2safe_timestampr	  r0  )rM   r:  r[   r   rR   orderIdrz   r   r   rS   rV   rU   r_   r  r  s                  rO   r  zkraken.parse_ws_trade  sR   B !!%0.?!@&&Q""5+6tY7''v6	v.{3w/.E>H!!'?u5$C H%F!v~"Y/ 
 	
rP   c                 H   K   | j                  d||||       d{   S 7 w)a/  

        https://docs.kraken.com/api/docs/websocket-v1/openorders

        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  orde structures to retrieve
        :param dict [params]: maximum number of orderic to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        
openOrdersNr  r6  s        rO   watch_orderszkraken.watch_orders  s'      ''feUFSSSSr8  c                    | j                  |dg       }t        |      }|dkD  r.| j                  | j                  dd      }| j                  t        |      | _        | j                  }i }t        dt        |            D ]U  }	| j                  ||	i       }
t        |
j                               }t        dt        |            D ]  }||   }|
|   }| j                  |      }||d<   d }| j                  | j                  di       }|d   |d   }|||<   || j                  d<   n| j                  ||      }| j                  |j                  |      }| j                  ||      }|}|.| j                  |d   |d         }| j                  |      }||d<   t        |      }||k(  r||d   }|d   |v r||d   = |j                  |       d||<    X d	}|j                  | j                  |       t        |j                               }t        dt        |            D ])  }	|d
z   ||	   z   }|j                  | j                  |       + y y )Nr   rB   r>   rz   rC   rR   r   Tr  r  )r   r   r   rH   ordersr   r   rf  rg  parse_ws_orderr~   hashmapr   r   r   )rM   r   r   r   	allOrdersallOrdersLengthrX   r   r  r   r  r   r  rz   r   r   rR   rC   previousOrderspreviousOrdernewOrdernewRawOrderr  r=  r   rg  r   s                              rO   handle_orderszkraken.handle_orders  sa   \ OOGQ3	i.Q%%dllM4HE{{"4U;[[FG1c)n- +Ar:6;;=)q#c(+ +AQB"2JE!007F#%F4L!F'+t||EWY['\$h'3!'!1/5(,;K%78!%!1!12BB!G%)__V^^V%LN$(OONB$GM%H$0&*kk-2GRXIY&Z#'#6#6{#C)+ [FM,A &q	 ;*:: 0t =MM(+&*GFO5++<  DNN4;;-'D1c$i( 9"Sj472t{{K89O rP   c           	      F   | j                  |di       }| j                  |d      }d }d }d }d }d }	|k|j                  d      }
| j                  |
d      }| j                  |
d      }	| j                  |
d      }| j                  |
d      }| j                  |
d      }| j                  |d	|      }| j                  |d
|      }| j                  |d|      }| j                  | j                  d   ||      }d }| j	                  |d      }| j                  |d|	      }	| j                  |d      }d }| j                  |d      }| j                  |d|      }|t        j                  |d      r| j                  |d      }|t        j                  |d      r| j                  |d|      }| j                  |dd      }|^|d   }d|v rU|d   }| j                  |d      }|d d}|j                  d      dk\  r	|d   |d<   n|j                  d      dk\  r|d   |d<   | j                  | j                  |d            }| j                  |d      }|$| j                  |d       }| j                  |d      }| j                  |d!      }| j                  |d"      }d }|| j                  ||d d d|i      }| 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/      S )0Ndescrr   rb  r   r   r   r  r  rS   r  r  r   opentmr  vol_execr_   rV   z0.0price2	avg_pricerR   r  oflags)r_   ratefciqrm   r  fcibbasestatusrz   txiduserrefr   	stoppricer]   r   r   r   lastTradeTimestamprp   r   r   	stopPricerc   rU   )filledr   	remainingr  r   )r   r~   rc  rH   r  r#   	string_eqr  findparse_order_statusr   safe_number
safe_orderr0  )rM   r   r[   descriptionorderDescriptionr   rS   r   rV   rU   rr  rR   r   r  r  r_   r   flagsfeeCostr  rz   r  r]   	rawTradesr   r  s                             rO   r  zkraken.parse_ws_orderY  s   @ ooeWb9++KA'$**3/E##E1-D%%eQ/F%%eQ/F##E1-D$$UA.EVT:[$?!!+vv>.?!@&&Q''x8	!!%7!!%4v.  gu=Mw00>$$[(;EMw00>$$UGU;E$$UKAH%F~h**5%8#  ::f%*&,WoC
OZZ'1,&,VnC
O(()9)9%)JKeT*:??5&1D!!$*B((	:OOE84	 &&y&$wPRmTF$$UK8	  
" 
] 
 E 
 	 

 Y/ 
 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
  
 I 
  D! 
" f# 
$ - 
  	rP   unifiedNamechannelNamec                 l  K   | j                          d {    | j                  |d ddd      }g }t        dt        |            D ]6  }|j	                  | j                  |d | j                  ||                      8 | j                  |      }g }	t        dt        |            D ]+  }| j                  ||   d   d      }
|	j	                  |
       - d| j                         |	d|id}| j                  d	   d
   d   }| j                  ||| j                  ||      ||       d {   S 7 7 w)NFTr   r   r  r  r   r  r9   r(   r:   )r   r  r   r   r   r   rR   markets_for_symbolsr~   r   rG   watch_multiplerJ   )rM   r  r  r  subscriptionArgsrY   messageHashesr   rT  wsMarketIds
wsMarketIdrT   r   s                rO   r   zkraken.watch_multi_helper  sV    !!!%%gtUD%Hq#g,' 	dA  !6!6{D$++V]^_V`Ja!bc	d **73q#g,' 	+A))'!*V*<hGJz*	+ !__&	
 iit$X.((mT=M=MgW]=^`mo  A  A  	A+ 	"* As"   D4D/DD4*D2+D42D4c                 2  K   | j                          d{    | j                          d{   }d}| j                  d   d   d   }| j                         }d|d|dd}| j	                  ||      }| j                  ||||       d{   S 7 z7 d7 w)	a^  
        watch balance and get the amount of funds available for trading or funds locked in orders

        https://docs.kraken.com/api/docs/websocket-v2/balances

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nbalancesr9   r(   r<   r  )channelr   )rQ   r   rY   )r   r   rG   r   rJ   r   )rM   rY   r   r   r   r   r  rT   s           rO   watch_balancezkraken.watch_balance  s      !!!'')) iit$[1OO%	!%
	 ""9f5ZZ[';GGG 	") Hs2   BBBBABBBBBc                 2   | j                  |dg       }d|i}t        dt        |            D ]W  }| j                  ||   d      }| j	                  |      }| j                         }| j                  ||   d      }	|	|d<   |||<   Y d}
| j                  |      }| j                  | j                  |
i       }| j                  ||      }| j                  |      | j                  |
<   | j                  |d      }|j                  | j                  |
   |       y )	Nr1  r   r   assetbalancetotalspotr  )r/  r   r   r~   safe_currency_codeaccountsafe_balancer   r  rJ   r   )rM   r   r   r1  r   r   
currencyIdcoder  eqrS   r  
oldBalance
newBalancer  s                  rO   handle_balancezkraken.handle_balance  s   , ~~gvr2(q#d)$ 	#A))$q'7;J**:6DllnG!!$q'95B!GG"F4L	# ##F+__T\\4<
%%j':
!..z:T""7I6t||D)73rP   unifiedElementNamesubChannelNamec                 F    |d u}|}|s|dz  }n|d|z   z  }||d|z   z  }|S )Ns@#r  )rM   r   r  rR   
withSymbolr   s         rO   r   zkraken.get_message_hash   sI     4'
(3K3<'K%3//KrP   c                 L    | j                  |d      }|||j                  |<   y y )N	channelID)r~   rn  )rM   r   r   	channelIds       rO   handle_subscription_statusz!kraken.handle_subscription_status-  s1    0 $$Wk:	 .5F  + !rP   c                     | j                  |dd      }|g| j                  |dd      }|R| j                  d   d   }| j                  ||      }d }|t	        |      }n ||   |      }|j                  ||       yy)	NerrorMessager  r   r   r(   rE   FT)r  r   rI   find_broadly_matched_keyr   ro  )rM   r   r   r  r   rE   broadKey	exceptions           rO   handle_error_messagezkraken.handle_error_messageM  s    ( ))'>7K#))'7HEI$-g688M 	# -l ;I /h =Ii3rP   c                    t        |t              r| j                  |d      }| j                  |j                  |i       }| j                  |di       }t        |      }| j                  ||dz
        }| j                  |d      }| j                  | j                  | j                  | j                  | j                  | j                  | j                  d}	| j                  |	||      }
|
 |
|||       y y | j                  |d      }|+d| j                  i}	| j                  |	|      }
|
	 |
||       | j                  ||      r| j!                  |dd	      }| j"                  | j$                  | j&                  | j(                  | j(                  | j*                  | j,                  d
}	| j                  |	|      }
|

 |
||       y y y )Nr   r   r   r   )rH  rL  r   r'  r:  r  r  r  r  r  rQ   )rW  systemStatussubscriptionStatusr   r   r   r   )
isinstancerf  r~   r   rn  r   r  r  r   r-  r   r  r  r   r  r  r  rZ  r  r
  r   r   r   )rM   r   r   r	  r   r   rp  r  r   methodsrQ   r  r  s                rO   handle_messagezkraken.handle_messagep  s   gt$((!4I??6+?+?BOL??<DDLM**7MA4EFK##D&1D ..)),,--++"00!22
G &&wkBF!vw5 " &&w	:G" 3 3! ':%67+((9**7GXF!%!6!6$($=$=*.*I*I!%!>!>#'#@#@$($<$<"&"?"?! %8%67+ & :rP   r  )NN)F__name__
__module____qualname__r   rL   strdictr	   r   r   r   r  r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r   r  r   r   r  r)  r-  r+  r   r   r7  r5  r   rA  r@  rf  rO  r   rX  rZ  r  rj  rh  r  r   r  r  r  r  r  r  r  r   r   r  r  r   r
  r  r  __classcell__)rN   s   @rO   r%   r%      s   c# cJ nrz| w!s w!C w!s w!T w![^ w!gj w!r pt|~  ]C  ]y  ]	  ][`  ]il  ]  DI  ]D+@ im{  IK ]c ]3 ]i ]y ]be ]ux ]  PU ]@ DHPR ]$s) ]S ]8 <@ ] ]S ]u ]8'  8<B ] ]4' 5,n,F ,8006 00d 79 H( 68  F  6:" E7 E E& 8<B FW F7 F&2V 2*" <@d[] S SS S Sbfglbm S OSaenp Sd3i S S[^ Suyz  vA S& @DB PS P PS\ P SW_a !$s) !C !fo !, 8<$]ajl $H $HC $HWZ $Hquvzq{ $HL ).b ( ,. ,'v '}3 }3~6 : )+ 7( 7;\`ik O O3 OVY O0 37TX\eg SC Ss SRU Slpqvlw S>;v >;@H
T 04$UYbd T TC Ts Timnsit Ty9F y9vm^ _cuy  CE AC Ac AT[ A0 *, H H2%4V %4N3  \_ 6 6@!6 !F,,V ,,rP   r%   )+ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   ccxt.base.typesr   r   r   r	   r
   r   r   r   r   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   ccxt.base.preciser#   async_supportr%   r  rP   rO   <module>r&     su     f f B  B  B  B 4  * 0 - - . ' & . ) * ) . 1 * %@,T&& @,rP   