
    eis                       d dl mZ d dlmZ d dl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, d dlm-Z- d dlm.Z. d dlm/Z/ d dl0m1Z1 d dl0m2Z2 d dl3m4Z4  G d dee          Z5dS )     )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)MarginModeAlreadySet)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)RequestTimeout)BadResponse)TRUNCATE)	TICK_SIZE)Precisec                   p    e Zd Zdef fdZd Zi fdefdZi fdee	         fdZ
di fdededefd	ZdBd
ede	defdZddi fdedededee         fdZdBdede	defdZdi fdedefdZd Zi fdedefdZdi fdefdZdBde	defdZdddi fdededededee         f
dZi fdefdZdCdZde fdZ!dBdede	de"fdZ#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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ddi fde dedefd,Z/i fd-ede0fd.Z1dddi fd-e dededee2         fd/Z3dddi fd-e dededee2         fd0Z4dBd1Z5dBd2ed3e6de2fd4Z7di fd-ed#e'd5ed6e de2f
d7Z8d8d9i ddfd:Z9d-e:d;ed<ed=ed>ed?efd@Z;i fdAZ< xZ=S )D
tokocryptoreturnc           ,      @   |                      t          t          |                                           dddg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i d]dd^dd_dd`ddaddbddcdddddeddfddgddhddiddjddkddlddmddddddddddddddndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddidddddddddgddgddgddggddddddddddddddddddiddiddidddddddddidddddddddddddddddddd|                     d          |                     d          dit
          dddddddddddddddddddi ddddddddddddddddddddddddddddēddƓddȓddʓi dd̓ddΓddГddғddԓdd֓ddؓddړddܓddޓddddddddddddddi dddddddddddddddddd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/d0i d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZddiddid[i d\dd]dd^dd_dd`ddaddbddcdddddeddfddgddhddiddjddkddldddddddddddddddddmdni dot          dpt          dqt          drt          dst          dtt          dut          dvt          dwt          dxt          dyt          dzt          d{t          d|t          d}t          d~t          dt          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          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          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          dt*          dt*          dt&          dt&          i dt          dt          dt          dt          dt          dt&          dt&          dt          dt          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          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&          d0t&          d1t&          d2t          d3t&          d4t          d5t          d6t&          d7t&          d8t&          d9t&          d:t&          t&          t$          t          t&          t&          t&          t&          t          t$          t$          t$          t$          t,          d;t          t$          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dAdddddBddddddCddd@d@ddddDddd@dd@ddddEdFdidG	d d dHd d dHdIdJ          S (K  Nr0   
TokocryptoIDFv1CORSspotTmarginswapfutureoption	addMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrderfetchAccountsfetchAllGreeksfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersemulatedfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchLongShortRatiofetchLongShortRatioHistoryfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawal)fetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdraw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/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpgrestzhttps://www.tokocrypto.comzhttps://api.binance.com/api/v3)publicbinanceprivatezhttps://tokocrypto.comz#https://www.tokocrypto.com/apidocs/z+https://www.tokocrypto.com/fees/newschedule)logoapiwwwdocfees   d        i  
   i  2   )costbyLimit(   )r   noSymbol   )pingtimedepthtrades	aggTradeshistoricalTradesklineszticker/24hrzticker/pricezticker/bookTickerexchangeInfouserDataStream)getputpostdeleter   )zopen/v1/common/timezopen/v1/common/symbolszopen/v1/market/depthzopen/v1/market/tradeszopen/v1/market/agg-tradeszopen/v1/market/klines)zopen/v1/orders/detailopen/v1/orderszopen/v1/account/spotzopen/v1/account/spot/assetzopen/v1/orders/tradesopen/v1/withdrawszopen/v1/depositszopen/v1/deposits/address)r   zopen/v1/orders/cancelzopen/v1/orders/ocor   zopen/v1/user-data-stream)r   r   )r   r   r   tradingz0.0075)	tierBased
percentagetakermakerGTCr   FULL)marketlimitETHTRXBNBBSCOMNIEOSSOL)ERC20TRC20BEP2BEP20r   r   SPLztronscan.orgr   zetherscan.ior   zbscscan.comzexplorer.binance.orgr   zbithomp.comXRPzbloks.iozstellar.expertXLMzblockchair.com/bitcoinBTCzblockchair.com/bitcoin-cashBCHzblockchair.com/ecashXECzexplorer.litecoin.netLTCzexplorer.avax.networkAVAXz
solscan.iozpolkadot.subscan.ioDOTzdashboard.internetcomputer.orgICPzexplorer.chiliz.comCHZzcardanoscan.ioADAzmainnet.theoan.comAIONzalgoexplorer.ioALGOzexplorer.ambrosus.comAMBzviewblock.io/zilliqaZILzviewblock.io/arweaveARzexplorer.ark.ioARKzatomscan.comATOMzwww.mintscan.ioCTKzexplorer.bitcoindiamond.orgBCDzbtgexplorer.comBTGzbts.aiBTSzexplorer.celo.orgCELOzexplorer.nervos.orgCKBzcerebro.cortexlabs.aiCTXCzchainz.cryptoid.infoVIAzexplorer.dcrdata.orgDCRzdigiexplorer.infoDGBzdock.subscan.ioDOCKzdogechain.infoDOGEzexplorer.elrond.comEGLDzblockscout.comETCzexplore-fetchhub.fetch.aiFETzfilfox.infoFILzfio.bloks.ioFIOzexplorer.firo.orgFIROz
neoscan.ioNEOzftmscan.comFTMzexplorer.gochain.ioGOzblock.gxb.ioGXSzhash-hash.infoHBARzwww.hiveblockexplorer.comHIVEzexplorer.helium.comHNTztracker.icon.foundationICXzwww.iostabc.comIOSTzexplorer.iota.orgIOTAziotexscan.ioIOTXzirishub.iobscan.ioIRISzkava.mintscan.ioKAVAzscope.klaytn.comKLAYzkmdexplorer.ioKMDzkusama.subscan.ioKSMzexplorer.lto.networkLTOzpolygonscan.comPOLYGONzexplorer.ont.ioONTzminaexplorer.comMINAznanolooker.comNANOzexplorer.nebulas.ioNASzexplorer.nbs.plusNBSzexplorer.nebl.ioNEBLz
nulscan.ioNULSz
nxscan.comNXSzexplorer.harmony.oneONEzexplorer.poa.networkPOAz	qtum.infoQTUMzexplorer.rsk.coRSKzwww.oasisscan.comROSEzravencoin.networkRVNzsc.tokenview.comSCzsecretnodes.comSCRTzexplorer.skycoin.comSKYzsteemscan.comSTEEMzexplorer.stacks.coSTXzwww.thetascan.ioTHETAzscan.tomochain.comTOMOzexplore.vechain.orgVETzexplorer.vite.netVITEzwww.wanscan.orgWANzwavesexplorer.comWAVESWAXPWTCXEMXVGYOYOWZECZEN)zwax.eosx.iozwaltonchain.prozchain.nem.ninjazverge-blockchain.infozexplorer.yoyow.orgzexplorer.zcha.inzexplorer.zensystem.io)r   r   MXNUGXSEKCHFVNDAEDDKKKZTHUFPENPHPUSDTRYEURNGNPLNBRL)ZARKESARSRUBAUDNOKCZKGBPUAHGHSHKDCADINRJPYNZD)!createMarketBuyOrderRequiresPricedefaultTimeInForce#hasAlreadyAuthenticatedSuccessfully"warnOnFetchOpenOrdersWithoutSymbol
recvWindowtimeDifferenceadjustForTimeDifferencenewOrderRespTypequoteOrderQtynetworksreverseNetworksimpliedNetworks
legalMoneyzSystem is under maintenance.zSystem abnormalityz/You are not authorized to execute self request.zAPI key does not existz Order would trigger immediately.z%Stop price would trigger immediately.z'Order would immediately match and take.z6Account has insufficient balance for requested action.z Rest API trading is not enabled.zYou don't have permission.zMarket is closed.z*Too many requests. Please try again later.z(This action disabled is on self account.z-1000z-1001z-1002z-1003z-1004z-1005z-1006z-1007z-1010z-1011z-1013z-1014z-1015z-1016z-1020z-1021z-1022z-1023z-1099z-1100z-1101z-1102z-1103z-1104z-1105z-1106z-1108z-1109z-1110z-1111z-1112z-1113z-1114z-1115z-1116z-1117z-1118z-1119z-1120z-1121z-1125z-1127z-1128z-1130z-1131z-1136z-2008z-2010z-2011z-2013z-2014-2015z-2016z-2018z-2019z-2020z-2021z-2022z-2023z-2024z-2025z-2026z-2027z-2028z-3000z-3001z-3002z-3003z-3004z-3005z-3006z-3007z-3008z-3009z-3010z-3011z-3012z-3013z-3014z-3015z-3016z-3017z-3018z-3019z-3020z-3021z-3022z-3023z-3024z-3025z-3026z-3027z-3028z-3029z-3036z-3037z-3038z-3041z-3042z-3043z-3044z-3045z-3999z-4001z-4002z-4003z-4004z-4005z-4006z-4007z-4008z-4010z-4011z-4012z-4013z-4014z-4015z-4016z-4017z-4018z-4019z-4021z-4022z-4023z-4024z-4025z-4026z-4027z-4028z-4029z-4030z-4031z-4032z-4033z-4034z-4035z-4036z-4037z-4038z-4039z-4040z-4041z-4042z-4043z-4044z-4045z-4046z-4047z-5001z-5002z-5003z-5004z-5005z-5006z-5007z-5008z-5009z-5010z-5011z-5012z-5013z-5021z-6001z-6003z-6004z-6005z-6006z-6007z-6008z-6009z-6011z-6012z-6013z-6014z-6015z-6016z-6017z-6018z-6019z-6020z-7001z-7002z-9000z-10017z-11008z-12014z-13000z-13001z-13002z-13003z-13004)z-13005z-13006z-13007z-21001z-21002z-21003	100001003220232103203321132073218)zhas no operation privilegeMAX_POSITION)exactbroad)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r  r   daysBack	untilDayssymbolRequired)r  triggerr  r  )r  r   r  r  r  )r  r   r  r  r  r  r  )r  r   r  daysBackCanceledr  r  r  r  r   )	sandboxrG   createOrdersrx   r   r}   r   rW   ry   )linearinverse)r7   r9   r:   )idname	countries	certifiedproversionhas
timeframesurlsr   r   precisionModeoptions
exceptionsfeatures)deep_extendsuperr0   describeparse_numberr-   r(   r   r   r   r"   r   r'   r%   r   r&   r+   r*   r    r   r)   r   r!   r#   )self	__class__s    M/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/tokocrypto.pyr  ztokocrypto.describe(   s   j$ 7 7 @ @ B B sss $s 	s
 %s %s Ts s "5s ts s $Us  s 's /s  ,U!s" 0#s s$ t%s& ('s( ')s* &u+s, (-s. "4/s0 (1s2  3s4 !%5s6 7s8  9s: &t;s< +D=s> )$?s@ &uAsB #ECsD $ZEs s sF 'GsH (IsJ "5KsL MsN &tOsP (QsR 1%SsT  UsV +EWsX &uYsZ '[s\ (]s^ #E_s` *5asb $Ucsd uesf "5gs s sh *5isj +Eksl #Emsn tosp  qsr %esst &uusv -ewsx +Jysz {s| !%}s~ !%s@ "5AsB +ECsD  EsF dGsH +EIs s sJ %eKsL !%MsN "4OsP uQsR #ESsT dUsV !$WsX "5YsZ t[s\ #E]s^  _s` 'asb $Ucsd !%esf *5gsh (isj %eks s sl )%msn )%osp uqsr usst usv Twsx tysz "5{s| #E}s~ %es@ &uAsB 'CsD $UEsF !%GsH (IsJ )%KsL "5Ms sN %),1 %$)',$"!&#(! es s sj  $ ">#C#?  0<E " !" !*+#qC8dTVZZ^`bYc8d!e!e"#%&,-"#01r'B'B12(B(B67Q-G-G(*  )! )! )!) 2 /02301125612 
 23*+016712-.,-45	 	 +,12./-.45  I7 7r !%"&!..x88!..x88	  ' 6:&+7<6:&"#+0$#% % "'""!""   ]$"G]$"G]$ "5]$ +F	]$
 "5]$ ]$ %e]$ -e]$ 25]$ +E]$ ,U]$ ,V]$ !%]$ *5]$ 5e]$  *5!]$" %e#]$ ]$$ )&%]$& &v']$( ,U)]$* +E+]$, +D-]$. &u/]$0 #F1]$2 &u3]$4 255]$6 &u7]$8 e9]$: (;]$< *5=]$> ,V?]$@ +EA]$B +EC]$D (E]$ ]$ ]$F &vG]$H %fI]$J *6K]$L %eM]$N 0O]$P "5Q]$R #ES]$T (U]$V !%W]$X "5Y]$Z *4[]$\ #E]]$^ %f_]$` 0a]$b *5c]$d .ue]$f &vg]$ ]$ ]$h (i]$j #Fk]$l )&m]$n 'o]$p 'q]$r %es]$t (u]$v +Ew]$x &yy]$z &u{]$| '}]$~ %f]$@ *5A]$B (C]$D 'E]$F !&G]$H !%I]$ ]$ ]$J +EK]$L +EM]$N  O]$P &uQ]$R (S]$T (U]$V 'W]$X &vY]$Z +E[]$\ $W]]$^ )%_]$` 'a]$b )&c]$d *5e]$f (g]$h &ui]$j (k]$ ]$l $*',',-2*1(--2y]$ ]$ ]$~ $U+#U+$ $!4!4! 4! 4	!
 4! 4! 4! 4! 4! 4! 4! 4! 4! 4! 4!  4!!" 4#!$  A! ! !w] ]@Z2MZ(-Z FGWZ -.A	Z
 78PZ <=UZ >?WZ MN_Z 78LZ 12BZ ()=Z A.Z ?@PZ 1Z 1Z  0!Z" .#Z Z$ ^%Z& -'Z( [)Z* ^+Z, [-Z. -/Z0 \1Z2 \3Z4 .5Z6 17Z8 Z9Z: \;Z< 0=Z> Z?Z@ 0AZB ZCZD ZEZ Z ZF ZGZH ZIZJ ZKZL ZMZN ZOZP ZQZR 0SZT ZUZV ZWZX \YZZ Z[Z\ Z]Z^ Z_Z` ZaZb ZcZd ZeZf ZgZ Z Zh ZiZj YkZl 0mZn ZoZp ZqZr ZsZt ZuZv ZwZx 0yZz ]{Z| ]}Z~ ]Z@ 0AZB 0CZD ZEZF .GZH .IZ Z ZJ -KZL 5MZN \OZP .QZR .SZT \UZV \WZX \YZZ .[Z\ ]]Z^ 0_Z` YaZb ZcZd ]eZf .gZh .iZj ]kZ Z Zl .mZn ZoZp ]qZr ZsZt ]uZv ZwZx -yZz ]{Z| Z}Z~ ]Z@ -AZB -CZD .EZF ZGZH -IZJ ZKZL ]MZ Z ZN ZOZP ZQZR YSZT YUZV ]WZX -YZZ ][Z\ Z]Z^ ._Z` ZaZb ZcZd ^eZf ]gZh ]iZj ZkZl ZmZn ZoZ Z Zp 0qZr .sZt ZuZv ZwZx ZyZz Z{Z| Z}Z~ ZZ@ 0AZB -CZD ]EZF -GZH -IZJ YKZL YMZN ZOZP ZQZ Z ZR ]SZT .UZV .WZX .YZZ ][Z\ Z]Z^ Z_Z` ]aZb ]cZd ]eZf ZgZh ]iZj -kZl ZmZn ]oZp ]qZr ZsZ Z Zt ZuZv ]wZx ]yZz Z{Z| Z}Z~ ]Z@ 0AZB ZCZD ZEZF .GZH .IZJ ZKZL .MZN ZOZP ZQZR .SZT ZUZ Z ZV ]WZX ZYZZ ][Z\ .]Z^ Z_Z` ZaZb ZcZd ]eZf \gZh ZiZj ZkZl ZmZn .oZp ZqZr .sZt ]uZv ZwZ Z Zx ZyZz Z{Z| Z}Z~ ZZ@ 0AZB ZCZD ZEZF ZGZH .IZJ jKZL /MZN /OZP jQZR jSZT jUZV jWZX jYZ ZZ )*1(((!+-(((()sZ Z Zx 3C$0 y` `F  %&+(,,1,0).+06:#'#'"&#(	( ( #($)$)+/26/3#')$ $, %)&+!%$*%+*.& & ',#($)*/	# # ',!%#($)*.( ( ',!%$*%+#($)*.$ $ ',!%$*,-%+#($)*.	* 	*  #AC CJ ## 
 ## SM Myj
E
 j
E
 j
 j
 j
	    c                 F    |                                  | j        d         z
  S )Nrk  )millisecondsr  )r  s    r  nonceztokocrypto.nonce  s!      ""T\2B%CCCr  c                 X    |                      |          }|                     |d          S )aR  

        https://www.tokocrypto.com/apidocs/#check-server-time

        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        	timestamp)publicGetOpenV1CommonTimesafe_integer)r  paramsresponses      r  
fetch_timeztokocrypto.fetch_time  s/     11&99   ;777r  c                 	   |                      |          }| j        d         r|                                  |                     |di           }|                     |dg           }g }t	          dt          |                    D ]A}||         }|                     |d          }|                     |d          }	|                     |d          }
|                     |d          }|                     |d          }|                     |          }|                     |	          }|                     |          }|d	z   |z   }|                     |d
g           }| 	                    |d          }|                     |d          }|dk    }|                     |dg           }t	          dt          |                    D ]}||         dk    rd} n| 
                    |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&                              |                     |                     |                     |d'                              d(d#d#d)d#d#d)d#d#d)d#d#d)d*d#|d+}d,|v r}|                     |d,i           }|                     |d-          |d.         d/<   |                     |d0          |                     |d1          d)|d2         d/<   |d-         |d.         d/<   d3|v rl|                     |d3i           }|                     |d4          |d.         d5<   |                     |d6          |                     |d7          d)|d2         d5<   d8|v rM|                     |d8i           }|                     |d6          |                     |d7          d)|d2         d9<   d:|v r=|                     |d:i           }|                     |d;d<          |d2         d=         d><   |                    |           C|S )?a(  

        https://www.tokocrypto.com/apidocs/#get-all-supported-trading-symbol

        retrieves data on all markets for tokocrypto
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        rl  datalistr   	baseAsset
quoteAssetsymbolmarginAsset/filters
filterTypespotTradingEnable1permissionsTRD_GRP_003FisMarginTradingAllowedr  lowercaseIdbasequotesettlebaseIdquoteIdsettleIdtyper7   Tr8   r9   r:   deliveryr;   activeNquantityPrecisionpricePrecisionbaseAssetPrecisionquotePrecision)amountpricer  r  )minmax)r  r  r  r   )contractr  r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfoPRICE_FILTERtickSizer  r  minPricemaxPricer  LOT_SIZEstepSizer  minQtymaxQtyMARKET_LOT_SIZEr   MIN_NOTIONALminNotionalnotionalr   r  )publicGetOpenV1CommonSymbolsr  load_time_difference
safe_valuerangelensafe_stringsafe_string_lowersafe_currency_codeindex_by	safe_boolr  parse_precisionsafe_numbersafe_number_2append)r  r  r  r  r  resultir   r  r  r  r  r  r  r  r  r  r  filtersByTypestatusr  r  jr  entryfilters                             r  fetch_marketsztokocrypto.fetch_markets  s    44V<<J <12 	(%%'''x44tVR00q#d))$$ f	! f	!A!WF%%fk::F&&v|<<G!!&(33B00BBK''>>H**622D++G44E,,X66FCZ%'Foofi<<G MM'<@@M%%f.ABBFmF//&-DDK1c+..//  q>]22"FE 3 &*^^F<TV[%\%\"4b4{4 &4 	4
 4 &4 &4 74 H4 4 4 04 4 %4 E4  %!4" &#4$ " $"&""//0D0DTEUEUV\^qErEr0s0stt!..t/C/CDDTDTU[]mDnDn/o/opp --d.B.B4CSCSTZ\pCqCq.r.rss!..t/C/CDDTDTU[]mDnDn/o/opp	   $#! !
  $# 
  $# 
  $#  $  g4 4 4Ej ..KK.2.>.>vz.R.Rk"7+  ++FJ??++FJ??, ,h( /5Z.@k"7+]**
BGG/3/?/?
/S/Sk"8,++FH==++FH==- -h) !M118I2NN++FH==++FH==- -h) ..KK151C1CFM[e1f1fh'.MM%    r  Nr  r   c                 &   |                                   |                     |          }i }|||d<   d}|d         dk    r>|d         |d         z   |d<   |                     |                     ||                    }n4|d         |d<   |                     |                     ||                    }|                     |d	|          }|                     |d
d          }|                     |||          }	|                     |d          |	d<   |	S )a*  

        https://www.tokocrypto.com/apidocs/#order-book

        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        Nr   r  USDTr  r  r  r  r  Tr  lastUpdateIdr  )	load_marketsr   binanceGetDepthextendpublicGetOpenV1MarketDepthr  safe_integer_2parse_order_bookr  )
r  r  r   r  r   requestr  r  r  	orderbooks
             r  fetch_order_bookztokocrypto.fetch_order_book  s     	V$$$GG'?f$$ &x 06)3D DGH++DKK,H,HIIHH &tGH66t{{7F7S7STTH< x::''#{CC	))$	BB	!..t^DD	'r  trader   c                 x   |                      |dd          }|                     |dd          }|                     |dd          }|                     |dd          }|                     |d	          }|                     ||          }|                     |d
d          }	|                     |dd|	          }	d }
|                     |d          }|                     |dd          }d }|	|rdnd}
d}n+d|v r|                     |d          }
nd|v r|d         rdnd}
d }d|v r@|                     |d          |                     |                     |d                    d}d|v r|d         rdnd}d|v r|d         rdnd}|                     |||                     |          ||	|d |
|||||d|          S )Nr  r   pr  qqtyquoteQtybaseQtyr  tar  tradeIdorderIdmisBuyerMakersellbuyr   sideisBuyer
commissioncommissionAsset)r   currencyisMakerr   )r  r  datetimer  r  orderr  r"  takerOrMakerr  r  r   fee)	r  safe_string_2r  safe_symbolsafe_value_2r  r  
safe_tradeiso8601)r  r  r   r  r  r  r   marketIdr  r  r"  r  
buyerMakerr*  r+  s                  r  parse_tradeztokocrypto.parse_trade  s0   | ''sF;;	""5#w77##E366!!%Y??##E844!!(F33sC00tY;;""5)44&&uc>BB
 !'266UD"LLu__))%88DDE!! %i 0<uuf5  ((== 33D4D4DUL]4^4^__ C &+I&6C77GLe&+GnA77'L"Y//( 
  
   	r  sincec                    |                                   |                     |          }d|                     |          i}|d         dk    rv|||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S |||d<   d}
|                     | j	        d	|
          }d}|d
k    rJ|H||d<   | 
                    |d          |d<   |                     |                     ||                    }n)|                     |                     ||                    }|                     ||||          S )ah  

        https://www.tokocrypto.com/apidocs/#recent-trades-list
        https://www.tokocrypto.com/apidocs/#compressedaggregate-trades-list

        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        r  r  r  Nr   r  r  binanceGetTradesfetchTradesMethodbinanceGetAggTrades	startTimei6 endTime)r
  r   get_market_id_by_typepublicGetOpenV1MarketTradesr  	safe_dict	safe_listparse_tradesr  r  sumr8  r6  )r  r  r4  r   r  r   r  responseInnerr  r  defaultMethodmethodr  s                r  fetch_tradesztokocrypto.fetch_tradesN  s    	V$$d0088
 '?f$$ #(  <<T[[RX=Y=YZZM( >>-<<D>>$33D$$T65%@@@$GG*!!$,0C]SS+++%2C#(GK  "&%!9!9GI//GV0L0LMMHH,,T[[&-I-IJJHN   65%@@@r  tickerc                    |                      |d          }|                     |d          }|                     ||          }|                     |d          }d|v }d }d }	|r-|                     |d          }|                     |d          }	n,|                     |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"|          S )#N	closeTimer  	lastPrice
baseVolumevolumequoteVolumer  r(  high	highPricelowlowPricebidbidPrice	bidVolumebidQtyaskaskPrice	askVolumeaskQtyvwapweightedAvgPriceopen	openPricecloselastpreviousCloseprevClosePricechangepriceChanger   priceChangePercentaverage)rI  rK  r  )r  r  r-  safe_tickerr0  )
r  rE  r   r  r1  r  r]  isCoinmrI  rK  s
             r  parse_tickerztokocrypto.parse_ticker  s   ^ %%fk::	##FH55!!(F33446)
 	B))&,??J**68<<KK))&(;;J**6=AAK !
f!
!
 Y//!
 D$$V[99	!

 4##FJ77!
 4##FJ77!
 ))&(;;!
 4##FJ77!
 ))&(;;!
 D$$V-?@@!
 D$$V[99!
 T!
 D!
 T--f6FGG!
 d&&v}==!
  $**63GHH!!
" t#!
$ %&)!
 !
 !
* +  	r  symbolsc                     |                                   |                     |          }|                     ||          S )a-  

        https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics

        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :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>`
        )r
  binanceGetTicker24hrparse_tickersr  rg  r  r  s       r  fetch_tickersztokocrypto.fetch_tickers  s?     	,,V44!!(G444r  c                 L    |d         dk    r|d         |d         z   S |d         S )Nr  r  r  r  r   )r  r   s     r  r;  z tokocrypto.get_market_id_by_type  s0    '?f$$(#fY&777d|r  c                 |   |                                   |                     |          }d|d         |d         z   i}|                     |                     ||                    }t	          |t
                    r-|                     |di           }|                     ||          S |                     ||          S )a  

        https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics

        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        r  r  r  r   )r
  r   ri  r  
isinstancer  r=  rf  )r  r  r  r   r  r  firstTickers          r  fetch_tickerztokocrypto.fetch_ticker  s     	V$$fX&	)::
 ,,T[[&-I-IJJh%% 	:..1b99K$$[&999  6222r  c                     |                                   |                     |          }|                     ||          S )a  

        https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker

        fetches the bid and ask price and volume for multiple markets
        :param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets 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>`
        )r
  binanceGetTickerBookTickerrj  rk  s       r  fetch_bids_asksztokocrypto.fetch_bids_asks.  s?     	226::!!(G444r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r   r         r   )r  r  )r  ohlcvr   s      r  parse_ohlcvztokocrypto.parse_ohlcv<  s    H eQ''UA&&UA&&UA&&UA&&UA&&
 	
r  r   	timeframec                    |                                   |                     |          }d}d}|                     |d          }	|                     |d          }
|                     |ddg          }||nt          ||          }|                     | j        ||          |d}|	dk    r|d         |d	<   n|                     |          |d
<   |||d<   |
|
|d<   d}|d         dk    r*|                     | 	                    ||                    }n)| 
                    | 	                    ||                    }|                     |d|          }|                     |||||          S )aO  

        https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :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 str [params.price]: "mark" or "index" for mark price and index price candles
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   i  r  untilN)intervalr   indexr  pairr  r9  r:  r  r  r  )r
  r   r  r  omitr  r  r;  binanceGetKlinesr  publicGetOpenV1MarketKlinesr>  parse_ohlcvs)r  r  r{  r4  r   r  r   defaultLimitmaxLimitr  r}  r  r  r  s                 r  fetch_ohlcvztokocrypto.fetch_ohlcvh  s    	V$$   11!!&'226GW#566!&S5I5I(()YOO
 
 G$TlGFOO $ : :6 B BGH#(GK !&GI'?f$$,,T[[&-I-IJJHH77GV8T8TUUH ~~h99  vy%GGGr  c                 |   |                                   |                     | j        ddd          }|                     |d|          }|                     | j        dd          }|                     |d|          }i }|                     |                     ||                    }|                     |||          S )a  

        https://www.tokocrypto.com/apidocs/#account-information-signed

        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'future', 'delivery', 'savings', 'funding', or 'spot'
        :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
        :param str[]|None [params.symbols]: unified market symbols, only used in isolated margin mode
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        rP   defaultTyper7   r  r  defaultMarginMode)r
  r,  r  r  r  privateGetOpenV1AccountSpotr  parse_balance_custom)r  r  r  r  r  r  r  r  s           r  fetch_balanceztokocrypto.fetch_balance  s     	((~}V\]]<< ..t|\K^__++FLBSTT
33DKK4P4PQQ2 ((4DDDr  c                 "   |                      |d          }|||                     |          d}|                     |di           }|                     |dg           }t          dt	          |                    D ]}||         }	|                     |	d          }
|                     |
          }|                                 }|                     |	d          |d<   |                     |	d          |d	<   |||<   |                     |          S )
N
updateTime)r  r  r(  r  accountAssetsr   assetfreelockedused)	r  r0  r  r  r  r  r  accountsafe_balance)r  r  r  r  r  r  r  balancesr  balance
currencyIdcoder  s                r  r  ztokocrypto.parse_balance_custom  s   %%h==	"Y//
 

 x44??4"==q#h--(( 	# 	#AqkG))'7;;J**:66DllnnG"..w??GFO"..wAAGFO"F4LL  (((r  r  c                 T    dddddddddddddddd}|                      |||          S )NrZ  closedcanceled	cancelingrejectedexpired)z-20r  23456NEWPARTIALLY_FILLEDFILLEDCANCELEDPENDING_CANCELREJECTEDEXPIREDr  r  r  statusess      r  parse_order_statusztokocrypto.parse_order_status  sU     &")" 
 
" &&999r  r)  c                    |                      |                     |d                    }|                     |d          }|                     ||          }|                     |dd          }|                     |d          }|                     |d          }|                     |dd          }	|                     |d	          }
|                     |g d
          }|                     |d          }|                     |                     |d                    }|                     |d          }|dk    rd}n|dk    rd}|                     |dg           }|                     |dd          }|                     |d          }|dk    rd}|dk    p|dk    }| 	                    i 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  executedQtyr  
createTimeavgPricer  executedPriceorigQty)cummulativeQuoteQtycumQuoteexecutedQuoteQtycumBaser  r  r"  r!  r  r   fillsclientOrderIdclientIdr  GTXr  limit_makerr  r  r  r(  lastTradeTimestamppostOnly
reduceOnlyr  	stopPricer  r   rc  )filled	remainingr  r+  r   )r  r  r-  r  r,  safe_string_nparse_order_typer  r  
safe_orderr0  r  	omit_zero)r  r)  r   r  r1  r  r  r  rc  r  r  r   r  r  r"  r  r  r  r  s                      r  parse_orderztokocrypto.parse_order  s   F (()9)9%)J)JKK##E844!!(F33!!%<<%%e\::	""5*55""5'?CC!!%33 !!%)k)k)klleY//$$T%;%;E6%J%JKK%%eV443;;DDS[[Dw33**5/:NN&&um<<%KM)C{d/B  
E 
" 
 ] 
 	 

 Y// 
 !$ 
 f 
 D 
 ; 
  
 $//%>> 
 D 
 U 
 D--dnnT=M=MeU`=a=a.b.bcc 
 f 
  D! 
" w# 
$ - 
  
  
. /  	r  c                 >    ddddd}|                      |||          S )Nr   r   )r  r  r  7r  r  s      r  r  ztokocrypto.parse_order_type  s4    	
 
 &&999r  r  r"  r  r  c                 ,   |                                   |                     |          }|                     |dd          }|                     |dd          }	|	rd}|                     |ddg          }|                                }
|
}|                     |dd          }|)|                     |ddg          }|d	k    rd
}n|dk    rd}|                     |d         d          }|                     ||          sL|
|k    r#t          | j
        dz   |z   dz   |z   dz             t          | j
        dz   |z   dz   |z   dz             dddddddd}|d         dz   |d         z   |                     ||          d}|d k    rd!|d"<   n|d#k    rd|d"<   |P|                     | j        d$          }|2|                     |d%          }|||                                 z   |d<   n||d<   d}d}d}|d	k    r|d k    r|d&         d'         }d}d(}|                     |d)d*d(          \  }}|                     |d+d,          }|                     |d+d,g          }||}n]|rY|t          | j
        d-z             |                     |          }|                     |          }t#          j        ||          }n|}|                     |t(          || j                  |d,<   nNd(}nK|dk    rd(}d(}n@|d
k    s|d.k    rd(}d(}|d/         s|d0         rd(}n|dk    s|d1k    rd(}d(}d(}n
|dk    rd(}d(}|r|                     ||          |d2<   |r8|t          | j
        d3z   |z   d4z             |                     ||          |d'<   |r8|t          | j
        d5z   |z   d4z             |                     ||          |d<   |                     |                     ||                    }|                     |d6i           }|                     ||          S )7a~  
        create a trade order

        https://www.tokocrypto.com/apidocs/#new-order--signed

        :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 float [params.triggerPrice]: the price at which a trigger order would be triggered
        :param float [params.cost]: for spot market buy orders, the quote quantity that can be used alternative for the amount
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r  r  r  FLIMIT_MAKERr  r  NMARKET	STOP_LOSSLIMITSTOP_LOSS_LIMITr  
orderTypesz+ triggerPrice parameter is not allowed for  z ordersz# is not a valid order type for the z marketr   r   rw  rx  r         )r  r  r  r  TAKE_PROFITTAKE_PROFIT_LIMITr  r  _r  )r  r  r!  r   r"  r   broker
marketTyper  r  TrG   rf  r   rn  a	   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(quote quantity) in the amount argumentr  r  r  r  quantityz/ createOrder() requires a price argument for a z orderz9 createOrder() requires a triggerPrice extra param for a r  )r
  r   r,  r  r  upperr.  r  in_arrayr    r  r  r  uuid22handle_option_and_paramsr  number_to_stringr.   
string_muldecimal_to_precisionr,   r  amount_to_precisionprice_to_precisionprivatePostOpenV1Ordersr  r=  r  )r  r  r  r"  r  r  r  r   r  r  initialUppercaseTypeuppercaseTyper  validOrderTypesreverseOrderTypeMappingr  r  brokerIdpriceIsRequiredtriggerPriceIsRequiredquantityIsRequiredr  quoteAmountrf  r   amountStringpriceStringr  rawOrders                                r  create_orderztokocrypto.create_order  sC     	V$$**6?JOO>>&*e<< 	! D6J#@AA#zz||,((MM#YYv'DEEF(( +')) 1//&.,GG}}]O<< 	v#}44"47-Z#Z]c#cfi#ilp#ps|#|}}}"47S=4#7:_#_bh#hkt#tuuu !")
 )
 X&,vi/@@$$%<mLL
 
 5==GFOOV^^GFO __T\8<<F!++FLAA'*2T[[]]*BGJ'"/GJ!&" H$$u}}";/8	"481<@<Y<YZ`bo  rU  W[  =\  =\916))&&/JJ6FO+DEE#"&KK6 )}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S"(K+/+D+D[RZ\egkgy+z+z((%)""g%%"O!%{**0N0N%)"!%h '6)#4 '"&000mGZ6Z6Z!%%)""OOm++"O!% 	K"&":":66"J"JGJ 	F}"47-^#^ae#ehp#pqqq#66vuEEGG! 	U#"47-h#hko#orz#z{{{'+'>'>v|'T'T$//GV0L0LMM: >>(FB77&111r  r  c                    d|i}|                      |                     ||                    }|                     |di           }|                     |dg           }|                     |di           }|                     |          S )a  

        https://www.tokocrypto.com/apidocs/#query-order-signed

        fetches information on an order made by the user
        :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>`
        r  r  r  r   )privateGetOpenV1Ordersr  r  r=  r  )	r  r  r  r  r  r  r  r  r  s	            r  fetch_orderztokocrypto.fetch_order.  s     r
 ..t{{7F/K/KLL> x44tVR00>>$2..)))r  c                    |t          | j        dz             |                                  |                     |          }d|d         i}|||d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S )	a+  

        https://www.tokocrypto.com/apidocs/#all-orders-signed

        fetches information on multiple 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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentr  r  r9  r   r  r  )	r   r  r
  r   r  r  r  r>  parse_orders)
r  r  r4  r   r  r   r  r  r  orderss
             r  fetch_ordersztokocrypto.fetch_orders`  s     >#DG.Y$YZZZV$$fTl	
 #(GK $GG..t{{7F/K/KLLD x44fb11  >>>r  c           	      b    ddi}|                      ||||                     ||                    S )a  

        https://www.tokocrypto.com/apidocs/#all-orders-signed

        fetch all unfilled currently open orders
        :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>`
        r  r   r  r  r  r  r4  r   r  r  s         r  fetch_open_ordersztokocrypto.fetch_open_orders  5        t{{7F7S7STTTr  c           	      b    ddi}|                      ||||                     ||                    S )a2  

        https://www.tokocrypto.com/apidocs/#all-orders-signed

        fetches information on multiple 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
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        r  r   r  r  s         r  fetch_closed_ordersztokocrypto.fetch_closed_orders  r   r  c                     d|i}|                      |                     ||                    }|                     |di           }|                     |          S )a  

        https://www.tokocrypto.com/apidocs/#cancel-order-signed

        cancels an open order
        :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>`
        r  r  )privatePostOpenV1OrdersCancelr  r=  r  )r  r  r  r  r  r  r  s          r  cancel_orderztokocrypto.cancel_order  s^     r
 55dkk'66R6RSS8 >>(FB77)))r  c                     |t          | j        dz             |                                  |                     |          }d|d         i}|                     |dd          }|||d<   |||d<   |                     |ddg          }|||d<   |                     |                     ||                    }|                     |d	i           }	| 	                    |	d
g           }
| 
                    |
|||          S )a  

        https://www.tokocrypto.com/apidocs/#account-trade-list-signed

        fetch all trades made by the user
        :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
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr  r  r}  r:  r9  r   r  r  )r   r  r
  r   r  r  privateGetOpenV1OrdersTradesr  r  r>  r?  )r  r  r4  r   r  r   r  r:  r  r  r   s              r  fetch_my_tradesztokocrypto.fetch_my_trades  s    >#DG.[$[\\\V$$fTl
 %%fgyAA#(GK !(GIYYv	7';<<F$GG44T[[&5Q5QRR4 x44fb11  >>>r  r  c                    |                                   |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|||d<   |                     |d          }|                     |                     ||                    }|                     |di           }|                     |d          }	|                     |dd	          }
t          |
          d
k    rd}
| 
                    |	           |||                     |d          |	|
dS )a|  
        fetch the deposit address for a currency associated with self account

        https://www.tokocrypto.com/apidocs/#deposit-address-signed

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        r  r  ro  networkNr  address
addressTag r   )r  r&  r
  r  tag)r
  r&  r  r  safe_string_upperr  r  privateGetOpenV1DepositsAddressr  r  check_address)r  r  r  r&  r  ro  r
  r  r  r  r  s              r  fetch_deposit_addressz tokocrypto.fetch_deposit_address(  s[    	==&&Xd^
 ??4<R@@((;;""8Wg>>!(GIYYvy11F 77GV8T8TUU  x44""433t\266s88q==C7###''i88
 
 	
r  c                    |                                   d}i }|                     |d          }| |                     |          }|d         |d<   |2||d<   |                     |d          }|t	          ||          }||d<   |||d<   |                     |                     ||                    }	|                     |	d	i           }
|                     |
d
g           }| 	                    ||||          S )aY  

        https://www.tokocrypto.com/apidocs/#deposit-history-signed

        fetch all deposits made to an account
        :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 deposits for
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr}  r  coinr9      X r:  r   r  r  )
r
  r  r&  r@  r  privateGetOpenV1Depositsr  r  r>  parse_transactions)r  r  r4  r   r  r&  r  r}  r:  r  r  depositss               r  fetch_depositsztokocrypto.fetch_deposits^  s    	!!&'22}}T**H&tnGFO#(GK hhuj11G gu--!(GI$GG00Wf1M1MNN0 x44>>$33&&x5%HHHr  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |d          |d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |d	g           }	|                     |	|||          S )
a  

        https://www.tokocrypto.com/apidocs/#withdraw-signed

        fetch all withdrawals made from an account
        :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  r  r9  r  r:  r   r  r  )r
  r&  r@  privateGetOpenV1Withdrawsr  r  r>  r  )
r  r  r4  r   r  r  r&  r  r  withdrawalss
             r  fetch_withdrawalsztokocrypto.fetch_withdrawals  s     	}}T**H&tnGFO#(GK !%%!<!<GI$GG11$++gv2N2NOO4 x44nnT6266&&{HeUKKKr  c           	      ~    dddddddddddd}|                      ||i           }|                     |||          S )Npendingok)r  r  r  failed)r  r  r  r  r  r  10)deposit
withdrawal)r  r  )r  r  r  statusesByTyper  s        r   parse_transaction_status_by_typez+tokocrypto.parse_transaction_status_by_type  sp      
   
  
 ??>4<<&&999r  transactionr&  c                    |                      |d          }|                      |d          }|t          |          dk     rd }|                      |d          }|#|                    d          dk    r
|dd          }|                     |dd	          }|                     ||          }d }|                     |d
          }	|                     |dd          }
|                      |d          }||	|
d}|	}n|	|
d}|
}|                     |dd          }d d d d}|
||d<   ||d<   |                     |d          }d}|d}|                      |d          }|/|                     |di           }|                      |d          }d}i d|d|d|d|d|d|                      |d          d| 	                    |d          d| 
                    |                      |d          |          d|d |                     |          d|d!d d"|d#|d$d d%|d&|                     |d'd(          d ||d)S )*Nr  r  r   txIdzInternal transfer r      r  fiatCurrency
insertTimer  r  r  r#  r$  transactionFeetotalFee)r&  r   rater&  r   transferTypeFTr  r  
withdrawIdr  txidr
  r  r  r(  addressFrom	addressTor  tagFromtagToupdatedsuccessTimer  )commentinternalr+  )r  r  findr,  r  r  r  r  r  r  r&  r0  )r  r'  r&  r  r  r2  r  r  r  r,  r  r  feeCostr+  internalRawr:  r  r  s                     r  parse_transactionztokocrypto.parse_transaction  s+   Z "";	::{L99?3xx!||V44499-A#B#Ba#G#G9D''V^LL
&&z8<<	&&{LAA
((lKPP
V44<&Z-? &		$:+A#&	$$[2BJOO
 

 "C
O!CK''^DD"Hk400:??;;;D!!$55BD
K
"
 D
 D	

 
 t''Y??
 d&&{H==
 d;;D<L<L[Zb<c<ceijj
 
 Y//
 w
 4
 
 3
 t
  S!
" t**;|TT#
$  )
 
 
 	
r  r  r  c                    |                      ||          \  }}|                                  |                     |           |                     |          }|d         ||                     |          d}|||d<   |                     |          \  }}	|                     |          }
|
|
                                |d<   |                     | 	                    ||	                    }| 
                    ||          S )a  

        https://www.tokocrypto.com/apidocs/#withdraw-signed

        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :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  r  r  Nr  r
  )handle_withdraw_tag_and_paramsr
  r  r&  r  handle_network_code_and_paramsnetwork_code_to_idr  privatePostOpenV1Withdrawsr  r>  )r  r  r  r  r  r  r&  r  networkCodequery	networkIdr  s               r  r   ztokocrypto.withdrawK	  s    99#vFFV7###==&&d^ ++F33
 
 ?$'GL!!@@HHU++K88	 !*!2!2GI224;;w3N3NOO %%h999r  r   GETc                 :   || j         d         d         vrt          | j        dz   |z   dz             | j         d         d         |         }|d|z   z  }|dk    r|dz  }|dk    p|d	k    }|rE| j        r'| j        d
d}|dk    r|                     |          }nt          | j        dz             |dk    s7|dk    r|dk    s+|dk    s%|dk    r|dk    s|dk    s|dk    s|dk    s|dk    r|                                  d }	|                     | j        d          }
| 	                    d| 
                                i|          }|
|
|d<   |                     |d          }|||d<   |dk    r|dk    r|                     |          }	ni|dk    s8|                    d          dk    s|dk    s|                    d          dk    r|                     |          }	n|                     |          }	|                     |                     |	          |                     | j                  t"          j                  }|	d|z   z  }	d | j        i}|dk    s|d!k    s|dk    r	|d"|	z   z  }n%|	}d
|d#<   n|r|d"|                     |          z   z  }||||d$S )%Nr   r   z) does not have a testnet/sandbox URL for z
 endpointsr  wapiz.htmlr   	listenKeyz!application/x-www-form-urlencoded)X-MBX-APIKEYContent-TyperG  z5 userDataStream endpoint requires `apiKey` credentialr   sapizsystem/statussapiV3systemStatusdapiPrivatedapiPrivateV2fapiPrivatefapiPrivateV2rj  r  z
asset/dustbatchOrderszsub-accountr   zcapital/withdraw/applystakingz&signature=rK  DELETE?rL  )urlrC  bodyheaders)r  r$   r  apiKey	urlencoder   check_required_credentialsr  r  r  r  urlencode_with_array_repeatr;  	rawencodehmacencodesecrethashlibsha256)r  pathr   rC  r  rZ  rY  rX  r   rE  defaultRecvWindowextendedParamsrj  	signatures                 r  signztokocrypto.signw	  s   ty'///tw)TTWZZ]iijjjiv&s+sTz&==7NC"22L8K )	4{ 	m %)K$G  U??>>&11D)$'4k*klllYC6MMdo6M6MSVZbSbSbhkouhuhuz~  CQ  {Q  {Q  WZ  ^k  Wk  Wk  qt  xG  qG  qG  MP  Ta  Ma  Ma  gj  n}  g}  g}++---E $ 1 1$, M M![[TZZ\\* N !,/@|,**6<@@J%/9|,vDL$8$888HH-''TYY}-E-E-J-JPTXpPpPpvzvv  AJ  wK  wK  OP  wP  wP~66~66		$++e"4"4dkk$+6N6NPWP^__I')33EG %Vx%7%7SF]]sU{"*M'' 4sT^^F3333fdwOOOr  reasonrX  rC  rZ  rY  c
                    |dk    s|dk    r3t          | j        dz   t          |          z   dz   |z   dz   |z             |dk    r|                    d          dk    rt	          | j        dz   |z             |                    d          dk    rt	          | j        d	z   |z             |                    d
          dk    rt	          | j        dz   |z             |d S |                     |dd          }
|
sM|                     |d          }d }|3	 t          j        |          }n# t          $ r}d }Y d }~nd }~ww xY w||}|                     |d          }|Z| 
                    | j        d         || j        dz   |z              |                     | j        d         || j        dz   |z              |                     |d          }||dk    st          j        |d          rd S |dk    r'| j        d         rt          | j        dz   |z             | j        dz   |z   }|dk    rt!          |          | 
                    | j        d         ||           t#          |          |
st#          | j        dz   |z             d S )Ni  i  r  i  zPrice * QTY is zero or lessr   z- order cost = amount * price is zero or less r  z5 order amount should be evenly divisible by lot size r  z order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use self.price_to_precision(symbol, amount) successTmsgr|  r}  r  200r  rs  rh  zNo need to change margin type.)r%   r  strr;  r    r  r  jsonloads	Exceptionthrow_exactly_matched_exceptionr  throw_broadly_matched_exceptionr.   string_equalsr  r   r   )r  r  rj  rX  rC  rZ  rY  r  requestHeadersrequestBodyrl  messageInnerparsedMessageemessageerrorfeedbacks                    r  handle_errorsztokocrypto.handle_errors	  s   CKKTS[[ 3T!:S!@6!IC!ORV!VWWW 3;;yy6771<<"47-\#\_c#cdddyy$$))"47-d#dgk#klllyy((A--"47  .a  $a  dh  $h  i  i  i4 ..9d;; 
	-++He<<L M')$(J|$<$<MM  ) ) )$(MMMMMM) !,,H""8U33001I7TXT[^aTadkTklll001I7TXT[^aTadkTklll  622 7#8#D#Dt   dl3X&Y $TWs]T%9:::w}t+H::: +8444001I5RZ[[[))) 	6# 4555ts   D, ,
E6D==Ec                 <   d|v rd|vr|d         S d|v rd|vr|d         S d|v rd|vr|d         S d|v rRd|v rN|d         }|d         }t          d	t          |                    D ] }||         }	||	d	         k    r
|	d
         c S !|                     |dd
          S )NnoCoinr  r   r  noPoolIdpoolIdr   r   r   r   r   )r  r  r  )
r  r   rC  re  r  configr   r   r  r  s
             r  calculate_rate_limiter_costz&tokocrypto.calculate_rate_limiter_cost	  s    6)9)9(##F""X-?-?*%%F""X-?-?*%%6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %  333r  )N)NN)>__name__
__module____qualname__r   r  r  r	   r  r   r
   r  ro  r   r  dictr   r3  rD  r   rf  r   r   rl  r;  rr  ru  r  rz  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   ri  intr~  r  __classcell__)r  s   @r  r0   r0   &   s2       k
# k
 k
 k
 k
 k
 k
ZD D D !# 8 8s 8 8 8 8( $& Z Z$v, Z Z Z Zx :>b 8 8s 83 8Y 8 8 8 8tJ J Jv J J J J JX 6:UW cA cA3 cAs cA# cA\`af\g cA cA cA cAJQ Q4 Q Q6 Q Q Q Qf 04B 5 5W 57 5 5 5 5  
 02 3 33 3f 3 3 3 3* 26b 5 5w 5 5 5 5*
 *
 *
4 *
 *
 *
 *
X 9=4^bkm 3H 3H# 3H# 3HS 3HX[ 3Hrvw{r| 3H 3H 3H 3Hj $& +E +E( +E +E +E +EZ) ) ) )&: : : : :(S S Sv S S S S Sj: : : gksu ]2 ]23 ]2i ]2y ]2RW ]2`c ]2 ]2 ]2 ]2~ 26b 0* 0*c 0*3 0* 0* 0* 0*d *.Dt\^ B? B?3 B?c B? B?cghmcn B? B? B? B?H /3TXac U U U3 Uc Uhlmrhs U U U U 154VZce U U# US UPS Ujnotju U U U U 37r +* +*s +*C +* +* +* +*Z -1tRV_a 7? 7?c 7? 7?C 7? 7? 7? 7?r 79 4
 4
# 4
^ 4
 4
 4
 4
l *.Dt\^ 7I 7I3 7Ic 7I 7Icghsct 7I 7I 7I 7Ir -1tRV_a 4L 4Lc 4L 4LC 4Lfjkvfw 4L 4L 4L 4Ll: : : :&i
 i
T i
X i
Q\ i
 i
 i
 i
V KOWY *: *:S *:% *:# *:C *:^i *: *: *: *:X &eBSW 2P 2P 2P 2Ph9# 9s 9 9c 9TX 9`c 9 9 9 9v MO 4 4 4 4 4 4 4 4r  r0   )6ccxt.base.exchanger   ccxt.abstract.tokocryptor   rc  rp  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&   r'   r(   r)   r*   r+   ccxt.base.decimal_to_precisionr,   r-   ccxt.base.preciser.   r0   rn  r  r  <module>r     s#   ( ' ' ' ' ' 0 0 0 0 0 0   q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & 1 1 1 1 1 1 . . . . . . ) ) ) ) ) ) * * * * * * 5 5 5 5 5 5 - - - - - - ) ) ) ) ) ) + + + + + + . . . . . . 1 1 1 1 1 1 * * * * * * ) ) ) ) ) ) + + + + + + ( ( ( ( ( ( 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %N'4 N'4 N'4 N'4 N'4; N'4 N'4 N'4 N'4 N'4r  