
    E#i                    (   S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJ r   S SKJ!r!  S SKJ"r"  S S	KJ#r#  S S
KJ$r$  S SKJ%r%  S SKJ&r&  S SKJ'r'  S SK(J)r)  S SK*J+r+   " S S\\5      r,g)    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTransactionTransferEntry)List)ExchangeError)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)NullResponse)	TICK_SIZE)Precisec                   j  ^  \ rS rSrS\4U 4S jjrS0 S4S\S\S\4U 4S jjjrS r	0 4S\
\   4S	 jjr0 4S
 jrS\S\4S jrSkU 4S jjrS0 4S\S\S\4S jjrSSS0 4S\S\S\S\
\   4S jjrS0 4S\S\4S jjrSkS\S\S\4S jjrSS0 4S\S\S\S\
\   4S jjrS\S\4S jrSkS\S\S\4S jjrS\4S jr0 4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SS0 4S\S\S\S\
\#   4S! jjr%SkS"\S#\&S\#4S$ jjr'S%\S\4S& jr(S0 4S'\S\
\)   4S( jjr*0 4S\S\)4S) jjr+SkS#\&S\)4S* jjr,SSS0 4S\S\S\S\
\-   4S+ jjr.SkS,\S#\&S\-4S- jjr/S. r00 4S\S/\1S0\S1\S\24
S2 jjr3SkS3\S#\&S\24S4 jjr4S%\S\4S5 jr5S0 4S\S6\6S7\7S/\1S8\84
S9 jjr9S0 4S\S6\6S7\7S/\1S8\84
S: jjr:S0 4S\S6\6S7\7S/\1S8\84
S; jjr;S0 4S\S6\6S7\7S/\1S8\84
S< jjr<S6\64S= jr=0 4S\S7\7S>\14S? jjr>0 4S\S>\1S\?4S@ jjr@0 4S\S>\1S\?4SA jjrAS0 4SB\S\S\?4SC jjrBS0 4SB\S\S\?4SD jjrCSSS0 4S\S\S\S\
\?   4SE jjrDSSS0 4S\S\S\S\
\?   4SF jjrESSS0 4S\S\S\S\
\?   4SG jjrFSSS0 4S\S\S\S\
\?   4SH jjrGS0 4SB\S\S\?4SI jjrHS0 4S\S\
\?   4SJ jjrISS0 4SB\S\S6\6S7\7S/\8S8\84SK jjrJS0 4SL\
\   S\S\
\?   4SM jjrKSkSN\S\S\?4SO jjrLS%\S\4SP jrMS6\S\4SQ jrNS6\S\4SR jrO0 4S\S\
\P   4SS jjrQS0 4S\S\
\P   4ST jjrRSkSU\S\S\P4SV jjrSS0 4SW\TS\4SX jjrUS0 4S\S\V4SY jjrW0 4S\S\X4SZ jjrYSkS\S\X4S[ jjrZSSS0 4S\S\S\4S\ jjr[SkS\4S] jjr\SSS0 4S\S\S\4S^ jjr]SSS0 4SB\S\S\S\4S_ jjr^S0 4S\S7\7S\?4S` jjr_SaSb0 SS4Sc jr`S\TSd\Se\Sf\Sg\Sh\4Si jraSjrbU =rc$ )ldeepcoin   returnc                   > U R                  [        [        U ]  5       0 SS_SS_SS/_SS_S	S
_SS_SS_S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_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_S0S_S1S_E0 S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_E0 SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_E0 STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_S\S_S]S_S^S_S_S_S`S_SaS_SbS_ScS_SdS_ESSSSSSSSSSSSSSe.E_SfSgShSiSjSkSlSmSnSoSpSqSr._SsStSuSuSv.SwSxSySzS{.S|._S}S~SSSSSSSSS.00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S.Sv._SSU R	                  S5      U R	                  S5      S.0_SS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SSS SS.S SSSSSS.S SSS S S SSSS.SS0S.	SS0SS0S.S._SSSSS._S[
        _SSSSSS.SSSSSSSS.0 SSS/0SSSS.SSSSS.SSSSSSS.S._S0 _S[        [        [        [        [        [        [        [        [        [        [        S.[        [        [        [        [        S.S.0E5      $ )Nidr'   nameDeepCoin	countriesSG	rateLimit   versionv1	certifiedFproThasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawclosePositioncreateConvertTradecreateDepositAddresscreateLimitBuyOrdercreateLimitOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrdercreateMarketSellOrderWithCostcreateOrdercreateOrders$createOrderWithTakeProfitAndStopLosscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLossOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrder	editOrderfetchAccountsfetchBalancefetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTrades)fetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchWithdrawalsreduceMarginsandboxsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw
timeframes1m5m15m30m1H4H12H1D1W1M1Y)r   r   r   r   1h4h12h1d1wr   1yurlszOhttps://github.com/user-attachments/assets/671bd35c-770e-4935-9070-f8fb114f79c4zhttps://api.deepcoin.com)publicprivatezhttps://www.deepcoin.com/zhttps://www.deepcoin.com/docszhttps://s.deepcoin.com/UzkyODgyg?)urldiscount)logoapiwwwdocreferralr   get      )zdeepcoin/market/bookszdeepcoin/market/candleszdeepcoin/market/instrumentszdeepcoin/market/tickerszdeepcoin/market/index-candleszdeepcoin/market/tradesz"deepcoin/market/mark-price-candleszdeepcoin/market/step-marginzdeepcoin/account/balanceszdeepcoin/account/billszdeepcoin/account/positionszdeepcoin/trade/fillszdeepcoin/trade/orderByIDzdeepcoin/trade/finishOrderByIDzdeepcoin/trade/orders-historyz deepcoin/trade/v2/orders-pendingzdeepcoin/trade/funding-ratez-deepcoin/trade/fund-rate/current-funding-ratez deepcoin/trade/fund-rate/historyz%deepcoin/trade/trigger-orders-pendingz%deepcoin/trade/trigger-orders-historyz&deepcoin/copytrading/support-contractsz$deepcoin/copytrading/leader-positionz$deepcoin/copytrading/estimate-profitz#deepcoin/copytrading/history-profit)z"deepcoin/copytrading/follower-rankz"deepcoin/internal-transfer/supportz(deepcoin/internal-transfer/history-orderdeepcoin/rebate/configzdeepcoin/agents/usersz!deepcoin/agents/users/rebate-listzdeepcoin/agents/users/rebateszdeepcoin/asset/deposit-listzdeepcoin/asset/withdraw-listz"deepcoin/asset/recharge-chain-listzdeepcoin/listenkey/acquirezdeepcoin/listenkey/extendzdeepcoin/account/set-leveragezdeepcoin/trade/orderzdeepcoin/trade/replace-orderzdeepcoin/trade/cancel-orderz!deepcoin/trade/batch-cancel-orderz#deepcoin/trade/cancel-trigger-ordergUUUUUU?zdeepcoin/trade/swap/cancel-allzdeepcoin/trade/trigger-orderz#deepcoin/trade/batch-close-positionz!deepcoin/trade/replace-order-sltpz$deepcoin/trade/close-position-by-idsz$deepcoin/copytrading/leader-settingsz"deepcoin/copytrading/set-contractszdeepcoin/internal-transferr   zdeepcoin/asset/transfer)r   postfeestradingz0.0015z0.0010)takermakerfeatures)lastmarkindex)triggerPriceTypeprice)IOCFOKPOGTD)
marginModetriggerPricer   triggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingmarketBuyRequiresPriced   <   )r   limitdaysBack	untilDayssymbolRequired)r   r   triggerr   r   )r   r   r   daysBackCanceledr   r   r   r   r   ,  )	r   rO   rP   rv   r|   r{   r~   r_   rw   extends)linearinverse)r8   r:   requiredCredentials)apiKeysecretpasswordprecisionModeoptionsi  ERC20TRC20)ETHUSDTUSDCARBITRUMz
BSC(BEP20)SOLBitcoinCardano)r   r   ARBBSCr   BTCADAtypesGTCr   r   )r   r   r   SPOTSWAP)r8   r:   r   r            
   )r8   fundrebater   r   demo)
recvWindowdefaultNetworksnetworksnetworksByIdrt   r   exchangeTypeaccountsByTypecommonCurrencies
exceptions)2431364449194195199100010unsupportedActionlocalIDNotExist)zno availablezfield is requiredznot in acceptable rangez%subscription cluster does not "exist"zmust be equal or lesser than)exactbroad)deep_extendsuperr'   describeparse_numberr$   r!   r   r   r    r"   r   )self	__class__s    U/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/deepcoin.pyr  deepcoin.describe   s9
   h > @ [C
*[C
J[C
 $[C
 	[C

 t[C
 [C
 4[C
  ccc $c 	c
 %c %c Uc "4c 'c tc c !%c  c %ec 'c  &t!c" #D#c$ '%c& ''c( /)c* $T+c, ,T-c. (/c0 01c2 t3c4 5c6 77c8 &t9c: (;c< &u=c> (?c@ ,UAcB -eCcD %dEcF TGcH  IcJ KcL /McN &tOcP #DQcR $TScT )%UcV $UWcX $UYcZ +E[c\ "5]c^ &t_c` (acb  ccd +Eecf +Egch &uicj #Dkcl *4mcn $Tocp "4qcr tsct  ucv %ewcx /ycz "5{c| }c~ !$c@  AcB dCcD $UEcF +EGcH !$IcJ "4KcL eMcN !$OcP uQcR #DScT  UcV 'WcX $UYcZ !$[c\ *4]c^ (_c` )%acb uccd uecf gch Uicj tkcl $)$)%*"'$( % #"!&#( !Ec[C
X Y[C
r i89 36< #s[C
L 123478349:23>?78	3Q0! 5a /	
 3A 9! 8 ;A 6q H ;A @ @ A! ?  ?!" >q#$ ?@>?DE2312=>9:7889>?6756;>7. 7 6q	
 <Q >u 9! 7 >q <Q ? ? =a 5a 1!  21!A2@M[C
N !..x8!..x8O[C
Z $&*(,$($)%*-
 -2)-+/ ).(-).1
 &*7 $(#'"&#(	( #'$)277$: %)&+!$$&%)*.& #'&+!$#'$)*.( $(&+!$$(,0%)#'$)*.	*  #u=@ "6 "6 	G[[C
j " $k[C
t Yu[C
v ""##$ %$%' $$! ff-! !   #"""	!  #A(w[C
H
 I
[C
J
 '++$&''%/)3'1 %1):/9=G4>K
[C
 [ [	    N
methodNamemarketc                    > U R                  US5      nU R                  US5      nU R                  US5      nUc  Ub  U R                  USU05      n[        [        U ]  XX45      $ )NinstTypetype)safe_stringomitextendr  r'   handle_market_type_and_params)r  r  r  paramsdefaultValuer  r  r  s          r  r"  &deepcoin.handle_market_type_and_paramsx  sk    ##FJ76:./Lx3[[&();<FXtB:W]llr  c                 `    U R                  U R                  S0 5      nU R                  X!U5      $ )Nr   )	safe_dictr   r  )r  r  exchangeTypess      r  convert_to_instrument_type#deepcoin.convert_to_instrument_type  s+    t||^RHT::r  c                   #    SS/nU R                  U R                  S5      nUb  U R                  USU5      nOU R                  U R                  SU5      n/ n/ n[        S[	        U5      5       H&  nUR                  U R                  X&   U5      5        M(     [        R                  " U6 I Sh  vN n[        S[	        U5      5       H  nU R                  XTU   5      nM     U$  N67f)z

https://www.deepcoin.com/docs/DeepCoinMarket/getBaseInfo

retrieves data on all markets for okcoin
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
r8   r:   rt   Nr   r   )
r'  r   	safe_listrangelenappendfetch_markets_by_typeasynciogatherarray_concat)r  r#  r   fetchMarketsOptionpromisesresultis          r  fetch_marketsdeepcoin.fetch_markets  s       !^^DLL.I)NN#5wFENN4<<GEq#e*%AOOD66uxHI & 22q#h-(A&&v{;F ) 3s   B.C)0C'17C)c                    #    SU R                  U5      0nU R                  U R                  X25      5      I S h  vN nU R                  US/ 5      nU R	                  U5      $  N(7f)Nr  data)r)  "publicGetDeepcoinMarketInstrumentsr!  r,  parse_markets)r  r  r#  requestresponsedataResponses         r  r0  deepcoin.fetch_markets_by_type  se     77=
 @@WA]^^< ~~h;!!,//? _s   7A$A")A$c                    U R                  US5      nU R                  US5      nUS:H  nUS:H  nU R                  US5      nU R                  USS5      nS nS n	U R                  U5      n
U R                  U5      nU
S-   U-   nS nU(       a)  US	:g  nU(       a  UOUnU R                  U5      n	US
-   U	-   nU R                  U R                  US0 5      nU R                  USS5      n[
        R                  " US5      nU R                  US5      nU R                  US5      nU R                  [
        R                  " UU5      5      nU R                  US5      nU R                  U0 SU_SU_SU
_SU_SU	_SU_SU_SU_SU_SU_SU=(       a    [
        R                  " US5      _SU_SS_SS_SUS:H  _S U_S!U_U(       a  U(       + OS U(       a  U R                  US"5      OS S S S S S U R                  US#5      U R                  US$5      S%.U R                  S5      U R                  U5      S&.U R                  US'5      US&.S S S&.S S S&.S(.US).
E5      $ )*NinstIdr  r8   r:   baseCcyquoteCcy /USD:r   lever1maxMktSzmaxLmtSzstater+   symbolbasequotesettlebaseIdquoteIdsettleIdr  r9   r;   Fr<   activelivecontractr   ctVallotSztickSz)amountr   )minmaxminSz)leverager\  r   cost)
r   contractSizeexpiryexpiryDatetimestrike
optionTypecreated	precisionlimitsinfo)r  safe_string_lowersafe_currency_codesafe_dict_2r   r%   
string_maxr  r!  	string_gtsafe_number)r  r  r+   r  r8   r:   rS  rT  rU  rR  rP  rQ  rO  isLinearr   maxLeveragemaxMarketSizemaxLimitSize	maxAmountrN  s                       r  parse_marketdeepcoin.parse_market  s   \ fh/%%fj9!!&)4""6:r:&&v.''0e#5(H"*wH,,X6Fc\F*F		4B?&&vw<((c:((<''
;%%g&8&8&UV	  1{{4 0"
"0"
f0"
 D0"
 U	0"

 f0"
 f0"
 w0"
 0"
 D0"
 D0"
 dD 1 1+s C0"
 D0"
 e0"
 e0"
 evo0"
  !0"
" h#0"
$ *.H4AED,,VW=4"**67;))&(;  ,,S1,,[9
  ++FG<$
  
  $ _0"
 0 0	r  c                 
  > [         [        U ]  X5      n[        UR	                  5       5      n[        S[        U5      5       H2  nX4   nX   nUS   (       d  M  US   US   -   nU/U R                  U'   M4     U R                  $ )Nr   r:   rS  rT  )	r  r'   set_marketslistkeysr-  r.  markets_by_idmarkets)	r  r}  
currenciessymbolsr7  rO  r  additionalIdr  s	           r  ry  deepcoin.set_markets9  s    $3GHw||~&q#g,'AZF_Ff~~%h/&2CC4:8""<0 ( ||r  rO  r   c           	         #    U R                  5       I Sh  vN   U R                  U5      nUc  SnUS   US.nU R                  U R                  XS5      5      I Sh  vN nU R	                  US0 5      nU R                  XqSSSSS	5      $  Ns N/7f)
a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.deepcoin.com/docs/DeepCoinMarket/marketBooks

: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
Ni  r+   )rC  szr;  bidsasksr   r   )load_marketsr  publicGetDeepcoinMarketBooksr!  r'  parse_order_book)r  rO  r   r#  r  r>  r?  r;  s           r  fetch_order_bookdeepcoin.fetch_order_bookD  s      !!!V$=ETl
 ::4;;w;WXX" ~~h3$$T4ANN5 	" Ys"   BB
ABB.BBr   sincec           	      d  #    U R                  5       I Sh  vN   SnSnU R                  USSS5      u  puU(       a0  U R                  USS05      nU R                  SXXBXV5      I Sh  vN $ U R	                  U5      nU R                  US5      n	U R                  US5      nU R                  U R                  X"5      n
US	   U
S
.nUb  XKS'   U R                  US5      nUb  XS'   U R                  US5      nU R                  USS5      nU(       ae  U R                  US5      nUbP  U R                  U5      nUc  UOUnX>U-  S-  -   nUb  [        UU5      nU R                  5       n[        UU5      US'   SnU	S:X  a)  U R                  U R                  X5      5      I Sh  vN nOWU	S:X  a)  U R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R!                  US/ 5      nU R#                  UXX45      $  GN GN N N[ N47f)aR  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://www.deepcoin.com/docs/DeepCoinMarket/getKlineData
https://www.deepcoin.com/docs/DeepCoinMarket/getIndexKlineData
https://www.deepcoin.com/docs/DeepCoinMarket/getMarkKlineData

: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
:param int [params.until]: timestamp in ms of the latest candle to fetch
:param str [params.price]: "mark" or "index" for mark price and index price candles
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns int[][]: A list of candles ordered, open, high, low, close, volume
Nr   Frw   paginatecalculateUntilTr   r+   )rC  barr   untilafteri  r   r   r;  )r  handle_option_and_paramsr!  "fetch_paginated_call_deterministicr  r  r   r   safe_integer	safe_boolparse_timeframer]  milliseconds'publicGetDeepcoinMarketMarkPriceCandles#publicGetDeepcoinMarketIndexCandlespublicGetDeepcoinMarketCandlesr,  parse_ohlcvs)r  rO  	timeframer  r   r#  maxLimitr  r  r   r  r>  r  r  durationnumberOfCandlesendTimenowr?  r;  s                       r  fetch_ohlcvdeepcoin.fetch_ohlcvk  sJ    $ !!!88z[`a[[*:D)ABF@@v^cpv  B  B  BV$  167+t	ETl
 $G!!&'2$GYYvw/F0@%HYYv'78F   //	:/4}(5o#="EE$!'51G'')#&w#4 F?!II$++V]JfggHg!EEdkkRYFbccH!@@WA]^^H6 ~~h3  v%GGI 	" B< hc^sY   H0H$AH0'H'(D9H0!H*".H0H,(H09H.:+H0'H0*H0,H0.H0r  c                 p  #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nSnU R                  SX25      u  pBSU R	                  U5      0nU R                  U R                  XR5      5      I Sh  vN nU R                  US/ 5      nU R                  Xq5      $  N N*7f)a  
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

https://www.deepcoin.com/docs/DeepCoinMarket/getMarketTickers

:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
Nr   r  r;  )	r  market_symbolsget_market_from_symbolsr"  r)  publicGetDeepcoinMarketTickersr!  r,  parse_tickers)r  r  r#  r  
marketTyper>  r?  tickerss           r  fetch_tickersdeepcoin.fetch_tickers  s      !!!%%g.--g6
!??PV_
77
C
 <<T[[=YZZ..626!!'33 	" [s"   B6B2A2B6	B4
)B64B6tickerc           	         U R                  US5      nU R                  US5      nU R                  XBS5      nUS   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S
   (       a  U	n
Un	U
nU R                  US5      nU R                  US5      nU R                  0 SU_SU_SU R	                  U5      _SU_SU_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U_SU_SU_SS _SS _SS _SS _U	US S US .EU5      $ )!NtsrC  -rO  r   open24h	volCcy24hvol24hr:   r   high24hlow24h	timestampdatetimehighlowbidbidPx	bidVolumebidSzaskaskPx	askVolumeaskSzvwapopenclosepreviousClosechange
percentageaverage)
baseVolumequoteVolume	markPrice
indexPricerj  )r  r  safe_marketsafe_tickeriso8601)r  r  r  r  marketIdrO  r   r  r  r  tempr  r  s                r  parse_tickerdeepcoin.parse_ticker  s   * %%fd3	##FH5!!(C8!/	2&&v{;%%fh7
&>fY/D$JK	2vx0 !
f!
!
 Y/!
 D	!

 3!
 4##FG4!
 ))&':!
 4##FG4!
 ))&':!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&-!
. / 	r  c                 D  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R                  U5      nXvS'   U R                  U R	                  Xd5      5      I Sh  vN nU R                  US/ 5      n	U R                  XX#5      $  N N+7f)a  
get the list of most recent trades for a particular symbol

https://www.deepcoin.com/docs/DeepCoinMarket/getTrades

: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(default 100, max 500)
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
NrC  r+   r   productGroupr;  )r  r  get_product_group_from_marketpublicGetDeepcoinMarketTradesr!  r,  parse_trades)
r  rO  r  r   r#  r  r>  r  r?  r;  s
             r  fetch_tradesdeepcoin.fetch_trades  s      !!!V$fTl
 $G99&A".;;DKK<XYY~~h3  u<< 	" Zs"   B BAB 2B3*B B c                 >    SnUS   (       a  US   (       a  SnU$ SnU$ )NSpotr:   r   SwapUSwap )r  r  r  s      r  r  &deepcoin.get_product_group_from_market.  s0    &>h&   &r  tradec                 8   U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nU R                  US5      nS nU R                  US5      nUb(  U R                  US5      n	U R                  U	5      n
UU
S.nU R	                  UUU R                  U5      US   U R                  US	5      U R                  US
5      S U R                  U5      UU R                  USS5      U R                  USS5      S US.U5      $ )NrC  r  sideexecTypefeefeeCcyra  currencyrO  tradeIdordIdfillPxpxfillSzr  )rj  r  r  rO  r+   orderr  takerOrMakerr  r   r\  ra  r  )r  r  r  rl  
safe_trader  parse_taker_or_makersafe_string_2)r  r  r  r  r  r  r  r  feeCostfeeCurrencyIdfeeCurrencyCodes              r  parse_tradedeepcoin.parse_trade7  s>   @ ##E84!!(3%%eT2	v.##E:6""5%0 ,,UH=M"55mDO+C "Y/X&""5)4%%eW5 55h?''x>(($? 
  	r  r  c                 0    SSS.nU R                  X!U5      $ )Nr   r   )TMr  )r  r  r   s      r  r  deepcoin.parse_taker_or_makeru  s$    
 ::r  c                   #    U R                  5       I Sh  vN   SnU R                  SSX5      u  p!SU R                  U5      0nU R                  U R	                  X15      5      I Sh  vN nU R                  U5      $  Ng N7f)a  
query for balance and get the amount of funds available for trading or funds locked in orders

https://www.deepcoin.com/docs/DeepCoinAccount/getAccountBalance

:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: "spot" or "swap", the market type for the balance
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
Nr8   r[   r  )r  r"  r)  !privateGetDeepcoinAccountBalancesr!  parse_balance)r  r#  r  r>  r?  s        r  fetch_balancedeepcoin.fetch_balance|  s      !!!
!??PTV\i
77
C
 ??G@\]]!!(++ 	" ^s"   BA>AB(B )B Bc                    US S S.nU R                  US/ 5      n[        S[        U5      5       H}  nX4   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US	5      US
'   XU'   M     U R                  U5      $ )N)rj  r  r  r;  r   ccybaltotal	frozenBalusedavailBalfree)r,  r-  r.  r  rl  accountsafe_balance)	r  r?  r6  balancesr7  balancerO  coder
  s	            r  r  deepcoin.parse_balance  s      

 >>(FB7q#h-(AkG%%gu5F**62DllnG#//?GG"..wDGFO"..w
CGFO"4L )   ((r  r  c                 @  #    U R                  5       I Sh  vN   SnU R                  USSS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   Ub  X&S
'   Ub  X6S'   U R	                  US5      nUb  XS'   U R                  US5      nU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  U
S/ 5      nSS0nU R                  XX#U5      $  GN N NF7f)a  
fetch all deposits made to an account

https://www.deepcoin.com/docs/assets/deposit

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch deposits for
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch entries for
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NFrg   r  r  r   2   r+   coin	startTimesizer  r  r;  r  deposit)r  r  fetch_paginated_call_cursorr  r  r   "privateGetDeepcoinAssetDepositListr!  r'  r,  parse_transactionsr  r  r  r   r#  r  r>  r  r  r?  r;  itemstransactionParamss                r  fetch_depositsdeepcoin.fetch_deposits  sM     !!!88R\^cd99/4X]gmosuvxz{{{}}T*H&tnGFO#(K #FO!!&'2!&IYYvw/F@@WA]^^~~h3tVR0I#
 &&uFWXX1 	" | _5   DD=DDB DDADDDc                 @  #    U R                  5       I Sh  vN   SnU R                  USSS5      u  pTU(       a  U R                  SXX4SSSS5	      I Sh  vN $ 0 nSnUb  U R                  U5      nUS   US	'   Ub  X&S
'   Ub  X6S'   U R	                  US5      nUb  XS'   U R                  US5      nU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S0 5      n
U R                  U
S/ 5      nSS0nU R                  XX#U5      $  GN N NF7f)aQ  
fetch all withdrawals made from an account

https://www.deepcoin.com/docs/assets/withdraw

:param str code: unified currency code of the currency transferred
:param int [since]: the earliest time in ms to fetch transfers for(default 24 hours ago)
:param int [limit]: the maximum number of transfer structures to retrieve(default 50, max 200)
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: the latest time in ms to fetch transfers for(default time now)
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
NFrg   r  r  r   r  r+   r  r  r  r  r  r;  r  
withdrawal)r  r  r  r  r  r   #privateGetDeepcoinAssetWithdrawListr!  r'  r,  r  r  s                r  fetch_withdrawalsdeepcoin.fetch_withdrawals  sM     !!!88R\^cd99/4X]gmosuvxz{{{}}T*H&tnGFO#(K #FO!!&'2!&IYYvw/FAA$++gB^__~~h3tVR0L#
 &&uFWXX1 	" | `r  transactionr  c                    U R                  US5      nU R                  US5      nU R                  XB5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  U5      n	U R                  U R                  US5      5      n
0 SU_SS _S	U_SU_S
U	_SS _SS _SU R                  US5      _SS _SS _SS _SU
_SS _SS _SU_SU_SU R                  U5      _S S S S S.S.E$ )NtxHashr  r\  
createTime	chainNamestatusrj  r+   r  networkaddressFrom	addressToaddresstagFromtagTotagr  updatedtxidr  r  )r  ra  )internalcommentr  )r  rl  rp  safe_timestampnetwork_id_to_codeparse_transaction_statusr  )r  r$  r  r2  
currencyIdr  r\  r  	networkIdr*  r)  s              r  parse_transactiondeepcoin.parse_transaction  s    X6%%k6:
&&z<!!+x8''\B	$$[+>	)))4..t/?/?X/VW
K
$
 
 f	

 w
 4
 
 t''Y?
 t
 T
 4
 f
 D
 t
 D
  !
" Y/#
$  )
 	
r  r)  c                 0    SSS.nU R                  X!U5      $ )Npendingok)
confirmingsucceedr  r  r)  statusess      r  r7  !deepcoin.parse_transaction_status-  s$    #
 &99r  codesc                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      e[        U5      nUS:w  a  [	        U R                  S-   5      eUS   nU R                  U5      nUS   SS.nU R                  U R                  Xb5      5      I Sh  vN nU R                  US0 5      nU R                  US	/ 5      n	S
U0n
U R                  XSU
5      $  N NC7f)af  
fetch deposit addresses for multiple currencies and chain types

https://www.deepcoin.com/docs/assets/chainlist

:param str[]|None codes: list of unified currency codes, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
Nz= fetchDepositAddresses requires a list with one currency coder   r   r+   en)currency_idlangr;  rz  r  F)r  r   r+   r.  r"   r  (privateGetDeepcoinAssetRechargeChainListr!  r'  r,  parse_deposit_addresses)r  rD  r#  lengthr  r  r>  r?  r;  rz  additionalParamss              r  fetch_deposit_addresses deepcoin.fetch_deposit_addresses4  s      !!!=#DGG.m$mnnUQ;tww)hhiiQx==&#D>
 FFt{{SZGcdd6 ~~h3~~dFB/"
 ++D@PQQY 	" es#   C&C"B	C& C$!AC&$C&c                   #    U R                  5       I Sh  vN   U R                  US5      nU R                  U R                  S0 5      nU R                  XA5      nU(       a  UOUnUb  U R	                  US5      nU R                  U/U5      I Sh  vN n[        U5      nU R                  US0 5      nUb*  US:  a$  [        SU5       H  n	Xi   n
U
S   U:X  d  M  U
nM     U$  N NS7f)a  
fetch the deposit address for a currency associated with self account

https://www.deepcoin.com/docs/assets/chainlist

:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.network]: unified network code for deposit chain
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
Nr*  r   r   r   )r  r  r'  r   r   rM  r.  r-  )r  r  r#  r*  r   defaultNetwork
addressessrK  r-  r7  entrys              r  fetch_deposit_addressdeepcoin.fetch_deposit_addressl  s      !!!""695..7H"M))/@$'.YYvy1F77GG
Z..Q3fqj1f%"#w.#G &  	" Hs)   C'C#A:C'C%AC'	C'%C'c                     U R                  US5      nU R                  US5      nU R                  U5        US U R                  U5      UU R                  US5      S.$ )Nchainr-  memo)rj  r  r*  r-  r0  )r  check_addressr6  )r  r?  r  rV  r-  s        r  parse_deposit_addressdeepcoin.parse_deposit_address  sg    &   73""8Y77#..u5##Hf5
 	
r  c                   #    U R                  5       I Sh  vN   SnU R                  SSXE5      u  pTSU R                  U5      0nSnUb  U R                  U5      nUS   US'   Ub  X&S'   Ub  X6S'   U R	                  US	5      nUb  XS
'   U R                  US	5      nU R                  U R                  Xd5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  XX#5      $  N N+7f)a  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://www.deepcoin.com/docs/DeepCoinAccount/getAccountBills

:param str [code]: unified currency code
:param int [since]: timestamp in ms of the earliest ledger entry
:param int [limit]: max number of ledger entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest ledger entry
:param str [params.type]: 'spot' or 'swap', the market type for the ledger(default 'spot')
:returns dict[]: a list of `ledger structures <https://docs.ccxt.com/#/?id=ledger>`
Nr8   ro   r  r+   r  r  r   r  beforer;  )
r  r"  r)  r  r  r   privateGetDeepcoinAccountBillsr!  r,  parse_ledger)r  r  r  r   r#  r  r>  r  r  r?  r;  s              r  fetch_ledgerdeepcoin.fetch_ledger  s     !!!
!??tU[h
77
C
 }}T*H%d^GEN$G$G!!&'2 %HYYvw/F<<T[[=YZZ6 ~~h3  >>] 	"$ [s"   C-C)B(C-?C+ *C-+C-itemc                    U R                  US5      nU R                  US5      n[        R                  " U5      n[        R                  " US5      (       a  SOSnU R                  US5      nU R                  Xr5      nU R                  US5      nU R                  UU R                  US5      US S S U R                  U5      US	   UUU R                  U5      S U R                  US
5      S S S.U5      $ )Nr  balChg0outinr  r  billIdr  r  )rj  r+   	directionr
  referenceAccountreferenceIdr  r  r\  r  r  r\  r  r)  r  )	r  r  r%   
string_abs	string_ltsafe_currencysafe_ledger_entryparse_ledger_entry_typer  )	r  ra  r  r  r  r\  rh  r8  r  s	            r  parse_ledger_entrydeepcoin.parse_ledger_entry  s    %%dD1	!!$1##F+$..vs;;E	%%dE2
%%j;f-%%""42" $006 ("Y/%%dE2'
  ! 	r  c                 6    SSSSSS.nU R                  X!U5      $ )Nr  r   r  )rK  2345r  )r  r  
ledgerTypes      r  ro   deepcoin.parse_ledger_entry_type	  s-    

 
$77r  r\  fromAccount	toAccountc                   #    SnU R                  USS5      u  peU(       a  UOU R                  US5      nUc  [        U R                  S-   5      eU R	                  5       I Sh  vN   U R                  U5      nU R                  U R                  S0 5      nU R                  XU5      n	U R                  XU5      n
US   U R                  X5      U	U
US.nU R                  U R                  X5      5      I Sh  vN nU R                  US	0 5      nU R                  X5      nU R                  U R                  S0 5      nU R                  US
S5      nU(       a  X>S'   XNS'   X.S'   U$  GN Np7f)aY  
transfer currency internally between wallets on the same account

https://www.deepcoin.com/docs/assets/transfer

:param str code: unified currency code
:param float amount: amount to transfer
:param str fromAccount: account to transfer from('spot', 'inverse', 'linear', 'fund', 'rebate' or 'demo')
:param str toAccount: account to transfer to('spot', 'inverse', 'linear', 'fund', 'rebate' or 'demo')
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.userId]: user id
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
Nr   userIduidz' transfer() requires a userId parameterr  r+   )rG  r\  from_idto_idr}  r;  fillResponseFromRequestTry  rz  r\  )r  r  r   r+   r  r  r'  r   currency_to_precision privatePostDeepcoinAssetTransferr!  parse_transferr  )r  r  r\  ry  rz  r#  r|  r  r  fromIdtoIdr>  r?  r;  r   transferOptionsr  s                    r  r   deepcoin.transfer  sk     66vz8T!t'7'7'F>#DGG.W$WXX!!!==&6FK!!.{K9E#D>00>
 >>t{{7?[\\ ~~h3&&t6..z2F"&..B[]a"b"&1]#$-[!!'XA 	" ]s&   A!E*#E%$BE*7E(8A.E*(E*r   c                     U R                  US5      nU R                  S U5      nUS S S US S S U R                  U5      S.	$ )NretCode)	rj  r+   r  r  r  r\  ry  rz  r)  )r  rl  parse_transfer_status)r  r   r  r)  currencyCodes        r  r  deepcoin.parse_transferH  sX     !!(I6..tX>$008

 
	
r  c                     US:X  a  gg)Nrd  r>  failedr  )r  r)  s     r  r  deepcoin.parse_transfer_status^  s    S=r  r  r  r   c                 j  #    U R                  5       I Sh  vN   U R                  U5      nU R                  US5      nU R                  XX4XV5      n	Sn
Ub  U R	                  U	5      I Sh  vN n
OU R                  U	5      I Sh  vN n
U R                  U
S0 5      nU R                  X5      $  N ND N,7f)a}  
create a trade order

https://www.deepcoin.com/docs/DeepCoinTrade/order
https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrder

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.clientOrderId]: a unique id for the order
:param str [params.timeInForce]: *non trigger orders only* 'GTC'(Good Till Cancel), 'IOC'(Immediate Or Cancel) or 'PO'(Post Only)
:param bool [params.postOnly]: *non trigger orders only* True to place a post only order
:param bool [params.reduceOnly]: *non trigger orders only* a mark to reduce the position size for margin, swap and future orders
:param float [params.triggerPrice]: the price a trigger order is triggered at
:param float [params.stopLoss.triggerPrice]: the price that a stop loss order is triggered at
:param float [params.takeProfit.triggerPrice]: the price that a take profit order is triggered at
:param str [params.positionSide]: if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
:param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode
:param str [params.marginMode]: *swap only*'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr   r;  )r  r  r  create_order_request$privatePostDeepcoinTradeTriggerOrderprivatePostDeepcoinTradeOrderr'  parse_order)r  rO  r  r  r\  r   r#  r  r   r>  r?  r;  s               r  create_orderdeepcoin.create_orderc  s     2 !!!V$''?++F$V#!FFwOOH  "??HHH~~h3--3 	" P  Is4   B3B-AB3*B/+B3B1)B3/B31B3c                    U R                  U5      nU R                  US5      nUSLn	U R                  US5      n
U
b%  US   (       a  Ub  [        U R                  S-   5      eU	(       a  U R	                  XX4XV5      $ U R                  XX4XV5      $ )z8
@ignore
       helper function to build request
       r   Nra  r8   zO createOrder() accepts a cost parameter for spot non-trigger market orders only)r  r  r   r+   create_trigger_order_requestcreate_regular_order_request)r  rO  r  r  r\  r   r#  r  r   isTriggerOrderra  s              r  r  deepcoin.create_order_request  s    
 V$''?&d2/&>l&> +|!|}}44V4QV__44V4QV__r  c                    U R                  U5      nUnU R                  X&5      u  pUS   UUS.n	U R                  US5      n
U
b  XS'   U R                  US5      nU R	                  US0 5      nU R                  US5      nUb'  U R                  US/5      nU R                  X5      U	S'   U R	                  US	0 5      nU R                  US5      nUb'  U R                  US	/5      nU R                  X5      U	S
'   US:H  nUb4  U(       a  [        U R                  S-   5      eU R                  X5      U	S'   OU(       d  [        U R                  S-   5      eUS   (       a  U R                  US5      nUbL  U(       d  [        U R                  S-   5      eU R                  US5      nU R                  UU5      U	S'   SU	S'   OU R                  X5      U	S'   SU	S'   X9S'   SU	S'   OU R                  X5      U	S'   SnU R                  SUU5      u  nnUU	S'   SnU R                  USSU5      u  nnUU	S'   SnU R                  USS5      nU(       a  US:X  a  S nOUS!:X  a  S"nOUS:X  a  S"nOUS!:X  a  S nUU	S#'   U R                  X5      $ )$a  
@ignore
       helper function to build request
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much you want to trade in units of the base currency
       :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param float [params.cost]: *spot only* the cost of the order in units of the quote currency, for market orders only
       :param str [params.clientOrderId]: a unique id for the order
       :param str [params.timeInForce]: 'GTC'(Good Till Cancel), 'IOC'(Immediate Or Cancel) or 'PO'(Post Only)
       :param bool [params.postOnly]: True to place a post only order
       :param bool [params.reduceOnly]: a mark to reduce the position size for margin and swap orders
       :param float [params.stopLossPrice]: the price that a stop loss order is triggered at
       :param float [params.takeProfitPrice]: the price that a take profit order is triggered at
       :param str [params.marginMode]: *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
       :param str [params.mrgPosition]: *swap only* 'merge' or 'split', the default is 'merge'
       r+   )rC  r  ordTypeclientOrderIdNclOrdIdstopLossr   slTriggerPx
takeProfittpTriggerPxr  zB createOrder() does not require a price argument for market ordersr  z9 createOrder() requires a price argument for limit ordersr8   ra  zC createOrder() accepts a cost parameter for spot market orders onlyr  	quote_ccytgtCcybase_ccyr  cashtdModecrossrO   mergemrgPosition
reduceOnlyFbuyshortselllongposSide)r  'handle_type_post_only_and_time_in_forcer  r   r'  price_to_precisionr   r+   cost_to_precisionamount_to_precisionhandle_margin_mode_and_paramsr  r  r!  )r  rO  r  r  r\  r   r#  r  	orderTyper>  r  r  r   r  r   isMarketOrderra  r   r  r  r  s                        r  r  %deepcoin.create_regular_order_request  s   ( V$	 HHV	Tl  
" ((A$!.IYYv7F>>&*b9((>B$YYv
|4F%)%<%<V%SGM"^^FL"=
**:~F&YYv~6F%)%<%<V%UGM") +o!opp 33FBGDMTWW'bbcc&>##FF3D$$TWW/t%tuu662 $ 6 6vt D$/! $ 8 8 H$.!"FO &GH 44VDGDM J!%!C!CMSY[e!fJ *GH!K"&"?"?Wdfq"rK%0GM"GeDJ5=%GV^$G5=$GV^%G!(GI{{7++r  c                    U R                  U5      nUS   U R                  US   5      U R                  X5      UUS.nU R                  US5      n	U R	                  X5      US'   Ub  U R	                  X5      US'   OUS:X  a  [        U R                  S-   5      eSn
U R                  S	Xj5      u  pS
nU
S:X  a  SnU R                  USS5      nU R                  US5      nXS'   XS'   US   (       a6  U(       a  US:X  a  SUS'   O#US:X  a  SUS'   OUS:X  a  SUS'   OUS:X  a  SUS'   SnU R                  US	SU5      u  pXS'   U R                  X5      $ )a  
@ignore
       helper function to build request
       :param str symbol: unified symbol of the market to create an order in
       :param str type: 'market' or 'limit'
       :param str side: 'buy' or 'sell'
       :param float amount: how much you want to trade in units of the base currency
       :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
       :param dict [params]: extra parameters specific to the exchange API endpoint
       :param bool [params.reduceOnly]: a mark to reduce the position size for margin orders
       :param str [params.marginMode]: *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
       r+   r  )rC  r  r  r  r  r   r   r   zA createOrder() requires a price argument for limit trigger ordersr  rO   r   isolatedr   r  FisCrossMarginr  r:   r  r  r  r  r  r  r  )r  
capitalizer  r  r  r   r+   r  r  r   r  r!  )r  rO  r  r  r\  r   r#  r  r>  r   r   r  r  r  s                 r  r  %deepcoin.create_trigger_order_request
  s    V$Tl OOF6N;**6: 
 ''? #'"9"9&"O#66vEGGW_#DGG.q$qrr
!??vb
#M^^FL%@
6<0#0 &&>5=)0GI&V^)/GI&5=)/GI&V^)0GI&";;FMS`bmn!,{{7++r  c                     SnU R                  US:H  US:H  U5      u  p2U(       a  SnU R                  U5      nU R                  US5      nUb  US:X  a  SnX/$ )NFr  	post_onlyr   r   ioc)handle_post_onlyhandle_time_in_forcer   )r  r  r#  postOnlyr   s        r  r  0deepcoin.handle_type_post_only_and_time_in_forceO  sk    001A4;CVX^_D//76=1#+*>D~r  ra  c                 r   #    U R                  USU05      nU R                  USUSSU5      I Sh  vN $  N7f)a  
create a market order by providing the symbol, side and cost
:param str symbol: unified symbol of the market to create an order in
:param str side: 'buy' or 'sell'
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
ra  r  r   Nr!  r  )r  rO  r  ra  r#  s        r  create_market_order_with_cost&deepcoin.create_market_order_with_costZ  s<      Vfd^4&&vxq$OOOO   .757c                 r   #    U R                  USU05      nU R                  USSSSU5      I Sh  vN $  N7f)an  
create a market buy order by providing the symbol and cost
:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
ra  r  r  r   Nr  r  rO  ra  r#  s       r  !create_market_buy_order_with_cost*deepcoin.create_market_buy_order_with_costf  s<      Vfd^4&&vx4PPPPr  c                 r   #    U R                  USU05      nU R                  USSSSU5      I Sh  vN $  N7f)ao  
create a market sell order by providing the symbol and cost
:param str symbol: unified symbol of the market to create an order in
:param float cost: how much you want to trade in units of the quote currency
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
ra  r  r  r   Nr  r  s       r  "create_market_sell_order_with_cost+deepcoin.create_market_sell_order_with_costq  s<      Vfd^4&&vxD&QQQQr  r+   c                 h  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nUS   US.nU R	                  U R                  XS5      5      I Sh  vN nU R                  US/ 5      nU R                  US0 5      nU R                  X5      $  N N=7f)as  
fetches information on a closed order made by the user

https://www.deepcoin.com/docs/DeepCoinTrade/finishOrderByID

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
N. fetchClosedOrder() requires a symbol argumentr+   rC  r  r;  r   )	r  r   r+   r  &privateGetDeepcoinTradeFinishOrderByIDr!  r,  r'  r  )	r  r+   rO  r#  r  r>  r?  r;  rR  s	            r  fetch_closed_orderdeepcoin.fetch_closed_order|  s      !!!>#DGG.^$^__V$Tl
 DDT[[QXEabb^ ~~h3tQ+..s 	" cs"   B2B.AB22B03<B20B2c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nUS   US.nU R	                  U R                  XS5      5      I Sh  vN nU R                  US/ 5      n[        U5      nUS:X  a  gU R                  US0 5      n	U R                  X5      $  N NO7f)aI  
fetch an open order by it's id

https://www.deepcoin.com/docs/DeepCoinTrade/orderByID

:param str id: order id
:param str symbol: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nr  r+   r  r;  r   )
r  r   r+   r   privateGetDeepcoinTradeOrderByIDr!  r,  r.  r'  r  )
r  r+   rO  r#  r  r>  r?  r;  rK  rR  s
             r  fetch_open_orderdeepcoin.fetch_open_order  s      !!!>#DGG.^$^__V$Tl
 >>t{{7?[\\~~h3TQ;tQ+.. 	" ]s#   CC AC2C3ACCc                 V  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ U R                  USS5      nSnU R	                  USU5      u  ptSn0 n	Ub  U R                  U5      nUS   U	S'   S	n
U R                  XxXJ5      u  pU R                  U
5      U	S
'   Ub  X9S'   SnU(       az  US:w  a  [        U R                  S-   U-   S-   5      eUc  [        U R                  S-   5      eU R                  US5      nU R                  U R                  X5      5      I Sh  vN nO(U R                  U R                  X5      5      I Sh  vN nU R                  US/ 5      nU R!                  XX#5      $  GN GNS NX N17f)a  

https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory
https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrdersHistory

fetches information on multiple canceled and closed orders made by the user
:param str [symbol]: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: whether to fetch trigger/algo orders(default False)
:param str [params.type]: *non trigger orders only* 'spot' or 'swap', the market type for the orders
:param str [params.state]: *non trigger orders only* 'canceled' or 'filled', the order state to filter by
:param str [params.OrderType]: *trigger orders only* 'limit' or 'market'
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
NFr\   r  r   r  r+   rC  r8   r  r    z"() does not support trigger orderszM fetchCanceledAndClosedOrders() requires a symbol argument for trigger ordersr;  )r  r  fetch_paginated_call_dynamicr  handle_param_stringr  r"  r)  r   r+   r   r   +privateGetDeepcoinTradeTriggerOrdersHistoryr!  $privateGetDeepcoinTradeOrdersHistoryr,  parse_orders)r  rO  r  r   r#  r  r   r  r  r>  r  r?  r;  s                r   fetch_canceled_and_closed_orders)deepcoin.fetch_canceled_and_closed_orders  s    $ !!!88A_akl::;Y[ajoxxx..E:3
!55flJW
[[(F &tGH
!??
TZg
"==jI
$G;; 3!;>b!bcc~'  3B  )B  C  CYYvy1F8 "MMdkkZaNjkkH` "FFt{{SZGcddH~~h3  u<<O 	" y` l` esF   F)F8F)F"C<F)F%(F)5F'6*F)"F)%F)'F)c                    #    SnU R                  USU05      nU R                  USS05      nU R                  XX45      I Sh  vN $  N7f)aH  
fetches information on multiple canceled orders made by the user

https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory

:param str symbol: unified market symbol of the market the orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap', the market type for the orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r]   r  rN  canceledNr!  r  r  rO  r  r   r#  r  s         r  fetch_canceled_ordersdeepcoin.fetch_canceled_ordersX  sO      +
VlJ%?@Vgz%:;::6%XXXX   A A	AA	c                    #    SnU R                  USU05      nU R                  USS05      nU R                  XX45      I Sh  vN $  N7f)aF  
fetches information on multiple closed orders made by the user

https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory

:param str symbol: unified market symbol of the market the orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap', the market type for the orders
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
r_   r  rN  filledNr  r  s         r  fetch_closed_ordersdeepcoin.fetch_closed_ordersj  sO      )
VlJ%?@Vgx%89::6%XXXXr  c                 f  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nU R	                  USS5      nSUS   0nUb  X7S'   U R                  USS	5      nSn	U(       aR  U R                  US5      nU R                  US
   5      US'   U R                  U R                  Xt5      5      I Sh  vN n	O,XgS'   U R                  U R                  Xt5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  XX#SS05      $  GN N\ N17f)a  
fetch all unfilled currently open orders

https://www.deepcoin.com/docs/DeepCoinTrade/ordersPendingV2
https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrdersPending

:param str symbol: unified market symbol of the market orders were made in
:param int [since]: the earliest time in ms to fetch orders for
:param int [limit]: the maximum number of order structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: whether to fetch trigger/algo orders(default False)
:param int [params.index]: *non trigger orders only* pagination index, default is 1
:param str [params.orderType]: *trigger orders only* 'limit' or 'market'
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz- fetchOpenOrders() requires a symbol argumentr   r   rC  r+   r   r   Fr  r  r;  r)  r  )r  r   r+   r  r  r  r   r)  +privateGetDeepcoinTradeTriggerOrdersPendingr!  &privateGetDeepcoinTradeV2OrdersPendingr,  r  )r  rO  r  r   r#  r  r   r>  r   r?  r;  s              r  fetch_open_ordersdeepcoin.fetch_open_orders|  s@      !!!>#DGG.]$]^^V$!!&'15fTl
 $G..E:YYvy1F"&"A"A&."QGJ@ "MMdkkZaNjkkH$G^ "HHU\IeffH~~h3  uh=OPPC 	"\ lb gs4   D1D*B9D1D-,D1=D/>-D1-D1/D1c                   #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nUS   US.nSnU R	                  USS5      nU(       a;  U R                  US5      nU R                  U R                  XS5      5      I Sh  vN nO(U R                  U R                  XS5      5      I Sh  vN nU R                  US0 5      nU R                  X5      $  N NS N,7f)a  
cancels an open order

https://www.deepcoin.com/docs/DeepCoinTrade/cancelOrder

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param bool [params.trigger]: whether the order is a trigger/algo order(default False)
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
Nz) cancelOrder() requires a symbol argumentr+   r  r   Fr;  )r  r   r+   r  r  r   *privatePostDeepcoinTradeCancelTriggerOrderr!  #privatePostDeepcoinTradeCancelOrderr'  r  )	r  r+   rO  r#  r  r>  r?  r   r;  s	            r  cancel_orderdeepcoin.cancel_order  s      !!!>#DGG.Y$YZZV$Tl
 ..E:YYvy1F!LLT[[Y`MijjH!EEdkkRYFbccH~~h3--! 	" kcs4   C8C2B	C8 C4!(C8	C6
)C84C86C8c                 R  #    U R                  5       I Sh  vN   Uc  [        U R                  S-   5      eU R                  U5      nUS   (       a  [	        U R                  S-   5      eU R                  U5      nU R                  US5      nSnUb  U R                  US5      nUS:X  a  SnS	nU R                  US
SU5      u  prUS   UUU(       a  SOSS.nU R                  U R                  X5      5      I Sh  vN n	U R                  U	S/ 5      n
U R                  X5      $  GN N+7f)a8  
cancel all open orders in a market

https://www.deepcoin.com/docs/DeepCoinTrade/cancelAllOrder

:param str symbol: unified market symbol of the market to cancel orders in
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
:param bool [params.merged]: *swap only* True for merged positions, False for split positions(default True)
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nz- cancelAllOrders() requires a symbol argumentr8   z4 cancelAllOrders() is not supported for spot marketsr   r   r  r   Tr>   mergedr+   )InstrumentIDProductGroupIsCrossMarginIsMergeModer;  )r  r   r+   r  r"   r  r  r   r  %privatePostDeepcoinTradeSwapCancelAllr!  r,  r  )r  rO  r#  r  r  r   encodedMarginModer  r>  r?  r;  s              r  cancel_all_ordersdeepcoin.cancel_all_orders  s1     !!!>#DGG.]$]^^V$&>tww)__``99&A%%fl;
!YYv|4FZ'$%!66v?PRZ\bc"4L(. &1A	
 CCDKKPWD`aa~~h3  ../ 	"* bs"   D'D"C"D'9D%:)D'%D'c                   #    U R                  5       I Sh  vN   SU0nSn	Ub8  U R                  U5      n	U	S   (       a  [        U R                  S-   5      eU	S   nU R	                  US5      n
U R	                  US5      nU
SL=(       d    USLnSnU(       a  Uc  Ub  [        U R                  S-   5      eU
b,  U(       a  U R                  X*5      OU R                  U
5      US	'   Ub,  U(       a  U R                  X+5      OU R                  U5      US
'   U R                  USS/5      nU R                  U R                  X5      5      I Sh  vN nOUb,  Ub  U R                  X&5      US'   OU R                  U5      US'   Ub,  Ub  U R                  X%5      US'   OU R                  U5      US'   U R                  U R                  X5      5      I Sh  vN nU R                  US0 5      nU R                  U5      $  GN N N-7f)a  
edit a trade order

https://www.deepcoin.com/docs/DeepCoinTrade/replaceOrder
https://www.deepcoin.com/docs/DeepCoinTrade/replaceTPSL

:param str id: cancel order id
:param str [symbol]: unified symbol of the market to create an order in(not used in deepcoin editOrder)
:param str [type]: 'market' or 'limit'(not used in deepcoin editOrder)
:param str [side]: 'buy' or 'sell'(not used in deepcoin editOrder)
:param float [amount]: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.stopLossPrice]: the price that a stop loss order is triggered at
:param float [params.takeProfitPrice]: the price that a take profit order is triggered at
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
N
OrderSysIDr8   z. editOrder() is not supported for spot marketsrO  r   r   z editOrder() with stopLossPrice or takeProfitPrice cannot have price or amount. Either use stopLossPrice/takeProfitPrice or price/amount to edit order.r  r  r   volumer;  )r  r  r"   r+   rp  r   r  number_to_stringr   (privatePostDeepcoinTradeReplaceOrderSltpr!  r  $privatePostDeepcoinTradeReplaceOrderr'  r  )r  r+   rO  r  r  r\  r   r#  r>  r  r   r   isTPSLr?  r;  s                  r  
edit_orderdeepcoin.edit_order2  s,    $ !!!"
 [[(Ff~"477-]#]^^H%F((A**63DEt+M1L!v'9   ,E  "E  F  F([a)@)@)Wgkg|g|  ~K  hL&*]c)@)@)Yimi~i~  @O  jP&YYv9J'KLF!JJ4;;W^KghhH %'+'>'>v'MGG$'+'<'<U'CGG$!%(,(@(@(PGH%(,(=(=f(EGH%!FFt{{SZGcddH~~h3%%I 	", i es5   HG;D4HG>BHH )H>H Hidsc                 R  #    U R                  5       I Sh  vN   SnUb3  U R                  U5      nUS   (       a  [        U R                  S-   5      eSU0nU R	                  U R                  XS5      5      I Sh  vN nU R                  US/ 5      nU R                  Xt5      $  N N*7f)a  
cancel multiple orders
:param str[] ids: order ids
:param str [symbol]: unified market symbol, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
Nr8   z1 cancelOrders() is not supported for spot marketsOrderSysIDsr;  )r  r  r"   r+   (privatePostDeepcoinTradeBatchCancelOrderr!  r,  r  )r  r  rO  r#  r  r>  r?  r;  s           r  cancel_ordersdeepcoin.cancel_ordersj  s      !!![[(Ff~"477-`#`aa3
 FFt{{SZGcdd~~h3  .. 	" es"   B'B#A#B':B%;)B'%B'r  c                    U R                  US5      nU R                  X25      nU R                  US5      nU R                  USS5      n[        U5      S:  a  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:X  a  S nU R                  US5      n	S n
U	b5  U R                  US	5      nU R                  U5      U R                  U	5      S
.n
U R                  0 SU R                  US5      _SU R                  US5      _SU R                  U5      _SU_SS _SU R                  US5      _SU R                  U5      _SUS   _SU R                  U5      _SU R                  U5      _SU R                  US5      _SU R                  USS5      _SU_SU R                  US5      _SU R                  US 5      _S!S _S"U R                  U R                  US#5      5      _U R                  US$S%5      U R                  US&S'5      S S U
S U(       a  US(:H  OS US).EU5      $ )*NrC  cTimerF     rN  r  avgPxr  r  r  r+   r  r  r  r  r  lastTradeTimestamplastUpdateTimestampuTimer)  rO  r  r   r  r   r  ordPxr  r\  r  r  	accFillSz	remainingr   	triggerPxr  tpTriggerPricer  slTriggerPricer  )r   r   ra  tradesr  r  r  rj  )r  r  r  r.  r5  r  rl  
safe_orderr  parse_order_statusparse_order_typeparse_order_time_in_forcer  	omit_zero)r  r  r  r  r  timestampStringrN  r  r  r  r  r  s               r  r  deepcoin.parse_order  s   F ##E84!!(3%%eW5	**5'2>"$++E7;I  0$$UI6	""5'2b=G((9$&&ue4G))'2 33MBC   
$""5'2 
T--eY? 
 Y/ 
 	 

 !$ 
 "4#4#4UG#D 
 d--e4 
 fX& 
 D)))4 
 499)D 
 D$$UF3 
 T''tW= 
 w 
 d&&ud3 
 d&&uk: 
  ! 
" DNN4+;+;E;+OP# 
$  $11%HXY!//}FVW6?k1T3 
4 5 	r  c                 4    SSSSS.nU R                  X!U5      $ )Nr  closedr  )rW  r  r  partially_filledr  rA  s      r  r"  deepcoin.parse_order_status  s*    " &	
 &99r  c                 6    SSSSSS.nU R                  X!U5      $ )Nr   r  )r   r  r  r  TPSLr  )r  r  r   s      r  r#  deepcoin.parse_order_type  s-     
 T22r  c                 4    SSSSS.nU R                  X!U5      $ )Nr   r   r   )r  r  r   r  r  )r  r  timeInForcess      r  r$  "deepcoin.parse_order_time_in_force	  s*    	
 D99r  c                 <  #    U R                  5       I Sh  vN   U R                  U5      nU R                  US   5      nUUS   S.nU R                  U R	                  XR5      5      I Sh  vN nU R                  US/ 5      nU R                  XsS   /5      $  N N.7f)ao  
fetch open positions for a single market

https://www.deepcoin.com/docs/DeepCoinAccount/accountPositions

fetch all open positions for specific symbol
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
Nr  r+   )r  rC  r;  rO  )r  r  r)  "privateGetDeepcoinAccountPositionsr!  r,  parse_positions)r  rO  r#  r  instrumentTyper>  r?  r;  s           r  fetch_positions_for_symbol#deepcoin.fetch_positions_for_symbol	  s      !!!V$88H&Tl
 @@WA]^^~~h3##D(+;*<== 	" _s"   BBAB+B,-BBc                   #    U R                  5       I Sh  vN   U R                  USSS5      nSnSnUb#  U R                  US5      nU R                  U5      nU R	                  SXBU5      u  p2U R                  U5      nSU0nU R                  U R                  Xr5      5      I Sh  vN nU R                  US/ 5      n	U R                  X5      $  N N*7f)a@  
fetch all open positions

https://www.deepcoin.com/docs/DeepCoinAccount/accountPositions

:param str[] [symbols]: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
NTr:   r   r   r  r;  )
r  r  r  r  r"  r)  r3  r!  r,  r4  )
r  r  r#  r  r  firstSymbolr5  r>  r?  r;  s
             r  fetch_positionsdeepcoin.fetch_positions#	  s      !!!%%gtT4@
**7A6K[[-F!??@PRXblm
88D
 @@WA]^^2 ~~h3##D22M 	" _s"   CCBC&C')CCpositionc                 r   U R                  US5      nU R                  X25      nU R                  US5      nU R                  0 SUS   _SU R                  US5      _SU_SU R	                  U5      _SU R                  US	5      _S
S _SU R                  US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U R                  US5      _SU R                  US5      _SS_U R                  US5      S S S S U R                  US5      S S S S US.E5      $ )NrC  r  rO  r+   posIdr  r  	contractsposrb  r  r  notionalr`  rJ  unrealizedPnlrealizedPnl
collateral
entryPricer  r  liquidationPriceliqPxr   mgnModer   T	useMarginr  )maintenanceMarginmaintenanceMarginPercentageinitialMargininitialMarginPercentagemarginRatior  	lastPricer   r   r  rj  )r  r  r  safe_positionr  r%  )r  r<  r  r  r  s        r  parse_positiondeepcoin.parse_positionU	  s   & ##Hh7!!(3%%h8	!! #
fX&#
$""8W5#
 #
 Y/	#

 ))(E:#
 D#
 D$$Xy9#
 #
 t'7'7''JK#
 T#
 4#
 $#
 $**8W=#
 #
  0 07 C#
  $**8Y?!#
" d##
$ "&!1!1(K!H+/!'+#'#4#4Xw#G!#9#
  	r  r`  c                 *  #    Uc  [        U R                  S-   5      eUS:  a  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nSnU R                  SX55      u  pSUS:w  a  US:w  a  [        U R                  S-   5      eS	nU R                  USS
U5      u  pcUS	:w  a  US:w  a  [        U R                  S-   5      eUUUS   US.nU R                  U R                  Xs5      5      I Sh  vN nU$  N N7f)a  
set the level of leverage for a market

https://www.deepcoin.com/docs/DeepCoinAccount/accountSetLeverage

:param float leverage: the rate of leverage
:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: 'cross' or 'isolated'(default is cross)
:param str [params.mrgPosition]: 'merge' or 'split', default is merge
:returns dict: response from the exchange
Nz) setLeverage() requires a symbol argumentr   z+ setLeverage() leverage should be minimum 1r  r   r  zT setLeverage() requires a marginMode parameter that must be either cross or isolatedr  r  splitzB setLeverage() mrgPosition parameter must be either merge or splitr+   )rJ  rH  rC  r  )	r   r+   r   r  r  r  r  %privatePostDeepcoinAccountSetLeverager!  )	r  r`  rO  r#  r  r   r  r>  r?  s	            r  set_leveragedeepcoin.set_leverage	  s)     >#DGG.Y$YZZ a<TWW'TTUU!!!V$
!??vb
'!
j(@TWW'}}~~";;FMS`bmn'!kW&<TWW'kkll!Tl&	
 CCDKKPWD`aa ? 	"  bs%   ADDB8DD	DDc                   #    U R                  5       I Sh  vN   U R                  USSSS5      nSnSnUb#  U R                  US5      nU R                  U5      nU R	                  SXBU5      u  p2SnUS:X  a  S	nOUS:w  a  [        U R                  S
-   5      eSU0nU R                  U R                  Xr5      5      I Sh  vN nU R                  US0 5      n	U R                  U	S/ 5      n
U R                  X5      $  N N=7f)a  
fetch the funding rate for multiple markets

https://www.deepcoin.com/docs/DeepCoinTrade/currentFundRate

:param str[]|None symbols: list of unified market symbols
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.subType]: "linear" or "inverse"
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
Nr:   Tr   r   rm   r  r   r  zG fetchFundingRates() subType parameter must be either linear or inverser  r;  current_fund_rates)r  r  r  r  handle_sub_type_and_paramsr   r+   1privateGetDeepcoinTradeFundRateCurrentFundingRater!  r'  r,  parse_funding_rates)r  r  r#  subTypefirstMarketr9  r  r>  r?  r;  ratess              r  fetch_funding_ratesdeepcoin.fetch_funding_rates	  s     !!!%%gvtT4H"**7A6K++k2K99:M{dkliH TWW'ppqq
 OOPTP[P[\cPlmm& ~~h3t%92>''77K 	"  ns"   C?C;B(C??C= <C?=C?c                   #    U R                  5       I Sh  vN   U R                  U5      nUS   (       d  [        U R                  S-   5      eUS   U R	                  U5      S.nU R                  U R                  XB5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      nU R                  US0 5      nU R                  X5      $  N NP7f)	a3  
fetch the current funding rate

https://www.deepcoin.com/docs/DeepCoinTrade/currentFundRate

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
Nr:   z2 fetchFundingRate() is only valid for swap marketsr+   )rC  r  r;  rY  r   )
r  r  r   r+   r  r[  r!  r'  r,  parse_funding_rate)	r  rO  r#  r  r>  r?  r;  r_  rR  s	            r  fetch_funding_ratedeepcoin.fetch_funding_rate	  s      !!!V$f~*^ ^__Tl::6B
 OOPTP[P[\cPlmm ~~h3t%92>ua,&&u555 	" ns#   CCA1CC	ACCc                     U R                  USS5      nU R                  X25      n0 SU_SU_SS _SS _SS _SS _S	S _S
S _SU R                  US5      _SS _SS _SS _SS _SS _SS _SS _SS _SS 0E$ )NinstrumentIdinstrumentIDrj  rO  r  r  interestRateestimatedSettlePricer  r  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimeinterval)r  safe_symbolrp  )r  rX  r  r  rO  s        r  rc  deepcoin.parse_funding_rate
  s    %%hO!!(3
H
f
 
 $	

 D
 #D
 
 
 4++HmD
 
 t
 t
 #D
 "4
 "4
  '!
" &t#
$ %
 	
r  c                 v  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nUb  X6S'   U R	                  U R                  Xd5      5      I Sh  vN nU R                  US0 5      nU R                  US/ 5      n	U R                  XX#5      $  N N>7f)a  
fetches historical funding rate prices

https://www.deepcoin.com/docs/DeepCoinTrade/fundingRateHistory

:param str symbol: unified symbol of the market to fetch the funding rate history for
:param int [since]: timestamp in ms of the earliest funding rate to fetch
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.page]: pagination page number
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
Nz5 fetchFundingRateHistory() requires a symbol argumentrC  r+   r  r;  rows)	r   r+   r  r  &privateGetDeepcoinTradeFundRateHistoryr!  r'  r,  parse_funding_rate_histories)
r  rO  r  r   r#  r  r>  r?  r;  rx  s
             r  fetch_funding_rate_history#deepcoin.fetch_funding_rate_history4
  s      >#DGG.e$eff!!!V$fTl
 #FODDT[[QXEabb. ~~h3~~dFB/00uLLA 	" cs"   /B9B5AB98B79=B97B9c                     U R                  US5      nU R                  USS5      nU R                  XBS S5      nUUS   U R                  US5      UU R	                  U5      S.$ )N
CreateTimerh  rg  r:   rO  rate)rj  rO  rk  r  r  )r5  r  r  rp  r  )r  rj  r  r  rh  s        r  parse_funding_rate_history#deepcoin.parse_funding_rate_historye
  sr     ''l;	))$O!!,fEX&++D&9"Y/
 	
r  c                 \  #    U R                  5       I Sh  vN   SnU R                  USS5      u  pTU(       a  U R                  SXX45      I Sh  vN $ SnUb  U R                  U5      nSnU R	                  SXdU5      u  ptSU R                  U5      0nUb  US   US'   Ub  X(S	'   Ub  X8S
'   U R                  US5      n	U	b  U R                  US5      nXS'   U R                  U R                  X5      5      I Sh  vN n
U R                  U
S/ 5      nU R                  XX#5      $  GN N N.7f)aH  
fetch all trades made by the user

https://www.deepcoin.com/docs/DeepCoinTrade/tradeFills

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param int [params.until]: timestamp in ms of the latest trade to fetch
:param str [params.type]: 'spot' or 'swap', the market type for the trades(default is 'spot')
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
NFrv   r  r8   r  r+   rC  beginr   r  endr;  )r  r  r  r  r"  r)  r  r   privateGetDeepcoinTradeFillsr!  r,  r  )r  rO  r  r   r#  r  r  r  r>  r  r?  r;  s               r  fetch_my_tradesdeepcoin.fetch_my_tradesy
  sV     !!!88R\]::?F[`iii[[(F
!??QWakl
77
C
  &tGH$G$G!!&'2YYvw/F"EN::4;;w;WXX4 ~~h3  u<<e 	" j& Ys4   D,D%8D,D(B+D,;D*<*D,(D,*D,c                    #    U R                  5       I Sh  vN   U R                  US5      nUc  Uc  [        U R                  S-   5      eU R	                  SU0U5      nU R                  X#XE5      I Sh  vN $  Nb N7f)a  
fetch all the trades made from a single order

https://www.deepcoin.com/docs/DeepCoinTrade/tradeFills

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.type]: 'spot' or 'swap', the market type for the trades
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
Nr  zK fetchOrderTrades requires a symbol argument or a market type in the paramsr  )r  r  r   r+   r!  r  )r  r+   rO  r  r   r#  r  s          r  fetch_order_tradesdeepcoin.fetch_order_trades
  s      !!!%%ff5
>j0#DGG.{${||gr]F3))&GGG 	"
 Hs"   A=A9AA=4A;5A=;A=c                   #    U R                  5       I Sh  vN   U R                  U5      nU R                  U5      nU R                  US5      nU R	                  US5      nUS   US.nSn	Uc,  Uc)  U R                  U R                  X5      5      I Sh  vN n	OCUb  U R                  US5      nU/US'   U R                  U R                  X5      5      I Sh  vN n	U R	                  U	S/ 5      n
U R                  X5      $  N Nn N,7f)aF  
closes open positions for a market

https://www.deepcoin.com/docs/DeepCoinTrade/batchClosePosition
https://www.deepcoin.com/docs/DeepCoinTrade/closePositionByIds

:param str symbol: Unified CCXT market symbol
:param str [side]: not used by deepcoin
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str|None [params.positionId]: the id of the position you would like to close
:param str[]|None [params.positionIds]: list of position ids to close(for batch closing)
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
N
positionIdpositionIdsr+   )rC  r  r;  )
r  r  r  r  r,  *privatePostDeepcoinTradeBatchClosePositionr!  r   *privatePostDeepcoinTradeClosePositionByIdsr  )r  rO  r  r#  r  r  r  r  r>  r?  r;  s              r  close_positiondeepcoin.close_position
  s     !!!V$99&A%%fl;
nnV];Tl(
 +"5!LLT[[Y`MijjH%6<8*4&!LLT[[Y`MijjH~~h3--% 	" k
 ks5   DDA=DDADD)DDDr   GETc                 2   UnUS:X  a)  U R                  U5      n[        U5      (       a  USU-   -  nU R                  S   U   S-   U-   n	US:X  a  U R                  5         U R	                  5       n
U R                  U
5      nX-   S-   U-   nU R                  UU R                  SS.nUS:w  a  U R                  U5      nSUS	'   X-  nU R                  U R                  U5      U R                  U R                  5      [        R                  S
5      nXS'   XXeS.$ )Nr  ?r   rG  r   200103)zDC-ACCESS-KEYzDC-ACCESS-TIMESTAMPzDC-ACCESS-PASSPHRASEappidzapplication/jsonzContent-Typebase64zDC-ACCESS-SIGN)r   methodbodyheaders)	urlencoder.  r   check_required_credentialsr  r  r   r   jsonhmacencoder   hashlibsha256)r  pathr   r  r#  r  r  requestPathqueryr   r  dateTimepayload	signatures                 r  signdeepcoin.sign
  s   U?NN6*E5zzsU{*iis#c)K7)++-))+I||I.H'#-;G!%'/(,!	G yy(*<'		$++g"6DKK8PRYR`R`bjkI(1$%dOOr  reasonr   r  r  r  c
                    U R                  US0 5      n
U R                  US5      nU R                  US5      nU R                  U
S5      nU R                  U
S5      nU R                  U
S5      nUb  US:X  a  Ub  UnU R                  U
S5      nUbA  [        S	[	        U5      5       H(  nU R                  UU0 5      nU R                  US5      nM*     U R
                  S
-   U-   nUc  Ub  UnU R                  U
S5      nUc  Ub  UnUS:w  d  US:w  d	  Ub  US:w  a  U R                  U R                  S   UU5        U R                  U R                  S   UU5        U R                  U R                  S   UU5        U R                  U R                  S   UU5        [        U5      eU R                  U
S/ 5      nSU
;   a  Uc  [        U5      eg )Nr;  msgr  sCodesMsg	errorCoderF  	errorListr   r  r  r1   rd  r  r  rz  )r'  r  r,  r-  r.  r+   throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr   r#   )r  r  r  r   r  r  r  r?  requestHeadersrequestBodyr;  r  messageCoder  r  r  r  r7  rR  feedbackr  rz  s                         r  handle_errorsdeepcoin.handle_errors  s   ~~h3x/&&x8  w/f-$$T;7	O#)$2BCNN45	 1c)n-y!R8 ,,UK@	 . 77S=4'M	 5E""43M 3ECK[C/U5F5TW<001I;X`a001I5RZ[001I3PXY001I3PXY))>>$3D$T\"8,,r  r  )N)d__name__
__module____qualname____firstlineno__r   r  strr   r"  r)  r   r8  r0  dictrv  ry  r	   r   r  rz  r  r   r   r  r   r  r   r  r  r  r   r  r   r   r  r   r  r"  r   r:  r7  r   rM  rS  rY  r
   r_  rp  ro  floatr   r   r  r  r   r   r   r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r#  r$  r   r6  r:  rQ  intrV  r   r`  r   rd  rc  r{  r  r  r  r  r  r  __static_attributes____classcell__)r  s   @r  r'   r'      s   \# \|
 OS[]lp m mV mux m m; *, V 0 8: #0Jv4 vF vp	 @DB %OS %O %OS\ %ON 8<$]ajl VH VHC VHWZ VHquvzq{ VHp 6:" 47 4 4,:4 : :6 :x <@d[] = =S = =bfglbm =2F s < <v < <|;S ; *, , ,&) )@ 04$UYbd &Y &YC &Ys &Yimnyiz &YP 37TX\eg &YC &Ys &YRU &Ylpq|l} &YP,
T ,
X ,
Q\ ,
\:s :s : >B" 6R7 6RQUVdQe 6Rp =?  > 8
 
N 
< .2SW`b <?s <?# <?S <?gklwgx <?|#t #x #; #J8 ac 33 3 3C 3TW 3gt 3j
t 
x 
= 
,C C 
 mqy{ 2. 2.I 2.Y 2.X] 2.fi 2.h os{} `3 `i `y `Z_ `hk `$ w{  DF _,3 _,i _,y _,bg _,ps _,B w{  DF C,3 C,i C,y C,bg C,ps C,J	I 	 eg 
P# 
PY 
PV[ 
P XZ 	Qc 	Q 	Q^c 	Q Y[ 	Rs 	R% 	R_d 	R ?C2 D/3 D/ D/RW D/L =A / /c /PU /6 DHVZimvx y=S y=PS y=cf y=  ~B  CH  ~I y=v 9=4^bkm Y# YS YX[ Yrvw|r} Y$ 7;\`ik Y Y3 YVY Yptuzp{ Y$ 59tZ^gi qQc qQ qQTW qQnrsxny qQf 9=R .S .# .E .< 59 #/c #/U #/J fjx|  FH 6&3 6& 6&9 6&I 6&_b 6&ru 6&p AER /tCy /# /TXY^T_ /*p pv p pd: : :3S 3S 3:c :c : DF >s >$x. >, 8<B 03W 034PX> 03d3t 3V 3x 3j ?C2 23 2 2h <@ 08 08| 08d <> $6s $6+ $6L
6 
[ 
< >BPTcgpr /Ms /M# /M]` /Mb
v 
( 37TX\eg A=C A=s A=RU A=F ?CQUdhqs H3 H H3 H^a H* CGr  .3  .i  .V[  .D &eBSW P4# s  c TX `c  r  r'   )- ccxt.async_support.base.exchanger   ccxt.abstract.deepcoinr   r1  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r    r!   r"   r#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'   r  r  r  <module>r     sh    6 .   r  r  r  r  r  r  * . ' . ) * ) ) 4 %S,x S,r  