
    E#i1                       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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
KJ$r$  S SKJ%r%   " S S\RL                  RN                  5      r'g)    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheBySymbolBySideArrayCacheByTimestamp)AnyBalancesBoolIntLiquidationNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTrade)Client)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InvalidNonce)ChecksumErrorc                     ^  \ rS rSrS\4U 4S jjrS[S\4S jjrS0 4S\4S jjr	0 4S	 jr
SS0 4S
\S\S\S\\   4S jjrSS0 4S\\   S\S\S\\   4S jjr0 4S\\   S\4S jjr0 4S
\S\4S jjrS\4S jr0 4S
\S\4S jjr0 4S\\   S\4S jjrS\4S jr0 4S
\S\4S jjr0 4S
\S\4S jjrS0 4S\S\4S jjr0 4S
\S\4S j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\4S jr#S\S jr$SS0 4S\\   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$ jr*S\S% 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S0 4S*\\\      S\S\4S+ jjr/0 4S*\\\      S\4S, jjr0S\4S- jr1S0 4S
\S\S\24S. jjr3S0 4S\\   S\S\24S/ jjr40 4S\\   S\4S0 jjr50 4S
\S\4S1 jjr6S2 r7S3 r8S\S\4S4 jjr9S\4S5 jr:0 4S6 jr;0 4S\<4S7 jjr=S\4S8 jr>S\4S9 jr?S\S: jr@SSS0 4S
\AS\S\S\\   4S; jjrBSSS0 4S\S\S\S\\C   4S< jjrDS= rESSS0 4S
\AS\S\S\\F   4S> jjrGS\S\4S? jjrHS\4S@ jrISA rJS0 4S
\SB\KSC\LSD\MSE\NS\F4SF jjrOS\4SG jrPSS0 4SH\S
\SB\KSC\LSD\NSE\NS\F4SI jjrQS0 4SH\S
\AS\F4SJ jjrRS0 4SK\\   S
\A4SL jjrSS0 4S
\AS\\F   4SM jjrTS\4SN jrUS\4SO jrVS\4SP jrWS\4SQ jrXS\4SR jrYS\S\Z4SS jr[S\4ST jr\S\S
\S\4SU jr]S\S
\S\4SV jr^S\S
\S\4SW jr_S\S
\4SX jr`S\4SY jraSZrbU =rc$ )]okx   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SSSSSSS.
ESS0SS0S.SSS.SSS0SS0SS0SS0SS 0SS!00 S".	U R                  S#S$.S%.5      $ )&NwsTwatchTickerwatchMarkPricewatchMarkPriceswatchTickerswatchBidsAskswatchOrderBookwatchTradeswatchTradesForSymbolswatchOrderBookForSymbolswatchBalancewatchLiquidationsemulatedwatchLiquidationsForSymbolswatchMyLiquidationswatchMyLiquidationsForSymbols
watchOHLCVwatchOHLCVForSymbols)
watchOrderswatchMyTradeswatchPositionswatchFundingRatewatchFundingRatescreateOrderWseditOrderWscancelOrderWscancelOrdersWscancelAllOrdersWszwss://ws.okx.com:8443/ws/v5zwss://wspap.okx.com:8443/ws/v5)apitestbooks)checksumdepthspotchanneltickerstypeANYopbatch-ordersamend-order)	r,   r0   r'   r*   r8   r9   r=   r>   r&   iPF  )ping	keepAlive)hasurlsoptions	streaming)deep_extendsuperr"   describerO   )self	__class__s    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/okx.pyrW   okx.describe   s   c4 9 ;dt !$ "4	
    !$ t ( +D  $Z .t &z 0  d!" '#$  $!%"&$(%)!%#!%"&%)7> 7 :	 !%0 %3#6 !'y  y! E  E" ." - _2l 		"	s_>
 _ _	    rH   c                     U R                   S   nU(       a  SOSnUS:H  nUS:H  nU R                  S   S   nU(       d  UR                  S5      S	:  d  US
:X  a  US-   U-   $ U(       a  US-   U-   $ US-   U-   $ )NsandboxModez?brokerId=9999 businesspublicrB   r&   candleorders-algoz	/businessz/publicz/private)rS   rR   find)rX   rH   access	isSandboxsandboxSuffix
isBusinessisPublicurls           rZ   get_urlokx.get_urlx   s    LL/	,5(2
*
h&iit$',,x0257m;S$}44?]22Z-//r\   Nsymbolsc                   #    U R                  5       I S h  vN   Uc  U R                  nU R                  U5      nU R                  X!5      n/ n/ n[	        S[        U5      5       HT  nU R                  X8   5      n	UU	S.n
UR                  U R                  X5      5        UR                  US-   X8   -   5        MV     SUS.nU R                  XVX5      I S h  vN $  N N7f)Nr   rH   instId::	subscriberL   args)
load_marketsrn   market_symbolsrl   rangelen	market_idappendextendwatch_multiple)rX   rf   rH   rn   paramsrk   messageHashesru   imarketIdargrequests               rZ   subscribe_multipleokx.subscribe_multiple   s     !!!?llG%%g.ll7+q#g,'A~~gj1H""C KKC01  4'*!<= ( 
 ((WTTT' 	"& Us"   C CC C CC C c                   #    U R                  5       I S h  vN   U R                  X15      nSU0nUb$  U R                  U5      nUSUS   -   -  nUS   US'   SU R                  Xu5      /S.n	U R	                  XbX5      I S h  vN $  No N7f)NrH   :idrq   rs   rt   )rv   rl   marketrU   watch)
rX   rf   messageHashrH   symbolr~   rk   firstArgumentr   r   s
             rZ   rs   okx.subscribe   s     !!!ll7+w
 [[(F3--K&,TlM(#  7
 ZZ'GGG 	" Hs"   B
BA*B
BB
B
r   sincelimitc                 F   #    U R                  U/X#U5      I Sh  vN $  N7f)aL  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-trades-channel
https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-all-trades-channel

get the list of most recent trades for a particular symbol
:param str symbol: unified symbol of the market to fetch trades for
:param int [since]: timestamp in ms of the earliest trade to fetch
:param int [limit]: the maximum amount of trades to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
N)watch_trades_for_symbols)rX   r   r   r   r~   s        rZ   watch_tradesokx.watch_trades   s$      22F8U6RRRRs   !!c                   #    [        U5      nUS:X  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nSnU R                  USSS5      u  pd/ n/ n[        S[        U5      5       HE  n	X   n
UR                  US-   U
-   5        U R                  U
5      nUUS.nUR                  U5        MG     S	US
.nSnUS:X  a  SnU R                  SU05      I Sh  vN   U R                  Xn5      nU R                  XX5      I Sh  vN nU R                  (       a6  U R                  US5      nU R                  US5      nUR                  UU5      nU R!                  UX#SS5      $  GN@ N Nd7f)a  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-trades-channel
https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-all-trades-channel

get the list of most recent trades for a particular symbol
:param str symbols:
: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
:param str [params.channel]: the channel to subscribe to, trades by default. Can be 'trades' and 'trades-all'
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
r   z> watchTradesForSymbols() requires a non-empty array of symbolsNr-   rH   tradesr   rp   rs   rt   ra   
trades-allr`   rf   r   	timestampT)ry   r   r   rv   rw   handle_option_and_paramsrx   r{   rz   authenticaterl   r}   
newUpdates
safe_valuesafe_stringgetLimitfilter_by_since_limit)rX   rn   r   r   r~   symbolsLengthrH   topicsr   r   r   r   topicr   rf   rk   r   firsttradeSymbols                      rZ   r   okx.watch_trades_for_symbols   s     GA#DGG.n$noo!!!%%g.77yZbcq#g,'AZF  3!78~~f-H""E MM%  ( 
 l"F##Xv$6777ll7+**3wVV??OOFA.E**5(;KOOK7E))&%TRR; 	", 8Vs6   =FE? B4F4F5*FF A FFFc                 
  #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2/ n/ n[        S[	        U5      5       HE  nX   nUR                  SU-   U-   5        U R                  U5      nUUS.n	UR                  U	5        MG     S	US
.n
SnUS:X  a  SnU R                  SU05      I Sh  vN   U R                  X;5      nU R                  XX5      I Sh  vN $  N N1 N7f)aG  
unWatches from the stream channel
:param str[] symbols:
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.channel]: the channel to subscribe to, trades by default. Can be trades, trades-all
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
NFr-   rH   r   r   unsubscribe:rp   unsubscribert   ra   r   r`   rf   )
rv   rw   r   rx   ry   r{   rz   r   rl   r}   )rX   rn   r~   rH   r   r   r   r   r   r   r   rf   rk   s                rZ   un_watch_trades_for_symbolsokx.un_watch_trades_for_symbols   s     !!!%%gtU;77yZbcq#g,'AZF  '!9F!BC~~f-H""E MM%  (  
 l"F##Xv$6777ll7+((WTTT1 	", 8Ts4   DC=B6DC?*D8D9D?DDc                 D   #    U R                  U/U5      I Sh  vN $  N7f)a  
unWatches from the stream channel
:param str symbol: unified symbol of the market to fetch trades for
: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)r   rX   r   r~   s      rZ   un_watch_tradesokx.un_watch_trades  s"      55vhGGGG     clientc                    U R                  US0 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U R                  U R                  SS5      n[        S[        U5      5       Hx  n	U R                  Xy   5      n
US-   U-   nU R                  U R                  U5      nUc  [        U5      nXR                  U'   UR                  U
5        UR                  X5        Mz     g )	Nr   rH   rq   datatradesLimit  r   r   )r   r   safe_symbolsafe_integerrS   rx   ry   parse_trader   r   r{   resolve)rX   r   messager   rH   r   r   r   r   r   trader   storeds                rZ   handle_tradesokx.handle_trades  s    B oogub1""3	2##C2!!(+w3''mTJq#d)$A$$TW-E!C-&0K__T[[&9F~#K0&,F#MM% NN6/ %r\   c                 n   #    U R                  U5      nU R                  U/U5      I Sh  vN nX1   $  N7f)aB  
watch the current funding rate

https://www.okx.com/docs-v5/en/#public-data-websocket-funding-rate-channel

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
N)r   watch_funding_rates)rX   r   r~   frs       rZ   watch_funding_rateokx.watch_funding_rateH  s9      V$++VHf==z >s   (53	5c                   #    U R                  5       I Sh  vN   U R                  U5      nSn/ n/ n[        S[        U5      5       HE  nX   nUR	                  US-   U-   5        U R                  U5      nUUS.n	UR	                  U	5        MG     SUS.n
U R                  US5      nU R                  XX5      I Sh  vN nU R                  (       a  U R                  US	5      n0 nXU'   U$ U R                  U R                  S	U5      $  N NN7f)
a  
watch the funding rate for multiple markets

https://www.okx.com/docs-v5/en/#public-data-websocket-funding-rate-channel

:param str[] symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
Nfunding-rater   r   rp   rs   rt   ra   r   )rv   rw   rx   ry   r{   rz   rl   r}   r   r   filter_by_arrayfundingRates)rX   rn   r~   rH   r   r   r   r   r   r   r   rk   fundingRateresults                 rZ   r   okx.watch_funding_ratesV  s     !!!%%g. q#g,'AZF  3!78~~f-H""E MM%  ( 
 ll7H- //G[[??%%k8<FF(6NM##D$5$5xII3 	"& \s#   DD	B%D<D=ADDc                     U R                  US/ 5      n[        S[        U5      5       HC  nX4   nU R                  U5      nUS   nX`R                  U'   UR                  USUS   -   5        ME     g )Nr   r   r   zfunding-rate:)	safe_listrx   ry   parse_funding_rater   r   )rX   r   r   r   r   rawfrr   r   s           rZ   handle_funding_rateokx.handle_funding_rate{  ss    ( ~~gvr2q#d)$AGE11%8K *F(3f%NN;(<{8?T(TU %r\   c                    #    SnU R                  USSS5      u  p2X2S'   U R                  U5      nUS   nU R                  U/U5      I Sh  vN nU R                  XQ5      $  N7f)aE  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

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
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr'   rH   rI   r   )r   r   watch_tickersr   rX   r   r~   rH   r   tickers         rZ   watch_tickerokx.watch_ticker  sp      77yZcd#yV$!))6(F;;v.. <s   A	A#A!A#c                 D   #    U R                  U/U5      I Sh  vN $  N7f)aG  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

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
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
N)un_watch_tickersr   s      rZ   un_watch_tickerokx.un_watch_ticker  s"      **F8V<<<<r   c                 .  #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2U R                  SX1U5      I Sh  vN nU R                  (       a  U$ U R                  U R                  SU5      $  Nz N67f)aW  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

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
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
NFr*   rH   rI   ra   r   rv   rw   r   r   r   r   rI   rX   rn   r~   rH   
newTickerss        rZ   r   okx.watch_tickers  s      !!!%%gtU;77PY[de228WvVV
??##DLL(GDD 	" W"   BBABB5BBc                    #    SnU R                  USSS5      u  p2X2S'   U R                  U5      nUS   nU R                  U/U5      I Sh  vN nXQ   $  N7f)a  

https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel

watches a mark price
:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr(   rH   
mark-pricer   )r   r   watch_mark_pricesr   s         rZ   watch_mark_priceokx.watch_mark_price  sl      77@PR[]ij#yV$!--vh??~ @s   A	AA	Ac                 .  #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2U R                  SX1U5      I Sh  vN nU R                  (       a  U$ U R                  U R                  SU5      $  Nz N67f)a  

https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel

watches mark prices
:param str[] [symbols]: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
NFr)   rH   r   ra   r   r   r   s        rZ   r   okx.watch_mark_prices  s      !!!%%gtU;77@QS\^jk228WvVV
??##DLL(GDD 	" Wr   c                   #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2/ n/ n[        S[	        U5      5       HB  nX   nUR                  SU-   5        U R                  U5      nUUS.n	UR                  U	5        MD     S	US
.n
U R                  US5      nU R                  XX5      I Sh  vN $  N N7f)aY  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

unWatches 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
:param str [params.channel]: the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
NFr*   rH   rI   r   unsubscribe:ticker:rp   r   rt   ra   )	rv   rw   r   rx   ry   r{   rz   rl   r}   )rX   rn   r~   rH   r   r   r   r   r   r   r   rk   s               rZ   r   okx.un_watch_tickers  s      !!!%%gtU;77PY[deq#g,'AZF  !6!?@~~f-H""E MM%  (  
 ll7H-((WTTT) 	"( Us"   CCB:CCCCc                    U R                  X5        U R                  US0 5      nU R                  US5      nU R                  US S5      nUS   nU R                  US5      nU R                  US/ 5      n0 n	[	        S[        U5      5       H(  n
U R                  X   5      nXR                  U'   XU'   M*     US-   U-   nUR                  X5        g )	Nr   rq   -r   rH   r   r   rr   )	handle_bid_askr   r   safe_marketrx   ry   parse_tickerrI   r   )rX   r   r   r   r   r   r   rH   r   r   r   r   r   s                rZ   handle_tickerokx.handle_ticker  s    4 	F,oogub1##C2!!(D#6!""3	2w3
q#d)$A&&tw/F#)LL !'v % nv-z/r\   c                 J  #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2U R                  US5      n/ n/ n[	        S[        U5      5       HQ  nU R                  X   5      nUUS.n	UR                  U R                  X5      5        UR                  S	X   -   5        MS     S
US.n
U R                  XEX5      I Sh  vN nU R                  (       a  0 nXUS   '   U$ U R                  U R                  SU5      $  GN N@7f)ac  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

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>`
NFr+   rH   rI   ra   r   rp   bidask::rs   rt   r   )rv   rw   r   rl   rx   ry   rz   r{   r|   r}   r   r   bidsasks)rX   rn   r~   rH   rk   r   ru   r   r   r   r   r   rI   s                rZ   watch_bids_asksokx.watch_bids_asks<  s,     !!!%%gtU;77QZ\efll7H-q#g,'A~~gj1H""C KKC01  gj!89 ( 
  ..s7ZZ
??G,6Jx()N##DMM8WEE1 	"& [s"   D#DC	D# D!!>D#!D#c                     U R                  US/ 5      nU R                  US0 5      nU R                  U5      nUS   nXPR                  U'   SU-   nUR	                  XW5        g )Nr   r   r   r   )r   	safe_dictparse_ws_bid_askr   r   )rX   r   r   r   r   parsedTickerr   r   s           rZ   r   okx.handle_bid_ask`  sd    4 ~~gvr2a,,,V4h' ,f 6)|1r\   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      $ )	Nrq   r   tsaskPxaskSzbidPxbidSz)r   r   datetimeask	askVolumebid	bidVolumeinfo)r   r   r   safe_tickeriso8601)rX   r   r   r   r   r   s         rZ   r   okx.parse_ws_bid_ask  s    ##FH5!!(3!!&(3%%fd3	"Y/##FG4))&':##FG4))&':	!
 	 		r\   c                 l  #    U R                  5       I Sh  vN   U R                  USSS5      nSn/ nUb8  [        S[        U5      5       H  nX   nUR	                  US-   U-   5        M      OUR	                  U5        U R                  U5      n	Sn
U R                  SX5      u  pSnU
S:X  a  S	n
OU
S
:X  a  Sn
U
R                  5       nSUUS./S.nU R                  US5      nU R                  XX5      I Sh  vN nU R                  (       a  U$ U R                  U R                  XUS5      $  GN N87f)a  
watch the public liquidations of a trading pair

https://www.okx.com/docs-v5/en/#public-data-websocket-liquidation-orders-channel

:param str symbols:
:param int [since]: the earliest time in ms to fetch liquidations for
:param int [limit]: the maximum number of liquidation structures to retrieve
:param dict [params]: exchange specific parameters for the okx api endpoint
:returns dict: an array of `liquidation structures <https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure>`
NTliquidationsr   rr   watchliquidationsForSymbolsliquidation-ordersrG   SWAPfuturefuturesrs   rH   instTypert   ra   )rv   rw   rx   ry   r{   get_market_from_symbolshandle_market_type_and_paramsupperrl   r}   r   filter_by_symbols_since_limitr  )rX   rn   r   r   r~   r   r   r   r   r   rJ   rH   uppercaseTyper   rk   newLiquidationss                   rZ   watch_liquidations_for_symbols"okx.watch_liquidations_for_symbols  sR     !!!%%gtT4@$1c'l+ $$[4%7&%@A ,   ---g699:WY_h&6>DXD

  ' -
 ll7H- $ 3 3C __??""11$2C2CWUZ\`aaA 	": `s"   D4D/C"D49D2:6D42D4c                    U R                  US/ 5      n[        S[        U5      5       H  nX4   nU R                  U5      nU R	                  US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                  U/S5        UR                  U/SU-   5        M     g )Nr   r   r   liquidationsLimitr   r  zliquidations::)r   rx   ry   parse_ws_liquidationr   r   r  r   rS   r   r{   r   )
rX   r   r   rawLiquidationsr   rawLiquidationliquidationr   r  r   s
             rZ   handle_liquidationokx.handle_liquidation  s    8 ..&"=q#o./A,/N33NCK%%k8<F??4+<+<fEL#))$,,8KTR)%0,(4f%NNK=.9NNK=*:V*CD 0r\   c                   #    U R                  5       I Sh  vN   U R                  USSS5      nU R                  USS/5      nU R                  SU(       a  SOS05      I Sh  vN   U R	                  USSS5      nS	n/ nUb8  [        S
[        U5      5       H  nX   n	UR                  US-   U	-   5        M      OUR                  U5        Sn
SSU
0/S.nU R                  U
S5      nU R                  XU R                  X5      U5      I Sh  vN nU R                  (       a  U$ U R                  U R                  XUS5      $  GN, N N:7f)a  
watch the private liquidations of a trading pair

https://www.okx.com/docs-v5/en/#trading-account-websocket-balance-and-position-channel

:param str[] symbols:
:param int [since]: the earliest time in ms to fetch liquidations for
:param int [limit]: the maximum number of liquidation structures to retrieve
:param dict [params]: exchange specific parameters for the okx api endpoint
:returns dict: an array of `liquidation structures <https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure>`
NstoptriggerFrf   r`   privateTmyLiquidationsr   rr   balance_and_positionrs   rH   rt   )rv   safe_value_2omitr   rw   rx   ry   r{   rl   r}   rU   r   r  r  )rX   rn   r   r   r~   	isTriggerr   r   r   r   rH   r   rk   r  s                 rZ   !watch_my_liquidations_for_symbols%okx.watch_my_liquidations_for_symbols  s^     !!!%%ffiG	6FI#67:	 RSSS%%gtT4@&1c'l+ $$[4%7&%@A ,   -( w
 ll7I. $ 3 3CHXHXY`Hikx yy??""11$2C2CWUZ\`aa5 	" 	T( zs5   E	EAE	"E#B)E	E6E	E	E	c                    U R                  US/ 5      n[        S[        U5      5       H  nX4   nU R                  US5      nUS:w  a    g U R	                  U5      nU R                  US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                  U/S5        UR                  U/S	U-   5        M     g )
Nr   r   	eventTyper   r   myLiquidationsLimitr   r'  zmyLiquidations::)r   rx   ry   r   parse_ws_my_liquidationr   r  r   rS   r   r{   r   )rX   r   r   r  r   r  r/  r   r   r  r   s              rZ   handle_my_liquidationokx.handle_my_liquidation  s    F ..&"=q#o./A,/N((EIM)66~FK%%k8<F??4+<+<fEL#))$,,8MtT)%0,(4f%NNK=*:;NNK=*<v*EF 0r\   c                    U R                  US/ 5      nU R                  US0 5      nU R                  US5      nU R                  XR5      nU R	                  US5      nU R                  UU R                  XR5      U R                  US5      U R                  US5      U R                  US5      S S UU R                  U5      S.	5      $ )	NposDatar   rq   uTImeposcontractSizeavgPx)	r  r   	contractsr8  price	baseValue
quoteValuer   r  	r   r   r   r   r   safe_liquidationr   safe_numberr  )rX   r   r   r5  firstPosDatar   r   s          rZ   r1  okx.parse_ws_my_liquidationF  s    : ..i<~~gq"5##L(;!!(3%%lG<	$$&&x8)),> ,,V^D%%k7;"Y/
&
 
 
	r\   c                    U R                  US/ 5      nU R                  US0 5      nU R                  US5      nU R                  XR5      nU R	                  US5      nU R                  UU R                  XR5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      S S UU R                  U5      S	.
5      $ )
Ndetailsr   rq   r   szr8  bkPxside)
r  r   r:  r8  r;  rG  r<  r=  r   r  r>  )rX   r   r   rD  liquidationDetailsr   r   s          rZ   r  okx.parse_ws_liquidationt  s    * ..i<!^^GQ;##K:!!(3%%&8$?	$$&&x8))*<dC ,,V^D%%&8&A$$%7@"Y/&
  	r\   1m	timeframec                 H  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U R                  X"5      nSU-   nU R	                  SXwX5      I Sh  vN nU R
                  (       a  UR                  X5      nU R                  XUSS5      $  N N<7f)a  
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nrb   ra   r   T)rv   r   r   
timeframesrs   r   r   r   )	rX   r   rK  r   r   r~   intervalnameohlcvs	            rZ   watch_ohlcvokx.watch_ohlcv  s      !!!V$##DOOYJ("nnXt6JJ??NN61E))%q$GG 	" Ks"   B"BAB"#B $;B" B"c                 z   #    U R                  5       I Sh  vN   U R                  X//U5      I Sh  vN $  N  N7f)a  
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
N)rv   un_watch_ohlcv_for_symbols)rX   r   rK  r~   s       rZ   un_watch_ohlcvokx.un_watch_ohlcv  s=      !!!44v6I5JFSSS 	"Ss   ;7;9;;symbolsAndTimeframesc                   #    [        U5      nUS:X  d  [        US   [        5      (       d  [        U R                  S-   5      eU R                  5       I Sh  vN   / n/ n[        S[        U5      5       Hs  nX   n	U	S   n
U	S   nU R                  U
5      nU R                  U R                  X5      nSU-   nUUS.nUR                  U5        UR                  SU-   S-   U
-   5        Mu     S	US
.nU R                  SS5      nU R                  UUUU5      I Sh  vN u  nnnU R                  (       a  UR                  UU5      nU R                  UX#SS5      nU R!                  UUU5      $  GN NU7f)a2  
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str[][] symbolsAndTimeframes: array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
: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
r   u watchOHLCVForSymbols() requires a an array of symbols and timeframes, like  [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]N   rb   rp   multi:r   rs   rt   ra   T)ry   
isinstancelistr   r   rv   rx   rz   r   rM  r{   rl   r}   r   r   r   create_ohlcv_object)rX   rW  r   r   r~   r   r   r   r   symbolAndTimeframesymtfr   rN  rH   r   r   rk   r   rK  candlesfiltereds                         rZ   watch_ohlcv_for_symbolsokx.watch_ohlcv_for_symbols  s     01AZ0DQ0G%N%N#DGG  /f  %f  g  g!!!q#234A!5!8$Q'C#A&B~~c*H''@H)G""E MM%   G!3c!9C!?@ 5 
 ll8X.+/+>+>sMSZ\i+j%j"	7??$$VU3E--guQM''	8DD3 	"* &ks&   AE2E-CE2E0AE20E2c                 F  #    [        U5      nUS:X  d  [        US   [        5      (       d  [        U R                  S-   5      eU R                  5       I Sh  vN   / n/ n[        S[        U5      5       Hs  nX   nUS   nUS   n	U R                  U5      n
U R                  U R                  X5      nSU-   nUU
S.nUR                  U5        UR                  SU-   S-   U-   5        Mu     S	US
.nU R                  SS5      nU R                  XX5      I Sh  vN $  N N7f)a  
unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
:param str[][] symbolsAndTimeframes: array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
r   rY  NrZ  rb   rp   zunsubscribe:multi:r   r   rt   ra   )ry   r\  r]  r   r   rv   rx   rz   r   rM  r{   rl   r}   )rX   rW  r~   r   r   r   r   r_  r`  ra  r   rN  rH   r   r   rk   s                   rZ   rT  okx.un_watch_ohlcv_for_symbols  sF     01AZ0DQ0G%N%N#DGG  /f  %f  g  g!!!q#234A!5!8$Q'C#A&B~~c*H''@H)G""E MM%   !5!?#!E!KL 5  
 ll8X.((WTTT+ 	"* Us%   AD!DC D!DD!D!c                    U R                  US0 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                  SS5      n	U R	                  U	5      n
[        S[        U5      5       H  nU R                  X[   U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S-   US   -   nUR                  X5        SU-   S-   U-   nUR                  XU/U5        M     g )Nr   rH   r   rq   r   rb   r_   r   
OHLCVLimitr   r   r   r[  )r   r   r   replacefind_timeframerx   ry   parse_ohlcvohlcvsr   rS   r   r{   r   )rX   r   r   r   rH   r   r   r   r   rN  rK  r   parsedr   r   r   messageHashForMultis                    rZ   handle_ohlcvokx.handle_ohlcv  st   " oogub1""3	2w3##C2!!(+!??8R0''1	q#d)$A%%dgv6F"&//$++vr"JDKK__T[[%8)DF~))$,,dK.u517F#I.MM&!!C-&,6KNN6/ #+W"4s":V"CNNFv68KL %r\   c                 D   #    U R                  U/X#5      I Sh  vN $  N7f)a  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

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.depth]: okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
: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)rX   r   r   r~   s       rZ   watch_order_bookokx.watch_order_book,  s#     F 66xOOOOr   c                   #    U R                  5       I Sh  vN   U R                  U5      nSnU R                  USSS5      u  pCUb)  US:X  a  SnO US:  a	  US::  a  SnOUS	:X  a  S
nOUS:X  a  SnUS:X  d  US
:X  aI  U R                  S5      (       d  [	        U R
                  S-   5      eU R                  SS05      I Sh  vN   / n/ n[        S[        U5      5       HE  nX   nUR                  US-   U-   5        U R                  U5      n	UU	S.n
UR                  U
5        MG     SUS.nU R                  US5      nU R                  XX5      I Sh  vN nUR                  5       $  GNR N N7f)a  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
:param str[] symbols: unified array of symbols
:param int [limit]: 1,5, 400, 50(l2-tbt, vip4+) or 40000(vip5+) the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.depth]: okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr,   rF   rD   rZ  bbo-tbt   books52   books50-l2-tbt  books-l2-tbtFz watchOrderBook/watchOrderBookForSymbols requires authentication for self depth. Add credentials or change the depth option to books or books5rf   ra   r   r   rp   rs   rt   )rv   rw   r   check_required_credentialsr   r   r   rx   ry   r{   rz   rl   r}   r   )rX   rn   r   r~   rF   r   r   r   r   r   r   r   rk   	orderbooks                 rZ   rs   okx.watch_order_book_for_symbolsQ  s     !!!%%g.55f>NPWY`az!uz "(#^#2B)B22599)$''  5E  +E  F  F##Xx$8999q#g,'AZF  v!56~~f-H "E MM%  ( 
 ll5(+--c'YY	  E 	"  :" Zs5   E/E(B)E/ E+BE/E-E/+E/-E/c                 h  #    U R                  5       I Sh  vN   U R                  USS5      nSnU R                  USSS5      u  p2U R                  US5      nUb)  US:X  a  SnO US:  a	  US	::  a  S
nOUS:X  a  SnOUS:X  a  Sn/ n/ n/ n[	        S[        U5      5       HY  nX   n	UR                  US-   U	-   5        UR                  SU	-   5        U R                  U	5      n
UU
S.nUR                  U5        M[     SUS.nU R                  US5      nU R                  XX5      I Sh  vN $  GN N7f)as  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
:param str[] symbols: unified array of symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.limit]: the maximum amount of order book entries to return
:param str [params.depth]: okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
NFr,   rF   rD   r   rZ  rw  rx  ry  rz  r{  r|  r   r   unsubscribe:orderbook:rp   r   rt   ra   )
rv   rw   r   r   rx   ry   r{   rz   rl   r}   )rX   rn   r~   rF   r   r   subMessageHashesr   r   r   r   r   r   rk   s                 rZ   un_watch_order_book_for_symbols#okx.un_watch_order_book_for_symbols  s_     !!!%%gtU;55f>NPWY`a!!&'2z!uz "(#q#g,'AZF##ECK&$89  !9F!BC~~f-H "E MM%  (  
 ll5(+((WTTTA 	"@ Us"   D2D-DD2(D0)D20D2c                 D   #    U R                  U/U5      I Sh  vN $  N7f)ap  

https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
:param str symbol: unified array of symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.limit]: the maximum amount of order book entries to return
:param str [params.depth]: okx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
N)r  r   s      rZ   un_watch_order_bookokx.un_watch_order_book  s"      996(FKKKKr   c                 n    U R                  US5      nU R                  US5      nUR                  X45        g )Nr   rZ  )
safe_floatstore)rX   booksidedeltar;  amounts        rZ   handle_deltaokx.handle_delta  s0     q)*u%r\   c                 d    [        S[        U5      5       H  nU R                  XU   5        M     g )Nr   )rx   ry   r  )rX   r  deltasr   s       rZ   handle_deltasokx.handle_deltas  s)    q#f+&Ahq	2 'r\   c                    U R                  US/ 5      nU R                  US/ 5      nUS   nUS   n	U R                  X5        U R                  X5        U R                  US5      n
U R                  X5      nU R	                  SSS5      nU R                  US5      nU(       Ga  U R                  US5      nUS	   n[        U5      n[        U	5      n/ n[        S
S5       H  nUU:  aL  UR                  U R                  U	U   S
   5      5        UR                  U R                  U	U   S   5      5        UU:  d  M]  UR                  U R                  UU   S
   5      5        UR                  U R                  UU   S   5      5        M     SR                  U5      nU R                  US5      nU R                  US5      nS nUS:w  a  X:w  a  [        U R                  S-   5      nUU:w  a*  [        U R                  S-   U R                  U5      -   5      nUb/  UR                   U	 Ub  U R"                  U	 UR%                  UU5        U R                  US5      nXS	'   UUS'   U R'                  U5      US'   U$ )Nasksbidsrq   r,   rE   TseqId	prevSeqIdnoncer      rZ  r   rc   z& watchOrderBook received invalid nonce r   r   r  )r   r  r   r   handle_optionr   ry   rx   r{   number_to_stringjoincrc32r   r   r    orderbook_checksum_messagesubscriptions
orderbooksrejectr  )rX   r   r   r  r   r   r  r  
storedAsks
storedBidsr   r   rE   r  r  r  
asksLength
bidsLengthpayloadArrayr   payloadresponseChecksumlocalChecksumerrorr   s                            rZ   handle_order_book_messageokx.handle_order_book_message  sq   ( w3w3v&
v&
:,:,##GX6!!(3%%&6
DI!!'73))';?Ig&EZJZJL1b\z> ''(=(=jmA>N(OP ''(=(=jmA>N(OPz> ''(=(=jmA>N(OP ''(=(=jmA>N(OP " hh|,G#00*E JJw5MEB5#5$TWW/W%WX=0%dggmd6U6UV\6]&]^ ((5%/e[1%%gt4	"'!*	+ $Y 7	*r\   c           
      D   U R                  US0 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 R                  U5      nUS   n	SSS	SS
S.n
U R	                  X5      nUS-   U	-   nUS:X  ai  [        S[        U5      5       HN  nXm   nU R                  0 U5      nXR                  U	'   XS'   U R                  XX5        UR                  X5        MP     U$ US:X  ad  XR                  ;   aS  U R                  U	   n[        S[        U5      5       H+  nXm   nU R                  XXU5        UR                  X5        M-     U$ US:X  d  US:X  a  XR                  ;  a  U R                  0 U5      U R                  U	'   U R                  U	   n[        S[        U5      5       HQ  nXm   nU R	                  US5      nU R                  XUSSSS5      nUR                  U5        UR                  X5        MS     U$ )Nr   rH   actionr   rq   r   rZ  r|  rx  rz  )rw  rD   ry  r}  r{  r   snapshotr   updatery  rw  r   r  r  )r   r   r   r   r   rx   ry   
order_bookr  r  r   parse_order_bookreset)rX   r   r   r   rH   r  r   r   r   r   depthsr   r   r   r  r  r   r  s                     rZ   handle_order_bookokx.handle_order_book  s*   l nnWeR0""3	2!!'84~~gvr2##C2!!(+! 
 !!&2mf,Z1c$i( OOB6	*3'&,(#..vyVy6 )0 # x( OOF3	q#d),A!WF2269[abNN9: -  !w)';oo-*.//"e*D'/I1c$i( --fd;	00FTZ\]_`a)y6 ) r\   c                   #    U R                  5         U R                  USS5      nU R                  US/5      nU R                  SU5      nSnU R	                  U5      nUR                  U5      nU R                  UR                  U5      nUc  [        U R                  5       5      nSn	Sn
X-   U
-   nU R                  U R                  U5      U R                  U R                  5      [        R                  S5      nSnUU R                  U R                   UUS	./S
.nSU;   a  US   US'   U R#                  X4X5        UI S h  vN $  N7f)Nrf   r&  usersauthenticatedGETz/users/self/verifybase64login)apiKey
passphraser   signrt   )r~  r   r*  rl   r   reusableFuturer   r  strsecondshmacencodesecrethashlibsha256r  passwordr   )rX   r~   rf   rk   r   r   r  r  r   methodpathauth	signature	operationr   s                  rZ   r   okx.authenticate  s<    '')!!&(I>6H:.ll7F+%S!&&{3(<(<kJ DLLN+IF'D%,D		$++d"3T[[5Mw~~_ghII #'++&*mm%. )	
G 6!$*8$4!JJs>||s   E E	EE	c                    #    U R                  5       I Sh  vN   U R                  5       I Sh  vN   U R                  SSSSU5      I Sh  vN $  N9 N# N7f)z
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>`
Nr&  account)rv   r   rs   )rX   r~   s     rZ   watch_balanceokx.watch_balance  sP      !!!!!!^^Iy)T6RRR 	"!Rs1   AAAAAAAAAc                 &    U R                  X5        g N)r2  rX   r   r   s      rZ   handle_balance_and_positionokx.handle_balance_and_position  s    ""63r\   c                 J   U R                  US0 5      nU R                  US5      nSnU R                  U5      nU R                  U R                  U0 5      nU R	                  Xv5      nU R                  U5      U R                  U'   UR                  U R                  U   U5        g )Nr   rH   rG   )r   r   parseTradingBalancebalancerU   safe_balancer   )	rX   r   r   r   rH   rJ   r  
oldBalance
newBalances	            rZ   handle_balanceokx.handle_balance  s    X oogub1""3	2**73__T\\4<
%%j:
!..z:Tt||D)73r\   c                 P   U R                  US0 5      nU R                  US5      nU R                  US5      nU R                  USS5      S:H  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(       a  SOS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5      S.S.U5      $ )Nr  fillTime
fillFeeCcyexecTyper_   Tr   tradeIdr   rJ   takermakerrG  fillPxfillSzcostfillFee)r  currency)r  r   r  r   r   orderrJ   takerOrMakerrG  r;  r  r  fee)r   r   r   
safe_trader  r@  safe_currency_code)rX   r  r   r  r   feeMarketIdisTakers          rZ   order_to_tradeokx.order_to_trade  s(   ufb1%%dJ7	&&t\:""4R8C?"Y/&&uh7""43%%eT2$$UF3(/Gg$$UF3%%dH5&&tX6$$UF3((y9 33K@ 
" # 	r\   c           
        #    SnU R                  USSS5      u  pTU R                  USSS5      nU R                  USS/5      nU R                  5       I Sh  vN   U R	                  SU(       a  S	OS
05      I Sh  vN   U(       a  SOSnUS-   nSn	Ub#  U R                  U5      n	U	S   nU	S   nUS-   U-   nUS:X  a  SnUR                  5       n
SnU R                  SU5      u  pU
S:X  a  Ub  Sn
SU
0nU R                  S
XSU R                  X5      5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XX#S5      $  N N N=7f)a-  
watches information on multiple trades made by the user

https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel

: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
:param bool [params.trigger]: True if fetching trigger or conditional trades
:param str [params.type]: 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
:param str [params.marginMode]: 'cross' or 'isolated', for automatically setting the type to spot margin
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr9   rJ   rK   r%  r$  Frf   r`   r&  rd   orders
::myTradesr   rr   r  r  SPOTMARGINr  T)r   safe_bool_2r*  rv   r   r   r  handle_margin_mode_and_paramsrs   r|   r   r   filter_by_symbol_since_limit)rX   r   r   r   r~   rJ   r+  rH   r   r   r  
marginModer   r  s                 rZ   watch_my_tradesokx.watch_my_trades  sz      44V_fV[\$$VYF	6Iv#67!!!:	 RSSS#,-(,[[(FH%F&>D%,v5K8D


!??QWX
F"% (
 ~~itT[[Y`Mijj??OOF2E00tTT1 	"S( ks7   AEE#E:E;BEE:EEEc           	        #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN   U R                  U5      nSS0nSnSnUcI  SSS.nU R                  X5      /n	SU	S.n
U R	                  US5      nU R                  XX5      I Sh  vN nO*U R                  SXaU R                  XT5      5      I Sh  vN nU R                  (       a  U$ U R                  U R                  XUS	5      $  N N Nd N;7f)
a  

       https://www.okx.com/docs-v5/en/#trading-account-websocket-positions-channel

       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  rK   	positionsr  rs   rt   r&  T)
rv   r   rw   r|   rl   r   r   r   r  r  )rX   rn   r   r   r~   r   rH   newPositionsr   ru   nonSymbolRequestrk   s               rZ   watch_positionsokx.watch_positions6  s     !!!'''%%g.
 ?&!C KK,-D!& ,,w	2C!%C:J!TTL!%!8!8GVZVaVabiVr!ssL??11$..'RWY]^^1 	"'$ UssD   C<C4C<C6A#C<C8*C<>C:?6C<6C<8C<:C<c                    U R                  US0 5      nU R                  US5      nU R                  US S5      nUS   nU R                  USS5      nU R                  US/ 5      nU R                  c  [	        5       U l        U R                  n	/ n
[        S[        U5      5       H  nX   nU R                  U5      nUS	   S:X  a=  S
US'   U R                  U5      nSUS'   U	R                  U5        U
R                  U5        U
R                  U5        U	R                  U5        M     UnUb  US-   U-   nUR                  X5        g )Nr   rq   r   r   rH   r_   r   r   r:  longrG  shortrr   )r   r   r   r  r   rx   ry   parse_positioncloner{   r   )rX   r   r   r   r   r   r   rH   r   cacher  r   rawPositionpositionshortPositionr   s                   rZ   handle_positionsokx.handle_positions\  sE   F oogub1##C2!!(D#6!""3	26w3>>!57DNq#d)$A'K**;7H$)#)  $

8 4(/f%]+##M2)LL" % !D.61K|1r\   c           
        #    SnU R                  USSS5      u  pTU R                  USSS5      nU R                  USS/5      nU R                  5       I Sh  vN   U R	                  SU(       a  S	OS
05      I Sh  vN   SnUb  U R                  U5      nUS   nUS   nUS:X  a  SnUR                  5       nSn	U R                  SU5      u  pUS:X  a  U	b  SnSU0n
U(       a  SOSnU R                  S
XXR                  X5      5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XX#S5      $  N N N=7f)a1  
watches information on multiple orders made by the user

https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel

:param str [symbol]: unified market symbol of the market the 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 fetching trigger or conditional orders
:param str [params.type]: 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
:param str [params.marginMode]: 'cross' or 'isolated', for automatically setting the type to spot margin
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr8   rJ   rK   r$  r%  Frf   r`   r&  r   r  r  r  r  r  rd   r  T)r   r)  r*  rv   r   r   r  r  rs   r|   r   r   r   )rX   r   r   r   r~   rJ   r+  r   r  r  r   rH   r  s                rZ   watch_ordersokx.watch_orders  s^     44V]FTYZ%%ffiG	6FI#67!!!:	 RSSS[[(FH%F&>D8D


!??vV
F"% (
 $--(~~i6;;W^Kghh??OOF2E00tTT- 	"S$ is7   AEE#E:E;BEE
:EE
Ec                    U R                  X5        U R                  US0 5      nU R                  US5      nU R                  US/ 5      n[        U5      nUS:  Ga   U R	                  U R
                  SS5      nU R                  c   [        U5      U l        [        U5      U l        US:X  a  U R                  OU R                  n	/ n
U R                  U5      n[        S[        U5      5       HB  nX   nU	R                  U5        US   nU R                  U5      nU
R                  US	   5        MD     UR                  X5        [        S[        U
5      5       H  nUS
-   X   -   nUR                  U	U5        M!     g g )Nr   rH   r   r   ordersLimitr   rd   r   r   r   )handle_my_tradesr   r   ry   r   rS   r  r   triggerOrdersparse_ordersrx   r{   r   r   )rX   r   r   subscriptionr   rH   r  ordersLengthr   r   	marketIdsrn  r   r  r   r   r   s                    rZ   handle_ordersokx.handle_orders  sY   n 	f.oogub1""3	2&"56{!%%dllM4HE{{"4U;%;E%B",3},DT''4;;FI&&v.F1c&k*	e$xV,  . + NN6+1c)n-%mil:v{3 . r\   c                    U R                  US0 5      nU R                  US5      nU R                  US/ 5      n/ n[        S[        U5      5       HM  nXW   nU R                  USS5      n	[        U	5      S:  d  M+  U R	                  U5      n
UR                  U
5        MO     [        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       H3  nXg   nU R                  U5      nUR                  U5        US	   nS
UU'   M5     US-   nUR                  U R                  U5        [        UR                  5       5      n[        S[        U5      5       H*  nUS-   UU   -   nUR                  U R                  U5        M,     g )Nr   rH   r   r   r  r_   r   r   r   Tr  rr   )r   r   rx   ry   parse_orderr{   myTradesr   rS   r   r  r   r]  keys)rX   r   r   r   rH   	rawOrdersfilteredOrdersr   rawOrderr  r  tradesLengthr   r$  rn   rawTrader   r   r   tradeSymbolssymbolMessageHashs                        rZ   r  okx.handle_my_trades4  s   n oogub1""3	2OOGVR8	q#i.)A |H&&xB?G7|a((2%%e, * >*1== %%dllM4HE259DM==q#n-.A%(H''1EOOE"8_F"GFO / ,t}}k2GLLN+q#l+,A +d 2\!_ DNN4==*;< -r\   c                 t    [        U R                  5       5      nU R                  S5      n[        U5      nX-   $ )N   )r  millisecondsrand_number)rX   r   randomNumber
randomParts       rZ   
request_idokx.request_id  s7    ""$%''*&
r\   rJ   rG  r  r;  c                 6  #    U R                  5       I Sh  vN   U R                  5       I Sh  vN   U R                  SS5      nU R                  5       nSn	U R	                  USSS5      u  pU R                  XX4XV5      n
U R                  U
S5      nUS:X  d  US:X  d  US	:X  d  US
:X  d  US:X  d  US:X  a  [        U R                  S-   5      eU	S:w  a  U	S:w  a  [        U R                  S-   5      eUU	U
/S.nU R                  XxX5      I Sh  vN $  N N N7f)a  

https://www.okx.com/docs-v5/en/#websocket-api-trade-place-order

create a trade 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|None [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
:param boolean params['test']: test order, default False
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr&  r=   rL   rM   ordTyper%  conditionalocomove_order_stopicebergtwapzw createOrderWs() does not support algo trading. self.options["createOrderWs"]["op"] must be either order or batch-orderr  z createOrderWs() does not support algo trading. self.options["createOrderWs"]["op"] must be either order or privatePostTradeOrder or privatePostTradeOrderAlgor   rL   ru   )
rv   r   rl   r4  r   create_order_requestr   r   r   r   )rX   r   rJ   rG  r  r;  r~   rk   r   rL   ru   r7  r   s                rZ   create_order_wsokx.create_order_ws  sU     !!!!!!ll9i0oo'226?DR`a
((tUS""43y g&>DEMW[_pWpvz  H  wH  NR  V\  N\TWW  (a  a  b  b'Mn 4TWW  (H  H  I  IF

 ZZ'GGG# 	"!  Hs2   DDDDCDDDDDc                    U R                  US5      nU R                  US/ 5      nU R                  USS5      nU R                  U5      (       aE  U R                  US5      nU R	                  U5      nU R                  SSUR                  U0 Xb0 0 5	        U R                  US S S 5      nU R                  US0 5      nUR                  X5        g )	Nr   r   sCode0rL   rZ  r_   r   )
r   r   	filter_byis_emptyjsonhandle_errorsrk   r  r   r   )	rX   r   r   r   ru   r  	stringMsgr  r   s	            rZ   handle_place_ordersokx.handle_place_orders  s    & &&w5w3~~dGS1==%%gt4F		'*Iq"fjj&"iRTVXY""4tT:vq"-u*r\   r   c           	      t  #    U R                  5       I Sh  vN   U R                  5       I Sh  vN   U R                  SS5      nU R                  5       n	Sn
U R	                  USSS5      u  pU R                  XX4XVU5      nU	U
U/S.nU R                  XU R                  X5      U	5      I Sh  vN $  N N N7f)a  
edit a trade order

https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-amend-order
https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-amend-multiple-orders

: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|None [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>`
Nr&  r>   rL   rN   r=  )rv   r   rl   r4  r   edit_order_requestr   r|   )rX   r   r   rJ   rG  r  r;  r~   rk   r   rL   ru   r   s                rZ   edit_order_wsokx.edit_order_ws  s       !!!!!!ll9i0oo'226=$P]^
&&r4vfUF

 ZZ$++g2NP[\\\ 	"! ]s2   B8B2B8B4A>B8-B6.B84B86B8c                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  5       I Sh  vN   U R	                  SS5      nU R                  5       nU R                  USS5      nU R                  USS/5      nSU R                  U5      0nUb  XgS'   OXS'   USU R                  Xs5      /S	.nU R                  XEX5      I Sh  vN $  N N N7f)
a  

https://okx-docs.github.io/apidocs/websocket_api/en/#cancel-order-trade

cancel multiple orders
:param str id: order id
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.clOrdId]: client order id
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz+ cancelOrderWs() requires a symbol argumentr&  clOrdIdclientOrderIdrq   ordIdcancel-orderr=  )r   r   rv   r   rl   r4  safe_string_2r*  rz   r|   r   )	rX   r   r   r~   rk   r   rQ  r   r   s	            rZ   cancel_order_wsokx.cancel_order_ws  s      >TWW'TTUU!!!!!!ll9i0oo'**69oN6OY#?@dnnV,
 $*	NL [[-.

 ZZ'GGG% 	"!" Hs4   /C,C&C,	C(
BC,!C*"C,(C,*C,idsc                   #    [        U5      nUS:  a  [        U R                  S-   5      eUc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  5       I Sh  vN   U R                  SS5      nU R                  5       n/ n[        SU5       H*  nU R                  U5      X   S.n	UR                  U	5        M,     USUS	.n
U R                  XVU R                  X5      U5      I Sh  vN $  N N N7f)
af  

https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-mass-cancel-order

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>`
r#   z0 cancelOrdersWs() accepts up to 20 ids at a timeNz, cancelOrdersWs() requires a symbol argumentr&  r   )rq   rR  zbatch-cancel-ordersr=  )ry   r   r   rv   r   rl   r4  rx   rz   r{   r   rU   )rX   rW  r   r~   	idsLengthrk   r   ru   r   r   r   s              rZ   cancel_orders_wsokx.cancel_orders_ws  s      H	r>TWW'YYZZ>TWW'UUVV!!!!!!ll9i0oo'q)$A..0C KK % '

 ZZ$2B2B72SU`aaa! 	"! bs7   ADDD2D3BD D	DD	Dc                   #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  5       I Sh  vN   U R	                  U5      nUS   S:w  a  [        U R                  S-   5      eU R                  SS5      nU R                  5       nUSU R                  SUS	   S
.U5      /S.nU R                  XEXe5      I Sh  vN $  N N N7f)a  

https://docs.okx.com/websockets/#message-cancelAll

cancel all open orders of a type. Only applicable to Option in Portfolio Margin mode, and MMP privilege is required.
: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>`
Nz/ cancelAllOrdersWs() requires a symbol argumentrJ   optionzh cancelAllOrdersWs is only applicable to Option in Portfolio Margin mode, and MMP privilege is required.r&  mass-cancelOPTIONr   )r  
instFamilyr=  )	r   r   rv   r   r   rl   r4  r|   r   )rX   r   r~   r   rk   r   r   s          rZ   cancel_all_orders_wsokx.cancel_all_orders_ws5  s      >TWW'XXYY!!!!!!V$&>X%TWW  (R  R  S  Sll9i0oo'[[$$Tl"  
 ZZ'GGG 	"! Hs4   /CCC	C
B
CCCCCc                 p    U R                  US5      nU R                  US/ 5      nUR                  XC5        g )Nr   r   )r   r   r   )rX   r   r   r   r   s        rZ   handle_cancel_all_ordersokx.handle_cancel_all_ordersR  s4     &&w5w3t)r\   c                     U$ r   r  s      rZ   handle_subscription_statusokx.handle_subscription_statusd  s	     r\   c                 ^    U R                  UR                  S5      nUR                  S5        g )Nr  T)r   r  r   )rX   r   r   r  s       rZ   handle_authenticateokx.handle_authenticatel  s$     Atr\   c                     g)NrO   rg  )rX   r   s     rZ   rO   okx.pings  s     r\   c                 0    U R                  5       Ul        U$ r  )r0  lastPongr  s      rZ   handle_pongokx.handle_pongx  s    ++-r\   c                    U R                  US5      n U(       Ga*  US:w  Ga#  U R                  S-   U R                  U5      -   nUS:w  a  U R                  U R                  S   X45        U R                  US5      nUb   U R                  U R                  S   XT5        OU R                  US/ 5      n[        S	[        U5      5       Hq  nXg   nU R                  US
5      nUb  U R                  U R                  S   X45        U R                  US5      nUc  MR  U R                  U R                  S   XT5        Ms     [        U5      eg! [         a  n	U R                  US5      n
U
c`  U R                  US5      nUbK  UR                  S5      (       a5  UR                  SS5      nU R                  U5      nU R                  US5      n
U
b  UR                  X5         S n	A	gUR                  U	5         S n	A	gS n	A	ff = f)NcoderC  r  1exactmsgbroadr   r   rB  sMsgr   zIllegal request: {zIllegal request: r_   FT)r   r   rF  throw_exactly_matched_exception
exceptionsr   throw_broadly_matched_exceptionr   rx   ry   r   	Exception
startswithrj  
parse_jsonr  )rX   r   r   	errorCodefeedbackmessageStringr   r   der   rw  stringifiedJson
parsedJsons                 rZ   handle_error_messageokx.handle_error_message|  s    $$Wf5	"	Y#-77S=499W+==#889QS\g $ ? ,889QS`k>>'62>D"1c$i0 G$($4$4Q$@	$0 @@QXAY[do(,(H(4 @@QXAY[hs 1 $H--" !  	 !!'40Bz&&w6?s~~6J'K'K&)kk2Er&JO!%!AJ))*d;B~a$MM!	s%   D E .E 
G:B	G5G55G:c           
      X   U R                  X5      (       d  g US:X  a  U R                  X5        g U R                  USS5      nUb  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  U R                  S.	nU R                  XC5      nUb	  U" X5        g g U R                  US0 5      nU R                  US5      n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                   _SU R                   _U R"                  U R$                  S.EnU R                  XG5      nUc(  UR'                  S5      S:X  a  U R)                  X5        g g U" X5        g )NpongeventrL   )	r  rs   r   r  rM   rN   zbatch-amend-ordersrS  r^  r   rH   rw  rD   ry  r{  r}  rI   r   r  zindex-tickerszsprd-tickerszblock-tickersr   r   r  r   r  rd   )r  r(  rb   r   )r  rq  rT  rk  rh  handle_unsubscriptionrI  rd  r   r   r  r   r  r   r  r   r   r!  r  re   rp  )rX   r   r   r  methodsr  r   rH   s           rZ   handle_messageokx.handle_message  s   ((99P fV- ""7GT: 11!<<#9911 $ 8 8#77&*&>&> $ 8 8#<<G __W4F!v' " //'5"5C&&sI6G411// $00 !$"8"8	
  6 6 4-- d00 T22  !3!3  2 2  !3!3 $,, d00 4..  8 8" $,,#$ t11%& '+&=&=(,(H(H)G, __W6F~<<)Q.%%f6 / v'r\   c                 |    US-   U-   nSU-   nU R                  XU5        X R                  ;   a  U R                  U	 g g )Nr   r   )clean_unsubscriptionr   rX   r   r   rH   subMessageHashr   s         rZ   handle_un_subscription_trades!okx.handle_un_subscription_trades		  sE     3/$~5!!&+F[[ F# !r\   c                 |    US-   U-   nSU-   nU R                  XU5        X R                  ;   a  U R                  U	 g g )Nr   r  )r  r  r  s         rZ    handle_unsubscription_order_book$okx.handle_unsubscription_order_book	  sE     3/.7!!&+F__$' %r\   c                     UR                  SS5      nU R                  U5      nSU-   S-   U-   nSU-   nU R                  XU5        XPR                  U   ;   a  U R                  U   U	 g g )Nrb   r_   r[  r   r   )rj  rk  r  rm  )rX   r   r   rH   ra  rK  r  r   s           rZ   handle_unsubscription_ohlcvokx.handle_unsubscription_ohlcv	  su    __Xr*''+	!G+c1F:$~5!!&+FF++F#I. ,r\   c                 |    US-   U-   nSU-   nU R                  XU5        X R                  ;   a  U R                  U	 g g )Nrr   r   )r  rI   r  s         rZ   handle_unsubscription_ticker okx.handle_unsubscription_ticker 	  sE     4&0+f4!!&+F\\!V$ "r\   c                    U R                  US0 5      nU R                  USS5      nU R                  US5      nU R                  U5      nUS:X  d  US:X  a  U R                  XU5        g UR	                  S5      (       d  UR	                  S5      (       a  U R                  XU5        g UR                  S	5      S
:  a  U R                  XU5        g UR	                  S5      (       a  U R                  XU5        g g )Nr   rH   r_   rq   r   r   bbobookrI   rc   rb   )	r   r   r   r  r~  r  re   r  r  )rX   r   r   r   rH   r   r   s          rZ   r  okx.handle_unsubscription'	  s     nnWeR0""3	26##C2!!(+h'\"9..vwG&&'*<*<V*D*D11&'J\\)$r)--fgF)),,VWE *r\   )r$  r  r  r  )ra   r  )d__name__
__module____qualname____firstlineno__r   rW   r  rl   r   r   rs   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  r1  r  r]  rQ  rU  rd  rT  rp  r   rt  rs  r  r  r  r  r  r  r   r   r  r  r  r  r   r  r   r  r  r   r  r   r  r4  r   r   floatr   r?  rI  rM  rU  rZ  ra  rd  rh  rk  rO   rq  r	   r  r  r  r  r  r  r  __static_attributes____classcell__)rY   s   @rZ   r"   r"      s   `# `D0s 0 LPXZ U U, LN H$ <@d[] S SS S Sbfglbm S OSaenp .Sd3i .S .S[^ .Suyz  vA .S` LN  Uc  URU  UD 9; HC Hs H/0F /0b <> s +  DF #Jc #J, #JJV& V8 68 / /F /& 9; =C =s = 6:" E7 E E( :< S  & :>b Ew EW E( 9=R Ug UC UB'0F '0R 8<B "FW "F7 "FH 2V  2D  UYgktv ,bDI ,bc ,bad ,b{  AL  |M ,b\(E (ET X\jnwy &btCy &bQT &bdg &b  C  DO  P &bP2GF 2Gh,\%N ?CQUdhqs H H H3 H^a Hx|  ~B  yC H& BFb 	T3 	T3 	TUX 	T aesw  AC %E$tCy/ %EZ] %Emp %EN ^` UT$s)_ Udg UB)M6 )MV @DB #PS #P #PS\ #PJ SW_a .!$s) .!C .!fo .!` PR ,UT#Y ,UVY ,U\ =? L L3 L&3< <| B )+ B *, S S4& 434V 34j0 37TX\eg ,UC ,Us ,URU ,Ulpqvlw ,U\ 8<$]ajl $_W $_C $_WZ $_quv~q $_L[2z 04$UYbd *U *UC *Us *Uimnsit *UXM4F M4^U=v U=n pt|~  HC  Hy  H	  H[`  Hil  H  DI  HD+& +@ im{  IK ]c ]3 ]i ]y ]be ]ux ]  PU ]< <@  H  HS  Hu  HD DHPR  b$s)  bS  bD 8<B H H4PU; H:*v *$ & 6 
& *6 *t *X_(V _(B$F $C $RU $(v (s (UX (/& /# /PS /%6 %3 %FF F Fr\   r"   )(ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   r   r  ccxt.base.typesr   r   r	   r
   r   r   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    async_supportr"   rg  r\   rZ   <module>r     sk     A  A  z  z  z  z  z 4  * 0 . ' ) *i$F$


 
  i$Fr\   