
    !:hq                       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      Z5y)     )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                   8    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d@d
ede	defdZddi fdedededee   fdZd@d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d@d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dAdZde fdZ!d@d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d/Z4d@d0Z5d@d1ed2e6de2fd3Z7di fd,ed"e'd4ede2fd5Z8d6d7i ddfd8Z9d,e:d9ed:ed;ed<ed=efd>Z;i fd?Z< xZ=S )B
tokocryptoreturnc           ,         | j                  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| j	                  d      | j	                  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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ddddd1dd{dddd2dd{d/d/dddd3dd{d/dwd/dddd4d5d{id6	d d d7d d d7d8d9      S (:  Nr0   
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)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )rk  r   daysBack	untilDayssymbolRequired)rk  triggerrt  r|  )rk  r   r}  rt  r|  )rk  r   rz  r{  r}  rt  r|  )rk  r   rz  daysBackCanceledr{  r}  rt  r|  r   )	sandboxrE   createOrdersrk   rp   ro   rs   rR   rl   )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    I/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/tokocrypto.pyr  ztokocrypto.describe(   s   j$ @ 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"#%&,-"#01r'B12(B67Q-G(* )! )! )!)2 /02301125612
 23*+016712-.,-45	 +,12./-.45I7r !%"&!..x8!..x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0 \1Z2 \3Z4 .5Z6 17Z8 Z9Z: \;Z< 0=Z> Z?Z@ 0AZB ZCZD ZE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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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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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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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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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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 )*1(((!+-(((()sZx 3C$0y`F  %&+(,,1,0).+06:#'#'"&#(	( #($)$)+/26/3#')$, %)&+!%$*%+*.& ',#($)*/	# ',!%#($)*.( ',!%$*%+#($)*.$ ',!%$*,-%+#($)*.	*  #ACJ ##
 ##SMKS
E
 S
 S
	    c                 B    | j                         | j                  d   z
  S )NrT  )millisecondsr  )r  s    r  nonceztokocrypto.nonce  s       "T\\2B%CCCr  c                 H    | j                  |      }| j                  |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   ;77r  c                    | j                  |      }| j                  d   r| j                          | j                  |di       }| j                  |dg       }g }t	        dt        |            D ]|  }||   }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d      }| j                  |d      }| j                  |      }| j                  |	      }| j                  |      }|d	z   |z   }| j                  |d
g       }| j                  |d      }| j                  |d      }|dk(  }| j                  |dg       }t	        dt        |            D ]  }||   dk(  sd} n | j                  |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#| j                  | j                  | j                  |d$                  | j                  | j                  | j                  |d%                  | j                  | j                  | j                  |d&                  | j                  | j                  | j                  |d'                  d(d#d#d)d#d#d)d#d#d)d#d#d)d*d#|d+}d,|v ra| j                  |d,i       }| j                  |d-      |d.   d/<   | j                  |d0      | j                  |d1      d)|d2   d/<   |d-   |d.   d/<   d3|v rV| j                  |d3i       }| j                  |d4      |d.   d5<   | j                  |d6      | j                  |d7      d)|d2   d5<   d8|v r>| j                  |d8i       }| j                  |d6      | j                  |d7      d)|d2   d9<   d:|v r/| j                  |d:i       }| j                  |d;d<      |d2   d=   d><   |j                  |        |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
        rU  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)ru  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tVR0q#d)$ f	!A!WF%%fk:F&&v|<G!!&(3B00BK''>H**62D++G4E,,X6FCZ%'Foofi<G MM'<@M%%f.ABFmF//&-DK1c+./ q>]2"F &*^^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\^qEr0st!..t/C/CDDTDTU[]mDn/op --d.B.B4CSCSTZ\pCq.rs!..t/C/CDDTDTU[]mDn/op	  $#!
  $#
  $#
  $#$  g4Ej .K.2.>.>vz.Rk"7+  ++FJ?++FJ?,h( /5Z.@k"7+]*
BG/3/?/?
/Sk"8,++FH=++FH=-h) !M18I2N++FH=++FH=-h) .K151C1CFM[e1fh'.MM% Mf	!N r  Nr  r   c                    | j                          | j                  |      }i }|||d<   d}|d   dk(  r0|d   |d   z   |d<   | j                  | j                  ||            }n)|d   |d<   | j	                  | j                  ||            }| j                  |d	|      }| j                  |d
d      }| j                  |||      }	| j                  |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_bookq  s     	V$$GG'?f$ &x 06)3D DGH++DKK,HIH &tGH66t{{7F7STH< x:''#{C	))$	B	!..t^D	'r  trader   c                    | j                  |dd      }| j                  |dd      }| j                  |dd      }| j                  |dd      }| j                  |d	      }| j                  ||      }| j                  |d
d      }	| j                  |dd|	      }	d }
| j                  |d      }| j	                  |dd      }d }|	|rdnd}
d}n$d|v r| j                  |d      }
nd|v r	|d   rdnd}
d }d|v r4| j                  |d      | j                  | j                  |d            d}d|v r	|d   rdnd}d|v r	|d   rdnd}| j                  ||| j                  |      ||	|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  s   | ''sF;	""5#w7##E36!!%Y?##E84!!(F3sC0tY;""5)4&&uc>B
 !'6UD"Lu_))%8DE! %i 0uf5 ((= 33D4D4DUL]4^_C &+I&67GLe&+Gn7'L"Y/( 
  	r  sincec                 ~   | j                          | j                  |      }d| j                  |      i}|d   dk7  rb|||d<   | j                  | j	                  ||            }| j                  |di       }| j                  |dg       }	| j                  |	|||      S |||d<   d}
| j                  | j                  d	|
      }d}|d
k(  r>|<||d<   | j                  |d      |d<   | j                  | j	                  ||            }n!| j                  | j	                  ||            }| j                  ||||      S )aj  

        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  sumr!  r  )r  r  r  r   r  r   r  responseInnerr  r  defaultMethodmethodr  s                r  fetch_tradesztokocrypto.fetch_trades7  s^    	V$d008
 '?f$ #(  <<T[[RX=YZM( >>-<D>>$3D$$T65%@@$GG*!!$,,0C]S++%2C#(GK  "&%!9GI//GV0LMH,,T[[&-IJHN   65%@@r  tickerc                 L   | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }d|v }d }d }	|r%| j                  |d      }| j                  |d      }	n$| j                  |d      }| j                  |d      }	| j                  i d|d|d| j	                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d|d|d| j                  |d      d| j                  |d      d| j                  |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)r2  r4  r  )r  r  r  safe_tickerr  )
r  r.  r   r  r  r  rF  isCoinmr2  r4  s
             r  parse_tickerztokocrypto.parse_ticker  s<   ^ %%fk:	##FH5!!(F346)
))&,?J**68<K))&(;J**6=AK !
f!
!
 Y/!
 D$$V[9	!

 4##FJ7!
 4##FJ7!
 ))&(;!
 4##FJ7!
 ))&(;!
 D$$V-?@!
 D$$V[9!
 T!
 D!
 T--f6FG!
 d&&v}=!
  $**63GH!!
" t#!
$ %&)!
* + 	r  symbolsc                 h    | j                          | j                  |      }| j                  ||      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  rP  r  r  s       r  fetch_tickersztokocrypto.fetch_tickers  s3     	,,V4!!(G44r  c                 2    |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  s-    '?f$(#fY&777d|r  c                 .   | j                          | j                  |      }d|d   |d   z   i}| j                  | j                  ||            }t	        |t
              r%| j                  |di       }| j                  ||      S | j                  ||      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   rR  r  
isinstancer  r&  rO  )r  r  r  r   r  r  firstTickers          r  fetch_tickerztokocrypto.fetch_ticker  s     	V$fX&	)::
 ,,T[[&-IJh%..1b9K$$[&99  622r  c                 h    | j                          | j                  |      }| j                  ||      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  binanceGetTickerBookTickerrS  rT  s       r  fetch_bids_asksztokocrypto.fetch_bids_asks  s3     	226:!!(G44r  c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr   r   r         r   )r  r  )r  ohlcvr   s      r  parse_ohlcvztokocrypto.parse_ohlcv%  so    H eQ'UA&UA&UA&UA&UA&
 	
r  r   c                 f   | j                          | j                  |      }d}d}| j                  |d      }	| j                  |d      }
| j	                  |ddg      }||nt        ||      }| j                  | j                  ||      |d}|	dk(  r	|d   |d	<   n| j                  |      |d
<   |||d<   |
|
|d<   d}|d   dk(  r"| j                  | j                  ||            }n!| j                  | j                  ||            }| j                  |d|      }| j                  |||||      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  r"  r#  r  r  r  )r  r   r  r  omitr  r  r$  binanceGetKlinesr  publicGetOpenV1MarketKlinesr'  parse_ohlcvs)r  r  	timeframer  r   r  r   defaultLimitmaxLimitr  re  r  r  r  s                 r  fetch_ohlcvztokocrypto.fetch_ohlcvQ  sU    	V$   1!!&'26GW#56!&S5I(()YO
 G$TlGFO $ : :6 BGH#(GK !&GI'?f$,,T[[&-IJH77GV8TUH ~~h9  vy%GGr  c                 P   | j                          | j                  | j                  ddd      }| j                  |d|      }| j                  | j                  dd      }| j	                  |d|      }i }| j                  | j                  ||            }| j                  |||      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>`
        rK   defaultTyper7   r  rk  defaultMarginMode)r  r  r  r  r  privateGetOpenV1AccountSpotr  parse_balance_custom)r  r  rr  r  rs  rk  r  r  s           r  fetch_balanceztokocrypto.fetch_balance  s     	((~}V\]< ..t||\K^_++FLBST
33DKK4PQ2 ((4DDr  c                    | j                  |d      }||| j                  |      d}| j                  |di       }| j                  |dg       }t        dt	        |            D ]i  }||   }	| j                  |	d      }
| j                  |
      }| j                         }| j                  |	d      |d<   | j                  |	d      |d	<   |||<   k | j                  |      S )
N
updateTime)r  r  r  r  accountAssetsr   assetfreelockedused)	r  r  r  r  r  r  r  accountsafe_balance)r  r  r  rk  r  r  r  balancesr  balance
currencyIdcoder~  s                r  ru  ztokocrypto.parse_balance_custom  s    %%h=	"Y/

 x4??4"=q#h-( 	#AqkG))'7;J**:6DllnG"..w?GFO"..wAGFO"F4L	#   ((r  r  c                 L    dddddddddddddddd}| j                  |||      S )NrC  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  sM     &")" 
" &&99r  r  c                    | j                  | j                  |d            }| j                  |d      }| j                  ||      }| j                  |dd      }| j                  |d      }| j                  |d      }| j	                  |dd      }	| j                  |d	      }
| j                  |g d
      }| j                  |d      }| j                  | j                  |d            }| j                  |d      }|dk(  rd}n|dk(  rd}| j                  |dg       }| j	                  |dd      }| j                  |d      }|dk(  rd}|dk(  xs |dk(  }| j                  i d|d|d|d|d| j                  |      dd d|d|d|d|d| j                  |d      d|d|	d| j                  | j                  | j                  |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clientIdrr  GTXri  limit_makerr  r  r  r  lastTradeTimestamppostOnly
reduceOnlyrl  	stopPricer  r   rL  )filled	remainingr  r  r   )r  r  r  r  r  safe_string_nparse_order_typer  r  
safe_orderr  r  	omit_zero)r  r  r   r  r  r  r  r  rL  r  r  r   r  r  r  r  r  rr  r  s                      r  parse_orderztokocrypto.parse_order  s   F (()9)9%)JK##E84!!(F3!!%<%%e\:	""5*5""5'?C!!%3 !!%)kleY/$$T%;%;E6%JK%%eV43;DS[Dw3**5/:N&&um<%KM)C{d/B  
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 f 
 D 
 ; 
  
 $//%> 
 D 
 U 
 D--dnnT=M=MeU`=a.bc 
 f 
  D! 
" w# 
$ - 
. / 	r  c                 6    ddddd}| j                  |||      S )Nr   r   )r  r  r  7r  r  s      r  r  ztokocrypto.parse_order_typeo  s,    	
 &&99r  r  r  r  r  c                 .   | j                          | j                  |      }| j                  |dd      }| j                  |dd      }	|	rd}| j	                  |ddg      }|j                         }
|
}| j                  |dd      }|#| j	                  |ddg      }|d	k(  rd
}n|dk(  rd}| j                  |d   d      }| j                  ||      sM|
|k7  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   | j                  ||      d}|d k(  rd!|d"<   n
|d#k(  rd|d"<   |I| j                  | j                  d$      }|0| j                  |d%      }||| j                         z   |d<   n||d<   d}d}d}|d	k(  r|d k(  r|d&   d'   }d}d(}| j                  |d)d*d(      \  }}| j                  |d+d,      }| j	                  |d+d,g      }||}nW|rS|t        | j                  d-z         | j!                  |      }| j!                  |      }t#        j$                  ||      }n|}| j'                  |t(        || j*                        |d,<   nBd(}n?|dk(  rd(}d(}n5|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| j-                  ||      |d2<   |r5|t        | j                  d3z   |z   d4z         | j/                  ||      |d'<   |r5|t        | j                  d5z   |z   d4z         | j/                  ||      |d<   | j1                  | j3                  ||            }| j5                  |d6i       }| j7                  ||      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_MAKERrl  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   r`  ra  r         )r  r  r  r  TAKE_PROFITTAKE_PROFIT_LIMITr  r  _r  )r  r  r
  r   r  r	  broker
marketTyper  r  TrE   rO  r   rW  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  ri  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uppercaseTyperl  validOrderTypesreverseOrderTypeMappingr  r  brokerIdpriceIsRequiredtriggerPriceIsRequiredquantityIsRequiredr  quoteAmountrO  r   amountStringpriceStringr  rawOrders                                r  create_orderztokocrypto.create_orderx  s|     	V$**6?JO>>&*e< D6J#@A#zz|,((M#YYv'DEF( +') 1//&.,G}}]O<#}4"477-Z#Z]c#cfi#ilp#ps|#|}}"477S=4#7:_#_bh#hkt#tuu !")
 X&,vi/@@$$%<mL
 5=GFOV^GFO __T\\8<F!++FLA'*2T[[]*BGJ'"/GJ!&" H$u}";/8	"481<@<Y<YZ`bo  rU  W[  =\916))&&/J6FO+DE#"&K6}*477  6A  ,A  B  B'+'<'<V'D&*&;&;E&B&-&8&8{&S"(K+/+D+D[RZ\egkgygy+z(%)"g%"O!%{*0N%)"!%h6)#4"&00mGZ6Z!%%)""Om+"O!%"&":":66"JGJ}"477-^#^ae#ehp#pqq#66vuEGG!#"477-h#hko#orz#z{{'+'>'>v|'T$//GV0LM: >>(FB7&11r  r  c                     d|i}| j                  | j                  ||            }| j                  |di       }| j                  |dg       }| j                  |di       }| j	                  |      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  sv     r
 ..t{{7F/KL> x4tVR0>>$2.))r  c                 X   |t        | j                  dz         | j                          | j                  |      }d|d   i}|||d<   |||d<   | j	                  | j                  ||            }| j                  |di       }| j                  |dg       }	| j                  |	|||      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>`
        z) fetchOrders() requires a symbol argumentr  r  r"  r   r  r  )	r   r  r  r   r  r  r  r'  parse_orders)
r  r  r  r   r  r   r  r  r  orderss
             r  fetch_ordersztokocrypto.fetch_ordersI  s     >#DGG.Y$YZZV$fTl	
 #(GK $GG..t{{7F/KLD x4fb1  >>r  c           	      R    ddi}| j                  |||| j                  ||            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  r  r   r  r  s         r  fetch_open_ordersztokocrypto.fetch_open_orders  /        t{{7F7STTr  c           	      R    ddi}| j                  |||| j                  ||            S )a4  

        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}| j                  | j                  ||            }| j                  |di       }| j                  |      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  sR     r
 55dkk'66RS8 >>(FB7))r  c                    |t        | j                  dz         | j                          | j                  |      }d|d   i}| j	                  |dd      }|||d<   |||d<   | j                  |ddg      }|||d<   | j                  | j                  ||            }| j                  |di       }	| j                  |	d	g       }
| j                  |
|||      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>`
        z+ fetchMyTrades() requires a symbol argumentr  r  re  r#  r"  r   r  r  )r   r  r  r   r  ri  privateGetOpenV1OrdersTradesr  r  r'  r(  )r  r  r  r   r  r   r  r#  r  r  r   s              r  fetch_my_tradesztokocrypto.fetch_my_trades  s     >#DGG.[$[\\V$fTl
 %%fgyA#(GK !(GIYYv	7';<F$GG44T[[&5QR4 x4fb1  >>r  r  c                 ,   | j                          | j                  |      }d|d   i}| j                  | j                  di       }| j	                  |d      }| j                  |||      }|||d<   | j                  |d      }| j                  | j                  ||            }| j                  |di       }| j                  |d      }	| j                  |dd	      }
t        |
      d
k(  rd}
| j                  |	       ||| j                  |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>`
        rz  r  rX  networkNr  address
addressTag r   )r  r  r  r  tag)r  r  r  r  safe_string_upperr  ri  privateGetOpenV1DepositsAddressr  r  check_address)r  r  r  r  r  rX  r  r  r  r  r  s              r  fetch_deposit_addressz tokocrypto.fetch_deposit_address  s'    	==&Xd^
 ??4<<R@((;""8Wg>!(GIYYvy1F 77GV8TU  x4""43t\26s8q=C7#''i8
 	
r  c                    | j                          d}i }| j                  |d      }|| j                  |      }|d   |d<   |*||d<   | j                  |d      }|t	        ||      }||d<   |||d<   | j                  | j                  ||            }	| j                  |	d	i       }
| j                  |
d
g       }| j                  ||||      S )a[  

        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>`
        Nre  r  coinr"      X r#  r   r  r  )
r  r  r  r)  r  privateGetOpenV1Depositsr  r  r'  parse_transactions)r  r  r  r   r  r  r  re  r#  r  r  depositss               r  fetch_depositsztokocrypto.fetch_depositsG  s     	!!&'2}}T*H&tnGFO#(GK hhuj1G gu-!(GI$GG00Wf1MN0 x4>>$3&&x5%HHr  c                 \   | j                          i }d}|| j                  |      }|d   |d<   |||d<   | j                  |d      |d<   |||d<   | j                  | j	                  ||            }| j                  |di       }| j                  |d	g       }	| j                  |	|||      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  r"  r  r#  r   r  r  )r  r  r)  privateGetOpenV1Withdrawsr  r  r'  r   )
r  r  r  r   r  r  r  r  r  withdrawalss
             r  fetch_withdrawalsztokocrypto.fetch_withdrawals  s     	}}T*H&tnGFO#(GK !%%!<GI$GG11$++gv2NO4 x4nnT626&&{HeUKKr  c           	      n    dddddddddddd}| j                  ||i       }| j                  |||      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  s[     
  
 ??>4<&&99r  transactionr  c                    | j                  |d      }| j                  |d      }|t        |      dk  rd }| j                  |d      }||j                  d      dk\  r|dd  }| j                  |dd	      }| j	                  ||      }d }| j                  |d
      }	| j                  |dd      }
| j                  |d      }||	|
d}|	}n|	|
d}|
}| j                  |dd      }d d d d}|
||d<   ||d<   | j                  |d      }d}|d}| j                  |d      }|'| j                  |di       }| j                  |d      }d}i d|d|d|d|d|d| j                  |d      d| j                  |d      d| j                  | j                  |d      |      d|d | j                  |      d|d!d d"|d#|d$d d%|d&| j                  |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successTimerx  )commentinternalr  )r  r  findr  r  r  r  r  r  r  r  r  )r  r  r  r  r  r  r  r  r  r  r  r  feeCostr  internalRawr#  r  r  s                     r  parse_transactionztokocrypto.parse_transaction  s   Z "";	:{L9?3x!|V4499-A#Ba#G9D''V^L
&&z8<	&&{LA
((lKP
V4<&Z-? &	$:+A#&	$$[2BJO

 "C
O!CK''^D"Hk40:??;;D!!$5BD
K
"
 D
 D	

 
 t''Y?
 d&&{H=
 d;;D<L<L[Zb<ceij
 
 Y/
 w
 4
 
 3
 t
  S!
" t**;|T#
$  )
 	
r  r  c                    | j                  ||      \  }}| j                          | j                  |       | j                  |      }|d   || j	                  |      d}|||d<   | j                  |      \  }}	| j                  |      }
|
|
j                         |d<   | j                  | j                  ||	            }| j                  ||      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  )rz  r  r  r  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.withdraw4	  s     99#vFV7#==&d^ ++F3
 ?$'GL!!@@HU++K8	 !*!2GI224;;w3NO %%h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(  xs |d	k(  }|rL| j                  r(| j                  d
d}|dk7  r| j	                  |      }nt        | j                  dz         |dk(  s.|dk(  r|dk7  s$|dk(  s|dk(  r|dk7  s|dk(  s|dk(  s|dk(  s|dk(  r`| j                          d }	| j                  | j                  d      }
| j                  d| j                         i|      }|
|
|d<   | j                  |d      }|||d<   |dk(  r|dk(  r| j                  |      }	nU|dk(  s-|j                  d      dk\  s|dk(  s|j                  d      dk\  r| j                  |      }	n| j	                  |      }	| j                  | j                  |	      | j                  | 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"| j	                  |      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-Typer0  z5 userDataStream endpoint requires `apiKey` credentialr   sapizsystem/statussapiV3systemStatusdapiPrivatedapiPrivateV2fapiPrivatefapiPrivateV2rS  r  z
asset/dustbatchOrderszsub-accountr   zcapital/withdraw/applystakingz&signature=r4  DELETE?r5  )urlr,  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   r,  r  rC  rB  rA  r   r.  defaultRecvWindowextendedParamsrS  	signatures                 r  signztokocrypto.sign`	  s   tyy'//tww)TTWZZ]iijjiiv&s+sTz&=7NC"22L8K{{ %)KK$G U?>>&1D)$''4k*kllYC6Mdo6MSVZbSbhkouhuz~  CQ  {Q  WZ  ^k  Wk  qt  xG  qG  MP  Ta  Ma  gj  n}  g}++-E $ 1 1$,, M![[TZZ\*N !,/@|,**6<@J%/9|,vDL$888H-'TYY}-E-JPTXpPpvzvv  AJ  wK  OP  wP~6~6		$++e"4dkk$++6NPWP^P^_I')33EG %Vx%7SF]sU{"*M'sT^^F333fdwOOr  reasonrA  r,  rC  rB  c
                    |dk(  s|dk(  r0t        | j                  dz   t        |      z   dz   |z   dz   |z         |dk\  r|j                  d      dk\  rt	        | j                  dz   |z         |j                  d      dk\  rt	        | j                  d	z   |z         |j                  d
      dk\  rt	        | j                  dz   |z         |y | j                  |dd      }
|
s0| j                  |d      }d }|	 t        j                  |      }||}| j                  |d      }|`| j                  | j                  d   || j                  dz   |z          | j                  | j                  d   || j                  dz   |z          | j                  |d      }||dk(  st        j                  |d      ry |dk(  r*| j                  d   rt        | j                  dz   |z         | j                  dz   |z   }|dk(  rt!        |      | j                  | j                  d   ||       t#        |      |
st#        | j                  dz   |z         y # t        $ r}d }Y d }~Sd }~ww xY w)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msgre  rf  r  200r  r\  rQ  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  rS  rA  r,  rC  rB  r  requestHeadersrequestBodyrU  messageInnerparsedMessageemessageerrorfeedbacks                    r  handle_errorsztokocrypto.handle_errors	  s   CKTS[ 3T!:S!@6!IC!ORV!VWW 3;yy671<"477-\#\_c#cddyy$)"477-d#dgk#kllyy(A-"477  .a  $a  dh  $h  i  i ..9d;++He<L M')$(JJ|$<M !,,H""8U3001I7TXT[T[^aTadkTkl001I7TXT[T[^aTadkTkl  62 7#8#8#D  dll3X&Y$TWWs]T%9::ww}t+H:: +844001I5RZ[))# 455C ! )$(M)s   <I 	I)I$$I)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 r<d|v r8|d   }|d   }t        d	t        |            D ]  }||   }	||	d	   k  s|	d
   c S  | j                  |dd
      S )NnoCoinr  r   r  noPoolIdpoolIdr   r   r   r   r   )r  r  r  )
r  r   r,  rN  r  configr   r   r  r  s
             r  calculate_rate_limiter_costz&tokocrypto.calculate_rate_limiter_cost	  s    6)9(##F"X-?*%%F"X-?*%%6!6(97OEY'G1c'l+ $
E!H$ 8O$   33r  )N)NN)>__name__
__module____qualname__r   r  r  r	   r  r   r
   r  rX  r   r  dictr   r  r-  r   rO  r   r   rU  r$  r[  r^  r  rc  rp  r   rv  ru  r   r  r   r  r  r   r   floatr   r  r  r  r  r  r  r  r   r  r   r  r  r  r   r'  r   rR  intrg  rm  __classcell__)r  s   @r  r0   r0   &   s<   T
# T
lD !# 8s 8( $& Z$v, Zx :>b 8s 83 8Y 8tJ Jv J JX 6:UW cA3 cAs cA# cA\`af\g cAJQ4 Q Q6 Qf 04B 5W 57 5
 02 33 3f 3* 26b 5w 5*
 *
4 *
X 26DW[df 3H# 3Hc 3HQT 3Hkoptku 3Hj $& +E( +EZ)&: :(S Sv S Sj: gksu ]23 ]2i ]2y ]2RW ]2`c ]2~ 26b 0*c 0*3 0*d *.Dt\^ B?3 B?c B? B?cghmcn B?H /3TXac U U3 Uc Uhlmrhs U 154VZce U# US UPS Ujnotju U 37r +*s +*C +*Z -1tRV_a 7?c 7? 7?C 7?r 79 4
# 4
^ 4
l *.Dt\^ 7I3 7Ic 7I 7Icghsct 7Ir -1tRV_a 4Lc 4L 4LC 4Lfjkvfw 4Ll:&i
T i
X i
Q\ i
V DHPR *:S *:% *:# *:Wb *:X &eBSW 2Ph9# 9s 9 9c 9TX 9`c 9v MO 4r  r0   )6ccxt.base.exchanger   ccxt.abstract.tokocryptor   rL  rY  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   rW  r  r  <module>r|     s    ( 0   q  q  q  q  q  * 0 - - . ' & 1 . ) * 5 - ) + . 1 * ) + ( 3 4 %w&4; w&4r  