
    ":h                         d dl Zd dlmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ  G d
 dej6                  j8                        Zy)    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheBySymbolBySide)
AnyIntMarketOrder	OrderBookPositionStrStringsTickerTrade)Client)List)AuthenticationError)ArgumentsRequired)NotSupported)Precisec            
           e Zd Zdef fdZd Zd Zddi fdededede	e
   fd	Zd
efdZdddi fdededede	e
   fdZd
efdZd+dZi fdedefdZd+dZd
efdZdi fdededefdZd
efdZd Zd
efdZd
efdZd Zd Zd
efdZdddi fdededede	e    fdZ!di fd
edefdZ"d Z#d Z$d+dZ%d
efd Z&d! Z'i fd"Z(i fd#Z)dddi fdededede	e*   fd$Z+d% Z,d+d&e-de*fd'Z.d
efd(Z/d
efd)Z0d
efd*Z1 xZ2S ),vertexreturnc                     | j                  t        t        |          ddddddddddddddiddiddddddd	d	i ddd
ddddiiddddidddt        iiid      S )NTF)wswatchBalancewatchMyTrades
watchOHLCVwatchOrderBookwatchOrderswatchTickerwatchTickerswatchTradeswatchTradesForSymbolswatchPositionsr   z2wss://gateway.prod.vertexprotocol.com/v1/subscribez:wss://gateway.sepolia-test.vertexprotocol.com/v1/subscribe)apitest)apiKeysecretwalletAddress
privateKey  )fetchPositionsSnapshotawaitPositionsSnapshotheadersSec-WebSocket-Extensionspermessage-deflate)inflateoptions)tradesLimitordersLimit	requestIdr$   r   	keepAlivei0u  exactzAuth is needed.)hasurlsrequiredCredentialsr2   	streaming
exceptions)deep_extendsuperr   describer   )self	__class__s    I/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/pro/vertex.pyr?   zvertex.describe   s    fd < > %!%#"&## %#)."& N V	  !%"	$  $#.2.2#
  $!68L$ & U
 )+>c8A
 8 8	    c                     | j                  | j                  di       }| j                  ||d      }| j                  |d      }|| j                  d   |<   |S )Nr5   r      )	safe_dictr2   safe_integersum)r@   urlr2   previousValuenewValues        rB   
request_idzvertex.request_idN   sT    ..{B?))'3:88M1-)1[!#&rC   c                    K   | j                   d   d   }| j                  |      }d|i}| j                  ||      }dddii}d|i| j                  d<   | j	                  |||||       d {   S 7 w)Nr%   r   idr.   r/   r0   r2   )r9   rL   extendr2   watch)r@   messageHashmessagerI   r5   	subscriberequest	wsOptionss           rB   watch_publiczvertex.watch_publicU   s     iit$OOC(	)
	 ++i1*,@
	 y
T ZZ[';	RRRRs   A)A2+A0,A2Nsymbolsincelimitc                 v  K   | j                          d{    | j                  |      }d}|d   dz   |z   }d|| j                  |d         dd}| j                  ||      }	| j	                  ||	       d{   }
| j
                  r|
j                  |d   |      }| j                  |
|||d	      S 7 7 <w)
aD  
        watches information on multiple trades made in a market

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        :param str symbol: unified market symbol of the market trades were made in
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trade structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        NtraderN   @rS   type
product_idmethodstreamrW   T)load_marketsmarketparse_to_numericrO   rV   
newUpdatesgetLimitfilter_by_symbol_since_limit)r@   rW   rX   rY   paramsrd   nametopicrT   rR   tradess              rB   watch_tradeszvertex.watch_tradesf   s      !!!V$ts"T)!"33F4LA
 ++gv.((88??OOF8$4e<E00tTT 	" 9s"   B9B5A#B9:B7;;B97B9clientc                    | j                  |d      }| j                  |d      }| j                  |      }|d   }|| j                  vr7| j                  | j                  dd      }t        |      }|| j                  |<   | j                  |   }	|	j                  |       |	| j                  |<   |j                  |	|dz   |z          y )Nr^   r_   rW   r3   r+   r\   )safe_stringparse_ws_traderl   rG   r2   r   appendresolve)
r@   rn   rR   rk   marketIdr[   rW   rY   storedrl   s
             rB   handle_tradezvertex.handle_trade   s        &1##G\:##G,x$++%%%dllM4HE&F"(DKKV$e$Fvx#~56rC   c                   K   |t        | j                  dz         | j                          d{    d}| j                  d|      \  }}| j	                  |      }d}|d   dz   |z   }d|| j                  |d         | j                  |      dd	}	| j                  |	|      }
| j                  ||
       d{   }| j                  r|j                  ||      }| j                  ||||d
      S 7 7 9w)a  
        watches information on multiple trades made by the user

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.user]: user address, will default to self.walletAddress if not provided
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz! watchMyTrades requires a symbol.r   fillrN   r\   rS   r^   r_   
subaccountr`   T)r   rN   rc   handlePublicAddressrd   re   convertAddressToSenderrO   rV   rf   rg   rh   )r@   rW   rX   rY   ri   userAddressrd   rj   rk   rT   rR   rl   s               rB   watch_my_tradeszvertex.watch_my_trades   s
     >#DGG.Q$QRR!!!"66OVV$ts"T)!"33F4LA"99+F
 ++gv.((88??OOFE2E00tTT% 	" 9s"   .C7C3B
C7;C5<8C75C7c                 J   | j                  |d      }| j                  |d      }| j                  -| j                  | j                  dd      }t	        |      | _        | j                  }| j                  |      }|j                  |       |j                  ||dz   |z          y )Nr^   r_   r3   r+   r\   )rp   myTradesrG   r2   r   rq   rr   rs   )r@   rn   rR   rk   rt   rY   rl   parseds           rB   handle_my_tradeszvertex.handle_my_trades   s    6   &1##G\:== %%dllM4HE259DM$$W-fvx#~56rC   c                    | j                  |d      }| j                  ||      }|d   }| j                  | j                  |d            }| j                  | j                  |dd            }t	        j
                  ||      }| j                  |dd      }d }	| j                  |d      }
|
|
rd	nd
}	d }| j                  |d      }||rdnd}| j                  d || j                  |      |||||| j                  |dd      |	d d |d|      S )Nr_   rW   price	taker_qty
filled_qty	timestampư>is_takertakermakeris_bidbuyselldigestrN   )rN   r   datetimerW   sider   amountcostordertakerOrMakerr^   feeinfo)
rp   safe_marketconvertFromX18safe_string_2r   
string_mulsafe_integer_product	safe_bool
safe_tradeiso8601)r@   r[   rd   rt   rW   r   r   r   r   r   isTakerr   isBids                rB   rq   zvertex.parse_ws_trade   s7   T ##E<8!!(F3!##D$4$4UG$DE$$T%7%7{L%YZ!!%0--e[(K	..
3'.7WLuh/"5D"Y/''x>( 
  	rC   c                 
  K   | j                          d{    d}| j                  |      }|d   dz   |z   }d|| j                  |d         dd}| j                  ||      }| j	                  ||       d{   S 7 h7 w)a  

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nbest_bid_offerrN   r\   rS   r]   r`   )rc   rd   re   rO   rV   )r@   rW   ri   rj   rd   rk   rT   rR   s           rB   watch_tickerzvertex.watch_ticker1  s      !!!V$ts"T)!"33F4LA
 ++gv.&&ug666 	" 7s"   BA?A#B:B;BBc           
      4   | j                  |dd      }| j                  i d| j                  d |      d|d| j                  |      d| j	                  |d      d| j	                  |d      d| j                  | j	                  |d            d	| j                  | j	                  |d
            d| j                  | j	                  |d            d| j                  | j	                  |d            dd dd dd dd dd dd dd dd d d |d|      S )Nr   r   rW   r   highlowbid	bid_price	bidVolumebid_qtyask	ask_price	askVolumeask_qtyvwapopencloselastpreviousClosechange
percentageaverage)
baseVolumequoteVolumer   )r   safe_tickersafe_symbolr   rp   r   )r@   tickerrd   r   s       rB   parse_ws_tickerzvertex.parse_ws_tickerI  s    --fk8L	 !
d&&tV4!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4&&t'7'7'LM!
 ,,T-=-=fi-PQ!
 4&&t'7'7'LM!
 ,,T-=-=fi-PQ!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ )!
* + 	rC   c                     | j                  |d      }| j                  |      }| j                  ||      }|d   |d<   || j                  |d   <   |j	                  ||dz          |S )Nr_   rW   z@best_bid_offer)rp   r   r   tickersrs   )r@   rn   rR   rt   rd   r   s         rB   handle_tickerzvertex.handle_tickero  ss     ##G\:!!(+%%gv6!(+x)/VH%&vx*;;<rC   c                   K   | j                          d{    d}| j                  |      }|d   dz   |z   }| j                  d   d   }| j                  |      }|d|| j	                  |d         dd	}	t        |      ||| j                  ||d
}
| j                  |	|      }| j                  |||||
       d{   }|j                         S 7 7 w)aL  

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        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
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        N
book_depthrN   r\   r%   r   rS   r]   )rN   ra   rb   )rN   rj   rW   ra   rY   ri   )
rc   rd   r9   rL   re   strhandle_order_book_subscriptionrO   rP   rY   )r@   rW   rY   ri   rj   rd   rQ   rI   r5   rT   subscriptionrR   	orderbooks                rB   watch_order_bookzvertex.watch_order_book  s      !!!V$TlS(4/iit$OOC(	!"33F4LA
 i.99
 ++gv.**S+w\ZZ	  1 	". [s"   CCB&C=C>CCc                 8   | j                  | j                  dd      }| j                  |d|      }| j                  |d      }|| j                  v r| j                  |= | j	                  i |      | j                  |<   | j                  | j                  |||       y )NwatchOrderBookLimitr+   rY   rW   )rG   r2   rp   
orderbooks
order_bookspawnfetch_order_book_snapshot)r@   rn   rR   r   defaultLimitrY   rW   s          rB   r   z%vertex.handle_order_book_subscription  s    ((7LdS!!,F!!,9T__$'"&//"e"<

41167LQrC   c           	      @  K   | j                  |d      }| j                  |      }|d   dz   }	 | j                  | j                  dd      }| j                  |d|      }| j	                  |d      }	| j                  |||	       d {   }
| j	                  | j                  |      y | j                  |   }|j                  |
       |j                  }t        dt        |            D ]X  }||   }| j                  t        j                  | j                  |d	      d
            }||d   k  rF| j                  |||       Z || j                  |<   |j                  ||       y 7 # t         $ r)}|j"                  |= |j%                  ||       Y d }~y d }~ww xY ww)NrW   rN   @book_depthr   r+   rY   ri   r   last_max_timestamp1000000r   )rp   rd   rG   r2   
safe_valuefetch_rest_order_book_safer   resetcacherangelenparse_to_intr   
string_divhandle_order_book_messagers   	Exceptionsubscriptionsreject)r@   rn   rR   r   rW   rd   rQ   r   rY   ri   snapshotr   messagesimessageItemlastTimestampes                    rB   r   z vertex.fetch_order_book_snapshot  s    !!,9V$Tl]2	*,,T\\;PRVWL%%lG\JE__\8<F!<<VUFSSHt7?/IOOH% H1c(m, S&qk $ 1 1'2D2DTEUEUVacwEx  {D  3E  !F 9[#99226;	RS '0DOOF#NN9k2 T   	*$$[1MM![))	*sN   ,FAE) E' E) (F)B=E) &F'E) )	F2FFFFc                    | j                  |d      }| j                  |      }|d   }|| j                  vr| j                         | j                  |<   | j                  |   }| j	                  |d      }||j
                  j                  |       y | j                  t        j                  | j                  |d      d            }||kD  r)| j                  |||       |j                  ||dz          y y )Nr_   rW   r   r   r   r   )rp   r   r   r   rG   r   rr   r   r   r   r   rs   )	r@   rn   rR   rt   rd   rW   r   r   r   s	            rB   handle_order_bookzvertex.handle_order_book  s    * ##G\:!!(+!$//)&*oo&7DOOF#OOF+	%%i=	OO""7+ --g.@.@AQAQRY[oApr{.|}My(..vw	Jy(]*BC )rC   c                    | j                  t        j                  | j                  |d      d            }g g d}| j	                  |dg       }t        dt        |            D ]A  }||   }|d   j                  | j                  |d         | j                  |d         g       C | j	                  |dg       }	t        dt        |	            D ]A  }|	|   }
|d   j                  | j                  |
d         | j                  |
d         g       C | j                  |d   | j	                  |dg              | j                  |d   | j	                  |dg              ||d<   | j                  |      |d	<   |S )
Nr   r   )bidsasksr   r   rE   r   r   r   )r   r   r   rp   	safe_listr   r   rr   r   handle_deltasr   )r@   rn   rR   r   r   datar   r   r   r   r   s              rB   r   z vertex.handle_order_book_message  s   %%g&8&89I9I'Sg9hjs&tu	 
 ~~gvr2q#d)$ 	Aq'CL##CF+##CF+! 	 ~~gvr2q#d)$ 	Aq'CL##CF+##CF+! 	 	9V,dnnT62.NO9V,dnnT62.NO!*	+ $Y 7	*rC   c                 p    | j                  |d      }| j                  |d      }|j                  ||       y )Nr   rE   )
safe_floatstore)r@   booksidedeltar   r   s        rB   handle_deltazvertex.handle_delta  s0    q)*uf%rC   c                 b    t        dt        |            D ]  }| j                  |||           y )Nr   )r   r   r   )r@   r   deltasr   s       rB   r   zvertex.handle_deltas  s0    q#f+& 	3Ahq	2	3rC   c                     | j                  |d      }| j                  |j                  d      }| j                  ||i       }| j                  |d      }|
 ||||       |S )NrN   ra   )rp   index_byr   r   )r@   rn   rR   rN   subscriptionsByIdr   ra   s          rB   handle_subscription_statusz!vertex.handle_subscription_status  sg     gt, MM&*>*>E'8"bAx867L1rC   symbolsc                   K   | j                          d{    | j                  |      }| j                  |      s&t        |      dkD  r0t	        | j
                  dz         t        | j
                  dz         d}| j                  d|      \  }}| j                  d   d   }| j                  |      }| j                  |||       | j                  ddd	      }| j                  dd
d	      }	|r<|	r:| j                  .|j                  d       d{   }
| j                  |
|||d	      S d}| j                  |d         }|d   dz   |z   }d|| j!                  |d         | j#                  |      dd}| j%                  ||      }| j'                  ||       d{   }| j(                  r|j+                  |d   |      }| j                  | j                  |||d	      S 7 7 7 Iw)a  

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        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
        :param str [params.user]: user address, will default to self.walletAddress if not provided
        :returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
        NrE   z( watchPositions require only one symbol.z# watchPositions require one symbol.r$   r%   r   r,   Tr-   position_changer   rN   r\   rS   ry   r`   )rc   market_symbolsis_emptyr   r   rN   r   r{   r9   rn   set_positions_cachehandle_option	positionsfuturefilter_by_symbols_since_limitrd   re   r|   rO   rV   rf   rg   )r@   r   rX   rY   ri   r}   rI   rn   r,   r-   r   rj   rd   rk   rT   rR   newPositionss                    rB   watch_positionszvertex.watch_positions'  s     !!!%%g.}}W%7|a"477-W#WXX#DGG.S$STT"667GPViit$S!  &9!%!3!34DF^`d!e!%!3!34DF^`d!e!&<AW#]]+CDDH55hPUW[\\ WQZ(ts"T)!"33F4LA"99+F
 ++gv.!..ug>>?? ))'!*e<E11$..'5RWY]^^A 	" E ?s6   G*G#C;G*G&BG*G(AG*&G*(G*c                     | j                  ddd      }|rBd}||j                  vr1|j                  |       | j                  | j                  ||||       y y t               | _        y )Nr$   r,   F)r   futuresr  r   load_positions_snapshotr   r   )r@   rn   r   ri   r,   rQ   s         rB   r   zvertex.set_positions_cacheV  sf    !%!3!34DF^`e!f!2K6>>1k*

477gW]^ 2 67DNrC   c                 >  K   | j                  ||       d {   }t               | _        | j                  }t        dt	        |            D ]  }||   }|j                  |        |j                  |   }	|	j                  |       |j                  |d       y 7 w)Nr   r   )fetch_positionsr   r   r   r   rr   r  rs   )
r@   rn   rQ   r   ri   r   r   r   positionr  s
             rB   r  zvertex.load_positions_snapshot`  s     ..w??	13q#i.) 	#A |HLL"	# ,uuk* @s   BBBBc                 2   | j                   t               | _         | j                   }| j                  |d      }| j                  |d      }| j                  |      }| j	                  ||      }|j                  |       |j                  ||dz   |z          y )Nr^   r_   r\   )r   r   rp   r   parse_ws_positionrr   rs   )r@   rn   rR   r   rk   rt   rd   r
  s           rB   handle_positionszvertex.handle_positionsl  s    " >>!57DN  &1##G\:!!(+))'6:XxC%!78rC   c                 (   | j                  |d      }| j                  |      }| j                  | j                  |d            }d}t        j                  |d      rd}| j                  t        j                  | j                  |d      d            }| j                  i d|d	d d
| j                  |d
      d|d| j                  |      dd dd dd dd dd dd dd dd dd dd d| j                  |      dd d d d d dd |d d d d d      S )Nr_   r   r   1r   r   r   r   rN   rW   r   lastUpdateTimestampinitialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalleverageunrealizedPnl	contractscontractSizemarginRatiocross)liquidationPrice	markPrice	lastPrice
collateral
marginMode
marginTyper   r   hedgedstopLossPricetakeProfitPrice)
rp   r   r   r   	string_ltr   r   safe_positionr   parse_number)r@   r
  rd   rt   r  r   r   s          rB   r  zvertex.parse_ws_position  s   " ##Hl;!!(+**4+;+;Hh+OP\3/D%%g&8&89I9I(T_9`bk&lm	!! #
H#
$#
 d&&vx8#
 	#

 Y/#
 "4#
 T#
 &t#
  #
 *4#
 $#
 #
 #
 T#
 #
  D--l;!#
" 4##
$ !%!!#9#
  	rC   c                    d}| j                  |d      }|.| j                  |j                  d      }|j                  d       y t	        | j                  |            }|j                  ||       ||j                  v r|j                  d= y y )NauthenticatederrorT)rp   r   r  rs   r   jsonr   r   )r@   rn   rR   rQ   r+  r  	authErrors          rB   handle_authzvertex.handle_auth  s     &  '2=__V^^_EFNN4 +DIIg,>?IMM)[1f222((9 3rC   c                 B    dddddddgi}| j                  ||||      S )NStreamAuthenticationsenderbytes32)rj   r^   
expirationuint64)buildSig)r@   rR   chainIdverifyingContractAddressmessageTypess        rB   build_ws_authentication_sigz"vertex.build_ws_authentication_sig  s9    "!95%x8%
 }}WlG=UVVrC   c                   K   | j                          | j                  d   d   }| j                  |      }d}|j                  |      }| j	                  |j
                  |      }|| j                  |      }| j                          d {   }| j                  |d      }	| j                  |d      }
| j                         }|dz   }| j                  | j                        |d}|d|d	   | j                  |d
         d| j                  ||	|
      d}| j                  ||      }| j                  ||||       | d {   S 7 7 w)Nr%   r   r*  chain_idendpoint_addri_ )r1  r3  authenticater1  r3  )rN   ra   tx	signature)check_required_credentialsr9   rn   r  r   r   rL   queryContractsrp   noncer|   r)   number_to_stringr9  rO   rP   )r@   ri   rI   rn   rQ   r  r*  r5   r  r6  r7  nowrB  authenticationrT   rR   s                   rB   r=  zvertex.authenticate  sS    '')iit$S!%{+(<(<kJ ,I"1133I&&y*=G'+'7'7	?'S$**,C%KE55d6H6HI#N
  (,X6"&"7"7|8T"U "==ngWopG kk'62GJJsK+>|) 4( s%   B	EEB6EE	E	Ec                    K   | j                  |       d {    | j                  d   d   }| j                  |      }d|i}| j                  ||      }| j	                  |||||       d {   S 7 Z7 w)Nr%   r   rN   )r=  r9   rL   rO   rP   )r@   rQ   rR   ri   rI   r5   rS   rT   s           rB   watch_privatezvertex.watch_private  s     '''iit$OOC(	)
	 ++i1ZZ[';	RRR 	( Ss"   A6A2AA6-A4.A64A6c                   K   |t        | j                  dz         | j                          | j                          d{    d}| j	                  |      }|d   dz   |z   }d|| j                  | j                        | j                  |d         dd}| j                  ||      }	| j                  ||	       d{   }
| j                  r|
j                  ||      }| j                  |
|||d	      S 7 7 9w)
aD  
        watches information on multiple orders made by the user

        https://docs.vertexprotocol.com/developer-resources/api/subscriptions/streams

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz watchOrders requires a symbol.order_updaterN   r\   rS   )r^   rz   r_   r`   T)r   rN   r@  rc   rd   r|   r)   re   rO   rG  rf   rg   rh   )r@   rW   rX   rY   ri   rj   rd   rk   rT   rR   orderss              rB   watch_orderszvertex.watch_orders  s      >#DGG.O$OPP'')!!!V$ts"T)!"99$:L:LM"33F4LA
 ++gv.))%99??OOFE2E00tTT! 	" :s$   >C: C6A=C:>C8?8C:8C:c                 <    |dddd}| j                  |||      S |S )Nr   canceled)filledplaced	cancelled)rp   )r@   statusstatusess      rB   parse_ws_order_statuszvertex.parse_ws_order_status"  s4      'H
 ##Hff==rC   rd   c           
      z   | j                  |d      }| j                  t        j                  | j                  |d      d            }| j	                  | j                  |d            }| j                  |      }| j                  | j                  |d            }t        j                  |d      r|dk(  rd}| j                  ||      }|d	   }| j                  i d
|d| j                  |dd      dd d|d| j                  |      dd dd d	|dd dd dd dd dd dd dd dd dd d d ||d d d|      S )Nr_   r   r   r   reason0r   closedrW   r   rN   r   clientOrderIdr   lastTradeTimestampr  r^   timeInForcepostOnly
reduceOnlyr   r   triggerPricer   )r   rN  	remainingrQ  r   rl   )rp   r   r   r   r   re   rS  	string_eqr   
safe_orderr   r   )	r@   r   rd   rt   r   remainingStringr^  rQ  rW   s	            rB   parse_ws_orderzvertex.parse_ws_order,  s   $ ##E<8%%g&8&89I9I%Q\9]_h&ij	--d.>.>uh.OP))/:	++D,<,<UH,MN_c2v7GF!!(F3!  
E 
$$$UHd; 
 T 
 	 

 Y/ 
 !$ 
 "4 
 f 
 D 
 4 
  
 $ 
 D 
 T 
 D 
  d! 
" D# 
$ "/ 
0 1 	rC   c                 b   | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }|| j                  -| j                  | j                  dd      }t        |      | _        | j                  }	| j                  |	j                  |i       }
| j                  |
|      }|*| j                  |d      |d<   | j                  |d      |d<   |	j                  |       |j                  | j                  |d	z   |z          y y )
Nr^   r_   rW   rN   r4   r+   r   r   r\   )
rp   rb  rJ  rG   r2   r   rF   hashmaprr   rs   )r@   rn   rR   rk   rt   r   rW   orderIdrY   cachedOrdersrJ  r   s               rB   handle_order_updatezvertex.handle_order_updatea  s#   $   &1##G\:$$W-!!&(3""640{{"))$,,tL4U;;;L^^L$8$8&"EFNN673E &*&7&7{&K{#%)%5%5eZ%Hz"'NN4;;3(>? rC   c                 ~   | j                  |d      }	 |A| j                  dz   | j                  |      z   }| j                  | j                  d   ||       y# t
        $ r[}t        |t              r0d}|j                  ||       ||j                  v r|j                  |= n|j                  |       Y d }~yd }~ww xY w)Nr+   r7   Fr*  T)
rp   rN   r,  throw_exactly_matched_exceptionr<   r   
isinstancer   r   r   )r@   rn   rR   errorMessagefeedbackr+  rQ   s          rB   handle_error_messagezvertex.handle_error_message  s     ''9	'77S=499W+==44T__W5M|]ef 	%!45-e[1&"6"66,,[9e$	s   AA 	B<!AB77B<c                    | j                  ||      ry | j                  | j                  | j                  | j                  | j
                  | j                  d}| j                  |d      }| j                  ||      }|
 |||       y | j                  |d      }|| j                  ||       y | j                  |j                  d      }|| j                  ||       y y )N)r[   r   r   rx   r   rI  r^   rN   r*  )rn  rv   r   r   r   r  rg  rp   r   r   r  r.  )r@   rn   rR   methodseventra   r5   auths           rB   handle_messagezvertex.handle_message  s    $$VW5&&"0000))#44 44
   &1%067#$$Wd3	 ++FG<v~~?VW- rC   )N)3__name__
__module____qualname__r   r?   rL   rV   r   r   r   r   rm   r   rv   r   r~   r   rq   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r  r   r  r  r  r.  r9  r=  rG  r	   rK  rS  r   rb  rg  rn  rs  __classcell__)rA   s   @rB   r   r      sO   9# 9vS" <@d[] U US U Ubfglbm U:76 7: 37TX\eg !UC !Us !URU !Ulpqvlw !UF#7v #7JGR 68 7 7F 70$LF , @DB #!S #! #!S\ #!JRV R*8#D #DJ 6&
3  8<$]ajl -_W -_C -_WZ -_quv~q -_^ FJRT 8& 87 8
+965n:& :"W )+ > @B S 04$UYbd U UC Us Uimnsit UB3F 3e 3j"@& "@H6 0.V .rC   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   r   ccxt.base.typesr   r   r   r	   r
   r   r   r   r   r   !ccxt.async_support.base.ws.clientr   typingr   ccxt.base.errorsr   r   r   ccxt.base.preciser   async_supportr    rC   rB   <module>r     sE     i i e e e 4  0 . ) %c.T&& c.rC   