
    iz                       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 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l.m/Z/ d dl.m0Z0 d dl1m2Z2  G d dee          Z3dS )     )Exchange)ImplicitAPIN)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)MarginModeAlreadySet)BadResponse)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)OrderNotFillable)NotSupported)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)InvalidNonce)RequestTimeout)TRUNCATE)DECIMAL_PLACES)Precisec                        e Zd Z fdZd Zi fdZi fdee         fdZdi fde	de
defd	Zd5d
edefdZddi fde	de
de
dee         fdZd5d
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d5d
edefdZdddi fde	de
de
dee         fdZi fdefdZd6dZd Zd5d
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	fd)Z.dddi fd(e'de
de
dee/         fd*Z0dddi fd(e'de
de
dee/         fd+Z1d5d,Z2d5d-e3de/fd.Z4di fd(e	de$fd/Z5d0d1i ddfd2Z6d3 Z7i fd4Z8 xZ9S )7
tokocryptoc           ,         |                      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ddddddd]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdpdridsdtdudvdwdwdwdxdwgdydzgd{d|gd}d~ggddwdwdzdwdwdddwdddwddd|dddwiddwiddwidddwdwdwdwdwdwdidwdwdwdwdwdwdwdwddwdwdwdwdwdddddd|                     d          |                     d          dit
          ddddd}dd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ddddddddddddddddi dd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/d0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ddiddidJi dKd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]i d^t          d_t          d`t          dat          dbt          dct          ddt          det          dft          dgt          dht          dit          djt          dkt          dlt          dmt          dnt          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&          t&          t$          t          t&          t&          t&          t&          t          t$          t$          t$          t$          t,          d*t          t$          d+d,d-          S (.  Nr.   
TokocryptoIDFv1CORSspotTmarginswapfutureoption	addMarginborrowMargincancelAllOrderscancelOrdercancelOrderscreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersemulatedfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawals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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)idname	countries	certifiedproversion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   r(   r   r    r"   )self	__class__s    U/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/tokocrypto.pyrr  ztokocrypto.describe(   s   j$ 7 7 @ @ B B \\\ $\ 	\
 %\ %\ T\ \ "5\ t\ \ '\ /\ ,U\ 0\  t!\" (#\ \$ '%\& ('\( "4)\*  +\, -\.  /\0 &t1\2 +D3\4 )$5\6 &u7\8 #E9\: $Z;\< '=\> (?\@ "5A\B C\D &tE\ \ \F (G\H 1%I\J  K\L +EM\N &uO\P #EQ\R *5S\T $UU\V "5W\X *5Y\Z +E[\\ #E]\^ t_\`  a\b %ec\d +Je\f g\ \ \h !%i\j  k\l dm\n +Eo\p !%q\r "4s\t du\v !$w\x "5y\z t{\| #E}\~  \@ !%A\B %eC\D )%E\F uG\H uI\ \ \J K\L TM\N tO\P "5Q\R #ES\T %eU\V &uW\X 'Y\Z $U[\\ !%]\^ "5_\` #Da\b +Ec\d e\f #Eg\h &ui\j uk\ \l #!&#(! w\ \ \|  $ ">#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` `IE	E
 E	E
 E	 E	 E		    c                 F    |                                  | j        d         z
  S )NrQ  )millisecondsrn  )rt  s    rv  nonceztokocrypto.noncep  s!      ""T\2B%CCCrw  c                 X    |                      |          }|                     |d          S )aV  
        :see: 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
        
serverTime)publicGetOpenV1CommonTimesafe_integer)rt  paramsresponses      rv  
fetch_timeztokocrypto.fetch_times  s/     11&99   <888rw  returnc                    |                      |          }| j        d         r|                                  |                     |di           }|                     |dg           }g }t	          dt          |                    D ]}||         }|                     |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 r|                     |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><   |                    |           |S )?a,  
        :see: 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
        rR  datalistr   	baseAsset
quoteAssetsymbolmarginAsset/filters
filterTypespotTradingEnable1permissionsTRD_GRP_003FisMarginTradingAllowedrd  lowercaseIdbasequotesettlebaseIdquoteIdsettleIdtyper4   Tr5   r6   r7   deliveryr8   activeNquantityPrecisionpricePrecisionbaseAssetPrecisionquotePrecision)amountpricer  r  )minmax)leverager  r  r   )contractlinearinverse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  )publicGetOpenV1CommonSymbolsrn  load_time_difference
safe_valuerangelensafe_stringsafe_string_lowersafe_currency_codeindex_by	safe_boolr~  precision_from_stringsafe_numbersafe_number_2append)rt  r  r  r  r  resultir   r  r  rd  r  r  r  r  r  r  r  filtersByTypestatusr  r  jr  entryfilterr  r  s                               rv  fetch_marketsztokocrypto.fetch_markets  s    44V<<J <12 	(%%'''x44tVR00q#d))$$ h	! h	!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$ " $"&""//8KLL!..v7GHH --f6JKK!..v7GHH	   $#! !
  $# 
  $# 
  $#  $  g4 4 4Ej ..KK++FJ??.2.H.H.R.Rk"7+  ++FJ??++FJ??, ,h( /3.H.HPZI[.\.\k"7+]**
BGG++FJ??/3/I/I(/S/Sk"8,++FH==++FH==- -h) !M118I2NN++FH==++FH==- -h) ..KK151C1CFM[e1f1fh'.MM%    rw  Nr  r   c                 &   |                                   |                     |          }i }|||d<   d}|d         dk    r>|d         |d         z   |d<   |                     |                     ||                    }n4|d         |d<   |                     |                     ||                    }|                     |d	|          }|                     |d
d          }|                     |||          }	|                     |d          |	d<   |	S )a0  
        :see: 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  rd  r  T	timestamplastUpdateIdrz  )	load_marketsr   binanceGetDepthextendpublicGetOpenV1MarketDepthr  safe_integer_2parse_order_bookr~  )
rt  r  r   r  r   requestr  r  r  	orderbooks
             rv  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	'rw  r   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ard  tradeIdorderIdmisBuyerMakersellbuyr   sideisBuyer
commissioncommissionAsset)r   currencyisMakerr   )r  r  datetimer  rd  orderr  r  takerOrMakerr  r  r   fee)	r  safe_string_2r  safe_symbolsafe_value_2r  r  
safe_tradeiso8601)rt  trader   r  r  r  r   marketIdr  rd  r  r  
buyerMakerr  r  s                  rv  parse_tradeztokocrypto.parse_tradeT  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//( 
  
   	rw  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 )at  
        :see: https://www.tokocrypto.com/apidocs/#recent-trades-list
        :see: 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  rn  sumr  r  )rt  r  r  r   r  r   r  responseInnerr  r  defaultMethodmethodr  s                rv  fetch_tradesztokocrypto.fetch_trades  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%@@@rw  c                    |                      |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)r  r  r  )r~  r  r  safe_tickerr  )
rt  tickerr   r  r  r  r*  isCoinmr  r  s
             rv  parse_tickerztokocrypto.parse_tickerC  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#!
$ %&)!
 !
 !
* +  	rw  symbolsc                     |                                   |                     |          }|                     ||          S )a3  
        :see: 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rt  r5  r  r  s       rv  fetch_tickersztokocrypto.fetch_tickers  s?     	,,V44!!(G444rw  c                 L    |d         dk    r|d         |d         z   S |d         S )Nr  r  r  r  rd   )rt  r   s     rv  r	  z tokocrypto.get_market_id_by_type  s0    '?f$$(#fY&777d|rw  c                 |   |                                   |                     |          }d|d         |d         z   i}|                     |                     ||                    }t	          |t
                    r-|                     |di           }|                     ||          S |                     ||          S )a  
        :see: 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   r7  r  
isinstancer  r  r4  )rt  r  r  r   r  r  firstTickers          rv  fetch_tickerztokocrypto.fetch_ticker  s     	V$$fX&	)::
 ,,T[[&-I-IJJh%% 	:..1b99K$$[&999  6222rw  c                     |                                   |                     |          }|                     ||          S )a  
        :see: 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  binanceGetTickerBookTickerr8  r9  s       rv  fetch_bids_asksztokocrypto.fetch_bids_asks  s?     	226::!!(G444rw  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r   r         r   )r~  r  )rt  ohlcvr   s      rv  parse_ohlcvztokocrypto.parse_ohlcv  s    H eQ''UA&&UA&&UA&&UA&&UA&&
 	
rw  r   c                    |                                   |                     |          }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 )aS  
        :see: 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   indexrd  pairr  r  r  r  r  r  )r  r   r  r~  omitr  rk  r	  binanceGetKlinesr  publicGetOpenV1MarketKlinesr  parse_ohlcvs)rt  r  	timeframer  r   r  r   defaultLimitmaxLimitr  rJ  r  r  r  s                 rv  fetch_ohlcvztokocrypto.fetch_ohlcv  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Grw  c                 |   |                                   |                     | j        ddd          }|                     |d|          }|                     | j        dd          }|                     |d|          }i }|                     |                     ||                    }|                     |||          S )a  
        :see: 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>`
        rH   defaultTyper4   r  
marginModedefaultMarginMode)r  r  rn  r  r  privateGetOpenV1AccountSpotr  parse_balance_custom)rt  r  rW  r  rY  rX  r  r  s           rv  fetch_balanceztokocrypto.fetch_balance%  s     	((~}V\]]<< ..t|\K^__++FLBSTT
33DKK4P4PQQ2 ((4DDDrw  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~  r  r  r  r  r  r  accountsafe_balance)rt  r  r  rX  r  r  r  balancesr  balance
currencyIdcoderd  s                rv  r[  ztokocrypto.parse_balance_customP  s   %%h==	"Y//
 

 x44??4"==q#h--(( 	# 	#AqkG))'7;;J**:66DllnnG"..w??GFO"..wAAGFO"F4LL  (((rw  c                 T    dddddddddddddddd}|                      |||          S )Nr'  closedcanceled	cancelingrejectedexpired)z-20r  23456NEWPARTIALLY_FILLEDFILLEDCANCELEDPENDING_CANCELREJECTEDEXPIREDr  rt  r  statusess      rv  parse_order_statusztokocrypto.parse_order_statusc  sU     &")" 
 
" &&999rw  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    }|                     |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  r  executedQtyrp  
createTimeavgPricer  executedPriceorigQty)cummulativeQuoteQtycumQuoteexecutedQuoteQtycumBaser  r  r  r  r  r  fillsclientOrderIdclientIdtimeInForceGTXPOlimit_maker	stopPricer  rd  r  r  lastTradeTimestamppostOnly
reduceOnlytriggerPricer  r   )r0  filled	remainingr  r  r   )r  r  r  r~  r  safe_string_nparse_order_typer  r  rs  	omit_zero
safe_orderr  )rt  r  r   r  r  r  r  r  r0  r  r  r   rd  r  r  r  r  r  r  stopPriceStringr  s                        rv  parse_orderztokocrypto.parse_orderw  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**5+>>%%dnn_&E&EFF	  
E 
" 
 ] 
 	 

 Y// 
 !$ 
 f 
 D 
 ; 
  
 $//%>> 
 D 
 U 
  
 I 
  f! 
" D# 
$ / 
  
  
0 1  	rw  c                 >    ddddd}|                      |||          S )Nr   r   )rq  r  rs  7r}  r~  s      rv  r  ztokocrypto.parse_order_type  s4    	
 
 &&999rw  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
        :see: https://www.tokocrypto.com/apidocs/#new-order--signed
        :see: https://www.tokocrypto.com/apidocs/#account-trade-list-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 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.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( stopPrice parameter is not allowed for  z ordersz# is not a valid order type for the z marketr   r   rE  rF  r         )r  r  r  r  TAKE_PROFITTAKE_PROFIT_LIMITr  r  _r  )r  r  r  r   r  r  broker
marketTyper  r  TrB   rL  r   rT  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 orderz6 createOrder() requires a stopPrice extra param for a r  )r  r   r  r  rN  upperr  r  in_arrayr   rd  r  rn  uuid22handle_option_and_paramsr  number_to_stringr,   
string_muldecimal_to_precisionr*   rm  amount_to_precisionprice_to_precisionprivatePostOpenV1Ordersr  r  r  )rt  r  r  r  r  r  r  r   r  r  initialUppercaseTypeuppercaseTyper  validOrderTypesreverseOrderTypeMappingr  r  brokerIdpriceIsRequiredstopPriceIsRequiredquantityIsRequiredr  quoteAmountrL  r   amountStringpriceStringr  rawOrders                                rv  create_orderztokocrypto.create_order  sC    	V$$**6?JOO>>&*e<< 	! D6J#@AA#zz||,%%fnkJJ	 YYv'DEEF(( +')) 1//&.,GG}}]O<< 	v#}44"47-W#WZ`#`cf#fim#mpy#yzzz"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 	R "47-e#ehl#low#wxxx'+'>'>vy'Q'Q$//GV0L0LMM: >>(FB77&111rw  rd  c                    d|i}|                      |                     ||                    }|                     |di           }|                     |dg           }|                     |di           }|                     |          S )a  
        :see: https://www.tokocrypto.com/apidocs/#all-orders-signed
        fetches information on an order made by the user
        :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  )	rt  rd  r  r  r  r  r  r  r  s	            rv  fetch_orderztokocrypto.fetch_order  s     r
 ..t{{7F/K/KLL> x44tVR00>>$2..)))rw  c                    |t          | j        dz             |                                  |                     |          }d|d         i}|||d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S )	a1  
        :see: 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  rd  r  r   r  r  )	r   rd  r  r   r  r  r  r  parse_orders)
rt  r  r  r   r  r   r  r  r  orderss
             rv  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  >>>rw  c           	      b    ddi}|                      ||||                     ||                    S )a  
        :see: 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  rt  r  r  r   r  r  s         rv  fetch_open_ordersztokocrypto.fetch_open_orders'  5     1+  t{{7F7S7STTTrw  c           	      b    ddi}|                      ||||                     ||                    S )a8  
        :see: 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         rv  fetch_closed_ordersztokocrypto.fetch_closed_orders4  r  rw  c                     d|i}|                      |                     ||                    }|                     |di           }|                     |          S )a  
        :see: 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  )rt  rd  r  r  r  r  r  s          rv  cancel_orderztokocrypto.cancel_orderA  s^     r
 55dkk'66R6RSS8 >>(FB77)))rw  c                     |t          | j        dz             |                                  |                     |          }d|d         i}|                     |dd          }|||d<   |||d<   |                     |ddg          }|||d<   |                     |                     ||                    }|                     |d	i           }	| 	                    |	d
g           }
| 
                    |
|||          S )a  
        :see: 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  rd  rJ  r  r  r   r  r  )r   rd  r  r   r  rN  privateGetOpenV1OrdersTradesr  r  r  r  )rt  r  r  r   r  r   r  r  r  r  r   s              rv  fetch_my_tradesztokocrypto.fetch_my_tradesl  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  >>>rw  ri  c                    |                                   |                     |          }d|d         i}|                     | j        di           }|                     |d          }|                     |||          }|||d<   |                     |d          }|                     |                     ||                    }|                     |di           }|                     |d          }	|                     |dd	          }
t          |
          d
k    rd}
| 
                    |	           ||	|
|                     |d          |dS )a  
        :see: https://www.tokocrypto.com/apidocs/#deposit-address-signed
        fetch the deposit address for a currency associated with self account
        :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`  rd  rU  networkNr  address
addressTag r   )r  r  tagr  r  )r  r  r  rn  safe_string_upperr  rN  privateGetOpenV1DepositsAddressr  r  check_address)rt  ri  r  r  r  rU  r  r  r  r  r  s              rv  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
 
 	
rw  c                    |                                   d}i }|                     |d          }| |                     |          }|d         |d<   |2||d<   |                     |d          }|t	          ||          }||d<   |||d<   |                     |                     ||                    }	|                     |	d	i           }
|                     |
d
g           }| 	                    ||||          S )a_  
        :see: 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>`
        NrJ  rd  coinr      X r  r   r  r  )
r  r~  r  r  r  privateGetOpenV1Depositsr  r  r  parse_transactions)rt  ri  r  r   r  r  r  rJ  r  r  r  depositss               rv  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Hrw  c                    |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |d          |d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |d	g           }	|                     |	|||          S )
a  
        :see: 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>`
        Nrd  r  r  r  r  r   r  r  )r  r  r  privateGetOpenV1Withdrawsr  r  r  r  )
rt  ri  r  r   r  r  r  r  r  withdrawalss
             rv  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Krw  c           	      ~    dddddddddddd}|                      ||i           }|                     |||          S )Npendingok)rp  r  rl  failed)rp  r  rq  rr  rs  rt  10)deposit
withdrawal)r  r  )rt  r  r  statusesByTyper  s        rv   parse_transaction_status_by_typez+tokocrypto.parse_transaction_status_by_typeB  sp      
  
 
 ??>4<<&&999rw  r  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   transferTypeFTrd  r  
withdrawIdr  txidr  r  r  r  addressFrom	addressTor  tagFromtagToupdatedsuccessTimer^  )commentinternalr  )r  r  findr  r  r~  r  r  r  r  r  r  )rt  transactionr  r  r  r  rh  ri  r  r  r  r  feeCostr  internalRawr  rd  r  s                     rv  parse_transactionztokocrypto.parse_transactionU  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#
$  )
 
 
 	
rw  c                    |                      ||          \  }}|                                  |                     |           |                     |          }|d         ||                     |          d}|||d<   |                     |          \  }}	|                     |          }
|
|
                                |d<   |                     | 	                    ||	                    }| 
                    ||          S )a  
        :see: 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>`
        rd  )r`  r  r  Nr  r  )handle_withdraw_tag_and_paramsr  r  r  r  handle_network_code_and_paramsnetwork_code_to_idr  privatePostOpenV1Withdrawsr  r  )rt  ri  r  r  r  r  r  r  networkCodequery	networkIdr  s               rv  r   ztokocrypto.withdraw  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9rw  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-Typer  z5 userDataStream endpoint requires `apiKey` credentialr   sapizsystem/statussapiV3systemStatusdapiPrivatedapiPrivateV2fapiPrivatefapiPrivateV2rP  r  z
asset/dustbatchOrderszsub-accountr   zcapital/withdraw/applystakingz&signature=r  DELETE?r  )urlr  bodyheaders)rl  r#   rd  apiKey	urlencoder   check_required_credentialsr~  rn  r  rz  urlencode_with_array_repeatr  	rawencodehmacencodesecrethashlibsha256)rt  pathr   r  r  r-  r,  r+  r   r  defaultRecvWindowextendedParamsrP  	signatures                 rv  signztokocrypto.sign  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Orw  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msgrb  rc  ri  200rp  rY  rN  zNo need to change margin type.)r$   rd  strr  r   r  r  jsonloads	Exceptionthrow_exactly_matched_exceptionro  throw_broadly_matched_exceptionr,   string_equalsrn  r   r   )rt  ri  reasonr+  r  r-  r,  r  requestHeadersrequestBodyr>  messageInnerparsedMessageemessageerrorfeedbacks                    rv  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~  )
rt  r   r  r8  r  configr   r   r  r  s
             rv  calculate_rate_limiter_costz&tokocrypto.calculate_rate_limiter_costY	  s    6)9)9(##F""X-?-?*%%F""X-?-?*%%6!!6(9(97OEY'G1c'll++ $ $
E!H$$ 8OOO %  333rw  )N)NN):__name__
__module____qualname__rr  rz  r  r   r   r  rA  r   r   r  r   r  r  r   r4  r   r   r:  r	  r@  rC  r  rH  rU  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<  rQ  rW  __classcell__)ru  s   @rv  r.   r.   &   s       F	 F	 F	 F	 F	PD D D !# 9 9 9 9 $& Z Z$v, Z Z Z Zx :>b 6 6s 63 6Y 6 6 6 6pJ J J5 J J J JX 6:UW aA aA3 aAs aA# aA\`af\g aA aA aA aAFQ Q6 QV 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 26DW[df 1H 1H# 1Hc 1HQT 1Hkoptku 1H 1H 1H 1Hf $& )E )E( )E )E )E )EV) ) ) )&: : :(V V V5 V V V Vp: : : gksu \2 \23 \2i \2y \2RW \2`c \2 \2 \2 \2| 26b -* -*c -*3 -* -* -* -*^ *.Dt\^ @? @?3 @?c @? @?cghmcn @? @? @? @?D /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 )* )* )* )*V -1tRV_a 5? 5?c 5? 5?C 5? 5? 5? 5?n 79 2
 2
# 2
 2
 2
 2
h *.Dt\^ 5I 5I3 5Ic 5I 5Icghsct 5I 5I 5I 5In -1tRV_a 2L 2Lc 2L 2LC 2Lfjkvfw 2L 2L 2L 2Lh: : : :&i
 i
x i
; i
 i
 i
 i
V ?C2 (: (:S (:% (: (: (: (:T &eBSW 2P 2P 2P 2Ph9 9 9v MO 4 4 4 4 4 4 4 4rw  r.   )4ccxt.base.exchanger   ccxt.abstract.tokocryptor   r6  rB  ccxt.base.typesr   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,   r.   r<  rw  rv  <module>rd     s   ( ' ' ' ' ' 0 0 0 0 0 0   \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \       * * * * * * 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 9 9 9 9 9 9 % % % % % %A%4 A%4 A%4 A%4 A%4; A%4 A%4 A%4 A%4 A%4rw  