
    E#inZ                         S SK rS SKJrJr  S SK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	\R,                  R.                  5      rg)
    N)
ArrayCacheArrayCacheBySymbolById)	AnyBalancesBoolIntOrder	OrderBookStrTickerTrade)Client)List)ExchangeError)NotSupportedc            
         ^  \ rS rSrS\4U 4S jjr0 4S\4S jjrS\4S jr	S r
0 4S\S\4S	 jjrS\4S
 jrSS0 4S\S\S\S\\   4S jjrS\4S jrSSS0 4S\S\S\S\\   4S jjrS\4S jrSSS0 4S\S\S\S\\   4S jjrS\4S jrS0 4S\S\S\4S jjrS r0 4S\S\4S jjrS\4S jrS rS r S\S\!4S jr"S\4S jr#S\4S jr$S\4S jr%0 4S jr&S r'U =r($ )!probit   returnc                    > U R                  [        [        U ]  5       SSSSSSSSSSS.
SS0SS0S.SS	S
S.00 S.5      $ )NTF)
wswatchBalancewatchTickerwatchTickerswatchTradeswatchTradesForSymbolswatchMyTradeswatchOrderswatchOrderBook
watchOHLCVr   z'wss://api.probit.com/api/exchange/v1/wsz,wss://demo-api.probit.com/api/exchange/v1/ws)apitestr   order_books_l2d   )filterinterval)hasurlsoptions	streaming)deep_extendsuperr   describe)self	__class__s    I/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/probit.pyr-   probit.describe   s    fd < > $# %#).!%#"&# C H	 !. ##7A
  	    c                 ~   #    U R                  U5      I Sh  vN   SnU R                  USU5      I Sh  vN $  N! N7f)a.  
watch balance and get the amount of funds available for trading or funds locked in orders

https://docs-en.probit.com/reference/balance-1

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nbalance)authenticatesubscribe_private)r.   paramsmessageHashs      r0   watch_balanceprobit.watch_balance1   s@      '''++KFKKK 	(Ks   =9=;==clientc                 b    SnU R                  U5        UR                  U R                  U5        g )Nr4   )parse_ws_balanceresolver4   )r.   r;   messager8   s       r0   handle_balanceprobit.handle_balance>   s)      g&t||[1r2   c                    U R                  USS5      nU R                  US0 5      n[        UR                  5       5      nU(       a  0 U l        [        S[        U5      5       Hd  nXE   nX6   nU R                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S'   XR                  U'   Mf     U R                  U R                  5      U l        g )NresetFdatar   	availablefreetotal)	safe_bool
safe_valuelistkeysr4   rangelensafe_currency_codeaccountsafe_stringsafe_balance)
r.   r?   rC   rD   currencyIdsi
currencyIdentrycoderO   s
             r0   r=   probit.parse_ws_balanceO   s     w7w3499;'DLq#k*+A$J$E**:6DllnG"..ukBGFO#//w?GG!(LL , ((6r2   symbolc                 J   #    SnU R                  SUSX25      I Sh  vN $  N7f)a  
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://docs-en.probit.com/reference/marketdata

: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 int [params.interval]: Unit time to synchronize market information(ms). Available units: 100, 500
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
tickerr   N)subscribe_public)r.   rX   r7   channels       r0   watch_tickerprobit.watch_tickerk   s)      **=&(G\\\\s   #!#c                     U R                  US5      nU R                  U5      nU R                  US0 5      nU R                  U5      nU R	                  XV5      nSU-   nXpR
                  U'   UR                  Xx5        g )N	market_idrZ   zticker:)rP   safe_symbolrI   safe_marketparse_tickertickersr>   )	r.   r;   r?   marketIdrX   rZ   marketparsedTickerr8   s	            r0   handle_tickerprobit.handle_tickery   sz    & ##G[9!!(+(B7!!(+((8&(+V|1r2   Nsincelimitc                    #    SnU R                  U5      nU R                  SUSXT5      I Sh  vN nU R                  (       a  UR                  X5      nU R	                  XaX#S5      $  N97f)aB  
get the list of most recent trades for a particular symbol

https://docs-en.probit.com/reference/trade_history

: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
:param int [params.interval]: Unit time to synchronize market information(ms). Available units: 100, 500
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
recent_tradesr   tradesNT)ra   r[   
newUpdatesgetLimitfilter_by_symbol_since_limit)r.   rX   rj   rk   r7   r\   rn   s          r0   watch_tradesprobit.watch_trades   se      "!!&),,]FHg^^??OOF2E00tTT _s   +A)A':A)c                 V   U R                  US5      nU R                  U5      nU R                  U5      nU R                  US/ 5      nU R	                  USS5      (       a  g SU-   nU R                  U R
                  U5      nUc6  U R                  U R                  SS5      n	[        U	5      nXR
                  U'   [        S[        U5      5       H)  n
Xj   nU R                  X5      nUR                  U5        M+     XR
                  U'   UR                  U R
                  U   U5        g )	Nr`   rm   rC   Fztrades:tradesLimit  r   )rP   ra   rb   rI   rH   rn   safe_integerr)   r   rL   rM   parse_tradeappendr>   )r.   r;   r?   re   rX   rf   rn   r8   storedrk   rS   tradeparseds                r0   handle_tradesprobit.handle_trades   s   * ##G[9!!(+!!(+/2>>>'7E22&(f5>%%dllM4HE&F"(KKq#f+&AIE%%e4FMM&! ' %Ft{{6*K8r2   c                 T  #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN   SnUb  U R                  U5      nUS-   U-   nU R                  USU5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XaX#S5      $  N Nt N=7f)a  
get the list of trades associated with the user

https://docs-en.probit.com/reference/trade_history

: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>`
Nrn   :trade_historyT)load_marketsr5   ra   r6   ro   rp   rq   )r.   rX   rj   rk   r7   r8   rn   s          r0   watch_my_tradesprobit.watch_my_trades   s      !!!'''%%f-F%+f4K--k?FSS??OOF2E00tTT 	"'
 Ts1   B(B"B(B$8B((B&):B($B(&B(c                    U R                  US/ 5      n[        U5      nUS:X  a  g U R                  USS5      (       a  g SnU R                  nUc.  U R	                  U R
                  SS5      n[        U5      nX`l        U R                  U5      n0 n	[        S[        U5      5       H:  n
X   nU R                  US   S	5      S
:X  a  M"  SXS   '   UR                  U5        M<     [        U	R                  5       5      n[        U5      nUS:X  a  g [        S[        U5      5       H!  nX   nUS-   U-   nUR                  UU5        M#     UR                  Xe5        g )NrD   r   rC   Frn   ru   rv   infostatusexecutedTrX   r   )rI   rM   rH   myTradesrw   r)   r   parse_tradesrL   rP   ry   rJ   rK   r>   )r.   r;   r?   	rawTradeslengthr8   rz   rk   rn   tradeSymbolsjr{   uniqueuniqueLengthrS   rX   symbolSpecificMessageHashs                    r0   handle_my_tradesprobit.handle_my_trades   sP   ( OOGVR8	YQ;>>'7E22>%%dllM4HE+E2F"M""9-q#f+&AIEfx8JF,0Lx)MM%  ' l'')*6{1q#f+&AYF(3c(9F(B%NN6#<= ' 	v+r2   c                    #    U R                  U5      I Sh  vN   SnUb  U R                  U5      nUS-   U-   nU R                  USU5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XaX#S5      $  Nr N;7f)a   
watches information on an order made by the user

https://docs-en.probit.com/reference/open_order

:param str symbol: unified symbol of the market the order was made in
:param int [since]: timestamp in ms of the earliest order to watch
:param int [limit]: the maximum amount of orders to watch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.channel]: choose what channel to use. Can open_order or order_history.
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nordersr   
open_orderT)r5   ra   r6   ro   rp   rq   )r.   rX   rj   rk   r7   r8   r   s          r0   watch_ordersprobit.watch_orders  s      '''%%f-F%+f4K--k<PP??OOF2E00tTT 	(
 Qs!   BB
8BB:BBc                 \   U R                  US/ 5      n[        U5      nUS:X  a  g SnU R                  USS5      nU R                  nUb  U(       a.  U R	                  U R
                  SS5      n[        U5      nXpl        0 n	[        S[        U5      5       H0  n
X:   nU R                  U5      nSXS	   '   UR                  U5        M2     [        U	R                  5       5      n[        S[        U5      5       H   n
X   nUS
-   U-   nUR                  X5        M"     UR                  Xu5        g )NrD   r   r   rC   FordersLimitrv   TrX   r   )rI   rM   rH   r   rw   r)   r   rL   parse_orderry   rJ   rK   r>   )r.   r;   r?   	rawOrdersr   r8   rC   rz   rk   orderSymbolsrS   rawOrderorderr   rX   r   s                   r0   handle_ordersprobit.handle_orders2  s   2 OOGVR8	YQ;w7>U%%dllM4HE+E2F Kq#i.)A |H$$X.E,0Lx)MM% 	 *
 l'')*q#f+&AYF(3c(9F(B%NN6= ' 	v+r2   c                    #    SnU R                  USSS5      u  pCU R                  SUSXC5      I Sh  vN nUR                  5       $  N7f)a  
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://docs-en.probit.com/reference/marketdata

:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
Nr   r%   order_books	orderbook)handle_option_and_paramsr[   rk   )r.   rX   rk   r7   r\   r   s         r0   watch_order_bookprobit.watch_order_bookc  sU      77@PRZ\ij//0@&+W^gg	   hs   0A	AA	c                    #    U R                   S   S   nSUS.nU R                  XS5      nUnU R                  XAXg5      I S h  vN $  N7f)Nr!   r   	subscribe)typer\   )r(   extendwatch)r.   r8   r\   r7   urlr   requestsubscribeHashs           r0   r6   probit.subscribe_privates  sQ     iit$
	 ++i0#ZZ'IIIIs   A A	AA	
methodNamec                   #    U R                  5       I S h  vN   U R                  U5      nUS   nU R                  S   S   nU R                  U5      nSU-   n	US-   U-   n
0 nXR                  ;   a!  UR                  U	   nXK;  a  UR                  U		 SX'   [        UR                  5       5      nS nU R                  XQSS5      u  pS	S
US   UUS.nU R                  X5      nU R                  XzXU5      I S h  vN $  N N7f)NrX   r!   r   zmarketdata:r   Tr&   r$   r   
marketdataid)r   r\   r`   r%   r&   )
r   rf   r(   r;   subscriptionsrJ   rK   r   r   r   )r.   r   rX   dataTyper%   r7   rf   r   r;   r   r8   filtersrK   r&   r   s                  r0   r[   probit.subscribe_public}  s    !!!V$!iit$S!%.nv-000**=9G%((7GLLN#88ZY\]# 
 ++g.ZZ''RRR5 	"4 Ss"   DC>C"D9D :D Dc           	         U R                  US5      nU R                  U5      nU R                  US5      nSU-   nXPR                  ;  a  U R	                  0 5      U R                  U'   U R                  U   nU R                  USS5      n	U	(       a(  U R                  XeS SSSS	5      n
UR                  U
5        OU R                  X5        UR                  X5        g )
Nr`   sidez
orderbook:rC   Fbuysellpricequantity)
rP   ra   group_by
orderbooks
order_bookrH   parse_order_bookrC   handle_deltar>   )r.   r;   r?   	orderBookre   rX   
dataBySider8   r   rC   snapshots              r0   handle_order_bookprobit.handle_order_book  s     ##G[9!!(+]]9f5
"V+//)&*oob&9DOOF#OOF+	w7,,ZufV]_ijHOOH%i4y.r2   c                     [        S[        U5      5       H+  nX#   nU R                  USS5      nUR                  U5        M-     g )Nr   r   r   )rL   rM   parse_bid_ask
storeArray)r.   bookSidebidAsksrS   bidAskr|   s         r0   handle_bid_asksprobit.handle_bid_asks  s@    q#g,'AZF''DF' (r2   c                     US   nUS   nU R                  US/ 5      nU R                  US/ 5      nU R                  X65        U R                  XE5        g )Nbidsasksr   r   )rI   r   )r.   r   delta
storedBids
storedAsksr   r   s          r0   r   probit.handle_delta  sV    v&
v&
ufb1ueR0Z.Z.r2   c                    U R                  US5      nU R                  USS5      nU R                  US5      nU R                  S-   U-   S-   U-   S-   U R                  U5      -   nSU R                  ;   a  U R                  U R                  S   X65        SU R                  ;   a  U R                  U R                  S   XF5        [        U5      e)N	errorCoder?    details exactbroad)rP   rI   r   json
exceptionsthrow_exactly_matched_exceptionthrow_broadly_matched_exceptionr   )r.   r;   r?   rV   
errMessager   feedbacks          r0   handle_error_messageprobit.handle_error_message  s     5%%gy"=
//'9577S=4'#-
:S@499WCUUdoo%001I4Zdoo%001I:`H%%r2   c                     U R                  US5      nUR                  S   nUS:X  a  SnUR                  X%5        g UR                  U5        UR                  S	 g )Nresultauthenticatedok)rP   r   r>   reject)r.   r;   r?   r   futurer8   s         r0   handle_authenticateprobit.handle_authenticate  sX     !!'84%%o6T>)KNN70MM'"$$_5r2   c                 0   U R                  US5      nUb  U R                  X5        U R                  US/ 5      n[        U5      nU(       a  U R                  X5        U R	                  U/ SQ/ 5      n[        U5      nU(       a  U R                  XU5        g g )NrZ   rm   )r   order_books_l1r#   order_books_l3order_books_l4)rI   rh   rM   r}   safe_value_nr   )r.   r;   r?   rZ   rn   tradesLengthr   orderBookLengths           r0   handle_market_dataprobit.handle_market_data  s    (3v//2>6{v/%%g  0G  IK  L	i.""6I> r2   c                    U R                  US5      nUb  U R                  X5        g U R                  US5      nUS:X  a  U R                  X5        g U R                  U R                  U R
                  U R                  U R                  S.nU R                  US5      nU R                  XV5      nUb	  U" X5        g [        U R                  S-   U R                  U5      -   5      nUR                  U5        g )Nr   r   authorization)r   r4   r   r   order_historyr\   z! handleMessage: unknown message: )rP   r   r   r   r@   r   r   rI   r   r   r   r   )	r.   r;   r?   r   r   handlersr\   handlererrors	            r0   handle_messageprobit.handle_message  s     $$Wk:	 %%f60?"$$V511**!22,,!//
 ""7I6//(4F$TWW'JJTYYW^M__`er2   c                   #    U R                   S   S   nU R                  U5      nSnU R                  U R                  SS5      nU R	                  UR
                  U5      nUb  U R                  5       U:  ag  U R                  5       I S h  vN nU R                  US5      nSUS.n	U R                  X$U R                  X5      U5      I S h  vN nXcR
                  U'   U$  NU N7f)	Nr!   r   r   expiresr   access_tokenr   )r   token)r(   r;   rw   r)   rI   r   millisecondssign_inrP   r   r   )
r.   r7   r   r;   r8   r  r   responseaccessTokenr   s
             r0   r5   probit.authenticate  s     iit$S!%##DLL)Q?!5!5{CN 1 1 3g =!\\^+H **8^DK'$G  ::cG8TVabbF06  - , cs%   B	C%C!A C%C#C%#C%)r4   r   r   ))__name__
__module____qualname____firstlineno__r   r-   r   r9   r   r@   r=   strr   r]   rh   r   r   r   rr   r}   r   r   r   r	   r   r   r
   r   r6   r[   r   r   r   r   r   r   r   r   r5   __static_attributes____classcell__)r/   s   @r0   r   r      s   # @ *, L L2V 2"78 68 ] ]F ]2F 28 <@d[] U US U Ubfglbm U(&9F &9P 37TX\eg UC Us URU Ulpqvlw U.1,v 1,f 04$UYbd U UC Us Uimnsit U./,F /,b @DB !S ! !S\ ! J ]_ S Sc S:/ /<(/&6 &t &(6& 6? ?"V "H )+  r2   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   async_supportr    r2   r0   <module>r     s<     O Z Z Z 4  * )_T&& _r2   