
    E#i                         S SK rS SKJrJr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Jr  S SKJr  S SKJr  S SKJr  S SKJr   " S S	\R2                  R4                  5      rg)
    N)
ArrayCacheArrayCacheBySymbolByIdArrayCacheBySymbolBySideArrayCacheByTimestamp)
AnyIntMarketOrder	OrderBookPositionStrStringsTickerTrade)Client)List)ExchangeError)
BadRequestc                     ^  \ rS rSrS\4U 4S jjrS\4S jrS\4S jrS r	SGS	\
S
\S\S\S\4
S jjr0 S4S	\
S\S\S\S\S\4S jjr0 0 S4S	\
S\S\S\S\S\S\4S jjr0 4S\S\S\4S jjr0 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SHS\S	\
S\4S jjrSS0 4S\S\S\S\\   4S jjr0 4S\4S  jjrS\4S! jrSHS"\S	\
S\4S# jjrS$\ S\ 4S% jr!S&\ S\ 4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\4S, jr&SHS	\
S\#4S- jjr'S0 4S\S\S\(4S. jjr)0 4S\S\4S/ jjr*S\4S0 jr+S\4S1 jr,S\4S2 jr-S3 r.SSS0 4S\ S\S\S\\   4S4 jjr/S\4S5 jr0SSS0 4S\ S\S\S\\1   4S6 jjr2S\4S7 jr3SHS	\
S\14S8 jjr4S9\ S\ 4S: jr5SSS0 4S;\6S\S\S\\7   4S< jjr8S\4S= jr9SHS	\
S\74S> jjr:S$\ S\ 4S? jr;S@\ S\ 4SA jr<S\4SB jr=S\4SC jr>S\S\4SD jr?S\4SE jr@SFrAU =rB$ )Ideepcoin   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SSSS.ESSSSS.SS.00S S S SS0SSSS S!S"S#S$S%S&S'S(.S).S*U R                  0S+.5      $ ),NwsTwatchTickerwatchMarkPriceFwatchMarkPriceswatchTickerswatchBidsAskswatchOrderBookwatchTradeswatchTradesForSymbolswatchOrderBookForSymbolswatchBalancewatchLiquidationswatchLiquidationsForSymbolswatchMyLiquidationswatchMyLiquidationsForSymbols
watchOHLCVwatchOHLCVForSymbols)watchOrderswatchMyTradeswatchPositionswatchFundingRatewatchFundingRatescreateOrderWseditOrderWscancelOrderWscancelOrdersWscancelAllOrdersWsunWatchTickerunWatchTradesunWatchOHLCVunWatchOrderBookapizBwss://stream.deepcoin.com/streamlet/trade/public/spot?platform=apizBwss://stream.deepcoin.com/streamlet/trade/public/swap?platform=api)spotswapz$wss://stream.deepcoin.com/v1/private)publicprivatemethod!privateGetDeepcoinListenkeyExtend1m5m15m30m1h4h12h1d1w1o1y)r@   rA   rB   rC   rD   rE   rF   rG   rH   1MrJ   )lastRequestId	listenKeylistenKeyExpiryTimestampauthenticate
timeframesping)hasurlsoptions	streaming)deep_extendsuperr   describerQ   )self	__class__s    K/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/pro/deepcoin.pyrX   deepcoin.describe   s   h > @ d t  !%  "5	 
      !$  t  (  +E    $U  .u  &u  0   d! " '# $  $!%"&$)%*!&$!&"'%*!%!% $$(? D $h$h# $J
 "&!,0A!    , 		EEC
 E E	    clientc                 p    UR                   nUR                  S5      S:  a  U R                  5       Ul        g)Nr=   r   rQ   )urlfindmillisecondslastPong)rY   r^   r`   s      r[   rQ   deepcoin.pingY   s/    jj88I!#"//1FOr]   c                 0    U R                  5       Ul        U$ N)rb   rc   )rY   r^   messages      r[   handle_pongdeepcoin.handle_pong`   s    ++-r]   c                     U R                  U R                  SS5      nU R                  US5      nX R                  S'   U$ )NrL   r      )safe_integerrT   sum)rY   previousValuenewValues      r[   
request_iddeepcoin.request_idd   s;    ))$,,K88M1-(0_%r]    market	requestIdtopicIDsuffixunWatchc                 n    US   nUS   S:X  a  US   US   -   nSnU(       a  SnSUS	U-   U-   US
US.0nU$ )Nsymboltyper;   baseIdquoteId10sendTopicAction	DeepCoin_)ActionFilterValueLocalNoResumeNoTopicID )	rY   rs   rt   ru   rv   rw   marketIdactionrequests	            r[   create_public_requestdeepcoin.create_public_requestj   sh    (#&>V#h'&*;;HF *X5>$" 
 r]   messageHashparamsc                    #    U R                   S   S   S   US      nU R                  5       nU R                  XX55      nUUS.n	U R                  XbU R	                  X5      X)5      I S h  vN $  N7f)Nr9   r   r<   rz   )subHashid)rS   rp   r   watchrV   )
rY   rs   r   ru   r   rv   r`   rt   r   subscriptions
             r[   watch_publicdeepcoin.watch_public|   sx     iit$X.vf~>OO%	,,VP"
 ZZ$2B2B72SU`oooos   A(A1*A/+A1r   c                   #    U R                   S   S   S   US      nU R                  5       nU R                  U5      n	U R                  U	R                  U5      n
U
c  [        U R                  S-   U-   5      eU R                  U
S5      nU R                  XX6S5      nSU-   nU R                  UUUUS	   /US
.5      nU R                  X}U R                  X5      X5      I S h  vN $  N7f)Nr9   r   r<   rz   z no subscription for r   Tunsubscribe::ry   )r   	unsubHashsymbolsr   )rS   rp   r^   	safe_dictsubscriptionsr   r   rl   r   extendr   rV   )rY   rs   r   ru   r   r   rv   r`   rt   r^   existingSubscriptionsubIdr   r   s                 r[   un_watch_publicdeepcoin.un_watch_public   s     iit$X.vf~>OO%	S!#~~f.B.BKP'TWW'>>LMM!!"6=,,VGTR#k1	{{<""x()	2
  ZZ0@0@0QS\kkkks   C!C*#C($C*c                    #    U R                  5       I S h  vN nU R                  S   S   S   S-   U-   nU R                  XAS SU5      I S h  vN $  N; N7f)Nr9   r   r=   ?listenKey=)rO   rS   r   )rY   r   r   rM   r`   s        r[   watch_privatedeepcoin.watch_private   sX     ++--	iit$Y/-?)KZZ$	6JJJ .Js!   AA6AAAAc                   #    U R                  5         U R                  5       nU R                  U R                  SU5      nX#-
  S:  nU R	                  U R                  S5      nS nUc  U R                  U5      I S h  vN nOvU(       ao  U R	                  U R                  SS5      nUS:H  nU(       a  U R                  U5      I S h  vN nO,SU0n	U R                  U R                  X5      5      I S h  vN nUbS  U R                  US0 5      n
U R	                  U
S5      nU R                  U
S	5      nXPR                  S'   X0R                  S'   U$  N N N`7f)
NrN   i`  rM   r>   r?   "privateGetDeepcoinListenkeyAcquire	listenkeydataexpire_time)
check_required_credentialsrb   rl   rT   safe_stringr   r?   r   r   safe_timestamp)rY   r   timerN   expiredrM   responser>   	getNewKeyr   r   s              r[   rO   deepcoin.authenticate   sS    '')  "#'#4#4T\\C]_c#d 2e;$$T\\;?	!DDVLLH%%dllH>abF#GGI!%!H!H!PP  ! "&!G!GT[Hd!ee>>(FB7D(({;I'+':':4'O$(1LL%7OLL34# M
 Q
 fs8   A:E<E=A	EE,E3E4AEEEry   c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nU R                  X4SU5      I Sh  vN $  N8 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://www.deepcoin.com/docs/publicWS/latestMarketData

: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ticker::ry   7)load_marketsrs   r   )rY   ry   r   rs   r   s        r[   watch_tickerdeepcoin.watch_ticker   sY      !!!V$%x(88&&vCHHH 	" Is!   AA3A
AAAc                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nSS0nU R                  X4SX%5      I Sh  vN $  N< N7f)a  
unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://www.deepcoin.com/docs/publicWS/latestMarketData

:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   ry   topictickerr   r   rs   r   rY   ry   r   rs   r   r   s         r[   un_watch_tickerdeepcoin.un_watch_ticker   g      !!!V$%x(88X
 ))&sFYYY 	" Z!   AA7AAAAc                 L   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nU R                  XW5      n	SU-   n
XR                  U'   UR                  X5        g )Nrr   dI/r   )	safe_listr   r   safe_marketsafe_symbolparse_ws_tickertickersresolve)rY   r^   rg   r   firstr   r   rs   ry   parsedTickerr   s              r[   handle_tickerdeepcoin.handle_ticker   s    > >>'33xB/~~eS"-##D#.!!(D#6!!(3++D9%.+V|1r]   Nr   c                     U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US	5      nUS
   (       a  U
nUn
UnU R                  0 SUS   _SU_SU R                  U5      _SU_SU_SU_SS _SU	_SS _SS _SU_SU_SU_SS _SS _SS _SS _U
UUS.EU5      $ )NUHLONBP1AP1VTinversery   	timestampdatetimehighlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechange
percentageaverage)
baseVolumequoteVolumeinfo)rl   safe_numbersafe_tickeriso8601)rY   r   rs   r   r   r   r   r   r   r   r   r   temps                r[   r   deepcoin.parse_ws_ticker  s   . %%fc2	,vs+,,vu-vu-%%fc2
&&vs3)D$JK !
fX&!
!
 Y/!
 D	!

 3!
 3!
 !
 3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r]   sincelimitc                   #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nU R                  XVSU5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XrUSS5      $  Nn N<7f)a  
watches information on multiple trades made in a market

https://www.deepcoin.com/docs/publicWS/lastTransactions

:param str symbol: unified market symbol of the market trades were made in
:param int [since]: the earliest time in ms to fetch orders 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trades::ry   2r   T)r   rs   r   
newUpdatesgetLimitfilter_by_since_limit)rY   ry   r   r   r   rs   r   tradess           r[   watch_tradesdeepcoin.watch_trades>  s      !!!V$%x(88((c6JJ??OOF2E))&TRR 	" Ks!   B	B3B	
B;B	B	c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nSS0nU R                  X4SX%5      I Sh  vN $  N< N7f)ag  
unWatches the list of most recent trades for a particular symbol

https://www.deepcoin.com/docs/publicWS/lastTransactions

: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>`
Nr   ry   r   r   r   r   r   s         r[   un_watch_tradesdeepcoin.un_watch_tradesR  r   r   c                    U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nXR
                  ;  a5  U R                  U R                  SS5      n	[        U	5      U R
                  U'   U R
                  U   n
Ub"  U R                  XW5      nU
R                  U5        SU-   nUR                  X5        g )	Nr   r   r   r   r   tradesLimit  r   )r   r   r   r   r   r   rl   rT   r   parse_ws_tradeappendr   )rY   r^   rg   r   r   r   r   rs   ry   r   stroredtrader   s                r[   handle_tradesdeepcoin.handle_tradesd  s    * >>'33xB/~~eS"-##D#.!!(D#6!!(3++%%%dllM4HE",U"3DKK++f%''5ENN5!%.w,r]   r  c                 (   U R                  US5      nU R                  USS5      nU R                  US5      nS nU R                  US5      nUb$  UU R                  U R                  US5      5      S.nU R                  UUU R	                  U5      US   U R                  US	S
5      U R                  US5      S U R                  U5      U R                  U5      U R                  US5      U R                  US5      U R                  US5      US.U5      $ )NDTTr   mFf)costcurrencyry   TradeIDTIOSPr   )r   r   r   ry   r   orderrz   takerOrMakersidepriceamountr  fee)r   safe_timestamp_2safe_currency_code
safe_trader   safe_string_2handle_taker_or_makerparse_trade_side)rY   r  rs   	directionr   	matchRoler  feeCosts           r[   r  deepcoin.parse_ws_trade  s*   D $$UC0	))%s;	$$UC0	""5#. 33D4D4DUC4PQC "Y/X&$$UIt<%%eT2 66yA)))4%%eS1&&uc2$$UC0 
  	r]   r"  c                 0    SSS.nU R                  X!U5      $ )Nbuysellr~   r}   r   )rY   r"  sidess      r[   r!  deepcoin.parse_trade_side  s$    
 )<<r]   r#  c                 0    SSS.nU R                  X!U5      $ )Nmakertakerr)  r*  )rY   r#  roless      r[   r   deepcoin.handle_taker_or_maker  s$    
 )<<r]   r@   	timeframec                   #    U R                  5       I Sh  vN   U R                  U5      nUS   nU R                  U R                  S0 5      nU R	                  XrU5      nSU-   S-   U-   n	SU-   n
U R                  XiSXZ5      I Sh  vN nU R                  (       a  UR                  X5      nU R                  XUSS	5      $  N N<7f)
aC  
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://www.deepcoin.com/docs/publicWS/KLines

: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
Nry   rP   ohlcv::::_11r   T)	r   rs   r   rT   r   r   r   r   r   )rY   ry   r2  r   r   r   rs   rP   intervalr   rv   ohlcvs               r[   watch_ohlcvdeepcoin.watch_ohlcv  s      !!!V$!^^DLL,C
##J9E$v-4y@x''T6RR??NN61E))%q$GG 	" Ss"   CCA/CC;CCc                 2  #    U R                  5       I Sh  vN   U R                  U5      nUS   nU R                  U R                  S0 5      nU R	                  XRU5      nSU-   S-   U-   nSU-   nSX//S.n	U R                  XGS	X9U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

https://docs.backpack.exchange/#tag/Streams/Public/K-Line

:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str [timeframe]: the length of time each candle represents
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nry   rP   r4  r5  r6  r9  )r   symbolsAndTimeframesr7  )r   rs   r   rT   r   r   )
rY   ry   r2  r   rs   rP   r8  r   rv   r   s
             r[   un_watch_ohlcvdeepcoin.un_watch_ohlcv  s      !!!V$!^^DLL,C
##J9E$v-4y@x&,%8$9
 ))&tV[abbb 	" cs"   BBA7BBBBc                    U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nU R                  US5      n	U R                  U	5      n
XR                  ;  a  0 U R                  U'   XR                  U   ;  a8  U R                  U R                  SS5      n[        U5      U R                  U   U
'   U R                  U   U
   nUb"  U R                  XW5      nUR                  U5        S	U-   S
-   U
-   nUR                  X5        g )Nr   r   r   r   r   r  
OHLCVLimitr  r4  r5  )r   r   r   r   r   find_timeframeohlcvsrl   rT   r   parse_ws_ohlcvr  r   )rY   r^   rg   r   r   r   r   rs   ry   r8  r2  r   storedr9  r   s                  r[   handle_ohlcvdeepcoin.handle_ohlcv  s>   0 >>'33xB/~~eS"-##D#.!!(D#6!!(3##D#.''1	++%"$DKK[[00%%dllL$GE-B5-IDKK	*V$Y/''5EMM% $v-4y@v+r]   c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )NBr   r   r   Cr   )r   r   )rY   r9  rs   s      r[   rD  deepcoin.parse_ws_ohlcv0  sn     s+UC(UC(UC(UC(UC(
 	
r]   c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nSnU R                  XESX65      I Sh  vN nUR                  5       $  NJ N7f)a
  
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.deepcoin.com/docs/publicWS/25LevelIncrementalMarketData

: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orderbook::ry   _0.125)r   rs   r   r   )rY   ry   r   r   rs   r   rv   	orderbooks           r[   watch_order_bookdeepcoin.watch_order_bookG  sj      !!!V$(6(+;;++FvVV	   	" Ws!   A%A!5A%A#A%#A%c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   -   nSnSS0nU R                  X4SX&U5      I Sh  vN $  N? N7f)a  
unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.deepcoin.com/docs/publicWS/25LevelIncrementalMarketData

:param str symbol: unified array of symbols
: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
NrM  ry   rN  r   rP  rO  r   )rY   ry   r   rs   r   rv   r   s          r[   un_watch_order_bookdeepcoin.un_watch_order_bookY  so      !!!V$(6(+;;[
 ))&tV[abbb 	" cs!   AA:AAAAc                 @   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nXR
                  ;  a  U R                  5       U R
                  U'   U R
                  U   n	U R                  US5      n
U	S   c4  U
S:X  a  U R                  X5        g U	R                  R                  U5        g U R                  XU	5        S	U-   nUR                  X5        g )
Nr   r   r   r   r   tr   r  rM  )r   r   r   r   r   
orderbooks
order_bookhandle_order_book_snapshotcacher  handle_order_book_messager   )rY   r^   rg   r   r   r   r   rs   ry   rP  rz   r   s               r[   handle_order_bookdeepcoin.handle_order_bookl  s	   " >>'33xB/~~eS"-##D#.!!(D#6!!(3//)&*oo&7DOOF#OOF+	-[!)s{//@ &&w/**6IF,v5KNN92r]   c                 z   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nU R
                  U   n	/ / S.n
[        S[        U5      5       H  nX;   n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S
:X  a  U
S   R                  UU/5        Mn  US:X  d  Mv  U
S   R                  UU/5        M     U R                  US5      nU R                  XU5      nU	R                  U5        U	R                  n[        S[        U5      5       H  nUU   nU R                  UUU	5        M     / U	l        SU-   nUR                  U	U5        g )Nr   r   r   r   r   )bidsasksr  r  r   r~   r`  r}   ra  mtrM  )r   r   r   r   r   rX  rangelenr   r  rl   parse_order_bookresetr[  r\  r   )rY   r^   rg   entriesr   r   r   rs   ry   rP  orderedEntriesientry	entryDatar  r  volumer   snapshotcachedMessagesjcachedMessager   s                          r[   rZ  #deepcoin.handle_order_book_snapshot  s   ..#r2w2.~~eS"-##D#.!!(D#6!!(3OOF+	 
 q#g,'AJEuc26I##Is3D$$Y4E%%i5Fs{v&--ufo>v&--ufo> ( %%gt4	((K!"q#n-.A*1-M**6=)L / 	(61y+.r]   c                     U R                  US5      nXCS   :  a=  U R                  US/ 5      nU R                  X55        XCS'   U R                  U5      US'   g g )Nrb  r   r   r   )rl   r   handle_deltasr   )rY   r^   rg   rP  r   r   s         r[   r\  "deepcoin.handle_order_book_message  sa      %%gt4	--~~gsB7Hy3%.k"$(LL$;Ij!	 .r]   c                 
   U R                  US0 5      nUS   nUS   nU R                  US5      nU R                  US5      nU R                  US5      nUS:X  a  UR                  Xx5        g US:X  a  UR                  Xx5        g g )	Nr   r`  ra  r  r  r   r~   r}   )r   r   r   store)	rY   rP  rj  r   r`  ra  r  r  rl  s	            r[   handle_deltadeepcoin.handle_delta  s    ~~eS"-  c*  s+!!$,3;JJu%S[JJu% r]   c                   #    SnU R                  5       I Sh  vN   Ub  U R                  U5      nUSU-   -  nU R                  XT5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XaX#S5      $  Nn N;7f)a  
watches information on multiple trades made by the user

https://www.deepcoin.com/docs/privateWS/Trade

: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>`
myTradesNr5  Tr   ry   r   r   r   filter_by_symbol_since_limit)rY   ry   r   r   r   r   r   s          r[   watch_my_tradesdeepcoin.watch_my_trades  s      !!!![[(F4&=(K))+>>??OOF2E00tTT 	" ?!   BB4BB	:B	Bc                 H   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nSn	U	S-   U-   n
XR
                  ;   d  XR
                  ;   a  U R                  c-  U R                  U R                  SS	5      n[        U5      U l        U R                  nU R                  XW5      nUR                  U5        UR                  X5        UR                  X5        g g )
Nresultr   r   r   r   rz  r5  r  r  )r   r   r   r   r   futuresrz  rl   rT   r   r  r  r   )rY   r^   rg   r  r   r   r   rs   ry   r   symbolMessageHashr   rE  parseds                 r[   handle_my_tradedeepcoin.handle_my_trade  s
   > 26vq"-~~eVR0##D#.!!(D#6!!(3 '$.7>>)/@NN/R}}$))$,,tL 6u =]]F((6FMM&!NN6/NN65 0Sr]   c                   #    SnU R                  5       I Sh  vN   Ub  U R                  U5      nUSU-   -  nU R                  XT5      I Sh  vN nU R                  (       a  UR	                  X5      nU R                  XaX#S5      $  Nn N;7f)a  
watches information on multiple orders made by the user

https://www.deepcoin.com/docs/privateWS/order

: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>`
ordersNr5  Tr{  )rY   ry   r   r   r   r   r  s          r[   watch_ordersdeepcoin.watch_orders"  s      !!![[(F4&=(K))+>>??OOF2E00tTT 	" ?r  c                 p   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nSn	U	S-   U-   n
XR
                  ;   d  XR
                  ;   a  U R                  c-  U R                  U R                  SS	5      n[        U5      U l        U R                  XW5      nU R                  R                  U5        UR                  U R                  U	5        UR                  U R                  U
5        g g )
Nr  r   r   r   r   r  r5  ordersLimitr  )r   r   r   r   r   r  r  rl   rT   r   parse_ws_orderr  r   )rY   r^   rg   r  r   r   r   rs   ry   r   r  r   r  s                r[   handle_orderdeepcoin.handle_order8  s   > 26vq"-~~eVR0##D#.!!(D#6!!(3'$.7>>)/@NN/R{{"))$,,tL4U;((6FKKv&NN4;;4NN4;;(9: 0Sr]   c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SU R                  US5      _SS _SU R                  U5      _SU_S	S _S
U R                  US5      _SU R	                  U5      _SUS   _SS _SS _SU R                  U5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SS _U R                  US5      U R                  US5      U R                  US5      S S S S US.EU5      $ )NOrITr  r   r  clientOrderIdr   r   lastTradeTimestamplastUpdateTimestampr   statusry   rz   timeInForcer  r  r  r   rW  r  r   filledVT	remainingtriggerPriceTPTSLTr   )takeProfitPricestopLossPricer  r   r  
reduceOnlypostOnlyr   )r   r   
safe_orderr   parse_ws_order_statusr!  )rY   r  rs   stater   r"  s         r[   r  deepcoin.parse_ws_orderh  s   .   -''t4	$$UC0	  
$""5$/ 
T 
 Y/ 
 	 

 !$ 
 "4#6#6uc#B 
 d007 
 fX& 
 D 
 4 
 D)))4 
 T%%eS1 
 t''s3 
 d&&uc2 
 d&&ud3 
  ! 
" D# 
$  $//u=!--eU;$$UC03 
4 5 	r]   r  c                 2    SSSS.nU R                  X!U5      $ )Nclosedr   canceled)r}   46r*  )rY   r  statusess      r[   r  deepcoin.parse_ws_order_status  s'    

 &99r]   r   c                   #    U R                  5       I Sh  vN   U R                  5       I Sh  vN nU R                  U5      nSn/ nUb:  [        S[	        U5      5       H   nX   n	US-   U	-   n
UR                  U
5        M"     OUR                  U5        U R                  S   S   S   S-   U-   nU R                  XUS/5      I Sh  vN nU R                  (       a  U$ U R                  U R                  XUS	5      $  N N N97f)
a  
watch all open positions

https://www.deepcoin.com/docs/privateWS/Position

:param str[] [symbols]: list of unified market symbols to watch positions for
:param int [since]: the earliest time in ms to fetch positions for
:param int [limit]: the maximum number of positions to retrieve
: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>`
N	positionsr   r5  r9   r   r=   r   T)r   rO   market_symbolsrc  rd  r  rS   watch_multipler   filter_by_symbols_since_limitr  )rY   r   r   r   r   rM   r   messageHashesri  ry   r  r`   r  s                r[   watch_positionsdeepcoin.watch_positions  s     !!!++--	%%g.!1c'l+ $/$$6$?!$$%67 ,
   -iit$Y/-?)K--c&9+VV	??11$..'RWY]^^! 	"- Ws2   DC>DD BDD	6D DDc                 4   U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R                  US S5      nU R	                  Xg5      nSn	U	S-   U-   n
XR
                  ;   d  XR
                  ;   a  U R                  c  [        5       U l        U R                  XW5      nU R                  R                  U5        UR                  U R                  U	5        UR                  U R                  U
5        g g )Nr  r   r   r   r   r  r5  )r   r   r   r   r   r  r  r   parse_ws_positionr  r   )rY   r^   rg   r  r   r   r   rs   ry   r   r  r  s               r[   handle_positiondeepcoin.handle_position  s    0 26vq"-~~eVR0##D#.!!(D#6!!(3!'$.7>>)/@NN/R~~%!9!;++D9FNN!!&)NN4>>;7NN4>>+<= 0Sr]   c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  0 SUS   _SS _SU_SU R                  U5      _SU R                  US	5      _S
S _SU R	                  U5      _SS _SU R                  U R                  US5      5      _SS _SS _SS _SU R                  US5      _SS _SS _SU R                  U5      _SS_U R                  US5      S S S S S S S S S US.E5      $ )Nr   pri  ry   r   r   r   	contractsPocontractSizer  notionalleveragelunrealizedPnlrealizedPnl
collateral
entryPriceOP	markPriceliquidationPrice
marginModehedgedTu)maintenanceMarginmaintenanceMarginPercentageinitialMargininitialMarginPercentagemarginRatior  	lastPricer  r  r   r   )rl   r   safe_positionr   parse_position_side	omit_zeroparse_ws_margin_mode)rY   positionrs   r   r"  r  s         r[   r  deepcoin.parse_ws_position  s     %%h4	$$Xs3	%%h4
!! #
fX&#
$#
 #
 Y/	#

 ))(D9#
 D#
 D,,Y7#
 #
 t'7'7#'FG#
 T#
 4#
 $#
 $**8T:#
 #
 #
  $33J?!#
" d##
$ "&!1!1(C!@+/!'+#'!#9#
  	r]   c                 :    Uc  U$ SSS.nU R                  X!U5      $ )Nlongshortr)  r*  )rY   r"  
directionss      r[   r  deepcoin.parse_position_side  s0    

 
yAAr]   r  c                 :    Uc  U$ SSS.nU R                  X!U5      $ )Nisolatedcrossr)  r*  )rY   r  modess      r[   r  deepcoin.parse_ws_margin_mode'  s0    
 :>>r]   c                 2   US:X  a  U R                  X5        g U R                  US5      nUb  US:w  a  U R                  X5        U R                  USS5      nUS:X  a  U R	                  X5        g US:X  a  U R                  X5        g US:X  a  U R                  X5        g US	:X  a  U R                  X5        g US
:X  a  U R                  X5        g US:X  a  U R                  X5        g US:X  a  U R                  X5        g US:X  a  U R                  X5        g g )Npongr  Successar   RecvTopicActionPOPMTPKPMO	PushTrade	PushOrderPushPosition)rh   r   handle_error_messager  handle_subscription_statusr   r  rF  r]  r  r  r  )rY   r^   rg   r  r   s        r[   handle_messagedeepcoin.handle_message0  s	   fV-  #.AAN))&:''h?F**//@4""635""634!!&25&&v7;&$$V5;&!!&2>)$$V5 *r]   c                    U R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nUS:X  a  U R                  UR                  S5      nU R                  US5      nU R                  Xx0 5      n	U R                  U	S5      n
S	U
-   nU R                  UR                  U0 5      nU R                  X5        g g )
Nr   r   r   Ar~   r   r   r   r   )r   r   r   index_byr   rl   handle_un_subscription)rY   r^   rg   r   r   r   r   subscriptionsByIdr   r   r   r   unsubsciptions                r[   r  #deepcoin.handle_subscription_statusI  s    $ >>'33xB/~~eS"-!!$,S= $f.B.BD I%%dC0E>>*;BGL&&|Y?G''1I NN6+?+?BOM''> r]   c                     U R                  US5      nU R                  US5      nU R                  XU5        U R                  U5        g )Nr   r   )r   clean_unsubscriptionclean_cache)rY   r^   r   r   r   s        r[   r  deepcoin.handle_un_subscriptionh  sD    ""<;$$\;?	!!&9=&r]   c                 d   U R                  USS5      nU R                  US/ 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nU R	                  UR
                  S5      nU R                  X0 5      n	U R                  U	S5      n
U R                  S	-   U R                  U5      -   n U R                  U R                  S
   X;5        U R                  U R                  S   X;5        [        U5      e! [         a  nUR                  X5         S nAg S nAff = f)Nr  rr   r   r   r   r   r   r    exactbroad)r   r   r   rl   r  r   r   jsonthrow_exactly_matched_exception
exceptionsthrow_broadly_matched_exceptionr   	Exceptionreject)rY   r^   rg   messageTextr   r   r   rt   r  r   r   feedbackes                r[   r  deepcoin.handle_error_messagen  s   $ &&wR8>>'33xB/~~eS"-%%dC0	 MM&*>*>E~~&7BG&&|Y?77S=499W#55	*001I;a001I;a)) 	*MM!))	*s   A	D
 

D/D**D/)rz  r  r  )rr   Frf   )C__name__
__module____qualname____firstlineno__r   rX   r   rQ   rh   rp   r	   floatstrboolr   dictr   r   r   rO   r   r   r   r   r   r   r   r   r   r   r  r  r   r!  r   listr:  r>  rF  rD  r   rQ  rT  r]  rZ  r\  rw  r}  r  r
   r  r  r  r  r   r   r  r  r  r  r  r  r  r  r  __static_attributes____classcell__)rZ   s   @r[   r   r      s   F# FP6 & F u s \_ os $ acrt p pc pC pY] plo py| p df|~  OQ lF l ls l\` luy l  IL l  VY l$ DF Ks KD K# K
 )+ 6 68 I IF I 9; ZC Zs Z$(2F (2T9d 9F 9f 9v <@d[] S SS S Sbfglbm S( 9; ZC Z$#-F #-J:D :& :E :x=# =# ==s =s = ?CQUdhqs H H H3 H^a Hx|  ~B  yC H2 BFb c3 c3 cUX c0*,6 *,X
F 
d 
. @DB !S ! !S\ !$ =? c c3 c&%3 %3N!/ !/F< <.& 37TX\eg UC Us URU Ulpqvlw U,/6f /6b 04$UYbd U UC Us Uimnsit U,.;6 .;`4F 4e 4l:C :C : 8<$]ajl _W _C _WZ _quv~q _<&>f &>P0& 0H 0dBS BS B?s ?s ?6V 62? ?>'V '4 ' *6  *  *r]   r   )ccxt.async_supportccxt ccxt.async_support.base.ws.cacher   r   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   async_supportr   r   r]   r[   <module>r     sE     A  A e e e 4  * '*t!!** *r]   