
    E#i                         S SK rS SKJrJr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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	KJr   " S
 S\R>                  R@                  5      r g)    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheBySymbolBySideArrayCacheByTimestamp)AnyBalancesBoolIntOrder	OrderBookPositionStrStringsTickerTickersTrade)Client)List)ExchangeError)AuthenticationError)NotSupported)Precisec                     ^  \ rS rSrS\4U 4S jjrS rS r0 4S\S\S\S\4S	 jjr	S
0 4S\S\
S\4S jjr0 4S\S\4S jjrS\4S jrS\4S jrS rS\4S jrS rS r0 4S\S\4S jjr0 4S\S\4S jjrSDS jrS\4S jrS
0 4S\S\4S jjrS
0 4S\S\4S jjrS\4S jrS
0 4S\S\4S jjrS
0 4S\S\4S jjr S\4S jr!SDS  jr"S!S
S
0 4S\S"\S#\
S\
S\#\$   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)0 4S\S\4S( jjr*S\4S) jr+SDS* jr,SES+ jr-0 4S, jr.0 4S- jr/0 4S. jr0S
S
S
0 4S\1S#\
S\
S\#\2   4S/ jjr3S
S
S
0 4S\1S#\
S\
S\#\(   4S0 jjr4SDS1 jr5S\4S2 jr6S\4S3 jr7S\4S4 jr8S
S
S
0 4S\S#\
S\
S\#\9   4S5 jjr:SDS\S\4S6 jjr;S7 r<S8 r=0 4S\>4S9 jjr?S: r@S\S\A4S; jrBS\4S< jrCS\4S= jrDS\4S> jrES\4S? jrFS\4S@ jrGS\4SA jrHS\4SB jrISCrJU =rK$ )Fwoo   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SSSS.0SSSS.0S.SSSS.SS0 SSS.S.U R                  SS.SS S![
        000S".5      $ )#NwsTwatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderswatchTickerwatchTickerswatchBidsAskswatchTradeswatchTradesForSymbolsFwatchPositionsunWatchTickerunWatchTickersunWatchOrderBookunWatchOHLCVunWatchTradeszwss://wss.woox.io/ws/streamz&wss://wss.woox.io/v2/ws/private/stream)publicprivatez#wss://wss.staging.woox.io/ws/streamz.wss://wss.staging.woox.io/v2/ws/private/stream)apitest)apiKeysecretuid  )fetchPositionsSnapshotawaitPositionsSnapshot)tradesLimitordersLimit	requestIdr)   i(#  )ping	keepAliveexactzAuth is needed.)hasurlsrequiredCredentialsoptions	streaming
exceptions)deep_extendsuperr   describer<   r   )self	__class__s    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/woo.pyrG   woo.describe   s}   c4 9 ;d   d	
 !$ t t    t ( !$   !$ #D  !"  #* "?#K "G#S $  $#.2.2#	 		!
 )+>i;>
 ; ;	    c                     U R                  U R                  S0 5      nU R                  X!S5      nU R                  US5      nX@R                  S   U'   U$ )Nr;   r      )
safe_valuerB   safe_integersum)rH   urlrB   previousValuenewValues        rJ   
request_idwoo.request_idR   sP    //$,,R@))':88M1-)1[!#&rL   c                   #    U R                   (       a  SU R                   -   OSnU R                  S   S   S   U-   nU R                  U5      nSU0nU R                  Xb5      nU R	                  XAXqU5      I S h  vN $  N7f)N/ r1   r   r/   id)r5   r@   rU   extendwatch)rH   messageHashmessageurlUidrR   r;   	subscriberequests           rJ   watch_publicwoo.watch_publicY   sz     $(HHtxx2iit$X.7OOC(	)
	 ++i1ZZ'	RRRRs   A7B 9A>:B subHashsymboltopicc                   #    U R                   (       a  SU R                   -   OSnU R                  S   S   S   U-   nU R                  U5      nSU-   nUSUS.n	[        U5      S	U/UU/U/S
.n
U R	                  US5      nUb  XS'   U R                  US5      nU R                  XhU R                  X5      X5      I S h  vN $  N7f)NrX   rY   r1   r   r/   unsubscribe::unsubscribe)rZ   eventrf   T)rZ   ri   symbolsrf   subMessageHashesunsubMessageHashessymbolsAndTimeframes)r5   r@   rU   str	safe_listomitr\   r[   )rH   rd   re   rf   paramsr_   rR   r;   	unsubHashr^   subscriptionrn   s               rJ   unwatch_publicwoo.unwatch_publicc   s     $(HHtxx2iit$X.7OOC(	#g-	"
 i.x!(	#,+
  $~~f6LM+3G/0YYv'=>FZZG0Liffffs   B<C>C?CNlimitc                   #    U R                  5       I Sh  vN   SnU R                  USSS5      u  pCU R                  U5      nUS   S-   U-   nU R                  (       a  SU R                  -   OSnU R                  S	   S
   S   U-   nU R                  U5      n	SUU	S.n
[        U	5      UUS   UUS.nUS:X  a  U R                  US'   U R                  XU R                  X5      Xk5      I Sh  vN nUR                  5       $  N N7f)aq  

https://docs.woox.io/#orderbookupdate
https://docs.woox.io/#orderbook

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
:param str [params.method]: either(default) 'orderbook' or 'orderbookupdate', default is 'orderbook'
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr"   method	orderbookrZ   @rX   rY   r1   r   r/   r`   )rj   rf   rZ   re   )rZ   namere   rw   rr   orderbookupdate)load_marketshandle_option_and_paramsmarketr5   r@   rU   ro   handle_order_book_subscriptionr\   r[   rw   )rH   re   rw   rr   ry   r   rf   r_   rR   r;   ra   rt   rz   s                rJ   watch_order_bookwoo.watch_order_book{   s     !!!66v?OQY[fgV$ts"V+$(HHtxx2iit$X.7OOC(	 
 i.X&
 &&%)%H%HL"**SW1Mucc	  / 	", ds"   DDCD.D/DDc                    #    U R                  5       I Sh  vN   SnU R                  USSS5      u  p2U R                  U5      nUS   S-   U-   nSnU R                  XTS   Xb5      I Sh  vN $  NW N7f)a  
unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs.woox.io/#orderbookupdate
https://docs.woox.io/#orderbook

:param str symbol: unified symbol of the market
: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
Nr"   ry   rz   rZ   r{   re   r~   r   r   ru   rH   re   rr   ry   r   rd   rf   s          rJ   un_watch_order_bookwoo.un_watch_order_book   s      !!!66v?OQY[fgV$,$v-((2BERRR 	" S"   A2A.AA2)A0*A20A2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R                  S5      S5      nUS:X  a  X`R                  ;  a  g U R                  U   n	U R                  U	S5      n
U
c  U	R                  R                  U5        g  U R                  US5      nX:  a$  U R                  XU	5        UR                  X5        g g X`R                  ;  a^  U R                  U R                  S	S
5      nUR                  U   nU R                  USU5      nU R                  0 U5      U R                  U'   U R                  U   n	U R                  US5      n
U R                  X6U
SS5      nU	R!                  U5        UR                  X5        g ! [         a5  nU R                  U	 UR                  U	 UR                  X5         S nAg S nAff = f)Ndatare   rf   r{   rN   r}   	timestamptswatchOrderBookLimitr6   rw   bidsasks)	safe_dictsafe_stringsafe_marketsplit
orderbooksrP   cacheappendhandle_order_book_messageresolve	ExceptionsubscriptionsrejectrB   
order_bookparse_order_bookreset)rH   r   r^   r   marketIdr   re   rf   ry   rz   r   r   edefaultLimitrt   rw   snapshots                    rJ   handle_order_bookwoo.handle_order_book   s   . ~~gv.##D(3!!(+!  '2!!%++c"2A6&&oo-/I)))[AI &&w/,**7D9B~66v	Ry8 & oo-#00?TVZ[%33E:)),N*.//"e*D'/I))'48I,,T9ffUHOOH%NN9, ! ,/,,U3MM!++,s   :G 
H+H  Hc                 8   U R                  U R                  SS5      nU R                  USU5      nU R                  US5      nX`R                  ;   a  U R                  U	 U R	                  0 U5      U R                  U'   U R                  U R                  XU5        g )Nr   r6   rw   re   )rP   rB   r   r   r   spawnfetch_order_book_snapshot)rH   r   r^   rt   r   rw   re   s          rJ   r   "woo.handle_order_book_subscription   s    ((7LdS!!,F!!,9__$'"&//"e"<

4116LQrL   c                   #    U R                  US5      nU R                  US5      n U R                  U R                  SS5      nU R                  USU5      nU R                  US5      nU R	                  XGU5      I S h  vN n	U R                  U R
                  U5      c  g U R
                  U   n
U
R                  U	5        U
R                  n[        S[        U5      5       H5  nX   nU R                  US5      nXS	   :  a  M#  U R                  XU
5        M7     XR
                  U'   UR                  X5        g  N! [         a(  nUR                  U	 UR                  X5         S nAg S nAff = f7f)
Nre   rf   r   r6   rw   rr   r   r   r   )r   rP   rB   rO   fetch_rest_order_book_safer   r   r   rangelenr   r   r   r   r   )rH   r   r^   rt   re   r]   r   rw   rr   r   rz   messagesimessageItemr   r   s                   rJ   r   woo.fetch_order_book_snapshot   sV    !!,9&&w8	*,,T\\;PRVWL%%lG\JE__\8<F!<<VFSSHt7?/IOOH% H1c(m,&k&&{D9+..226	R - '0OOF#NN92 T   	*$$[1MM!))	*sN   %E3AD> ?D< !D> !E3"BD> ;E3<D> >
E0E+&E3+E00E3c                    U R                  US5      nU R                  US   U R                  US/ 5      5        U R                  US   U R                  US/ 5      5        U R                  US5      nXSS'   U R	                  U5      US'   U$ )Nr   r   r   r   r   datetime)r   handle_deltasrO   rP   iso8601)rH   r   r^   rz   r   r   s         rJ   r   woo.handle_order_book_message  s    ~~gv.9V,doodFB.OP9V,doodFB.OP%%gt4	!*+ $Y 7	*rL   c                 r    U R                  USS5      nU R                  USS5      nUR                  X45        g )Npricer   quantityrN   )safe_float_2store)rH   booksidedeltar   amounts        rJ   handle_deltawoo.handle_delta  s6    !!%!4""5*a8u%rL   c                 d    [        S[        U5      5       H  nU R                  XU   5        M     g )Nr   )r   r   r   )rH   r   deltasr   s       rJ   r   woo.handle_deltas   s)    q#f+&Ahq	2 'rL   c                    #    U R                  5       I Sh  vN   SnU R                  U5      nUS   nUS   S-   U-   nSUS.nU R                  Xb5      nU R                  XW5      I Sh  vN $  NV N7f)ah  
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>`
Ntickerre   rZ   r{   r`   rj   rf   )r~   r   r[   rb   )rH   re   rr   r|   r   rf   ra   r^   s           rJ   watch_tickerwoo.watch_ticker$  s      !!!V$!ts"T) 
 ++g.&&u666 	" 7s"   A1A-AA1(A/)A1/A1c                    #    U R                  5       I Sh  vN   SnU R                  USSS5      u  p2U R                  U5      nUS   S-   U-   nSnU R                  XTS   Xb5      I Sh  vN $  NW N7f)aj  
unWatches 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>`
Nr$   ry   r   rZ   r{   re   r   r   s          rJ   un_watch_tickerwoo.un_watch_ticker7  s      !!!66v}hX`aV$,$v-((2BERRR 	" Sr   c                 x   U R                  0 SU R                  S U5      _SS _SS _SU R                  US5      _SU R                  US5      _SS _SS _SS _S	S _S
S _SU R                  US5      _SU R                  US5      _SS _SS _SS _SS _SS _U R                  US5      U R                  US5      US.EU5      $ )Nre   r   r   highlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechange
percentageaveragevolumer   )
baseVolumequoteVolumeinfo)safe_tickersafe_symbolr   )rH   r   r   s      rJ   parse_ws_tickerwoo.parse_ws_tickerF  sT     !
d&&tV4!
!
 !
 D$$VV4	!

 4##FE2!
 4!
 !
 4!
 !
 D!
 D$$VV4!
 T%%fg6!
 D!
 T!
 d!
  $!!
" t#!
$ **68<++FH=)!
* + 	rL   c                 6   U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  US5      nXsS'   U R	                  X65      nUS   US'   XR
                  US   '   UR                  X5        U$ )Nr   rf   re   r   date)rO   r   r   rP   r   tickersr   )	rH   r   r^   r   rf   r   r   r   r   s	            rJ   handle_tickerwoo.handle_tickerj  s    " w/1##D(3!!(+%%gt4	 V%%d3!(+x)/VH%&v%rL   rk   c                    #    U R                  5       I Sh  vN   U R                  U5      nSnUnSUS.nU R                  XR5      nU R                  XF5      I Sh  vN nU R	                  USU5      $  N[ N7f)a  

https://docs.woox.io/#24h-tickers

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
: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>`
Nr   r`   r   re   )r~   market_symbolsr[   rb   filter_by_array)rH   rk   rr   r|   rf   ra   r^   r   s           rJ   watch_tickerswoo.watch_tickers  s      !!!%%g. 
 ++g.))%99##GXw?? 	" :s"   A6A2AA6A4A64A6c                    #    U R                  5       I Sh  vN   Ub  [        U R                  S-   5      eSnSnU R                  USX25      I Sh  vN $  N> N7f)a  

https://docs.woox.io/#24h-tickers

stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
:param str[] symbols: unified symbol of the market to stop fetching 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>`
NzW unWatchTickers() does not support a symbols argument. Only unwatch all tickers at oncer   r   r~   r   rZ   ru   )rH   rk   rr   rf   rd   s        rJ   un_watch_tickerswoo.un_watch_tickers  sm      !!!tww  *C   C  D  D(($FFF 	"
 G!   AA9AAAAc                    U R                  US5      nU R                  US5      nU R                  US5      n/ n[        S[        U5      5       Hp  nU R	                  XG   S5      nU R                  U5      n	U R                  U R                  XG   SU05      U	5      n
XR                  U	S   '   UR                  U
5        Mr     UR                  Xc5        g )Nrf   r   r   r   re   r   )rO   rP   r   r   r   r   r   r[   r   r   r   )rH   r   r^   rf   r   r   resultr   r   r   r   s              rJ   handle_tickerswoo.handle_tickers  s    < 1w/%%gt4	q#d)$A'':H%%h/F))$++dg	?R*SU[\F-3LL)*MM&! % 	v%rL   c                 *  #    U R                  5       I Sh  vN   U R                  U5      nSnUnSUS.nU R                  XR5      nU R                  XF5      I Sh  vN nU R                  (       a  U$ U R                  U R                  SU5      $  Nx N67f)a.  

https://docs.woox.io/#bbos

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>`
Nbbosr`   r   re   )r~   r   r[   rb   
newUpdatesr   bidsasks)rH   rk   rr   r|   rf   ra   r^   r   s           rJ   watch_bids_askswoo.watch_bids_asks  s      !!!%%g. 
 ++g.**5::??O##DMM8WEE 	" ;s"   BBABB5BBc                    #    U R                  5       I Sh  vN   Ub  [        U R                  S-   5      eSnSnU R                  USXB5      I Sh  vN $  N> N7f)aA  

https://docs.woox.io/#bbos

unWatches best bid & ask for symbols
:param str[] [symbols]: unified symbol of the market to fetch the ticker for(not used by woo)
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
NzY unWatchBidsAsks() does not support a symbols argument. Only unwatch all bidsAsks at oncer   r   r   )rH   rk   rr   rd   rf   s        rJ   un_watch_bids_askswoo.un_watch_bids_asks  sm      !!!tww  *E   E  F  F(($FFF 	"
 Gr   c                 J   U R                  US5      nU R                  US/ 5      nU R                  US5      n0 n[        S[	        U5      5       H@  nU R                  XG5      nXXS'   U R                  U5      n	U	S   n
XR                  U
'   XU
'   MB     UR                  Xc5        g )Nrf   r   r   r   re   )	r   rp   rP   r   r   r   parse_ws_bid_askr   r   )rH   r   r^   rf   r   r   r   r   r   parsedTickerre   s              rJ   handle_bid_askwoo.handle_bid_ask  s        '2~~gvr2%%gt4	q#d)$A^^D,F$4L008L!(+F$0MM&!)6N % 	v%rL   c                 d   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  UUU R	                  U5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      US.U5      $ )Nre   r   r   askSizer   bidSize)re   r   r   r   r   r   r   r   )r   r   rP   r   r   )rH   r   r   r   re   r   s         rJ   r  woo.parse_ws_bid_ask  s    ##FH5!!(3!!&(3%%fd3	"Y/##FE2))&)<##FE2))&)<	!
 	 		rL   1m	timeframesincec                 $  #    U R                  5       I Sh  vN   US:w  aB  US:w  a<  US:w  a6  US:w  a0  US:w  a*  US:w  a$  US:w  a  US	:w  a  [        U R                  S
-   5      eU R                  U5      nU R	                  U R
                  X"5      nSnUS   S-   U-   S-   U-   n	SU	S.n
U R                  X5      nU R                  X5      I Sh  vN nU R                  (       a  UR                  US   U5      nU R                  XUSS5      $  N N@7f)a0  
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.woox.io/#k-line

: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	  5m15m30m1h1d1w1MzG watchOHLCV timeframe argument must be 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1MklinerZ   r{   _r`   r   re   r   T)r~   r   rZ   r   r   
timeframesr[   rb   r   getLimitfilter_by_since_limit)rH   re   r
  r  rw   rr   r   intervalr|   rf   ra   r^   ohlcvs                rJ   watch_ohlcvwoo.watch_ohlcv.  sH     !!!I$5I<NU^bgUgnw{n  GP  TX  GX  _h  lp  _p  w@  DH  wH*s sttV$##DOOYJts"T)C/(: 
 ++g.''77??NN6(#3U;E))%q$GG 	" 8s"   DDB6DD?DDc                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  X"5      nSnSnUS   S-   U-   S-   U-   nUS   U//US'   U R	                  XS   Xc5      I Sh  vN $  Nn N7f)	a  
unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://docs.woox.io/#k-line

:param str symbol: unified symbol of the market
:param str timeframe: the length of time each candle represents
:param dict [params]: extra parameters specific to the exchange API endpoint
:param dict [params.timezone]: if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr  r  rZ   r{   r  re   rn   )r~   r   r   r  ru   )	rH   re   r
  rr   r   r  rf   r|   rd   s	            rJ   un_watch_ohlcvwoo.un_watch_ohlcvL  s      !!!V$##DOOYJ,$t+c1H<+1(+;Y*G)H%&((2BERRR 	" Ss"   B	BA)B	 BB	B	c           	          U R                  US5      n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5      n	U R	                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US	5      U R                  US
5      /n
U R                  U R                  U0 5      U R                  U'   U R                  U R                  U   U	5      nUc9  U R	                  U R                  SS5      n[        U5      nXR                  U   U	'   UR                  U
5        UR                  X5        g )Nr   rf   re   type	startTimer   r   r   r   r   
OHLCVLimitr6   )rO   r   r   find_timeframerP   
safe_floatohlcvsrB   r   r   r   )rH   r   r^   r   rf   r   r   re   r  r
  parsedstoredrw   s                rJ   handle_ohlcvwoo.handle_ohlcva  sY   & w/1##D(3!!(+!##D&1''1	dK0OOD&)OOD&)OOD%(OOD'*OOD(+
 #oodkk62FFV!4i@>%%dllL$GE*51F-3KK	*fv%rL   c                 N  #    U R                  5       I Sh  vN   U R                  U5      nUS   nUS   S-   nSUS.nU R                  Xt5      nU R                  Xh5      I Sh  vN n	U R                  (       a  U	R                  US   U5      nU R                  XX#S5      $  N N?7f)a  
watches information on multiple trades made in a market

https://docs.woox.io/#trade

: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>`
Nre   rZ   @trader`   r   T)r~   r   r[   rb   r   r  filter_by_symbol_since_limit)
rH   re   r  rw   rr   r   rf   ra   r^   tradess
             rJ   watch_tradeswoo.watch_trades  s      !!!V$!tx' 
 ++g.((88??OOF8$4e<E00tTT 	" 9s"   B%B!AB%#B#$>B%#B%c                    #    U R                  5       I Sh  vN   U R                  U5      nSnUS   S-   nU R                  XSS   XB5      I Sh  vN $  N< N7f)a  
unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

https://docs.woox.io/#trade

: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>`
Nr.  rZ   r,  re   )r~   r   ru   )rH   re   rr   r   rf   rd   s         rJ   un_watch_tradeswoo.un_watch_trades  s`      !!!V$,)((2BERRR	 	" Ss!   AA7AAAAc                    U R                  US5      nU R                  US5      n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SU05      U5      n	U R                  U R                  U5      n
U
c(  U R                  U R                  SS5      n[        U5      n
U
R                  U	5        XR                  U'   UR                  X5        g )Nrf   r   r   re   r   r9   r6   )r   rP   rO   r   parse_ws_trader[   r.  rB   r   r   r   )rH   r   r^   rf   r   r   r   r   re   tradetradesArrayrw   s               rJ   handle_tradewoo.handle_trade  s       '2%%gt4	w/##D(3!!(+!##DKK{I6N$OQWXoodkk6:%%dllM4HE$U+K5!)F{*rL   c                    U R                  US5      nU R                  X25      nUS   nU R                  USS5      nU R                  USS5      n[        R                  " XV5      nU R                  US5      nU R                  US5      n	U R                  US5      n
S nU
b  U
(       a  S	OS
nU R                  US5      nS nU R                  US5      nUb$  UU R                  U R                  US5      5      S.nU R                  U R                  US5      U	U R                  U	5      UUUUUU R                  US5      UUUUS.U5      $ )Nre   executedPricer   executedQuantitysizesider   markermakertakerr!  feefeeCurrencycostcurrencytradeIdorderId)rZ   r   r   re   r>  r   r   rE  ordertakerOrMakerr!  rB  r   )r   r   safe_string_2r   
string_mulsafe_string_lowerrP   	safe_boolsafe_numbersafe_currency_code
safe_trader   )rH   r6  r   r   re   r   r   rE  r>  r   r@  rJ  r!  rB  feeCosts                  rJ   r5  woo.parse_ws_trade  sm   P ##E84!!(3!""5/7C##E+=vF!!%0%%eV4%%e[9	uh/&+7L%%eV4""5%0 33D4D4DUM4Z[C ""5)4"Y/%%eY7( 
  	rL   c                 f    U R                   (       d   U(       a  [        U R                  S-   5      egg)Nz: requires `uid` credential(woox calls it `application_id`)FT)r5   r   rZ   )rH   errors     rJ   check_required_uidwoo.check_required_uid  s'    xx)$''4p*pqqrL   c                 R  #    U R                  5         U R                  S   S   S   S-   U R                  -   nU R                  U5      nSnSnUR	                  U5      nU R                  UR                  U5      nUc  [        U R                  5       5      nSU-   n	U R                  U R                  U	5      U R                  U R                  5      [        R                  5      n
UU R                  U
US.S	.nU R                  X5      nU R!                  X$XU5        UI S h  vN $  N7f)
Nr1   r   r0   rX   authenticatedauth|)apikeysignr   )rj   rr   )check_required_credentialsr@   r5   r   reusableFuturerO   r   ro   noncehmacencoder4   hashlibsha256r3   r[   r\   )rH   rr   rR   r   r]   rj   futurerY  r   rZ  	signaturera   r^   s                rJ   authenticatewoo.authenticate'  s    '')iit$Y/#5@S!%&&{3(<(<kJ TZZ\"B8D		$++d"3T[[5Mw~~^I"kk%!#G kk'2GJJswG||s   DD' D%!D'c                   #    U R                  U5      I S h  vN   U R                  S   S   S   S-   U R                  -   nU R                  U5      nSU0nU R	                  Xb5      nU R                  XAXqU5      I S h  vN $  Nj N7fNr1   r   r0   rX   rZ   )rg  r@   r5   rU   r[   r\   )rH   r]   r^   rr   rR   r;   r`   ra   s           rJ   watch_privatewoo.watch_private?  s     '''iit$Y/#5@OOC(	)
	 ++i1ZZ'	RRR 	( S"   BBA%B=B>BBc                   #    U R                  U5      I S h  vN   U R                  S   S   S   S-   U R                  -   nU R                  U5      nSU0nU R	                  Xb5      nU R                  XAXqU5      I S h  vN $  Nj N7frj  )rg  r@   r5   rU   r[   watch_multiple)rH   messageHashesr^   rr   rR   r;   r`   ra   s           rJ   watch_private_multiplewoo.watch_private_multipleI  s     '''iit$Y/#5@OOC(	)
	 ++i1((WU^___ 	( `rm  c                   #    U R                  5       I Sh  vN   U R                  USSS5      nU(       a  SOSnU R                  USS/5      nUnUb  U R                  U5      nUS   nUSU-   -  nS	US
.n	U R	                  X5      n
U R                  Xz5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XX#S5      $  N N;7f)a<  

https://docs.woox.io/#executionreport
https://docs.woox.io/#algoexecutionreportv2

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
:param bool [params.trigger]: True if trigger order
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NstoptriggerFalgoexecutionreportv2executionreportre   :r`   r   T	r~   safe_bool_2rq   r   r[   rk  r   r  r-  )rH   re   r  rw   rr   ru  rf   r]   r   ra   r^   orderss               rJ   watch_orderswoo.watch_ordersS  s      !!!""669eD,3':K6FI#67[[(FH%F3<'K 
 ++g.))+????OOF2E00tTT# 	" @"   CCBCC:CCc                   #    U R                  5       I Sh  vN   U R                  USSS5      nU(       a  SOSnU R                  USS/5      nSnUb  U R                  U5      nUS   nUS	U-   -  nS
US.n	U R	                  X5      n
U R                  Xz5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XX#S5      $  N N;7f)a<  

https://docs.woox.io/#executionreport
https://docs.woox.io/#algoexecutionreportv2

watches information on multiple trades 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
:param bool [params.trigger]: True if trigger order
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nrt  ru  Frv  rw  myTradesre   rx  r`   r   Try  )rH   re   r  rw   rr   ru  rf   r]   r   ra   r^   r.  s               rJ   watch_my_tradeswoo.watch_my_tradest  s      !!!""669eD,3':K6FI#67 [[(FH%F3<'K 
 ++g.))+????OOF2E00tTT# 	" @r~  c           
         U R                  US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      U R                  US5      S.nU R                  US5      nU R	                  US5      n	U R	                  US	5      n
[
        R                  " US
5      (       a  U
b  U
n	U R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      nU R                  US5      nUnX:  a  UU-  nU R                  USS5      nU R                  U5      nS nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU_SU_SU_SU R                  U5      _SU_SU_SS _SS _SU_SU	_SU_SU_SU R                  US5      _SU_SS _U
UUUUUS.E5      $ )NrH  algoOrderIdre   r   totalFeefeeAssetrD  r   avgPrice0r   r>  r!  totalExecutedQuantitystatus
algoStatusclientOrderIdtriggerPricer   rZ   r   lastTradeTimestamptimeInForcepostOnly	stopPrice
reduceOnlyr   rE  )r   filled	remainingr  rB  r.  )rK  r   r   rP   rO  r   	string_eqr%  rM  parse_order_status
safe_orderr   rN  )rH   rI  r   rH  r   re   r   rB  priceStringr   r  r   r>  r!  r  totalExecQuantityr  	rawStatusr  r.  r  r  s                         rJ   parse_ws_orderwoo.parse_ws_order  s   H $$UI}E##E84X&!%%e[9	$$UJ7((
;
 &&ug6  0##E:6[#..H4HE
3%%eV4%%eV4!!%)@A OOE3JK	&**I&&uhE	((3((@''~>  
E 
f 
 ' 
 ]	 

  
 Y/ 
 !) 
 D 
 4 
  
 D 
 U 
  
 L 
 $..= 
  f! 
" D# 
$  "/ 
  	rL   c                    U R                  US5      nU R                  US5      n[        U[        5      (       ah  [	        S[        U5      5       HN  nXE   nU R                  U R                  US5      5      nUb  U R                  X5        U R                  XU5        MP     g U R                  U R                  US5      5      nUb  U R                  X5        U R                  XU5        g )Nrf   r   r   rG  )	r   rO   
isinstancelistr   r   	omit_zerohandle_my_tradehandle_order)rH   r   r^   rf   r   r   rI  rG  s           rJ   handle_order_updatewoo.handle_order_update  s    <   '2w/dD!!1c$i(..)9)9$	)JK&((7!!&7 ) nnT%5%5dI%FGG"$$V2fE2rL   c                    U R                  U5      nU R                  US5      nU R                  US5      nUGb:  U R                  c-  U R                  U R                  SS5      n[        U5      U l        U R                  nU R                  UR                  U0 5      n	U R                  X5      n
U
bq  U R                  U
S5      nUb  XS'   U R                  U
S5      nUb  XS'   U R                  U
S5      US'   U R                  U
S5      US'   U R                  U
S	5      US	'   UR                  U5        UR                  U R                  U5        US
-   U-   nUR                  U R                  U5        g g )Nre   rZ   r:   r6   rB  feesr.  r   r   rx  )
r  r   r{  rP   rB   r   rO   hashmapr   r   )rH   r   r^   rf   r'  re   rH  rw   cachedOrdersr{  rI  rB  r  messageHashSymbols                 rJ   r  woo.handle_order=  sb   $$W-!!&(3""640{{"))$,,tL4U;;;L__\%9%962FFOOF4E ooeU3?$'5Muf5#%)6N#'??5(#Cx &*&7&7{&K{#%)%5%5eZ%Hz"'NN4;;. %f 4NN4;;(9:) rL   c                    U R                   nUc(  U R                  U R                  SS5      n[        U5      nU R	                  U5      nUR                  U5        SUS   -   nUR                  X65        SnUR                  X65        g )Nr9   r6   z	myTrades:re   r  )r  rP   rB   r   r5  r   r   )rH   r   r^   r  rw   r6  r]   s          rJ   r  woo.handle_my_tradeW  s|    > ==%%dllM4HE-e4H##G,!E(O3x- x-rL   c                 .  #    U R                  5       I Sh  vN   / nU R                  U5      nU R                  U5      (       d5  [        S[	        U5      5       H  nX   nUR                  SU-   5        M     OUR                  S5        U R                  S   S   S   S-   U R                  -   nU R                  U5      n	U R                  X5        U R                  S	S
S5      n
U R                  S	SS5      nU
(       a@  U(       a9  U R                  c,  U	R                  S
5      I Sh  vN nU R                  XX#S5      $ SSS.nU R                  X]U5      I Sh  vN nU R                  (       a  U$ U R                  U R                  XUS5      $  GNx Nj N:7f)az  

       https://docs.woox.io/#position-push

       watch all open positions
       :param str[]|None symbols: list of unified market symbols
@param since
@param limit
       :param dict params: extra parameters specific to the exchange API endpoint
       :returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
       Nr   positions::	positionsr1   r   r0   rX   r)   r7   Tr8   r`   positionr   )r~   r   is_emptyr   r   r   r@   r5   r   set_positions_cachehandle_optionr  re  filter_by_symbols_since_limitrq  r   )rH   rk   r  rw   rr   rp  r   re   rR   r   r7   r8   r   ra   newPositionss                  rJ   watch_positionswoo.watch_positions  s     !!!%%g.}}W%%1c'l+ $$]V%;< ,   -iit$Y/#5@S!  1!%!3!34DF^`d!e!%!3!34DF^`d!e!&<AW#]]+CDDH55hW[\\ 
 "88QWXX??11$..'RWY]^^1 	" E Ys4   FFDF&F'1FF6FFFc                     U R                  SSS5      nU(       a@  SnXQR                  ;  a.  UR                  U5        U R                  U R                  X5        g g [        5       U l        g )Nr)   r7   F)r  futuresre  r   load_positions_snapshotr   r  )rH   r   r!  rk   r7   r]   s         rJ   r  woo.set_positions_cache  s]    !%!3!34DF^`e!f!2K>>1k*

477M 2 67DNrL   c                 r  #    U R                  5       I S h  vN n[        5       U l        U R                  n[        S[	        U5      5       H3  nX5   nU R                  USS5      nUS:  d  M"  UR                  U5        M5     UR                  U   nUR                  U5        UR                  US5        g  N7f)Nr   	contractsr  )	fetch_positionsr   r  r   r   rO  r   r  r   )	rH   r   r]   r  r   r   r  r  re  s	            rJ   r  woo.load_positions_snapshot  s     ..00	13q#i.)A |H((;BI1}X&	 * ,uuk* 1s   B7B5AB7-A	B7c                    U R                  US0 5      nU R                  US0 5      n[        UR                  5       5      nU R                  c  [	        5       U l        U R                  n/ n[        S[        U5      5       Hh  nXX   n	U R                  U	5      n
XI   nU R                  X5      nUR                  U5        UR                  U5        SU
S   -   nUR                  X5        Mj     UR                  US5        g )Nr   r  r   r  re   )rO   r  keysr  r   r   r   r   parse_positionr   r   )rH   r   r^   r   rawPositionspostitionsIdsr   r  r   r   r   rawPositionr  r]   s                 rJ   handle_positionswoo.handle_positions  s    4 w3t["=\..01>>!57DNq#m,-A$'H%%h/F&0K**;?H)LL"'&*::KNN81 . 	|[1rL   c                    #    U R                  5       I Sh  vN   SnUnSUS.nU R                  XA5      nU R                  X55      I Sh  vN $  N7 N7f)a  

https://docs.woox.io/#balance

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
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nbalancer`   r   )r~   r[   rk  )rH   rr   rf   r]   ra   r^   s         rJ   watch_balancewoo.watch_balance  s^      !!! 
 ++g.''=== 	" >s!   AA2A	A
AAc                    U R                  US5      nU R                  US5      n[        UR                  5       5      nU R                  US5      nX0R                  S'   X`R                  S'   U R                  U5      U R                  S'   [        S[        U5      5       H  nXW   nXH   n	U R                  U5      n
XR                  ;   a  U R                  U
   OU R                  5       nU R                  U	S5      nU R                  U	S	5      nXS
'   XS'   [        R                  " X5      US'   XR                  U
'   M     U R                  U R                  5      U l        UR                  U R                  S5        g )Nr   balancesr   r   r   r   r   holdingfrozentotalusedfreer  )rO   r  r  rP   r  r   r   r   rP  accountr   r   
string_subsafe_balancer   )rH   r   r^   r   r  r  r   r   keyvaluecoder  r  r  s                 rJ   handle_balancewoo.handle_balance  sD   : w/??44HMMO$w-#V$&[!#'<<#3Z q#d)$A'CME**3/D-1\\-Adll4(G$$UI6E##E84D$G"FO%00=GFO!(LL % ((6t||Y/rL   c                    SU;  a  gU R                  US5      nU(       a  gU R                  US5      n Ub@  U R                  S-   U R                  U5      -   nU R	                  U R
                  S   XE5        g! [         a`  n[        U[        5      (       a0  SnUR                  Xg5        XqR                  ;   a  UR                  U	 OUR                  U5         S nAgS nAff = f)NsuccessFerrorMsg r>   rY  T)rN  r   rZ   jsonthrow_exactly_matched_exceptionrD   r   r  r   r   r   )rH   r   r^   r  errorMessagefeedbackrU  r]   s           rJ   handle_error_messagewoo.handle_error_message0  s     W$..)4''<	'77S=499W+==44T__W5M|f 	%!455-e1"6"66,,[9e$	s   AA9 9
C#ACC#c                 F   U R                  US5      nSU-   nU R                  UR                  U0 5      nU R                  US/ 5      nU R                  US/ 5      n[	        S[        U5      5       H  nXh   n	Xx   n
U R                  XU
5        M     U R                  U5        g )Nr   rh   rl   rm   r   )r   r   r   rp   r   r   clean_unsubscriptionclean_cache)rH   r   r^   subscribeHashunsubscribeHashrt   rl   rm   r   rd   rs   s              rJ   handle_un_subscriptionwoo.handle_un_subscriptionI  s     ((&9)M9~~f&:&:ORP>>,8JBO!^^L:NPRSq#./0A&)G*-I%%fyA 1 	&rL   c                    U R                  X5      (       a  g 0 SU R                  _SU R                  _SU R                  _SU R                  _SU R
                  _SU R
                  _SU R                  _SU R                  _S	U R                  _S
U R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _nU R                  US5      nU R!                  X45      nUb	  U" X5        g U R                  US5      nUb  U R!                  X65      nUb	  U" X5        g UR#                  S5      n[%        U5      nUS:X  a  U R                  US5      n	U R!                  X95      nUb	  U" X5        g U	R#                  S5      n
[%        U5      nUS:X  a.  U R!                  X0R                  U
S5      5      nUb	  U" X5        g g g g g )Nr<   pongr`   ri   rz   r}   r   r   r  rZ  rw  rv  r6  r  r  r   rj   rf   r{      rN   r  r   )r  handle_pinghandle_ponghandle_subscriber  r   r   r   r)  handle_authr  r8  r  r  r  r   rO   r   r   )rH   r   r^   methodsrj   ry   rf   
splitTopicsplitLengthr|   	splitNamesplitNameLengths               rJ   handle_messagewoo.handle_message^  sO   $$V55
D$$
D$$
 ..
 466	

 //
 t55
 d((
 t**
 T&&
 D$$
 t77
 $T%=%=
 T&&
 t**
 --
  D''!
$   '206#  '2__W4F!v'S)Jj/Ka''
A67%6+ JJsO	"%j/"a'!__W6F6FyRS6TUF)v/ * (   rL   c                 
    SS0$ )Nrj   r<    )rH   r   s     rJ   r<   woo.ping        rL   c                 
    SS0$ )Nrj   r  r  rH   r   r^   s      rJ   r  woo.handle_ping  r  rL   c                 0    U R                  5       Ul        U$ N)millisecondslastPongr  s      rJ   r  woo.handle_pong  s     ++-rL   c                     U R                  US5      nU R                  UR                  S5      nU R                  XC0 5      nU R                  US5      nUb	  U" XU5        U$ )NrZ   ry   )r   index_byr   rO   )rH   r   r^   rZ   subscriptionsByIdrt   ry   s          rJ   r  woo.handle_subscribe  sc     gt, MM&*>*>E'8bAx86L1rL   c                 &   SnU R                  US5      nU(       a.  U R                  UR                  S5      nUR                  S5        g [        U R	                  U5      5      nUR                  Xc5        X1R                  ;   a  UR                  S	 g g )NrY  r  T)rO   r  r   r   r  r   r   )rH   r   r^   r]   r  re  rU  s          rJ   r  woo.handle_auth  sz     &//'95__V^^_EFNN4 '		'(:;EMM%-222((9 3rL   )r  r{  r  r  )T)L__name__
__module____qualname____firstlineno__r   rG   rU   rb   ro   ru   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   r/  r2  r8  r5  rV  rg  rk  rq  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  __static_attributes____classcell__)rI   s   @rJ   r   r      s)   <# <|S RT gC g gS gX[ g0 @DB $!S $! $!S\ $!L =? S S3 S&8- 8-tRV R*6 &
3 68 7 7F 7& 9; SC Ss S"HF : 6:" @7 @ @, 9=R Gg GG G"(&V (&T 8<B FW F7 F0 ;?r G Gc G"&V &:  ?CQUdhqs H H H3 H^a Hx|  ~B  yC H< BFb S3 S3 SUX S*)&6 )&V <@d[] U US U Ubfglbm U4 9; SC Ss S +6 +:JX )+ 0 @B S KM ` 04$UYbd U UC Us Uimnsit UB 37TX\eg UC Us URU Ulpqvlw UBwr-3& -3^;6 ;4(.f (.T 8<$]ajl $_W $_C $_WZ $_quv~q $_L8& 8 8+*2X *, > >&00d6 t 2'V '*-0V -0^!6 !!& !& v ":& : :rL   r   )!ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   r   rc  ccxt.base.typesr   r   r	   r
   r   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  rL   rJ   <module>r     sQ     A  A  v v v v 4  * 0 ) %l:$


 
  l:rL   