
    E#iW                         S SK rS SKJrJr  S SKrS SKJrJrJ	r	J
r
JrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr   " S	 S
\R.                  R0                  5      rg)    N)
ArrayCacheArrayCacheBySymbolById)AnyBalancesBoolIntOrder	OrderBookStrTrade)Client)List)AuthenticationError)
BadRequest)	BadSymbolc            
         ^  \ rS rSrS\4U 4S jjrS0 4S\S\S\4S jjr	S\
4S	 jrSS0 4S\S
\S\S\\   4S jjrS\
4S jrSSS0 4S\S
\S\S\\   4S jjrSS\
4S jjrSSS0 4S\S
\S\S\\   4S jjrSS\
4S jjr0 4S\4S jjrS\
4S jr0 4S jr0 4S jrS\
S\4S jrS\
4S jrS\
4S jrS\
4S jrS\
4U 4S jjr S\
4U 4S jjr!Sr"U =r#$ )hollaex   returnc                    > U R                  [        [        U ]  5       SSSSSSSSSSS.
SS0SS0S.0 0 S.S	U R                  0SS
[
        [        S.00S.5      $ )NTF)
wswatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderswatchTickerwatchTickerswatchTradeswatchTradesForSymbolsr   zwss://api.hollaex.com/streamz$wss://api.sandbox.hollaex.com/stream)apitest)r   r   pingexact)z&Bearer or HMAC authentication requiredzError: wrong input)hasurlsoptions	streaming
exceptions)deep_extendsuperr   describer#   r   r   )self	__class__s    J/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/hollaex.pyr,   hollaex.describe   s    gt = ? $!&#"&#$ %#). 8 @	! 	 		 BK.8A(B
 ( (	    Nsymbollimitc                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nU R                  XS5      I Sh  vN nUR                  5       $  NF N7f)a  
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://apidocs.hollaex.com/#sending-receiving-messages

: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
Nz
orderbook:id)load_marketsmarketwatch_publicr3   )r-   r2   r3   paramsr7   messageHash	orderbooks          r/   watch_order_bookhollaex.watch_order_book>   s`      !!!V$'&,6++K@@	  	 	" As!   A!A1A!A	A!A!clientc                    U R                  US5      nU R                  US5      nU R                  U5      nUS   nU R                  US5      nU R                  US5      nU R                  U5      n	U R	                  XvU	5      n
S nX`R
                  ;  a   U R                  U
5      nXR
                  U'   O U R
                  U   nUR                  U
5        US-   U-   nUR                  X5        g )Nr2   topicdata	timestamp:)	safe_stringsafe_market
safe_value	parse8601parse_order_book
orderbooks
order_bookresetresolve)r-   r>   messagemarketIdchannelr7   r2   rA   rB   timestampMssnapshotr;   r:   s                r/   handle_order_bookhollaex.handle_order_bookO   s    , ##GX6""7G4!!(+!w/$$T;7	nnY/(({C	//)1I&/OOF#/IOOH%mh.y.r1   sincec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   nSUS   -   nU R                  Xd5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XrUSS5      $  Nq N<7f)a  
get the list of most recent trades for a particular symbol

https://apidocs.hollaex.com/#sending-receiving-messages

: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>`
Nr2   ztrade:r5   rB   T)r6   r7   r8   
newUpdatesgetLimitfilter_by_since_limit)r-   r2   rT   r3   r9   r7   r:   tradess           r/   watch_tradeshollaex.watch_tradesw   s      !!!V$!#fTl2((==??OOF2E))&TRR 	" >s!   BB6BB
;B
Bc                    U R                  US5      nU R                  US5      nU R                  U5      nUS   nU R                  U R                  U5      nUc6  U R	                  U R
                  SS5      n[        U5      nXpR                  U'   U R                  US/ 5      n	U R                  X5      n
[        S[        U
5      5       H  nUR                  X   5        M     US-   U-   nUR                  X|5        UR                  Xs5        g )Nr@   r2   tradesLimit  rA   r   rC   )rD   rE   rF   rY   safe_integerr'   r   parse_tradesrangelenappendrL   )r-   r>   rM   rO   rN   r7   r2   storedr3   rA   parsedTradesjr:   s                r/   handle_tradeshollaex.handle_trades   s      ""7G4##GX6!!(+!f5>%%dllM4HE&F"(KKw3((6q#l+,AMM,/* -mh.v+v'r1   c                 .  #    U R                  5       I Sh  vN   SnSnUb!  U R                  U5      nUS   nUSUS   -   -  nU R                  XT5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XqX#S5      $  Nz N;7f)a  
watches information on multiple trades made by the user

https://apidocs.hollaex.com/#sending-receiving-messages

: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	usertrader2   rC   r5   Tr6   r7   watch_privaterV   rW   filter_by_symbol_since_limit)r-   r2   rT   r3   r9   r:   r7   rY   s           r/   watch_my_tradeshollaex.watch_my_trades   s      !!!![[(FH%F3--K))+>>??OOF2E00tTT 	" ?"   BBA BB:BBc                    U R                  US5      nU R                  US5      n[        U5      nUS:X  a  g U R                  c-  U R	                  U R
                  SS5      n[        U5      U l        U R                  n0 n	[        S[        U5      5       HH  n
XZ   nU R                  U5      nUR                  U5        US   nU R                  U5      nUS   nSX'   MJ     UR                  U R                  U5        [        U	R                  5       5      n[        S[        U5      5       H,  n
UU
   nUS	-   U-   nUR                  U R                  U5        M.     g )
Nr@   rA   r   r]   r^   r2   r5   TrC   )rD   rF   rb   myTradesr_   r'   r   ra   parse_traderc   r7   rL   listkeys)r-   r>   rM   subscriptionrO   	rawTrades
dataLengthr3   rd   	marketIdsitradeparsedr2   r7   rN   ru   r:   s                     r/   handle_my_tradeshollaex.handle_my_trades   s:   . ""7G4OOGV4	 ^
?== %%dllM4HE&u-DM	q#i.)ALE%%e,FMM&!8_F[[(Fd|H"&I * 	t}}g.INN$%q#d)$AAwH!C-(2KNN4==+6 %r1   c                 .  #    U R                  5       I Sh  vN   SnSnUb!  U R                  U5      nUS   nUSUS   -   -  nU R                  XT5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XqX#S5      $  Nz N;7f)a  
watches information on multiple orders made by the user

https://apidocs.hollaex.com/#sending-receiving-messages

: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orderr2   rC   r5   Trk   )r-   r2   rT   r3   r9   r:   r7   orderss           r/   watch_ordershollaex.watch_orders   s      !!![[(FH%F3--K))+>>??OOF2E00tTT 	" ?rp   c                    U R                  US5      nU R                  US0 5      n[        U5      nUS:X  a  g U R                  c-  U R	                  U R
                  SS5      n[        U5      U l        U R                  nS n	[        U[        5      (       d  U/n	OUn	0 n
[        S[        U	5      5       HI  nX   nU R                  U5      nUR                  U5        US   nU R                  U5      nUS   nSU
U'   MK     UR                  U R                  U5        [        U
R                  5       5      n[        S[        U5      5       H,  nUU   nUS	-   U-   nUR                  U R                  U5        M.     g )
Nr@   rA   r   ordersLimitr^   r2   r5   TrC   )rD   rF   rb   r   r_   r'   r   
isinstancert   ra   parse_orderrc   r7   rL   ru   )r-   r>   rM   rv   rO   rA   rx   r3   rd   	rawOrdersry   rz   r   r|   r2   r7   rN   ru   r:   s                      r/   handle_orderhollaex.handle_order  s[   t ""7G4w3Y
?;;%%dllM4HE07DK	$%%II	q#i.)ALE%%e,FMM&!8_F[[(Fd|H"&Ih * 	t{{G,INN$%q#d)$AAwH!C-(2KNN4;;4 %r1   c                 D   #    SnU R                  X!5      I Sh  vN $  N7f)a7  
watch balance and get the amount of funds available for trading or funds locked in orders

https://apidocs.hollaex.com/#sending-receiving-messages

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
walletN)rl   )r-   r9   r:   s      r/   watch_balancehollaex.watch_balancej  s#      ''<<<<s     c                    U R                  US5      nU R                  US5      n[        UR                  5       5      nU R	                  US5      nX@R
                  S'   X`R
                  S'   U R                  U5      U R
                  S'   [        S[        U5      5       H  nXW   nUR                  S5      n	U R                  U	S5      n
U R                  U
5      nXR
                  ;   a  U R
                  U   OU R                  5       nU R                  U	S	5      nUS
:X  a  SOSnU R                  XH5      X'   XR
                  U'   M     U R                  U R
                  5      U l        UR                  U R
                  U5        g )Nr@   rA   timeinforB   datetimer   _   	availablefreetotal)rD   rF   rt   ru   safe_timestampbalanceiso8601ra   rb   splitsafe_currency_codeaccountsafe_balancerL   )r-   r>   rM   r:   rA   ru   rB   rz   keyparts
currencyIdcoder   secondfreeOrTotals                  r/   handle_balancehollaex.handle_balancev  sJ   " &&w8w/DIIK ''8	#V$-[!#'<<	#:Z q#d)$A'CIIcNE))%3J**:6D-1\\-Adll4(G%%eQ/F%+{%:&K#'#3#3D#>G !(LL % ((6t||[1r1   c                    #    U R                   S   S   nSU/S.nU R                  XB5      nU R                  X1XQ5      I S h  vN $  N7f)Nr!   r   	subscribeopargs)r&   extendwatch)r-   r:   r9   urlrequestrM   s         r/   r8   hollaex.watch_public  sN     iit$ M
 ++g.ZZ'GGGGs   ?AAAc                   #    U R                  5         U R                  U R                  S5      nUcZ  [        U R                  [        S5      -  5      nU R                  U R                  5       U5      n[        U5      nX0R                  S'   U R                  S   S   nSU-   nU R                  U R                  U5      U R                  U R                  5      [        R                  5      nU R                  UUS.nUS-   U R                  U5      -   n	SU/S	.n
U R!                  X5      nU R#                  XX5      I S h  vN $  N7f)
N
ws-expiresr^   r!   r   zCONNECT/stream)zapi-keyzapi-signaturezapi-expires?r   r   )check_required_credentialsrD   r'   inttimeoutstrsumsecondsr&   hmacencodesecrethashlibsha256apiKey	urlencoder   r   )r-   r:   r9   expiresr   r   auth	signature
authParams	signedUrlr   rM   s               r/   rl   hollaex.watch_private  s    '')""4<<>?4<<#d)35Ghht||~w7G'lG *1LL&iit$$w.IIdkk$/T[[1I7>>Z	{{&"


 #Iz ::	 M
 ++g.ZZ	MMMMs   D=E?E Ec                    U R                  US5      n UbC  U R                  S-   U R                  U5      -   nU R                  U R                  S   S   X45        U$ ! [
         a%  n[        U[        5      (       a   S nAg S nAU$ S nAff = f)Nerror r   r$   F)r_   r5   jsonthrow_exactly_matched_exceptionr)   	Exceptionr   r   )r-   r>   rM   r   feedbackes         r/   handle_error_messagehollaex.handle_error_message  s    
 !!'73	 77S=499W+==44T__T5J75SUZe   	!011 2	s   AA 
B&BBc                 X   U R                  X5      (       d  g U R                  US5      nUS:X  a  U R                  X5        g U R                  U R                  U R
                  U R                  U R                  S.nU R                  US5      nU R                  XE5      nUb	  U" X5        g g )NrM   pong)r{   r;   r   r   rj   r@   )	r   rD   handle_pongrg   rR   r   r   r}   rF   )r-   r>   rM   contentmethodsr@   methods          r/   handle_messagehollaex.handle_message  s    l ((99""7I6fV-''//&&))..
 106# r1   c                 
    SS0$ )Nr   r#    )r-   r>   s     r/   r#   hollaex.ping5  s    f~r1   c                 0    U R                  5       Ul        U$ N)millisecondslastPong)r-   r>   rM   s      r/   r   hollaex.handle_pong9  s    ++-r1   c                 J   > S U R                   S'   [        [        U ]  X5        g Nr   )r'   r+   r   on_errorr-   r>   r   r.   s      r/   r   hollaex.on_error=       %)\"gt%f4r1   c                 J   > S U R                   S'   [        [        U ]  X5        g r   )r'   r+   r   on_closer   s      r/   r   hollaex.on_closeA  r   r1   )r   rr   r   r   )$__name__
__module____qualname____firstlineno__r   r,   r   r   r
   r<   r   rR   r   r   rZ   rg   r   rn   r}   r	   r   r   r   r   r   r8   rl   r   r   r   r#   r   r   r   __static_attributes____classcell__)r.   s   @r/   r   r      s   )# )V @DB !S ! !S\ !"&/ &/P <@d[] S SS S Sbfglbm S*(F (B 37TX\eg UC Us URU Ulpqvlw U017v 17f 04$UYbd U UC Us Uimnsit U0X56 X5t *, 
= 
=#2V #2J 68 H 79 N46 t f$V f$P6 & 5v 55v 5 5r1   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   ccxt.base.typesr   r   r   r   r	   r
   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   async_supportr   r   r1   r/   <module>r      sB     O  R R R 4  0 ' &r5d  (( r5r1   