
    !:hL                    P   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ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,  G d dee      Z-y)    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)OrderImmediatelyFillable)RateLimitExceeded)OnMaintenance)InvalidNonce)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee   fdZdefdZdddi fde	de
de
dee   fd	ZdCd
ededefdZdddi fde	de
de
fdZdefdZi fdefdZdi fdede
defdZdCdededefdZi f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dCdededefdZd Z dCdede!fdZ"dddi fdede
de
dee!   fdZ#dCd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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ede-fd)Z.dCdede/fd*Z0i fdede/fd+Z1di fd,edee/   fd-Z2i fded$e)d.ed/ede3f
d0Z4dCd1edede3fd2Z5d3e	de	fd4Z6di fded$e)d5ede7fd6Z8dCd7edede7fd8Z9d9d:i ddfd;Z:d<e;d=ed>ed?ed@edAefdBZ< xZ=S )Dzondareturnc           (      f   | j                  t        t        |          dddg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	d/dd0d	d1d	d2d	d3d	d4d	d5d	d6d	d7d	d8dd9d	i d:d	d;d	d<d	d=dd>dd?d	d@d	dAd	dBddCd	dDd	dEddFd	dGd	dHd	dId	dJd	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`dadbdcdddedfdgdhdidjdkdldmdndodpdqdqdrdsdtgdudvdwdxg dyidzg d{idxg d|ig d}g d~ddgdgddr| j	                  d      | j	                  d      dd	d| j	                  d      | j	                  d      dd| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      ggdddi idddg ddd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 ddd	dd d	dd	d	d	dd d dd idĜ	d d dŜd d dŜdƜt
        i dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        t        t        t        t        t         t        t"        t        t        t        t"        t        d؜ddidۜ      S )Nr)   ZondaEE  CORSTspotmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChainfetchOrderBookfetchOrderBooksfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalfetchWithdrawalsreduceMargin)repayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdraw6018030090018003600720014400216004320086400259200604800)1m3m5m15m30m1h2h4h6h12h1d3d1wzzondacrypto.exchangez-https://auth.zondaglobal.com/ref/jHlbB4mIkdS1zdhttps://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpgzhttps://zondaglobal.comzhttps://{hostname}/API/Publicz-https://{hostname}/API/Trading/tradingApi.phpzhttps://api.{hostname}/rest)publicprivatev1_01Publicv1_01Privatez"https://docs.zondacrypto.exchange/z https://github.com/BitBayNet/APIz2https://zondaglobal.com/en/helpdesk/zonda-exchangez1https://zondaglobal.com/legal/zonda-exchange/fees)referrallogowwwapidocsupportfeesget)z{id}/allz{id}/marketz{id}/orderbookz{id}/tickerz{id}/tradespost)	infotradecancel	orderbookordersr   r   historytransactions)ztrading/tickerztrading/ticker/{symbol}ztrading/statsztrading/stats/{symbol}ztrading/orderbook/{symbol}ztrading/transactions/{symbol}z,trading/candle/history/{symbol}/{resolution})z&api_payments/deposits/crypto/addresseszpayments/withdrawal/{detailId}zpayments/deposit/{detailId}ztrading/offerztrading/stop/offertrading/config/{symbol}ztrading/history/transactionszbalances/BITBAY/historybalances/BITBAY/balancez#fiat_cantor/rate/{baseId}/{quoteId}zfiat_cantor/historyz>client_payments/v2/customer/crypto/{currency}/channels/depositzAclient_payments/v2/customer/crypto/{currency}/channels/withdrawalz.client_payments/v2/customer/crypto/deposit/feez1client_payments/v2/customer/crypto/withdrawal/fee)
ztrading/offer/{symbol}ztrading/stop/offer/{symbol}r   r   z7balances/BITBAY/balance/transfer/{source}/{destination}zfiat_cantor/exchangezapi_payments/withdrawals/cryptozapi_payments/withdrawals/fiatz*client_payments/v2/customer/crypto/depositz-client_payments/v2/customer/crypto/withdrawalz*trading/offer/{symbol}/{id}/{side}/{price}z/trading/stop/offer/{symbol}/{id}/{side}/{price}zbalances/BITBAY/balance/{id})r   r   deleteputz0.0z0.001)makertaker
percentage	tierBasedz0.0030z0.00430z0.00421250z0.00413750z0.00407500z0.003910000z0.003815000z0.003720000z0.003625000z0.003537500z0.003450000z0.003375000z0.0032100000z0.0031150000200000z0.0029250000z0.0028375000z0.0027500000z0.0026625000z0.0025875000z0.0024z0.0023z0.0022z0.0021z0.0020z0.0019z0.0018z0.0017)r   r   )r   r   r   r   tiersr   )tradingfiatfunding!v1_01PublicGetTradingTickerSymbolv1_01PublicGetTradingTicker)EURUSDGBPPLNfillResponseFromRequest)fetchTickerMethodfetchTickersMethodfiatCurrenciesr   )IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r   limitdaysBack	untilDayssymbolRequiredd   )r   r   triggerr   r   r   )	sandboxr<   createOrdersre   
fetchOrderrj   fetchOrdersfetchClosedOrdersrf   )linearinverse)r0   r2   r3   400401402403404405406408501502503504505506509510FUNDS_NOT_SUFFICIENT)"OFFER_FUNDS_NOT_EXCEEDING_MINIMUMSOFFER_NOT_FOUND&OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLEDACTION_LIMIT_EXCEEDEDUNDER_MAINTENANCEREQUEST_TIMESTAMP_TOO_OLDPERMISSIONS_NOT_SUFFICIENTINVALID_STOP_RATETIMEOUTRESPONSE_TIMEOUTACTION_BLOCKEDINVALID_HASH_SIGNATUREGGCzGlobal Game Coin)idname	countries	rateLimithas
timeframeshostnameurlsr   r   optionsfeaturesprecisionMode
exceptionscommonCurrencies)deep_extendsuperr)   describeparse_numberr&   r   r    r   r   r%   r   r   r!   r"   r#   r$   r   )self	__class__s    D/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/zonda.pyr0  zzonda.describe   s   eT ; =^^^ %^ 	^
 %^ %^ U^ "5^ t^ ^ $U^  ^ '^ t^ (^  !^" &u#^$ "5%^& +E'^( )%)^* #E+^, ,U-^. '/^0 (1^2 3^4 &t5^6 (7^8 1%9^:  ;^< &u=^> '?^@ (A^B #EC^D *5E^F $UG^H uI^J "5K^L *5M^N +EO^P )%Q^R tS^T  U^V !%W^X %eY^Z $U[^\ /]^^ "5_^` #Ea^b +Ec^d e^f !%g^h "5i^j &uk^l +Em^n  o^p dq^r $Us^t +Eu^v !%w^x "4y^z u{^| #E}^~ !$^@ "5A^B  C^D $UE^F !%G^H %eI^J )%K^L )%M^N tO^P Q^R US^T tU^V "5W^X #EY^Z &u[^\ ']^^ $T_^`  a^b (c^d )%e^f "5g^h #Di^j k^l %*',$"!&#(  {^@  /K~0=N#@$A	 96 PK&    
  
 " EI
 7E%!EHV "..u5!..w7"&!&	 "..x8!..x8"&!% "..x8$:K:KC:PQ!..x8$:K:KF:ST!..x8$:K:KF:ST!..x8$:K:KF:ST!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV'", "..x8$:K:KC:PQ!..x8$:K:KF:ST!..x8$:K:KF:ST!..x8$:K:KF:ST!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KG:TU!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV'"-+1f s<| &I&C">-t	  %&+(,,1,0).+06:#'#'"&#(	( #($)$)+/27/4#()$, %)&+!%$*%+*/& #'&+!$#($)*/( $()-#U-^ ##
 ##g7p ' } |  |  |	 
 |  |  (  |  *  *  |  }  *  ' " }# $ y% & '(9' ( 7C#0:R):%2-9.>%1($1"2*=? D )![p@
 p p	    c                     | j                  |      }| j                  |di       }t        |j                               }| j	                  |      S )a  

        https://docs.zondacrypto.exchange/reference/ticker-1

        retrieves data on all markets for zonda
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        items)r   
safe_valuelistvaluesparse_markets)r2  paramsresponser7  marketss        r4  fetch_marketszzonda.fetch_markets  sI     33F;( '26u||~&!!'**r5  c                    | j                  |di       }| j                  |d      }| j                  |di       }| j                  |di       }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }	| j                  | j                  di       }
| j                  | j                  dg       }| j                  ||      s| j                  |	|      r| j                  | j                  di       }
i d	|d
|dz   |	z   d|d|	dd d|d|dd dddddddddddddd dddd d | j                  |
d      | j                  |
d      d d d d d | j                  | j                  | j                  |d                  | j                  | j                  | j                  |d                  d d d d!| j                  |d"      d d!d d d!d d d!d#d |d$S )%Nmarketcodefirstsecondcurrencyr   r   r   r!  symbol/basequotesettlebaseIdquoteIdsettleIdtyper0   Tr1   Fr2   r3   r4   activecontractr  r   r   scale)amountprice)minmaxminOffer)r   rR  rS  cost)r  r   r   contractSizeexpiryexpiryDatetime
optionTypestrike	precisionlimitscreatedr   )	r8  safe_stringsafe_currency_coder   r)  in_arraysafe_numberr1  parse_precision)r2  itemrA  r!  rC  rD  rK  rL  rH  rI  r   r   s               r4  parse_marketzzonda.parse_market  s   x4ff-426!!%4""6:6&&v.''0tyy)R87GL==~.$--~2V??499fb9D2
"2
dSj5(2
 D2
 U	2

 d2
 f2
 w2
 2
 F2
 D2
 e2
 E2
 e2
 e2
 d2
  !2
" d#2
$ %%dG4%%dG4 "++D,@,@AQAQRWY`Aa,bc**4+?+?@P@PQWY`@a+bc  
  ++E:>
  
  $ c2
 2	
r5  NrF  sincer   c                     | j                          i }| j                  | j                  ||            }| j                  |dg       }| j	                  |d||ddi      S )a  

        https://docs.zondacrypto.exchange/reference/active-orders

        fetch all unfilled currently open orders
        :param str symbol: not used by zonda fetchOpenOrders
        :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>`
        r7  Nstatusopen)load_marketsv1_01PrivateGetTradingOfferextend	safe_listparse_orders)r2  rF  rg  r   r<  requestr=  r7  s           r4  fetch_open_orderszzonda.fetch_open_orders  s`     	33DKK4PQx"5  eUXv<NOOr5  orderrA  c                    | j                  |d      }| j                  ||d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j	                  i d| j                  |d      dd d	|d
|d| j                  |      dd dd d|d| j                  |d      dd d|d| j                  |d      d| j                  |d      dd d|dd dd |d d d d|      S )NrA  -timestartAmountcurrentAmountpostOnlyr!  clientOrderIdr   	timestampdatetimelastTradeTimestampri  rF  rN  moder   side	offerTyperS  rater   rR  rW  filled)	remainingaveragefeetrades)r`  safe_symbolsafe_integerr8  
safe_orderiso8601safe_string_lower)	r2  rr  rA  marketIdrF  rz  rR  r  rx  s	            r4  parse_orderzzonda.parse_order  s   4 ##E84!!(FC8%%eV4	!!%7$$UO<	??5*5  
$""5$/ 
T 
 E 
 	 

 Y/ 
 !$ 
 d 
 f 
 D$$UF3 
 4 
  
 D**5+> 
 T%%eV4 
 D 
 f 
  D! 
" d# 
$ #+ 
, - 	r5  c                 Z   | j                          i }|r(| j                  |      g}| j                  |      }||d<   d| j                  | j	                  ||            i}| j                  |      }| j                  |d      }	| j                  |	d||      }
||
S | j                  |
|      S )a  

        https://docs.zondacrypto.exchange/reference/transactions-history

        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>`
        r>  queryr7  N)	rk  	market_idrF  jsonrm  )v1_01PrivateGetTradingHistoryTransactionsr8  parse_tradesfilter_by_symbol)r2  rF  rg  r   r<  rp  r>  r  r=  r7  results              r4  fetch_my_tradeszzonda.fetch_my_trades?  s     	~~f-.G[[(F!(GI		$++gv*F GHAA%H* '2""5$u=>M$$VV44r5  c                    | j                  |d      }|*t        | j                  dz   | j                  |      z         d|i}t	        dt        |            D ]i  }||   }| j                  |d      }| j                  |      }| j                         }| j                  |d      |d<   | j                  |d      |d	<   |||<   k | j                  |      S )
Nbalancesz empty balance response r   r   rE  lockedFundsusedavailableFundsfree)
r8  r   r!  r  rangelenr`  ra  accountsafe_balance)	r2  r=  r  r  ibalance
currencyIdrB  r  s	            r4  parse_balancezzonda.parse_balancem  s    ??8Z8*D DtyyQYGZ Z[[)q#h-( 	#AqkG))':>J**:6DllnG"..wFGFO"..w8HIGFO"F4L	#   ((r5  c                 f    | j                          | j                  |      }| j                  |      S )ag  

        https://docs.zondacrypto.exchange/reference/list-of-wallets

        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
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )rk  $v1_01PrivateGetBalancesBITBAYBalancer  )r2  r<  r=  s      r4  fetch_balancezzonda.fetch_balance|  s1     	<<VD!!(++r5  c           	         | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |dg       }| j	                  |dg       }| j                  |d      }	|d   | j                  |dd      | j                  |dd      |	| j                  |	      | j                  |d      d	S )
a5  

        https://docs.zondacrypto.exchange/reference/orderbook-2

        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
        rF  r!  buysellrz  racaseqNo)rF  bidsasksrz  r{  nonce)rk  rA  $v1_01PublicGetTradingOrderbookSymbolrm  r8  r  parse_bids_asksr  )
r2  rF  r   r<  rA  rp  r=  rawBidsrawAsksrz  s
             r4  fetch_order_bookzzonda.fetch_order_book  s     	V$fTl
 <<T[[RX=YZ$ //(E26//(FB7%%h<	X&(($=(($="Y/&&x9
 	
r5  tickerc                 l   | j                  |d      }| j                  |dd      }| j                  ||      }| j                  |d      }| j                  |d      }| j	                  i d| j                  ||      d|d| j                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      dd d| j                  |d      dd dd d| j                  |d      d|d|d| j                  |d      dd dd dd | j                  |d      d |d|      S )NrA  rB  mru  r  rF  rz  r{  highhlowlbid
highestBid	bidVolumeask	lowestAsk	askVolumevwaprj  r24hcloselastpreviousClosepreviousRatechanger   r  v)
baseVolumequoteVolumer   )	r8  safe_string_2safe_marketr  safe_tickerr  r  r`  rc  )r2  r  rA  tickerMarketr  rz  r  s          r4  parse_tickerzzonda.parse_ticker  s   L vx8%%lFC@!!(F3%%ff5	vv. !
d&&x8!
!
 Y/!
 D$$VS1	!

 4##FC0!
 4##FL9!
 !
 4##FK8!
 !
 D!
 D$$VV4!
 T!
 D!
 T__V^D!
 d!
  $!!
" t#!
$ **637)!
* + 	r5  c                    | j                          | j                  |      }d|d   i}d}| j                  | j                  d|      }| j	                  |dd|      }d}||k(  r"| j                  | j                  ||            }n?|dk(  r"| j                  | j                  ||            }nt        | j                  dz         | j                  |d	d
      }	| j                  |	|      S )a  
        v1_01PublicGetTradingTickerSymbol retrieves timestamp, datetime, bid, ask, close, last, previousClose, v1_01PublicGetTradingStatsSymbol retrieves high, low, volume and opening price of an asset

        https://docs.zondacrypto.exchange/reference/market-statistics

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.method]: v1_01PublicGetTradingTickerSymbol(default) or v1_01PublicGetTradingStatsSymbol
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        rF  r!  r   r   methodN v1_01PublicGetTradingStatsSymbolzo fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"r  stats)rk  rA  r`  r)  r  r   rm  r  r   r!  safe_value_2r  )
r2  rF  r<  rA  rp  r  defaultMethodr   r=  r  s
             r4  fetch_tickerzzonda.fetch_ticker  s    	V$fTl
 5((7JFS ..vxATVcd&==dkk'SY>Z[H: "DD<<T[[RX=YZH TWW  (Y  Y  Z  Z!!(Hg>  //r5  symbolsc                 `   | j                          d}| j                  | j                  d|      }| j                  |dd|      }d}||k(  r| j	                  |      }n/|dk(  r| j                  |      }nt        | j                  dz         | j                  |d      }| j                  ||      S )a  
 @ignore
        v1_01PublicGetTradingTicker retrieves timestamp, datetime, bid, ask, close, last, previousClose for each market, v1_01PublicGetTradingStats retrieves high, low, volume and opening price of each market

        https://docs.zondacrypto.exchange/reference/market-statistics

        :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
        :param str [params.method]: v1_01PublicGetTradingTicker(default) or v1_01PublicGetTradingStats
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   r   r  Nv1_01PublicGetTradingStatszd fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"r7  )
rk  r`  r)  r  r   r  r   r!  	safe_dictparse_tickers)r2  r  r<  r  r  r   r=  r7  s           r4  fetch_tickerszzonda.fetch_tickers>  s     	.((7KVT!//BVXef'77?H@  #??66v>H" TWW  (N  N  O  Ox1!!%11r5  rB  c                    g }|%| j                  |      }|j                  |d          d|i}|||d<   |||d<   | j                  ||      }| j                  d| j	                  |      i      }|d   }	| j                  |	d||      S )aZ  
        fetch the history of changes, actions done by the user or operations that altered the balance of the user

        https://docs.zondacrypto.exchange/reference/operations-history

        :param str [code]: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entries to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
        Nr!  balanceCurrenciesfromTimer   r  r7  )rE  appendrm  $v1_01PrivateGetBalancesBITBAYHistoryr  parse_ledger)
r2  rB  rg  r   r<  r  rE  rp  r=  r7  s
             r4  fetch_ledgerzzonda.fetch_ledger  s     }}T*H$$Xd^4!2
 "'GJ$GG++gv.<<gtyyQXGY=Z[!  eU;;r5  re  rE  c                    | j                  |d      }| j                  |di       }| j                  |d      }| j                  ||      }| j                  |di       }| j                  |d      }d}t	        j
                  |d      rd}t	        j                  |      }| j                  |d	i       }	| j                  |d
i       }
| j                  || j                  |d      |d | j                  |d      d | j                  | j                  |d            | j                  |      | j                  |      | j                  |	d      | j                  |
d      d|| j                  |      d d|      S )Nru  r  rE  r  totalinr   outfundsBefore
fundsAfter	historyIddetailIdrN  ok)r   r!  	directionr  referenceIdreferenceAccountrN  rE  rR  beforeafterri  rz  r{  r  )r  r8  r`  safe_currencyr'   	string_lt
string_negsafe_ledger_entryparse_ledger_entry_typera  r1  rc  r  )r2  re  rE  rz  r  r  r  rR  r  r  r  s              r4  parse_ledger_entryzzonda.parse_ledger_entry  sv   X %%dF3	//$	26%%gz:
%%j(;x4!!&'2	VS)I''/F oodM2>__T<<
%%""45"++D*= $001A1A$1OP//
;''/&&{G<%%j':"Y/'
  ! 	r5  c                 J    ddddddddddddddd}| j                  |||      S )Ntransactionr  r   )	ADD_FUNDSBITCOIN_GOLD_FORKCREATE_BALANCEFUNDS_MIGRATIONWITHDRAWAL_LOCK_FUNDSWITHDRAWAL_SUBTRACT_FUNDSWITHDRAWAL_UNLOCK_FUNDSTRANSACTION_COMMISSION_OUTCOMETRANSACTION_COMMISSION_RETURN TRANSACTION_OFFER_ABORTED_RETURN"TRANSACTION_OFFER_COMPLETED_RETURNTRANSACTION_POST_INCOMETRANSACTION_POST_OUTCOMETRANSACTION_PRE_LOCKINGr`  )r2  rN  typess      r4  r  zzonda.parse_ledger_entry_type  sJ    &!.+,%2)6'4.3-20729'.(/'.
  tT22r5  c           	          | j                  |di       }| j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )N   r   or  r  cr  )r8  r  rc  )r2  ohlcvrA  rC  s       r4  parse_ohlcvzzonda.parse_ohlcv  s     q"-eQ'UC(UC(UC(UC(UC(
 	
r5  r   c                    | j                          | j                  |      }|d   dz   |d   z   }|| j                  | j                  ||      d}|d}nt	        |d      }| j                  |      }	||	z  dz  }
|| j                         |d<   |d   |
z
  |d	<   n||d	<   | j                  |d	   |
      |d<   | j                  | j                  ||            }| j                  |d
g       }| j                  |||||      S )a  

        https://docs.zondacrypto.exchange/reference/candles-chart

        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
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        rK  rt  rL  )rF  
resolutionr   i*  r.   tofromr7  )rk  rA  r`  r&  rT  parse_timeframemillisecondssum2v1_01PublicGetTradingCandleHistorySymbolResolutionrm  rn  parse_ohlcvs)r2  rF  	timeframerg  r   r<  rA  tradingSymbolrp  duration	timeranger=  r7  s                r4  fetch_ohlcvzzonda.fetch_ohlcv  s"    	V$x(3.	1BB#**4??IyQ
 =Eu%E''	2H$t+	= --/GDM%dmi7GFO#GFO HHWV_i@GDMJJ4;;W^`fKgh x"5  	5%HHr5  r   c                 0   | j                  |dd      }| j                  |dd      }| j                  |d      }d }||rdnd}| j                  |dd	      }| j                  |d
d      }| j	                  |d      }	| j	                  |d      }
| j                  |
|d      }|d   }d }|	|dk(  r|d   n|d   }||	d}| j	                  |d      }d }||rdnd}| j                  | j	                  |d      ||| j                  |      |||||d |||d|      S )Nru  t
userActiontywasTakerr   r   r  rrR  acommissionValuerA  rt  rF  r  rH  rI  )rE  rW  offerIdr   r!  )r!  rr  rz  r{  rF  rN  r~  rS  rR  rW  takerOrMakerr  r   )safe_integer_2safe_string_lower_2r8  r  r`  r  
safe_trader  )r2  r   rA  rz  r~  r#  r(  priceStringamountStringfeeCostStringr  rF  r  feeCurrencyrr  rN  s                   r4  parse_tradezzonda.parse_trade)  si   D ''vs;	''|TB??5*5 &.7GL((<))%3?((0AB##E84!!(FC8!$-1U]&.K'%C   	2#7D""5$/"Y/ "( 
  	r5  c                    | j                          | j                  |      }|d   dz   |d   z   }d|i}||dz
  |d<   |||d<   | j                  | j                  ||            }| j	                  |d      }	| j                  |	|||      S )	a%  

        https://docs.zondacrypto.exchange/reference/last-transactions

        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>`
        rK  rt  rL  rF  r  r  r   r7  )rk  rA  'v1_01PublicGetTradingTransactionsSymbolrm  rn  r  )
r2  rF  rg  r   r<  rA  r  rp  r=  r7  s
             r4  fetch_tradeszzonda.fetch_tradess  s     	V$x(3.	1BBm
 "'!)GJ$GG??GU[@\]x1  u==r5  rN  r~  rR  rS  c                    | j                          | j                  |      }|d   dz   |d   z   }t        | j                  ||            }||j	                         |d}	| j                  |dd      }
|
du}|dk(  }|d	k(  }|d
k(  xs |xr |}|dk(  xs |xr |}|xs |}|s|r| j                  ||      |	d<   |rd
nd|	d<   n&|s|r
|rdnd	|	d<   nt        | j                  dz         | j                  |ddg      }d}|rQ|st        | j                  dz         | j                  ||
      |	d<   | j                  | j                  |	|            }n!| j                  | j                  |	|            }| j                  |dd      }| j                  |dd      }|rdnd}| j                  |d      }| j!                  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i      S )*a  
        create a trade order

        https://docs.zondacrypto.exchange/reference/new-order

        :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
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        rK  rt  rL  )rF  r  rR  	stopPricer   Nr   rA  z
stop-limitzstop-marketr  r}  z createOrder() invalid typez[ createOrder() zonda requires `triggerPrice` parameter for stop-limit or stop-market ordersstopRater'  stopOfferId	completedFclosedrj  r   r!  r   rz  r{  r|  ri  rF  rN  r~  rS  rR  rW  r  r  r  r  r  ry  )rk  rA  floatamount_to_precisionupperr  price_to_precisionr   r!  omit&v1_01PrivatePostTradingStopOfferSymbolrm  "v1_01PrivatePostTradingOfferSymbolr  	safe_boolr8  r  )r2  rF  rN  r~  rR  rS  r<  rA  r  rp  r   isStopLossPriceisLimitOrderisMarketOrderisStopLimitisStopMarketisStopOrderr=  r!  r8  ri  r   s                         r4  create_orderzzonda.create_order  s    	V$x(3.	1BBt//?@#

 ))&+O't3w(|+R1Q/},S1R?!1\;"55feDGFO.9lwGFOl/;mGFO*G GHH6K#AB"#DGG  /L  %L  M  M"&"9"9&-"PGJBB4;;wX^C_`H>>t{{7TZ?[\Hn )]CNN8[%@	&Fx@  
" 
H 
  
 	 

 !$ 
 f 
 f 
 D 
 D 
 U 
 f 
 D 
 d 
  
 t 
  4! 
" l# 
$ T% 
  	r5  r!  c                    | j                  |d      }|t        | j                  dz         | j                  |d      }|t        | j                  dz         | j	                          | j                  |      }|d   dz   |d   z   }||||d}| j                  | j                  ||            }	| j                  |	      S )	a  

        https://docs.zondacrypto.exchange/reference/cancel-order

        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~  z; cancelOrder() requires a `side` parameter("buy" or "sell")rS  z< cancelOrder() requires a `price` parameter(float or string)rK  rt  rL  )rF  r!  r~  rS  )	r`  r   r!  r8  rk  rA  /v1_01PrivateDeleteTradingOfferSymbolIdSidePricerm  r  )
r2  r!  rF  r<  r~  rS  rA  r  rp  r=  s
             r4  cancel_orderzzonda.cancel_order
  s     /<*g ghh0=*h hiiV$x(3.	1BB#	
 GGT[]cHde ))r5  c                 4    dddd}| j                  ||d      S )NT)r   r   r   F)rA  )r2  rE  r   s      r4  is_fiatzzonda.is_fiat)  s'     

 ~~nh>>r5  c                     | j                  |d      }| j                  |d      }| j                  |       || j                  ||      d || j                  |d      dS )NrE  addresstag)r   rE  networkrO  rP  )r`  check_addressra  )r2  depositAddressrE  r  rO  s        r4  parse_deposit_addresszzonda.parse_deposit_address1  si     %%njA
"">9=7#"//
HE##NE:
 	
r5  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |d      }| j                  |d      }| j                  ||      S )a  

        https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto

        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
        :param str [params.walletId]: Wallet id to filter deposit adresses.
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        rE  r!  datar   )rk  rE  1v1_01PrivateGetApiPaymentsDepositsCryptoAddressesrm  r8  r  rT  )r2  rB  r<  rE  rp  r=  rV  rC  s           r4  fetch_deposit_addresszzonda.fetch_deposit_addressF  s     	==&
 II$++V]_eJfg x0tQ'))%::r5  codesc                     | j                          | j                  |      }| j                  |d      }| j                  ||      S )a  

        https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto

        fetch deposit addresses for multiple currencies and chain types
        :param str[]|None codes: zonda does not support filtering filtering by multiple codes and will ignore self parameter.
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
        rV  )rk  rW  rn  parse_deposit_addresses)r2  rY  r<  r=  rV  s        r4  fetch_deposit_addresseszzonda.fetch_deposit_addressesh  sE     	II&Q ~~h/++D%88r5  fromAccount	toAccountc                 J   | j                          | j                  |      }|||| j                  ||      d}| j                  | j	                  ||            }| j                  ||      }	| j                  | j                  di       }
| j                  |
dd      }|r||	d<   |	S )a  

        https://docs.zondacrypto.exchange/reference/internal-transfer

        transfer currency internally between wallets on the same account
        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        )sourcedestinationrE  fundsr   r   TrR  )	rk  rE  currency_to_precision>v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestinationrm  parse_transferr8  r)  rA  )r2  rB  rR  r]  r^  r<  rE  rp  r=  r   transferOptionsr   s               r4  r   zzonda.transfer  s     	==&!$//f=	
 VVW[WbWbcjlrWst: &&x://$,,
BG"&..B[]a"b"!'HXr5  r   c                 4   | j                  |d      }| j                  |di       }| j                  |d      }| j                  |di       }| j                  |d      }| j                  |d      }|d d d | j                  ||      d ||| j                  |      d	S )Nri  r  r!  r  rE  )	r   r!  rz  r{  rE  rR  r]  r^  ri  )r`  r8  ra  parse_transfer_status)	r2  r   rE  ri  r]  fromIdr  toIdr  s	            r4  re  zzonda.parse_transfer  s    : !!(H5ooh;!!+t4__XtR0D)%%k:>
//
HE!008

 
	
r5  ri  c                 2    ddd}| j                  |||      S )Nr  failed)OkFailr	  )r2  ri  statusess      r4  rh  zzonda.parse_transfer_status  s&    
 &&99r5  rO  c                    | j                  ||      \  }}| j                  |       | j                          d}| j                  |      }|d   ||d}| j	                  |      r"| j                  | j                  ||            }n(|||d<   | j                  | j                  ||            }| j                  |d      }	| j                  |	|      S )a  

        https://docs.zondacrypto.exchange/reference/crypto-withdrawal-1

        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>`
        Nr!  )rE  rR  rO  rP  rV  )
handle_withdraw_tag_and_paramsrR  rk  rE  rM  *v1_01PrivatePostApiPaymentsWithdrawalsFiatrm  ,v1_01PrivatePostApiPaymentsWithdrawalsCryptor  parse_transaction)
r2  rB  rR  rO  rP  r<  r=  rE  rp  rV  s
             r4  r   zzonda.withdraw  s     99#vFV7#==& 
 <<FFt{{SZ\bGcdH!$HHU\^dIefH ~~h/%%dH55r5  r  c                     | j                  d |      }i d| j                  |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S )Nr!  txidrz  r{  rQ  addressFromrO  	addressTorR  rN  rE  rB  ri  updatedtagFromrP  tagTocomment)internalr  r   )r  r`  )r2  r  rE  s      r4  rt  zzonda.parse_transaction  s
    %%dH5
$"";5
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 	
r5  r   GETc           	      <   | j                  | j                  d   |         }|dk(  rX| j                  || j                  |            }|d| j	                  ||      z   dz   z  }|r1|d| j                  |      z   z  }n|dk(  rU| j                  || j                  |            }|d| j	                  ||      z   z  }|r|d| j                  |      z   z  }n|dk(  r| j                          | j                  || j                  |            }|d| j	                  ||      z   z  }t        | j                               }	d }
|dk7  r)|r|d| j                  |      z   z  }| j                  |	z   }
n%|#| j                  |      }| j                  |	z   |z   }
|	| j                         | j                  | j                  | j                  |
      | j                  | j                        t        j                         d	d
}n| j                          | j                  | j#                  || j%                         d|            }d| j                  | j                  | j                  |      | j                  | j                        t        j                         d}||||dS )Nr   r   rG  z.json?r   r   POSTzapplication/json)zRequest-TimestampzOperation-IdAPI-KeyAPI-HashContent-Type)r  momentz!application/x-www-form-urlencoded)r  r  r  )urlr  bodyheaders)implode_hostnamer(  r>  extract_paramsimplode_params	urlencodecheck_required_credentialsstrr  apiKeyr  uuidhmacencodesecrethashlibsha512rm  r  )r2  pathr   r  r<  r  r  r  r  r  payloads              r4  signz
zonda.sign=  sk   ##DIIe$4S$9:(?IIfd&9&9$&?@E3,,T6::WDDCsT^^E222M!IIfd&9&9$&?@E3,,T6:::CsT^^E222N"++-IIfd&9&9$&?@E3,,T6:::C))+,EG3!666C++-yy'++-4%* $		;; IIdkk'&:DKK<TV]VdVde 2G ++->>$++**,/ # D
 !D;; IIdkk$&7T[[9QSZSaSabG
 fdwOOr5  httpCodereasonr  r  r  r  c
                    |y d|v rL| j                  |d      }
| j                  dz   |z   }| j                  | j                  |
|       t	        |      d|v r| j                  |d      }|dk(  rk| j                  |d      }| j                  dz   |z   }t        dt        |            D ]$  }||   }| j                  | j                  ||       & t	        |      y )NrB   ri  rn  errorsr   )r`  r!  throw_exactly_matched_exceptionr,  r   r8  r  r  )r2  r  r  r  r  r  r  r=  requestHeadersrequestBodyrB  feedbackri  r  r  errors                   r4  handle_errorszzonda.handle_errorsj  s    X4 ##Hf5Dww}t+H00$Q))! %%h9F8<77S=4/q#f+. [A"1IE88%QYZ[ $H--r5  )N)>__name__
__module____qualname__r   r0  r   r   r?  rf  r   r	   r   rq  dictr  r  r   r  r  r  r   r  r   r  r  r   r   r  r
   r  r   r  r  r9  r  r  r   r0  r3  r   r   r:  r   rH  rK  boolrM  r   rT  rX  r\  r   r   re  rh  r   r   rt  r  intr  __classcell__)r3  s   @r4  r)   r)      s   q# qf $& +$v, +B@
F @
D /3TXac P P3 Pc Phlmrhs P&6 6v 6 6p -1tRV_a ,5c ,5 ,5C ,5\) ) $& ,( , :>b ,
s ,
3 ,
Y ,
\@4 @ @6 @D 02 C03 C0J 04B F2W F27 F2P (,$TZ\ < <C <s <aefqar <8jt jx j; jX	3&
 
4 
0 26DW[df .I# .Ic .IQT .Ikoptku .I`H Hv H HT 6:UW >3 >s ># >\`af\g >4 gksu {3 {i {y {RW {`c {z 37r *s *C *>? ? ?
h 
R` 
* 79  ;#  ;^  ;D 8<B 9W 94P^K_ 98 [] 7S 7% 7c 7c 7an 7r-
t -
x -
= -
^:C :C : DHPR (6S (6% (6# (6Wb (6T
T 
X 
Q\ 
@ &eBSW +PZ-c -3 -S -# -X\ -dg -r5  r)   ).ccxt.base.exchanger   ccxt.abstract.zondar   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   ccxt.base.decimal_to_precisionr&   ccxt.base.preciser'   r)    r5  r4  <module>r     st    ( +  M  M  M  M  M  M  * 0 - - ' & . ) * 5 . * ) 4 %{Hk {r5  