
    i@a                    t   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dl*m+Z+ d dl,m-Z-  G d dee          Z.dS )    )Exchange)ImplicitAPIN)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)BadResponse)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)DuplicateOrderId)NotSupported)RateLimitExceeded)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Z fdZi fdZi fdZi fdZi fdee         fdZ	di fde
defd	Zi fd
edefdZd>dedefdZdi fd
ededefdZdddi fd
edededee         fdZd>dedefdZddi fd
edededee         fdZdddi fd
ededefdZdddi fded
ededefdZd>dedefdZi fdefdZdefdZdi fd
ede de!de"de#f
dZ$di fded
efd Z%dddi fd
edededee&         fd!Z'dddi fd
edededee&         fd"Z(di fded
efd#Z)di fd
efd$Z*d>dede&fd%Z+d& Z,d' Z-d( Z.d) Z/d* Z0d+ Z1i fd
ede2fd,Z3i fde4fd-Z5d>dede2fd.Z6di fd/ede"fd0Z7dddi fd/edededee8         fd1Z9dddi fd/edededee8         fd2Z:d>d3e;de8fd4Z<d5 Z=i fd/efd6Z>d>d3e;fd7Z?i fd8Z@d9 ZAd:d;i ddfd<ZBd= ZC xZDS )?coinsphc           "         |                      t          t          |                                           dddgddddi dd dd	d
ddddddddddd	dd	dddddddddd	dddddd	i dddddd	dd	dd	dd	ddd dd!d	d"dd#dd$dd%dd&dd'dd(d	d)di d*dd+dd,d d-d	d.dd/dd0d	d1dd2dd3dd4dd5dd6dd7dd8dd9dd:di d;dd<dd=dd>dd?d	d@ddAd	dBd	dCddDd dEd	dFd	dGd	dHddIddJd	dKdi dLddMddNddOd	dPd	dQd	dRd	dSd	dTd	dUd	dVddWddXddYddZdd[d d\d	ddddddddddd	dd]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndododpdqdrgdsdtdudvdvdvdwdxdwgdydzgd{dvggd|dvd}d~dvd}d~ddvdxdgd{dvggddvdvdvdvdii ddddddvddvdddddwd~ddvdd}dddwd~ddddvddvddvddvddvddvi ddddvddvddvddvddvddvddvddvddvddvddvddvddvddvddvddvdvdvdvddvdvdvdddpddud	d	|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg
|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg
ddÜit
          d	ddiddiddddǜdȜddiddidddddϜdМi dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          d t          dt          dt          dt          i dt           dt          dt          dt          dt          d	t          d
t          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          i dt          dt          dt          dt           dt          dt          dt          dt          dt          dt          dt          d t          d!t          d"t          d#t          d$t"          i d%t           d&t          d't          d(t          d)t          d*t          d+t          d,t          d-t          d.t          d/t          d0t          d1t$          d2t          d3t          d4t          d5t&          t          t          t          t          t          t          t          t          d6d7d8          S (9  Nr*   zCoins.phPHv12   FCORSspotTmarginswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawalfetchWithdrawals)fetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws1m3m5m15m30m1h2h4h6h8h12h1d3d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zdhttps://user-images.githubusercontent.com/1294454/225719995-48ab2026-4ddb-496c-9da7-0d7566617c9b.jpgzhttps://api.pro.coins.ph)publicprivatezhttps://coins.ph/z%https://coins-docs.github.io/rest-apizDhttps://support.coins.ph/hc/en-us/sections/4407198694681-Limits-Fees)logoapiwwwdocfeesget   (   e         r   )costnoSymbolAndNoSymbolsbyNumberOfSymbols   )r   noSymbol
      )r   byLimit)zopenapi/v1/pingzopenapi/v1/timezopenapi/quote/v1/ticker/24hrzopenapi/quote/v1/ticker/pricez"openapi/quote/v1/ticker/bookTickerzopenapi/v1/exchangeInfozopenapi/quote/v1/depthzopenapi/quote/v1/klineszopenapi/quote/v1/tradeszopenapi/v1/pairszopenapi/quote/v1/avgPricezopenapi/wallet/v1/config/getallz!openapi/wallet/v1/deposit/addressz!openapi/wallet/v1/deposit/historyz"openapi/wallet/v1/withdraw/historyzopenapi/v1/accountopenapi/v1/openOrders   zopenapi/v1/asset/tradeFeeopenapi/v1/orderzopenapi/v1/historyOrderszopenapi/v1/myTradesz"openapi/v1/capital/deposit/historyz#openapi/v1/capital/withdraw/historyz.openapi/v3/payment-request/get-payment-requestzmerchant-api/v1/get-invoicesz"openapi/account/v3/crypto-accountsz"openapi/transfer/v3/transfers/{id}z openapi/wallet/v1/withdraw/applyiX  zopenapi/v1/order/testz!openapi/v1/capital/withdraw/applyz openapi/v1/capital/deposit/applyz+openapi/v3/payment-request/payment-requestsz1openapi/v3/payment-request/delete-payment-requestz3openapi/v3/payment-request/payment-request-reminderopenapi/v1/userDataStreamzmerchant-api/v1/invoiceszmerchant-api/v1/invoices-cancelz.openapi/convert/v1/get-supported-trading-pairszopenapi/convert/v1/get-quotezopenapi/convert/v1/accpet-quotezopenapi/fiat/v1/support-channelzopenapi/fiat/v1/cash-outzopenapi/fiat/v1/history)zopenapi/migration/v4/sellorderz#openapi/migration/v4/validate-fieldzopenapi/transfer/v3/transfers)r   r   r   )r   postdeletetradingz0.0025z0.0030500000z0.00271000000z0.00242500000z0.0025000000z0.001810000000z0.0015	100000000z0.0012	500000000z0.0009
1000000000z0.0007
2500000000z0.0005z0.0022z0.001z0.0008z0.0006)takermaker)feeSide	tierBased
percentager   r   tierswarningGTCFULL)marketlimit)timeInForcenewOrderRespTypemethod!publicGetOpenapiQuoteV1Ticker24hrTRXETHBSCARBITRUM)TRC20ERC20BEP20ARB)!createMarketBuyOrderRequiresPricer   rE   r?   rw   rx   networksz-1000z-1001z-1002z-1003z-1004z-1006z-1007z-1014z-1015z-1016z-1020z-1021z-1022z-1023z-1024z-1025z-1030z-1100z-1101z-1102z-1103z-1104z-1105z-1106z-1111z-1112z-1114z-1115z-1116z-1117z-1118z-1119z-1120z-1121z-1122z-1125z-1127z-1128z-1130z-1131z-1132z-1133z-1134z-1135z-1136z-1137z-1138z-1139z-1140z-1141z-1142z-1143z-1144z-1145z-1146z-1147z-1148z-1149z-1150z-1151z-1152z-1153z-1154z-1155z-1156z-1157z-1158z-1159z-1160z-1161z-2010z-2013z-2011z-2014z-2015z-2016z-3126z-3127z-4001z-100011z-100012z-30008z-30036403zUnknown order sentzDuplicate order sentzMarket is closedz5Account has insufficient balance for requested actionz/Market orders are not supported for self symbolz0Iceberg orders are not supported for self symbolz2Stop loss orders are not supported for self symbolz8Stop loss limit orders are not supported for self symbolz4Take profit orders are not supported for self symbolz:Take profit limit orders are not supported for self symbolzPrice* QTY is zero or lesszIcebergQty exceeds QTYz'This action disabled is on self accountzUnsupported order combinationzOrder would trigger immediatelyz6Cancel order is invalid. Check origClOrdId and orderIdz&Order would immediately match and take)PRICE_FILTERLOT_SIZEMIN_NOTIONALMAX_NUM_ORDERSMAX_ALGO_ORDERSBROKER_MAX_NUM_ORDERSBROKER_MAX_ALGO_ORDERSICEBERG_PARTS)exactbroad)idname	countriesversion	rateLimit	certifiedprohas
timeframesurlsr   r   precisionModeoptions
exceptions)deep_extendsuperr*   describeparse_numberr'   r   r   r%   r    r   r$   r   r   r   r#   r!   r&   r   r"   )self	__class__s    R/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/coinsph.pyr   zcoinsph.describe!   s6   gt 4 4 = = ? ?bbb %b 	b
 %b %b Ub "4b tb b $Ub  b 'b /b ,Ub  0!b" t#b b$ &u%b& ('b( ')b* (+b, "4-b. 4/b0 U1b2  3b4 5b6  7b8 &u9b: +E;b< )%=b> &u?b@ #EAbB $TCbD 'Eb b bF (GbH "5IbJ KbL &tMbN (ObP 1%QbR  SbT *5UbV +EWbX &uYbZ #E[b\ *5]b^ $U_b` "5abb *5cbd +Eebf #Egb b bh uibj  kbl %embn +Eobp qbr !%sbt  ubv dwbx +Eybz !${b| "4}b~ db@ !$AbB "5CbD uEbF #DGbH  Ib b bJ !%KbL %eMbN )%ObP tQbR tSbT UbV TWbX tYbZ "4[b\ #D]b^ %e_b` &uabb 'cbd $Uebf !%gbh "4ibj #Dkb bl -2 %$)',$"!&#(! Cb b bH  $ 89  +; _  +,+, BC\^wz|~v  CE  GI  BJ  MN  PQ  LR  vS  9T  9T CDQR9S9S HIVW>X>X35;<3PQ(UVXYTZI[2\2\3434,-56' 092;R <Q =a	
 -b 0!1L1L 4Q +A 3RR4P4P .r =a >q I!  7!" =a#$ =a%(:C/ +A <Q	
 ;A Fq LQ Nq 4Q 3A :1 I! 7 :1 :1  3A!" 21#$ ;<?@9:)  . -.1256 W0 01I IX $!%"&!..x88!..w77 "..s33T5F5Fw5O5OP!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LW;U;UV!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..{;;T=N=Nx=X=XY!..{;;T=N=Nx=X=XY!..|<<d>O>OPX>Y>YZ!..|<<d>O>OPX>Y>YZ" "..s33T5F5Fx5P5PQ!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..z::D<M<Mg<V<VW!..{;;T=N=Nx=X=XY!..{;;T=N=Nx=X=XY!..|<<d>O>OPX>Y>YZ!..|<<d>O>OPX>Y>YZ"    #H ' 6:u u $)"(!') )    A  A! #""% + @UZUZU 0U .	U
 \U [U [U \U .U \U \U ZU ZU 0U ZU  Z!U" ]#U U$ Z%U& Z'U( Z)U* Z+U, Z-U. Z/U0 Z1U2 Z3U4 [5U6 Z7U8 \9U: \;U< \=U> \?U@ \AUB ZCUD YEU U UF \GUH ZIUJ ZKUL ZMUN ZOUP .QUR \SUT \UUV \WUX \YUZ \[U\ \]U^ \_U` \aUb \cUd -eUf \gU U Uh ]iUj \kUl \mUn \oUp \qUr \sUt \uUv \wUx YyUz \{U| 0}U~ ZU@ ZAUB \CUD YEUF \GUH \IU U UJ ZKUL ZMUN \OUP ]QUR ZSUT ZUUV 0WUX [YUZ \[U\ \]U^ Z_U` yaUb ycUd /eUf /gUh /iU Ul(-*,< '	 LM^	
 Fy G	 I) OPY KI QR[ 1* -j >?O 4\ 6|  Ml!" =>V#$ %1 ,$0&2'3-9.:%/3  or roJB
 JB
 J J J	    c                    d|v rd|vr|d         S d|v rd|vrd|vr|d         S d|v rbd|v r^|d         }t          |          }|d         }t          dt          |                    D ] }	||	         }
||
d         k    r
|
d         c S !nVd|v rRd	|v rN|d	         }|d         }t          dt          |                    D ] }	||	         }
||
d         k    r
|
d         c S !|                     |d
d          S )Nr   symbolr   symbolsr   r   r   r   r   r   )lenrange
safe_value)r   r   r   pathparamsconfigr   symbolsAmountr   ientryr   r   s                r   calculate_rate_limiter_costz#coinsph.calculate_rate_limiter_cost  s`   &  8v+=+=*%%$..V9K9KV_ciViVi011!V++)v2E2EY'GLLM &': ;1c"34455 $ $)!, E!H,, 8OOO -$ 6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %vvq111r   c                 <    |                      |          }dddd|dS )aV  
        the latest known information on the availability of the exchange API
        :see: https://coins-docs.github.io/rest-api/#test-connectivity
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
        okN)statusupdatedetaurlinfo)publicGetOpenapiV1Pingr   r  responses      r   fetch_statuszcoinsph.fetch_status  s5     ..v66
 
 	
r   c                 X    |                      |          }|                     |d          S )aY  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: https://coins-docs.github.io/rest-api/#check-server-time
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        
serverTime)publicGetOpenapiV1Timesafe_integerr  s      r   
fetch_timezcoinsph.fetch_time  s/     ..v66   <888r   returnc                    |                      |          }|                     |d          }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }	|                     |          }
|                     |	          }|                     |                     |d          d          }|                     |di           }|                     |d	i           }|                     |d
i           }|                    i d|d|
dz   |z   d|
d|ddd|d|	ddddddddddddddd|                     |d          dk    ddd ddddddddd| 	                    |                     |d!                    | 	                    |                     |d"                    d#ddd$| 	                    |                     |d%                    | 	                    |                     |d&                    d$| 	                    |                     |d'                    | 	                    |                     |d(                    d$| 	                    |                     |d)                    dd$d*d|d+           | 
                    |           |S ),a   
        retrieves data on all markets for coinsph
        :see: https://coins-docs.github.io/rest-api/#exchange-information
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r   r   	baseAsset
quoteAssetfilters
filterTyper   r   NOTIONALr   /basequotesettleNbaseIdquoteIdsettleIdtyper0   Tr1   Fr2   r3   r4   activer  r   contractlinearstepSizetickSize)amountprice)minmaxminQtymaxQtyminPricemaxPriceminNotional)leverager/  r0  r   )inverser   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedr  )publicGetOpenapiV1ExchangeInfor  r  r  safe_stringsafe_currency_codeindex_byappendsafe_string_lowerr   set_markets)r   r  r  marketsresultr  r   r   r&  r'  r#  r$  r@  amountLimitspriceLimits
costLimitss                   r   fetch_marketszcoinsph.fetch_markets  s    66v>>x //(I66q#g,,'' =	 =	AQZF!!&(33B%%fk::F&&v|<<G**622D++G44E]]4??69#E#E|TTF??6:rBBL//&."EEKR@@JMM 2b2$*u,2 2 	2
 $2 &2 72 D2 2 2 %2 2 %2 %2 $00BBiO2  E!2" $#2$   $"&""//0@0@z0Z0Z[[!..t/?/?Z/X/XYY   $#! !
  $001A1A,PX1Y1YZZ#001A1A,PX1Y1YZZ 
  $001A1A+z1Z1Z[[#001A1A+z1Z1Z[[ 
  $001A1A*m1\1\]]#  $  c2 2 2 2 2 2 2f 	   r   Nr   c                    |                                   i }|_g }t          dt          |                    D ]:}|                     ||                   }|d         }|                    |           ;||d<   d}|                     | j        di           }	|                     |	d|          }
d}|
dk    r*|                     | 	                    ||                    }nY|
d	k    r*| 
                    | 	                    ||                    }n)|                     | 	                    ||                    }|                     |||          S )
a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://coins-docs.github.io/rest-api/#24hr-ticker-price-change-statistics
        :see: https://coins-docs.github.io/rest-api/#symbol-price-ticker
        :see: https://coins-docs.github.io/rest-api/#symbol-order-book-ticker
        :param str[]|None 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   rx   r   "publicGetOpenapiQuoteV1TickerPrice'publicGetOpenapiQuoteV1TickerBookTicker)load_marketsr  r  r   rF  r  r   rC  rP  extendrQ  r   parse_tickers)r   r   r  requestidsr  r   r   defaultMethodr   r   tickerss               r   fetch_tickerszcoinsph.fetch_tickersg  sP    	C1c'll++  WQZ00D\

2!$GI;//$,CC!!'8]CC999==dkk'SY>Z>Z[[GG@@@BB4;;wX^C_C_``GG<<T[[RX=Y=YZZG!!'7F;;;r   r   c                    |                                   |                     |          }d|d         i}d}|                     | j        di           }|                     |d|          }d}|dk    r*|                     |                     ||                    }nY|dk    r*|                     |                     ||                    }n)|                     |                     ||                    }| 	                    ||          S )	a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://coins-docs.github.io/rest-api/#24hr-ticker-price-change-statistics
        :see: https://coins-docs.github.io/rest-api/#symbol-price-ticker
        :see: https://coins-docs.github.io/rest-api/#symbol-order-book-ticker
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   r   r   rw   r   NrP  rQ  )
rR  r   r  r   rC  rP  rS  rQ  r   parse_ticker)	r   r   r  r   rU  rW  r   r   tickers	            r   fetch_tickerzcoinsph.fetch_ticker  s	    	V$$fTl
 <//$,rBB!!'8]CC999<<T[[RX=Y=YZZFF@@@AA$++gW]B^B^__FF;;DKKQW<X<XYYF  000r   r   c           	         |                      |d          }|                     ||          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }	|                      |d          }
|                      |d	          }|                      |d
          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }t          j        |d          }|                     i d|d         d|d|                     |          d|d|d|d|                     |dd          d|d|d|d|d|d|d|d |d!d d"|	|
|d#|          S )$Nr   	closeTimebidPriceaskPricebidQtyaskQtyvolumequoteVolume	openPrice	highPricelowPriceprevClosePriceweightedAvgPricepriceChangepriceChangePercent100	timestampdatetimeopenhighlowclose	lastPricer0  bid	bidVolumeask	askVolumevwappreviousClosechanger   average
baseVolume)re  r  )rC  safe_marketr  r(   
string_mulsafe_tickeriso8601safe_string_2)r   r\  r   marketIdrn  ru  rw  rv  rx  r}  re  rp  rq  rr  	prevClosery  changeValue
changePcnts                     r   r[  zcoinsph.parse_ticker  s   N ##FH55!!(F33%%fk::	vz22vz22$$VX66	$$VX66	%%fh77
&&v}==4444vz22$$V-=>>	(:;;&&v}==%%f.BCC
'
E::
 !
fX&!
!
 Y//!
 D	!

 D!
 3!
 T''WEE!
 3!
 !
 3!
 !
 D!
 Y!
 k!
 *!
  t!!
" *#!
$ ''!
 !
 !
( )  	r   r   c                 *   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     ||          }|                     |d          |d<   |S )aI  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://coins-docs.github.io/rest-api/#order-book
        :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(default 100, max 200)
        :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
        r   r   Nr   lastUpdateIdnonce)rR  r   publicGetOpenapiQuoteV1DepthrS  parse_order_bookr  )r   r   r   r  r   rU  r  	orderbooks           r   fetch_order_bookzcoinsph.fetch_order_book  s     	V$$fTl
 $GG44T[[&5Q5QRR ))(F;;	!..xHH	'r   r   sincec                    |                                   |                     |          }|                     | j        |          }|d         |d}|\||d<   d|d<   |8|                     |          dz  }	|                     ||	|dz
  z            |d<   n|                                 |d<   n|||d<   |                     |                     ||                    }
| 	                    |
||||          S )	a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://coins-docs.github.io/rest-api/#klinecandlestick-data
        :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(default 500, max 1000)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   )r   intervalN	startTime  r   r   endTime)
rR  r   rC  r   parse_timeframesummillisecondspublicGetOpenapiQuoteV1KlinesrS  parse_ohlcvs)r   r   	timeframer  r   r  r   r  rU  durationr  s              r   fetch_ohlcvzcoinsph.fetch_ohlcv  s    	V$$##DOY??Tl 
 
 #(GK #GG //	::TA%)XXeX5K%L%L	""%)%6%6%8%8	"" #( 55dkk'66R6RSS$   69eUKKKr   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r   r   r      r   )r  safe_number)r   ohlcvr   s      r   parse_ohlcvzcoinsph.parse_ohlcvC  s~    eQ''UA&&UA&&UA&&UA&&UA&&
 	
r   c                    |                                   |                     |          }d|d         i}|d|d<   n|||d<   |                     |                     ||                    }|                     ||||          S )a<  
        get the list of most recent trades for a particular symbol
        :see: https://coins-docs.github.io/rest-api/#recent-trades-list
        :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 500, max 1000)
        :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>`
        r   r   Nr  r   )rR  r   publicGetOpenapiQuoteV1TradesrS  parse_tradesr   r   r  r   r  r   rU  r  s           r   fetch_tradeszcoinsph.fetch_tradesM  s     	V$$fTl
 #GG #( 55dkk'66R6RSS   65%@@@r   c                 D   |t          | j        dz             |                                  |                     |          }d|d         i}|||d<   d|d<   n|||d<   |                     |                     ||                    }|                     ||||          S )a  
        fetch all trades made by the user
        :see: https://coins-docs.github.io/rest-api/#account-trade-list-user_data
        :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(default 500, max 1000)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr   r   r  r  r   )r   r   rR  r   privateGetOpenapiV1MyTradesrS  r  r  s           r   fetch_my_tradeszcoinsph.fetch_my_tradesr  s     >#DG.[$[\\\V$$fTl
 #(GK #GG$GG33DKK4P4PQQ  65%@@@r   r   c           	          |t          | j        dz             d|i}|                     ||||                     ||                    S )a(  
        fetch all the trades made from a single order
        :see: https://coins-docs.github.io/rest-api/#account-trade-list-user_data
        :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
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz. fetchOrderTrades() requires a symbol argumentorderId)r   r   r  rS  )r   r   r   r  r   r  rU  s          r   fetch_order_tradeszcoinsph.fetch_order_trades  sU     >#DG.^$^___r
 ##FE5$++gv:V:VWWWr   c                    |                      |d          }|                     ||          }|d         }|                     |dd          }|                      |d          }|                     |d          }|                      |d          }|                      |d          }	d }
d }|                      |d          }|.|                      |d	          }||                     |          d
}|                     |ddd           }d }||du rdnd}|                     |dd           }d }|
|dk    rdnd}d }||                      |d          }|                     ||||                     |          ||
||||	|||d|          S )Nr   r   tradeIdr  timer0  qty
commissioncommissionAsset)r   currencyisBuyerisBuyerMakerTbuysellisMakertruer   r   quoteQty)r   orderrn  ro  r   r)  sidetakerOrMakerr0  r/  r   feer  )rC  r~  r  r  rD  safe_value_2
safe_trader  )r   trader   r  r   r   r  rn  priceStringamountStringr)  r  feeCostfeeCurrencyIdr  r  r  r  
costStrings                      r   parse_tradezcoinsph.parse_trade  s   L ##E844!!(F33!tY77""5)44%%eV44	&&ug66''u55""5,77 ,,U4EFFM 33MBB C ##E9ndKK$__556D$$UIt<<'.&'8'877wL
))%<<J"Y//( " 
  
   	r   c                 ~    |                                   |                     |          }|                     |          S )ag  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://coins-docs.github.io/rest-api/#accept-the-quote
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )rR  privateGetOpenapiV1Accountparse_balancer  s      r   fetch_balancezcoinsph.fetch_balance  s?     	226::, !!(+++r   c                    |                      |dg           }|d d d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )Nbalances)r  rn  ro  r   assetfreelockedused)r  r  r  rC  rD  accountsafe_balance)	r   r  r  rJ  r  balance
currencyIdcoder  s	            r   r  zcoinsph.parse_balance  s    ??8Z<<
 

 q#h--(( 	# 	#AqkG))'7;;J**:66DllnnG"..w??GFO"..wAAGFO"F4LL  (((r   r)  r  r/  r0  c                 z   |                                   |                     |          }|                     |dd          }|                     |d          }|                     |d|          }	|                     |	          }	|                     |d          }|                     |          }
|d         |	|
d}|                     | j        di           }|                     |di           }|	dk    s|	d	k    s|	d
k    s|	dk    r|t          | j
        dz   |z   dz             |                     |dd          }|                     ||          |d<   |                     ||          |d<   |	dk    r|                     |dd          |d<   nA|	dk    s|	dk    s|	dk    r.|                     |dd          }|
dk    r|                     ||          |d<   n|
dk    rd}d}|                     |ddd          \  }}|                     |dd          }|                     |d          }||                     ||          }n|ro|t!          | j
        dz             |                     |          }|                     |          }t%          j        ||          }|                     ||          }n|                     ||          }||d<   |	dk    s|	d	k    s|	dk    s|	d
k    rI|                     |d d!          }|t!          | j
        d"z             |                     ||          |d!<   ||d<   |                     |dd!d dd          }d}|r*|                     |                     ||                    }n)|                     |                     ||                    }|                     ||          S )#a  
        create a trade order
        :see: https://coins-docs.github.io/rest-api/#new-order--trade
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market', 'limit', 'stop_loss', 'take_profit', 'stop_loss_limit', 'take_profit_limit' or 'limit_maker'
        :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 fullfilled, 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]: the quote quantity that can be used alternative for the amount for market buy orders
        :param bool [params.test]: set to True to test an order, no order will be created but the request will be validated
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        testFr)  r   )r   r)  r  r?   r   LIMITSTOP_LOSS_LIMITTAKE_PROFIT_LIMITLIMIT_MAKERNz/ createOrder() requires a price argument for a z orderr   r   r0  quantityr   r   MARKET	STOP_LOSSTAKE_PROFITr   SELLBUYTr   r   quoteOrderQtyz createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumenttriggerPrice	stopPricez createOrder() requires a triggerPrice or stopPrice param for stop_loss, take_profit, stop_loss_limit, and take_profit_limit orders)rR  r   	safe_boolomitrC  encode_order_typeencode_order_sider  r   r   r   price_to_precisionamount_to_precisionhandle_option_and_paramssafe_number_2cost_to_precisionr    number_to_stringr(   r  r  privatePostOpenapiV1OrderTestrS  privatePostOpenapiV1Orderparse_order)r   r   r)  r  r/  r0  r  r   	testOrder	orderType	orderSiderU  r   r   quoteAmountr   r   r  r  costRequestr  r  s                         r   create_orderzcoinsph.create_order!  ss    	V$$NN66599	66**$$VVT::	**955	66****400	Tl
 

 //$,rBB??74FKK90A#A#AYReEeEeir  wD  jD  jD}'2c(cfj(jmu(uvvv#//0@'6RR#66vuEEGG"&":":66"J"JGJM)))-)9)9'=RW)X)X&(""i;&>&>)}B\B\#//0@(FSSF""&*&>&>vv&N&N
##e##"481<@<Y<YZ`bo  rU  W[  =\  =\916))&&/JJ6622#"&"8"8"F"FKK6 	I}*47  6q  ,q  r  r  r'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S&*&<&<V[&Q&Q"&"8"8"H"HK+6(##y4E'E'EVcIcIcgp  uH  hH  hH**6>;OOI "47  .s  $s  t  t  t#'#:#:69#M#MGK &6"#67KUdee 	T99$++gv:V:VWWHH55dkk'66R6RSSH8 &111r   c                 "   |                                   i }|                     |dd          }|||d<   n||d<   |                     |ddg          }|                     |                     ||                    }|                     |          S )a  
        fetches information on an order made by the user
        :see: https://coins-docs.github.io/rest-api/#query-order-user_data
        :param int|str id: order id
        :param str symbol: not used by coinsph fetchOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        origClientOrderIdclientOrderIdNr  )rR  r  r  privateGetOpenapiV1OrderrS  r  r   r   r   r  rU  r  r  s          r   fetch_orderzcoinsph.fetch_order  s     	))&2EWW$+8G'((!#GI6O5H#IJJ00Wf1M1MNN)))r   c                     |                                   d}i }| |                     |          }|d         |d<   |                     |                     ||                    }|                     ||||          S )a  
        fetch all unfilled currently open orders
        :see: https://coins-docs.github.io/rest-api/#query-order-user_data
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   )rR  r   privateGetOpenapiV1OpenOrdersrS  parse_ordersr  s           r   fetch_open_orderszcoinsph.fetch_open_orders  s     	[[((F &tGH55dkk'66R6RSS  65%@@@r   c                 D   |t          | j        dz             |                                  |                     |          }d|d         i}|||d<   d|d<   n|||d<   |                     |                     ||                    }|                     ||||          S )aY  
        fetches information on multiple closed orders made by the user
        :see: https://coins-docs.github.io/rest-api/#history-orders-user_data
        :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(default 500, max 1000)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz/ fetchClosedOrders() requires a symbol argumentr   r   r  r  r   )r   r   rR  r    privateGetOpenapiV1HistoryOrdersrS  r   r  s           r   fetch_closed_orderszcoinsph.fetch_closed_orders  s     >#DG._$_```V$$fTl
 #(GK #GG$GG88Wf9U9UVV  65%@@@r   c                 "   |                                   i }|                     |dd          }|||d<   n||d<   |                     |ddg          }|                     |                     ||                    }|                     |          S )a{  
        cancels an open order
        :see: https://coins-docs.github.io/rest-api/#cancel-order-trade
        :param str id: order id
        :param str symbol: not used by coinsph cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  r  Nr  )rR  r  r  privateDeleteOpenapiV1OrderrS  r  r  s          r   cancel_orderzcoinsph.cancel_order  s     	))&2EWW$+8G'((!#GI6O5H#IJJ33DKK4P4PQQ)))r   c                 &   |t          | j        dz             |                                  d}i }| |                     |          }|d         |d<   |                     |                     ||                    }|                     ||          S )av  
        cancel open orders of market
        :see: https://coins-docs.github.io/rest-api/#cancel-all-open-orders-on-a-symbol-trade
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- cancelAllOrders() requires a symbol argumentr   r   )r   r   rR  r    privateDeleteOpenapiV1OpenOrdersrS  r   )r   r   r  r   rU  r  s         r   cancel_all_orderszcoinsph.cancel_all_orders  s     >#DG.]$]^^^[[((F &tGH88Wf9U9UVV  6222r   c           
         |                      |d          }|                      |d          }|                     ||          }|                     |dd          }|                     |dd           }|                      |d          }t	          j        |d          rd }|                     i d|d	|                      |d	          d
|d|                     |          dd d|                     |                      |d                    d|d         d| 	                    |                      |d                    d| 
                    |                      |d                    d|                     |                      |d                    d|                      |d          d|d|dd d|                      |d          d|                      |d          d|                      |d          d d d ||d|          S )Nr  r   r  transactTimefillsr  r   r   r  rn  ro  lastTradeTimestampr  r)  r   r  r0  r  r|  r/  origQtyr   cummulativeQuoteQtyfilledexecutedQty)	remainingr  r   tradesr  )rC  r~  safe_integer_2r  r(   	string_eq
safe_orderr  parse_order_statusparse_order_typeparse_order_time_in_forceparse_order_side)r   r  r   r   r  rn  r  r  s           r   r  zcoinsph.parse_order  s   J eY//##E844!!(F33''v~FF	66$$UK88	Y,, 	I  
" 
T--e_EE 
  
 Y//	 

 !$ 
 d--d.>.>uh.O.OPP 
 fX& 
 D))$*:*:5&*I*IJJ 
 499$:J:J5R_:`:`aa 
 D))$*:*:5&*I*IJJ 
 T%%eW55 
  
 I 
 t 
 d&&ui88 
  D$$U,ABB! 
" d&&um<<# 
$ - 
  
  
. /  	r   c                 :    ddd}|                      |||          S )Nr  r  )r  r  rC  r   r  statusess      r   r  zcoinsph.parse_order_sideW  .    
 
 &&999r   c                 :    ddd}|                      |||          S )Nr  r  )r  r  r  r  s      r   r  zcoinsph.encode_order_side^  r   r   c                 D    dddddddd}|                      |||          S )Nr   r   )r  r  r  r  r  r  r  r  r  s      r   r  zcoinsph.parse_order_typee  s=    "!&#!(
 
 &&999r   c                 D    dddddddd}|                      |||          S )	Nr  r  r  r  r  r  r  )r   r   limit_maker	stop_lossstop_loss_limittake_profittake_profit_limitr  r  s      r   r  zcoinsph.encode_order_typeq  s=    ($0(!4
 
 &&999r   c                 B    ddddddd}|                      |||          S )Nrp  closedcanceledrejected)NEWFILLEDCANCELEDPARTIALLY_FILLEDPARTIALLY_CANCELEDREJECTEDr  r  s      r   r  zcoinsph.parse_order_status}  s:    " &","
 
 &&999r   c                 <    dddd}|                      |||          S )Nr   FOKIOC)r   r4  r5  r  r  s      r   r  z!coinsph.parse_order_time_in_force  s1    
 

 &&999r   c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )aY  
        fetch the trading fees for a market
        :see: https://coins-docs.github.io/rest-api/#trade-fee-user_data
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
        r   r   r   )rR  r    privateGetOpenapiV1AssetTradeFeerS  r  parse_trading_fee)r   r   r  r   rU  r  
tradingFees          r   fetch_trading_feezcoinsph.fetch_trading_fee  s     	V$$fTl
 88Wf9U9UVV __Xq"55
%%j&999r   c                     |                                   |                     |          }i }t          dt          |                    D ]*}|                     ||                   }|d         }|||<   +|S )aY  
        fetch the trading fees for multiple markets
        :see: https://coins-docs.github.io/rest-api/#trade-fee-user_data
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r   r   )rR  r7  r  r  r8  )r   r  r  rJ  r  r  r   s          r   fetch_trading_feeszcoinsph.fetch_trading_fees  s     	88@@ q#h--(( 	! 	!A((!55C]F F6NNr   c                     |                      |d          }|                     ||          }|d         }|||                     |d          |                     |d          d d dS )Nr   makerCommissiontakerCommission)r  r   r   r   r   r   )rC  r~  r  )r   r  r   r  r   s        r   r8  zcoinsph.parse_trading_fee  s{     ##C22!!(F33!%%c+<==%%c+<==
 
 	
r   r  c                 l   |                      | j        d          }|                     |dd          }|rt          | j        dz             |                     |d          }|                     ||          }	|	t          | j        dz             |                                  | 	                    |          }
|
d         | 
                    |          |	|d	}|||d
<   |                     |d          }|                     |                     ||                    }|                     ||
          S )a  
        make a withdrawal to coins_ph account
        :see: https://coins-docs.github.io/rest-api/#withdrawuser_data
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: not used by coinsph withdraw()
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r   r   Tz withdraw() makes a withdrawals only to coins_ph account, add .options['withdraw']['warning'] = False to make a withdrawal to your coins_ph accountnetworkNz% withdraw() require network parameterr   )coinr/  rA  addresswithdrawOrderId)r  r   r  r   r   rC  network_code_to_idr   rR  r  r  r  'privatePostOpenapiWalletV1WithdrawApplyrS  parse_transaction)r   r  r/  rC  tagr  r   r   networkCode	networkIdr  rU  r  s                r   r   zcoinsph.withdraw  sL    //$,
;;..)T:: 	B   ,A  "A  B  B  B&&vy99++K>>	TW'NNOOO==&&TN++F33 	
 
 ?),G%&69--??GU[@\@\]]%%h999r   c                    |                                   d}i }| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     ||||          S )a  
        fetch all deposits made to an account
        :see: https://coins-docs.github.io/rest-api/#deposit-history-user_data
        :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
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   rB  r  r   )rR  r  'privateGetOpenapiWalletV1DepositHistoryrS  parse_transactionsr   r  r  r   r  r  rU  r  s           r   fetch_depositszcoinsph.fetch_deposits  s     	}}T**H&tnGFO#(GK $GG??GU[@\@\]]: &&x5%HHHr   c                    |                                   d}i }| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     ||||          S )a"  
        fetch all withdrawals made from an account
        :see: https://coins-docs.github.io/rest-api/#withdraw-history-user_data
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   rB  r  r   )rR  r  (privateGetOpenapiWalletV1WithdrawHistoryrS  rM  rN  s           r   fetch_withdrawalszcoinsph.fetch_withdrawals1  s     	}}T**H&tnGFO#(GK $GG@@WV\A]A]^^F &&x5%HHHr   r  c                 l   |                      |d          }|                      |d          }|                      |d          }|t          |          dk     rd }|                      |d          }|                      |d          }|                     ||          }d }	|                     |dd          }	d }
d }|                      |d	          }|                      |d
          }|d}n|d}|                     |                      |d                    }|                     |d          }|                     |d          }d }|||d}|                      |d          }|dk    }i d|d|d|d|	d|                     |	          d|d|d|dd d|d|dd d|d|d|d|d|
|d |dS ) Nr   rC  
addressTagr   txIdrB  
insertTime	applyTimerD  depositOrderId
withdrawalrE   r  r/  transactionFee)r  r   rA  Internalr  txidrn  ro  	addressToaddressFromrH  tagTotagFromr)  r  r  )internalcommentr  )rC  r  rD  r  parse_transaction_statusr  r  )r   transactionr  r   rC  rH  r\  r  r  rn  r  r)  rD  rX  r  r/  r  r  rA  ra  s                       r   rG  zcoinsph.parse_transactionk  s   J k400"";	::{L99?3xx!||V44%%k6::
&&z8<<	''\;OO	**;8IJJ))+7GHH&DD'D..t/?/?X/V/VWW!!+x88"";0@AA#W55C"";	::j(
K
"
 D
 	

 Y//
 w
 w
 
 4
 3
 S
 t
 D
 f
 
  f!
" w#
$ !)
 
 
 	
r   c                 >    ddddd}|                      |||          S )Npendingr  failed)r   123r  r  s      r   rc  z coinsph.parse_transaction_status  s4    	
 
 &&999r   c                    |                      |d          }|                     ||          }|t          | j        dz             |                                  |                     |          }|d         |d}|                     |d          }|                     |                     ||                    }| 	                    ||          S )a  
        fetch the deposit address for a currency associated with self account
        :see: https://coins-docs.github.io/rest-api/#deposit-address-user_data
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: network for fetch deposit address
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        rA  Nz0 fetchDepositAddress() require network parameterr   )rB  rA  )
rC  rE  r   r   rR  r  r  'privateGetOpenapiWalletV1DepositAddressrS  parse_deposit_address)r   r  r  rI  rJ  r  rU  r  s           r   fetch_deposit_addresszcoinsph.fetch_deposit_address  s     &&vy99++K>>	TW'YYZZZ==&&TN 
 
 69--??GU[@\@\]] ))(H===r   c                     |                      |d          }|                     ||          }||                      |d          |                      |d          d |dS )NrB  rC  rT  )r  rC  rH  rA  r  )rC  rD  )r   depositAddressr  r  parsedCurrencys        r   rm  zcoinsph.parse_deposit_address  sl     %%nf==
00XFF&''	BB##NLAA"
 
 	
r   c                    d}t          |                                          }t          dt          |                    D ]i}||         }t	          ||         t                     rD|dk    r|dz  }||         }|                     ||          }|                     ||          }||z  }j|                     |          }t          |          dk    r|dz   |z   S |S )N r   &)listkeysr  r  
isinstancer  parse_array_param	urlencode)	r   queryencodedArrayParamsrv  r  key
innerArrayencodedArrayParamencodedQuerys	            r   url_encode_queryzcoinsph.url_encode_query  s    EJJLL!!q#d))$$ 	8 	8Aq'C%*d++ 866&#-&"3Z
		%--$($:$::s$K$K!"&77"~~e,,|!!#%(:::%%r   c                     |                      |          }|                    dd          }|                    dd          }|dz   |z   }|S )N[z%5B]z%5D=)jsonreplace)r   arrayr|  stringifiedArrayurlEncodedParams        r   rx  zcoinsph.parse_array_param  sU    99U+++33C??+33C??)&66r   r   GETc                    | j         d         |         }|                     ||                     |                    }|                     ||          }	|dz   |	z   }|dk    r|                                  |                                 |d<   |                     |d          }
|
"|                     | j        d          }|||d<   |                     |          }| 	                    | 
                    |          | 
                    | j                  t          j                  }|dz   |z   dz   |z   }d| j        i}n0|                     |          }t          |          d	k    r|d|z   z  }||||d
S )Nr   r"  r   rn  
recvWindow?z&signature=zX-COINS-APIKEYr   )r  r   bodyheaders)r   r  extract_paramsimplode_paramscheck_required_credentialsr  r  r   r  hmacencodesecrethashlibsha256apiKeyr  )r   r  r   r   r  r  r  r  rz  endpointr  defaultRecvWindow	signatures                r   signzcoinsph.sign  s   is#		&$"5"5d";";<<&&tV44Ci(")++---!%!2!2!4!4E+**5,??J!$($5$5dlL$Q$Q!$0*;E,'))%00E		$++e"4"4dkk$+6N6NPWP^__I)e#m3i?C $+GG ))%00E5zzQsU{"fdwOOOr   c
                    |d S |                      |dd           }
|
l|
dk    rf|
dk    r`| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           t          |          d S )Nr  200r    r   r   )rC  r   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r   r  reasonr  r   r  r  r  requestHeadersrequestBodyresponseCodefeedbacks               r   handle_errorszcoinsph.handle_errors-  s    4''&$??$<5+@+@|WZGZGZw}t+H001I4QYZZZ001I<Yabbb)))tr   )N)E__name__
__module____qualname__r   r
  r  r  r   r   rN  r   r   rY  strr   r]  r[  r   r   r  ru  r  r  r   r  r   r  r  r  r   r  r  r   r   floatr	   r  r  r
   r  r  r  r
  r  r  r  r  r  r  r  r   r:  r   r<  r8  r   r   rO  rR  r   rG  rc  rn  rm  r  rx  r  r  __classcell__)r   s   @r   r*   r*      sw       K K K K KZ MO 2 2 2 2, #% 
 
 
 
  !# 9 9 9 9 $& D D$v, D D D DL 04B < <W <7 < < < <> 02 1 13 1f 1 1 1 16L L6 LV L L L L\ :>b    s  3  Y        D 26DW[df 0L 0L# 0Lc 0LQT 0Lkoptku 0L 0L 0L 0Ld
 
 
4 
 
 
 
 6:UW #A #A3 #As #A# #A\`af\g #A #A #A #AJ -1tRV_a A Ac A AC A A A A4 9=4^bkm X XS X# XS XX[ X X X X$P P P5 P P P Pd $& , ,( , , , ,@) ) ) ) )" gksu f2 f23 f2i f2y f2RW f2`c f2 f2 f2 f2P 26b * *c *3 * * * *( /3TXac A A A3 Ac Ahlmrhs A A A A& 154VZce A A# AS APS Ajnotju A A A A4 37r * *s *C * * * *( /32 3 3 3 3 3 3&d d d5 d d d dL: : :: : :
: 
: 
:
: 
: 
:	: 	: 	:: : : 57 : : :;N : : : :4 )+  {    <
 
V 
?R 
 
 
 
( ?C2 : :S :% : : : :B *.Dt\^ 2I 2I3 2Ic 2I 2Icghsct 2I 2I 2I 2Ih -1tRV_a 8I 8Ic 8I 8IC 8Ifjkvfw 8I 8I 8I 8ItU
 U
x U
; U
 U
 U
 U
n: : : 79 > ># > > > ><
 
h 
 
 
 
$ &( & & & &$   &eBSW P P P P2	 	 	 	 	 	 	r   r*   )/ccxt.base.exchanger   ccxt.abstract.coinsphr   r  ccxt.base.typesr   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   r   r    r!   r"   r#   r$   r%   r&   ccxt.base.decimal_to_precisionr'   ccxt.base.preciser(   r*    r   r   <module>r     s   ( ' ' ' ' ' - - - - - -  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & ( ( ( ( ( ( . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 - - - - - - ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %W W W W Wh W W W W Wr   