
    eiq:                    H   d dl mZ d dlmZ d dl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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,  G d dee          Z-dS )    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesIntLeverage	LeveragesMarginModificationMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTradingFees)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)RateLimitExceeded)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdZi fdefdZi fdee	         fdZ
i fdefdZi fdedefdZi fdefd	Zd
i fdededefdZi f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
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fdZdDde de	defdZ!i fde"fdZ#d
i fdede$de%de&de'f
dZ(d
i fd Z)d
i fdedefd!Z*d
i fd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.dDd%e de	de,fd&Z/d
i fdede%de,fd'Z0d
i fdede1fd(Z2i fdede3fd)Z4d
i fd*e5defd+Z6d
i fdefd,Z7i fdede&de8fd-Z9i fdede&de8fd.Z:i fdee	         fd/Z;i fdee	         fd0Z<de"fd1Z=dDd2e de	fd3Z>dDd*e de	de3fd4Z?dDd5e de	defd6Z@dDd7e de	defd8ZAdDde	de8fd9ZBd:d;i d
d
fd<ZCd=e5d>ed?ed@edAe dBefdCZD xZES )Ezebpayreturnc                    |                      t          t          |                                           i ddddddg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d(dd)dd*dd+dd,dd-dd.dd/dd0dd1ddddddddddddd2d3d4d5d6d7d8d9d:d;d<d=d>
d?d@dAdBdCdDdEdCdFdGdHdIdJdKdLdLdLdLdLdLdLdLdLdLdM
idLdLdLdLdLdLdLdLdNdOdLidPdCdQdLidLdLdLdLdLdRdLdLdLdSdTdLdLdLdLdLdLdLdUdLdLdLdLdLdLdVdWdLidXdCdYdZt          d[i d\i d]ddd^d_d`ddgiddadbdcd/dddeiiidft
          t          t          t          t          t          t          t          t          t
          t
          t          t          t          t          dgdht
          idii          S )jNidr'   nameZebpay	countriesIN	rateLimit2   versionv1	certifiedFprohasCORSspotTmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrdersclosePositioncreateOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeveragesfetchMarketsfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrder)fetchOrderBookfetchOrderTradesfetchPositionsfetchTickerfetchTickersfetchTradesfetchTradingFeereduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage
timeframes            <   x   i  i  i  i`'  )
1m5m15m30m1h2h4h12h1d1wurlszOhttps://github.com/user-attachments/assets/8094e7be-55a7-46f4-a087-0ca31b48ecadzhttps://sapi.zebpay.comzhttps://futuresbe.zebpay.com)r7   r9   zhttps://www.zebstage.comz"https://dev-futuresbe.zebstage.comzhttps://www.zebpay.comz/https://github.com/zebpay/zebpay-api-referencesz&https://zebpay.com/in/features/pricing)logoapitestwwwdocfeesrv   get
   )
zv2/system/timezv2/system/statuszv2/market/orderbookzv2/market/tradeszv2/market/tickerzv2/market/allTickerszv2/ex/exchangeInfozv2/ex/currencieszv2/market/klineszv2/ex/tradefees)zv1/system/timezv1/system/statuszv1/exchange/tradefeezv1/exchange/tradefeeszv1/market/orderBookzv1/market/ticker24Hrzv1/market/marketszv1/market/aggTradezv1/market/klines)r{   postv2/ex/orders)r~   zv2/account/balancezv2/ex/tradefeev2/ex/orderzv2/ex/order/fills)r   r~   zv2/ex/orders/cancelAll)r}   r{   delete)zv1/wallet/balancev1/trade/orderzv1/trade/order/open-orderszv1/trade/userLeverageszv1/trade/userLeveragezv1/trade/positionszv1/trade/history)r   zv1/trade/order/addTPSLzv1/trade/addMarginzv1/trade/reduceMarginzv1/trade/position/closezv1/trade/update/userLeverager   )r{   r}   r   )publicprivateprecisionModerz   commonCurrenciesrequiredCredentials)apiKeysecretoptionstypes)rS   defaultTypefeaturesdefaultlimitd   
exceptions)774004014034044295005033013zOrder quantity is out of rangezInvalid trade order typezInsufficient marginzinsufficient balancezleverage must be in [1,8]zthe request you sent is invalidr   )exactbroad)deep_extendsuperr'   describer$   r   r   r   r!   r"   r#   r    r   )self	__class__s    W/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/zebpay.pyr   zzebpay.describe   sB   fd 3 3 < < > > FA
(FA
HFA
 $FA
 	FA

 tFA
 FA
 5FA
  ... %. 	.
 %. $. T. $U. '. . "4. t. .  . t.  !." &u#. .$ "5%.& +E'.( )%).* #E+., ,U-.. '/.0 (1.2 "43.4 *55.6 +E7.8  9.: !$;.< =.>  ?.@ dA.B "4C.D dE. .F #'$("&# $##' $$)',#[. . .FA
n  oFA
F i5: 
 7@  0H@ GFA
b  .00235020246240202/1     /102465735461324	  	  /!  D +B! -/24.0+-13    ,.,.68# # & 24.0:<68572402    /168245779<>! ! -b#% %( (AI IcFA
v YwFA
x ByFA
z  !{FA
~ "$ $FA
F ff-!  &	 GFA
R  #SFA
` &%.'',//)6B0<+<,=1;7A $ #L% aFA
 FA
 F F F	    c                 4  K   d}|                      dd|          \  }}|dk    }d}i }|r|                     |           d{V }|}n2|                     |           d{V }|                     |di           }|                     |dd          }|ddd|dS )a  
        the latest known information on the availability of the exchange API

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#system-status
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-status

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        NfetchStatusr7   datasystemStatusstatus)r   updatedetaurlinfo)handle_market_type_and_paramspublicSpotGetV2SystemStatuspublicSwapGetV1SystemStatus	safe_dictsafe_string_2)r   paramstypeisSpotresponser   r   s          r   fetch_statuszzebpay.fetch_status   s       99-vVVf&. 	8!==fEEEEEEEEHDD!==fEEEEEEEEH>>(FB77D ##D.(CC
 
 	
r   c                 &  K   d}|                      dd|          \  }}|dk    }d}i }|r|                     |           d{V }|}n2|                     |           d{V }|                     |di           }|                     |d          }|S )a,  
        fetches the current integer timestamp in milliseconds from the poloniexfutures server

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-server-time
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/system.md#get-system-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the poloniexfutures server
        N	fetchTimer7   r   	timestamp)r   publicSpotGetV2SystemTimepublicSwapGetV1SystemTimer   safe_integer)r   r   r   r   r   r   times          r   
fetch_timezzebpay.fetch_time  s       99+tVTTf&. 	8!;;FCCCCCCCCHDD!;;FCCCCCCCCH>>(FB77D   {33r   c                 j  K   g }|                      | j        d          }ddg}|                     |d|          }t          dt	          |                    D ]}||         }|dk    r)|                    |                     |                     9|dk    r)|                    |                     |                     ht          | j	        dz   |z   dz             t          j        |  d{V }|                     |dg           }	|                     |d	g           }
|                     |	|
          S )
a  
        retrieves data on all markets for zebpay

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-trading-pairs
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#fetch-markets

        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        rS   r7   r9   r   r   z+ fetchMarkets() self.options fetchMarkets "z " is not a supported market typeNrd   )r   r   	safe_listrangelenappendfetch_spot_marketsfetch_swap_marketsr   r*   asynciogatherarray_concat)r   r   promisesUnresolvedfetchMarketsOptionsdefaultMarketsr   ir   promisesspotMarketsfutureMarketss              r   fetch_marketszzebpay.fetch_markets2  s[       "nnT\>JJ &)2G^LLq#e**%% 	I 	IA8Dv~~"))$*A*A&*I*IJJJJ"))$*A*A&*I*IJJJJ#DG.[$[^b$b  fH  %H  I  I  I );<<<<<<<nnXq"55xB77  m<<<r   c                   K   |                      |           d{V }|                     |dg           }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |d          }	|                     |                     |                     |d                              }
|                     |dg           }i }d}d}d}d}d}t          dt          |                    D ]X}||         }|                     |d	          }|                     |          }| 	                    |d
          du }|r|n|}| 	                    |d          du }|r|n|}|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }|                     |d          }|||nt          j        ||          }||||o||||                     |          |
|                     |          dd|                     |          dddd	||<   Z|                     ||||	|o||||                     |          |
ddd|                     |          dd|                     |          ddd|d          ||<   |S )aY  
        fetches all available currencies on an exchange

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-coin-settings

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   r   currencyr+   	precisionchainsFchainIdisDepositEnabledTisWithdrawEnabledwithdrawalFeewithdrawalMinSizedepositMinSizeminmax)withdrawdeposit)	r   r*   networkactiver   r   feer   limits)amountr   r   )r   coder*   r+   r   r   r   r   r   r   networks)publicSpotGetV2ExCurrenciesr   r   r   safe_stringsafe_currency_codeparse_numberparse_precisionnetwork_id_to_code	safe_boolr%   
string_minsafe_currency_structure)r   r   r   rowsresultr   r   
currencyIdr   r+   r   r   r   minWithdrawFeeStringminWithdrawStringminDepositStringr   r   jchain	networkIdnetworkCodedepositAllowedwithdrawAllowedwithdrawFeeStringminNetworkWithdrawStringminNetworkDepositStrings                              r   fetch_currencieszzebpay.fetch_currenciesM  s      99&AAAAAAAA@ ~~h33q#d))$$ K	 K	AAwH))(J??J**:66D##Hf55D))$*>*>t?O?OPXZe?f?f*g*ghhI^^Hh;;FH#'  $#GH1c&kk** $ $q	 ,,UI>>	"55i@@!%7I!J!Jd!R-;I..'"&..8K"L"LPT"T/>M??X$($4$4UO$L$L!$0AUA]+<+<dkdv  xI  K_  e`  e`(+/+;+;ECV+W+W(+7EVE^(@(@elew  yQ  Sd  fe  fe%*.*:*:5BR*S*S'*6CSC['>'>bibt  vM  O_  c`  c`$!#*,@- /,,->??!* $(#4#45M#N#N#'% %
 $(#4#45L#M#M#'$ $	 	) )%%(  77  !.h"$(()=>>&  $# 
  $001BCC#! !
  $001ABB#     %19 9  F4LL4 r   symbolc                   K   |                                   d{V  |                     |          }d}| d|d         i}|d         rG|                     |                     ||                     d{V }|                     |di           }n\|                     |                     ||                     d{V }|                     |dg           }|                     |d          }|                     ||          S )a  
        fetch the trading fees for a market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-exchange-fee
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fee-single-symbol

        :param str symbol: unified symbol of the market to fetch the order book for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param dict [params.side]: side to fetch trading fee
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        Nr   r*   r7   r   r   )load_marketsmarketprivateSpotGetV2ExTradefeeextendr   publicSwapGetV1ExchangeTradefeer   parse_trading_fee)r   r   r   r  r   r   requestresponseDatas           r   fetch_trading_feezzebpay.fetch_trading_fee  s&      !!!!!!!!!V$$fTl
 &> !	3!<<T[[RX=Y=YZZZZZZZZH >>(FB77DD!AA$++gW]B^B^________H   >>(FB??L>>,22D%%dF333r   c                   K   d}|                      dd|          \  }}d}|dk    r|                     |           d{V }n|                     |           d{V }|                     |dg           }i }t	          dt          |                    D ]*}|                     ||                   }|d         }|||<   +|S )a  
        fetch the trading fees for multiple markets

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/exchange.md#get-trade-fees-all-symbols

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        NfetchTradingFeesr7   r   r   r   )r   publicSpotGetV2ExTradefees publicSwapGetV1ExchangeTradefeesr   r   r   r  )	r   r   r   r   rz   r   r   r   r   s	            r   fetch_trading_feeszzebpay.fetch_trading_fees  s       99:LdTZ[[f6>>!<<VDDDDDDDDHH!BB6JJJJJJJJH ~~h33q#d))$$ 	! 	!A((a11C]F F6NNr   Nr   c           	        K   |                                   d{V  |                     |          }d|d         i}d}|d         r7|||d<   |                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     ||d         dddd	d
          }|                     |d          |d<   |S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-order-book
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-order-book

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :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*   r7   r   r   bidsasksr   rd   nonce)r  r  publicSpotGetV2MarketOrderbookr  publicSwapGetV1MarketOrderBookr   parse_order_bookr   )	r   r   r   r   r  r  r   bookData	orderbooks	            r   fetch_order_bookzzebpay.fetch_order_book#  s9      !!!!!!!!!V$$fTl
 &> 	_ #(  "@@WV\A]A]^^^^^^^^HH!@@WV\A]A]^^^^^^^^H>>(FB77))(F84DdFTZ\]_`aa	!..xAA	'r   c                   K   |                                   d{V  |                     |          }d|d         i}d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-ticker
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-24hr-ticker

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        Nr   r*   r7   r   )r  r  publicSpotGetV2MarketTickerr  publicSwapGetV1MarketTicker24Hrr   parse_tickerr   r   r   r  r  r   r   s          r   fetch_tickerzzebpay.fetch_tickerL  s       !!!!!!!!!V$$fTl
 &> 	`!==dkk'SY>Z>Z[[[[[[[[HH( "AA$++gW]B^B^________H~~h33  v...r   symbolsc                 r  K   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     ||          S )aQ  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-all-tickers

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nr\   r7   z! fetchTickers() does not support  marketsr   )r   r!   r*   r  market_symbolspublicSpotGetV2MarketAllTickersr   parse_tickers)r   r  r   r   r   
tickerLists         r   fetch_tickerszzebpay.fetch_tickersv  s       99.$PVWWf6>>tw)LLtSV``aaa!!!!!!!!!%%g..==fEEEEEEEE& ^^Hfb99
!!*g666r   rj   sincec                   K   |                                   d{V  |                     |          }|d}d|d         i}|d         r |                     | j        ||          |d<   n||d<   |d         r|||d<   ||d         r||d	<   n||d
<   |                     |dd          }|||d<   |                     |ddg          }d}	|d         rK||t          | j        dz             |                     | 	                    ||                     d{V }	n/| 
                    | 	                    ||                     d{V }	|                     |	dg           }
|                     |
||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-klinescandlesticks
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#-get-k-lines-ohlcv-data

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.endtime]: the latest time in ms to fetch orders for
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   r   r*   r7   intervalcontractr   	startTimer'  untilendtimeendTimezR fetchOHLCV() requires a both a since and until/endtime parameter for spot marketsr   )r  r  r   rc   safe_integer_2omitr   r*   publicSpotGetV2MarketKlinesr  publicSwapPostV1MarketKlinesr   parse_ohlcvs)r   r   	timeframer'  r   r   r  r  r,  r   r   s              r   fetch_ohlcvzzebpay.fetch_ohlcv  s      !!!!!!!!!V$$=EfTl
 &> 	,"&"2"24?Iy"Y"YGJ"+GJ* 	%5#4$GGf~ )',$$#( ##FGY??!&GIYYv	7';<<F&> 	]}'  3G  )G  H  H  H!==dkk'SY>Z>Z[[[[[[[[HH!>>t{{7TZ?[?[\\\\\\\\H@ ~~h33  vy%GGGr   c                   K   |                                   d{V  |                     |          }d|d         i}|d         r|||d<   d}|d         r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a  
        get the list of most recent trades for a particular symbol

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/public-endpoints.md#get-recent-trades
        https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/public-endpoints/market.md#get-aggregate-trades

        :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>`
        Nr   r*   r7   r   r   )r  r  publicSpotGetV2MarketTradesr  publicSwapGetV1MarketAggTrader   parse_trades)	r   r   r'  r   r   r  r  r   r   s	            r   fetch_tradeszzebpay.fetch_trades  s      !!!!!!!!!V$$fTl
 &> 	%e/$GG&> 	^!==dkk'SY>Z>Z[[[[[[[[HH!??GU[@\@\]]]]]]]]H ~~h33  vue<<<r   c                   K   |                                   d{V  d}||                     |          }d}|                     d||          \  }}d}|dk    rt          | j        dz             |                     |           d{V }|                     |di           }|                     |dg           }	|                     |	|||          S )ac  
        get the list of most recent trades for a particular symbol

        https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-trade-history

        :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>`
        NrT   r7   z. fetchMyTrades() does not support spot marketsr   items)	r  r  r   r!   r*   privateSwapGetV1TradeHistoryr   r   r9  )
r   r   r'  r   r   r  r   r   r   r<  s
             r   fetch_my_tradeszzebpay.fetch_my_trades  s       !!!!!!!!![[((F99/6SYZZf6>>tw)YYZZZ!>>vFFFFFFFFH~~h33tWb11  u===r   r*   c                 |  K   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  d{V  d|i}|                     |                     ||                     d{V }|                     |di           }	|	g}
|                     |
          S )aW  
        fetch all the trades made from a single order

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-fills

        :param str id: order id
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        NrY   r7   z% fetchOrderTrades() does not support r!  orderIdr   )r   r!   r*   r  privateSpotGetV2ExOrderFillsr  r   r9  )r   r*   r   r'  r   r   r   r  r   r   tradess              r   fetch_order_tradeszzebpay.fetch_order_trades-  s       99:LdTZ[[f6>>tw)PPSWWZddeee!!!!!!!!!r
 ::4;;wPV;W;WXXXXXXXX$ ~~h33  (((r   trader  c                 b   |                      |dd          }|                      |dd          }|                     |dd          }|                     |d          }|                     ||d          }|d         }|                     |d          }|                     |d	          }	|                      |d
d          }
|                     ||||                     |          |||                     |d          |d |	|
|                     |d          |                     |d          d|          S )Nr*   aggregateTradeIdorderr   	tradeTimer   _sidepricer   quantityr   costr   )r*   r   r   datetimer   rG  r   rJ  takerOrMakerrK  r   rM  r   )r   r/  r   safe_marketsafe_string_lower
safe_tradeiso8601r   )r   rD  r  r*   r@  r   marketIdr   rJ  priceStringamountStrings              r   parse_tradezzebpay.parse_tradeX  sH   B t-?@@$$UD'::''{KHH	##E844!!(FC88!%%eV44&&ug66))%:FF"Y//**5&99  "$$UF33>>%// 
  
   	r   c                   K   |                                   d{V  d}|                     dd|          \  }}|dk    }d}|r|                     |           d{V }n|                     |           d{V }|                     |          S )a4  
        query for balance and get the amount of funds available for trading or funds locked in orders

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-account-balance
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/wallet.md#get-wallet-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        NrE   r7   )r  r   privateSpotGetV2AccountBalanceprivateSwapGetV1WalletBalanceparse_balance)r   r   r   r   r   s        r   fetch_balancezzebpay.fetch_balance  s       !!!!!!!!!99.$PVWWf&. 	H!@@HHHHHHHHHH!??GGGGGGGGH& !!(+++r   r   rJ  r   rK  c                 Z  K   |                                   d{V  |                     |          }|                                }|                     |d          }	|                     |d          }
|                     |g d          }|d         |                                d}d}|d         rN|                     ||||||          \  }}|                     |                     ||                     d{V }n|                     |dd	          }|                     |d
d          }||d
<   | 	                    | 
                    |d         |                    |d<   ||d<   |	du}|
du}|s|r|r,| 	                    |                     ||	                    |d<   |r,| 	                    |                     ||
                    |d<   |                     |                     ||                     d{V }n||d<   |dk    rE|t          | j        dz             | 	                    |                     ||                    |d<   |                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        Create an order on the exchange

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#place-new-order
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--create-order

        :param str symbol: Unified CCXT market symbol
        :param str type: 'limit' or 'market'
        :param str side: 'buy' or 'sell'
        :param float amount: the amount of currency to trade
        :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 str [params.formType]: The price at which a trigger order is triggered at
        :param str [params.marginAsset]: The asset the order creates, default is INR.
        :param boolean [params.takeProfit]: Takeprofit flag for the order.
        :param boolean [params.stopLoss]: Stop loss flag for the order.
        :param str [params.positionId]: PositionId of the order.
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        NtakeProfitPricestopLossPrice)marginAssetr^  r^  r*   )r   rJ  r7   r`  INRformType
ORDER_FORMr   r   r   z9 createOrder() requires a price argument for limit ordersrK  r   )r  r  upperr   r0  order_requestprivateSpotPostV2ExOrdersr  safe_string_upperparse_to_numericamount_to_precisionprice_to_precision"privateSwapPostV1TradeOrderAddTPSLr   r*   privateSwapPostV1TradeOrderr   parse_order)r   r   r   rJ  r   rK  r   r  upperCaseTyper^  r_  r  r   r`  rb  hasTPhasSLr   s                     r   create_orderzzebpay.create_order  s     ( !!!!!!!!!V$$

**63DEE((AA6#X#X#XYYTlJJLL
 
 &> 	`"00vwPUW]^^OGV!;;DKKQW<X<XYYYYYYYYHH**6=%HHK--fj,OOH"*GJ $ 5 5d6N6NvVZ|]c6d6d e eGH%0GM"#4/E!-E ` ` y151F1FtG^G^_egvGwGw1x1xG-. u/3/D/DTE\E\]cerEsEs/t/tGO,!%!H!HU\^dIeIe!f!fffffff"/7??}/:u0uvvv'+'<'<T=T=TU[]b=c=c'd'dGG$!%!A!A$++gW]B^B^!_!_______ ~~h33f---r   c                 j   |                                 }|                     |dd           }|                     |ddd           }	|                     |dd          }
|                     |d|                                           }|                     |g d          }||d<   ||d<   |
|d<   |d	k    r3|	t          | j        d
z             |                     ||	          |d<   nM||                     ||          |d<   | 	                    ||          |d<   |                     ||          |d<   ||gS )Nr_  quoteOrderQtyrM  timeInForceGTCclientOrderId)r_  rM  rt  rv  r   MARKETz* spot market orders require cost in paramsquoteOrderAmountr   rK  )
rd  r   r   uuidr0  r   r*   cost_to_precisionrj  ri  )r   r   r   r   r  rK  r   rn  triggerPricers  rt  rv  s               r   re  zzebpay.order_request  sP   

''FF**6?FDQQ&&v}eDD(($))++NN6#\#\#\]]'#0 !,H$$$#DG.Z$Z[[[*.*@*@*W*WG&'''+/+B+B6<+X+X( $ 8 8 H HGH#66vuEEGG  r   c                   K   |                                   d{V  |                     |          }d}i }|d         r5||d<   |                     |                     ||                     d{V }nn|                     |d          }|t          | j        dz             ||d<   |d         |d<   |                     |                     ||                     d{V }|                     | 	                    |d                    S )	a  
        cancels an open order

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-order
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-cancel-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
        :param dict [params.timestamp]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr7   r@  rv  zA cancelOrder() requires a clientOrderId parameter for swap ordersr*   r   r   )
r  r  privateSpotDeleteV2ExOrderr  r   r   r*   privateSwapDeleteV1TradeOrderrm  r   )r   r*   r   r   r  r   r  rv  s           r   cancel_orderzzebpay.cancel_order  s5      !!!!!!!!!V$$&> 		^!#GI!<<T[[RX=Y=YZZZZZZZZHH ,,V_EEM$'2u(uvvv'4GO$ &tGH!??GU[@\@\]]]]]]]]H x @ @AAAr   c                 L  K   d}|                      dd|          \  }}|dk    rt          | j        dz   |z   dz             |                                  d{V  |                     |           d{V }|                     |di           }|                     |          }|gS )a  
        cancels all open orders

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#cancel-all-orders

        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param dict [params.timestamp]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr@   r7   z$ cancelAllOrders() does not support r!  r   )r   r!   r*   r  $privateSpotDeleteV2ExOrdersCancelAllr   rm  )r   r   r   r   r   r   parsedOrders          r   cancel_all_orderszzebpay.cancel_all_orders4  s       99:KTSYZZf6>>tw)OORVVYccddd!!!!!!!!!BB6JJJJJJJJ ~~h33&&t,,}r   c                 j  K   |                                   d{V  |                     |          }d|d         i}d}g }|d         rjd|d<   |||d<   |                     |                     ||                     d{V }|                     |di           }	|                     |	d	g           }nk|||d
<   |||d<   |                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }|                     ||d|          S )a  
        fetches information on multiple open orders made by the user

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-orders
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-open-orders

        :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>`
        Nr   r*   r7   rd   currentPagepageSizer   r<  r'  r   )r  r  privateSpotGetV2ExOrdersr  r   r   $privateSwapGetV1TradeOrderOpenOrdersparse_orders)
r   r   r'  r   r   r  r  r   ordersr  s
             r   fetch_open_orderszzebpay.fetch_open_ordersQ  sz      !!!!!!!!!V$$fTl
 &> 	>%&GM" &+
#!::4;;wPV;W;WXXXXXXXXH>>(FB??L^^L'2>>FF #(  #( !FFt{{SZ\bGcGcddddddddH>>(FB??L^^L&"==F4   u===r   c                   K   |                                   d{V  |                     |          }i }d}|d         r5||d<   |                     |                     ||                     d{V }n4||d<   |                     |                     ||                     d{V }|                     |d          }|                     ||          S )a  
        fetches information on an order made by the user

        [Spot] https://github.com/zebpay/zebpay-api-references/blob/main/spot/api-reference/private-endpoints.md#get-order-details
        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-order-details

        :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
        :param str [params.clientOrderId]: cancel order by client order id
        :param str [params.timestamp]: cancel order by client order id
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr7   r@  r*   r   )r  r  privateSpotGetV2ExOrderr  privateSwapGetV1TradeOrderr   rm  )r   r*   r   r   r  r  r   r  s           r   fetch_orderzzebpay.fetch_order  s       !!!!!!!!!V$$&> 	[!#GI!99$++gv:V:VWWWWWWWWHHGDM!<<T[[RX=Y=YZZZZZZZZH4 ~~h77f555r   rG  c           
         |                      |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|          }|S )Nr   r   r   rK  rJ  r   rv  rt  r   r@  r*   postOnly
reduceOnlyr{  rM  filled	remainingrN  r   )r   r   lastTradeTimestamplastUpdateTimestampaveragerB  )r   rP  safe_numberrS  rQ  
safe_order)r   rG  r  rT  r   r   r   rN  rK  rJ  r   rv  rt  r   r@  r  s                   r   rm  zzebpay.parse_order  s   $ ##E844!!(F33!v..$$UK88	<<	**  00v..!!%22((@@&&um<<''x88""5)T::oo '
''
]'
 f'
 D	'

 ;'
 '
 $'
 D'
 f'
 U'
 D'
 D'
 d'
 '
 '
  !'
" 4#'
$ "&#'/'
 '
 '
0 1 2 r   c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a5  
        closes open positions for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-close-position

        :param str symbol: Unified CCXT market symbol
        :param str side: not used by kucoinfutures closePositions
        :param dict [params]: extra parameters specific to the okx api endpoint
        :param str [params.positionId]: client order id of the order
        :returns dict[]: `A list of position structures <https://docs.ccxt.com/?id=position-structure>`
        Nr   r*   r   )r  r  #privateSwapPostV1TradePositionCloser  r   rm  )r   r   rJ  r   r  r  r   r   s           r   close_positionzzebpay.close_position  s       !!!!!!!!!V$$fTl
 AA$++gW]B^B^________~~h33f---r   c                    K   |                                   d{V  |                     |           d{V }|                     |dg           }|                     ||d          S )a  
        fetch the set leverage for all contract and margin markets

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-get-all-user-leverages

        :param str[] [symbols]: a list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `leverage structures <https://docs.ccxt.com/?id=leverage-structure>`
        Nr   r   )r  "privateSwapGetV1TradeUserLeveragesr   parse_leverages)r   r  r   r   leveragePreferencess        r   fetch_leverageszzebpay.fetch_leverages  s       !!!!!!!!!@@HHHHHHHH #nnXvrBB##$7(KKKr   c                 T  K   |                                   d{V  |                     |          }d|d                                         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetch the set leverage for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#get-user-leverage-single-symbol

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `leverage structure <https://docs.ccxt.com/?id=leverage-structure>`
        Nr   r*   r   )r  r  rd  !privateSwapGetV1TradeUserLeverager  r   parse_leverager  s          r   fetch_leveragezzebpay.fetch_leverage-  s       !!!!!!!!!V$$fTl((**
 ??GU[@\@\]]]]]]]] ~~h33""4000r   leveragec                   K   |t          | j        dz             |                                  d{V  |                     |          }||d         d}|                     |                     ||                     d{V }|S )a  
        set the level of leverage for a market

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-update-user-leverage

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz) setLeverage() requires a symbol argumentr*   )r  r   )r   r*   r  r  (privateSwapPostV1TradeUpdateUserLeverager  )r   r  r   r   r  r  r   s          r   set_leveragezzebpay.set_leverageE  s       >#DG.Y$YZZZ!!!!!!!!!V$$ Tl
 
 FFt{{SZ\bGcGcddddddddr   c                 X  K   |                                   d{V  i }||                     |          |d<   |                     |                     ||                     d{V }|                     |dg           }|                     |          }|                     |d|d          S )ao  

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#--get-positions

        Fetches current contract trading positions
        :param str[] symbols: List of unified symbols
        :param dict [params]: Not used by krakenfutures
        :returns: Parsed exchange response for positions
        Nr  r   r   F)r  
market_idsprivateSwapGetV1TradePositionsr  r   parse_positionsfilter_by_array_positions)r   r  r   r  r   	positionsr   s          r   fetch_positionszzebpay.fetch_positions^  s       !!!!!!!!!!%!9!9GI<<T[[RX=Y=YZZZZZZZZ NN8VR88	%%i00--fhOOOr   c                 `  K   |                                   d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |di           }|                     |                     ||          |dd          S )aF  
        add margin

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-add-margin-to-position

        :param str symbol: unified market symbol
        :param float amount: amount of margin to add
        :param dict [params]: extra parameters specific to the exchange API endpoint.
        :param str [params.positionId]: PositionId of the order to add margin.
        :param str [params.timestamp]: Tiemstamp.
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        Nr*   r   r   r   inr   	direction)r  r  privateSwapPostV1TradeAddMarginr  r   parse_margin_modificationr   r   r   r   r  r  r   r   s           r   
add_marginzzebpay.add_margin~  s       !!!!!!!!!V$$Tl
 
 ==dkk'SY>Z>Z[[[[[[[[& ~~h33{{499$GGJ
 J
   	r   c                 `  K   |                                   d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |di           }|                     |                     ||          |dd          S )aM  
        add margin

        [Swap] https://github.com/zebpay/zebpay-api-references/blob/main/futures/api-reference/private-endpoints/trade.md#-reduce-margin-from-position

        :param str symbol: unified market symbol.
        :param float amount: amount of margin to add.
        :param dict [params]: extra parameters specific to the exchange API endpoint.
        :param str [params.positionId]: PositionId of the order to add margin.
        :param str [params.timestamp]: Tiemstamp.
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        Nr*   r  r   outr  )r  r  "privateSwapPostV1TradeReduceMarginr  r   r  r  s           r   reduce_marginzzebpay.reduce_margin  s       !!!!!!!!!V$$Tl
 
 @@WV\A]A]^^^^^^^^ ~~h33{{499$GGJ
 J
   	r   c                 :  K   |                      |           d {V }g }|                     |di           }|                     |dg           }t          dt	          |                    D ].}||         }|                     |d          }|                     |d          }	|                     |d          }
|                     |	          }|                     |
          }|dz   |z   }|                    i d|d|d	|d
|d|	d|
dddddddddddddd dd d|                     |d          d|                     |d          dd d |                     |d          |                     |d          dd d dd d dd d dd |d!           0|S )"Nr   r  r   r   	baseAsset
quoteAsset/r*   basequotebaseIdquoteIdr   r7   Tr9   Fr8   r:   r;   r   r*  takertakerFeemakermakerFeestrikelotSztickSzr   rK  r   )r   rK  rM  
optionTyper   r   r   )	publicSpotGetV2ExExchangeInfor   r   r   r   r   r   r   r  )r   r   r   r   r   marketsr   r  r*   r  r  r  r  r   s                 r   r   zzebpay.fetch_spot_markets  s     ;;FCCCCCCCC& ~~h33..y"55q#g,,'' .	 .	AQZF!!&(33B%%fk::F&&v|<<G**622D++G44ECZ%'FMM &b&&& & 	&
 && 7& & & & %& %& %& $& D& ))&*==&  ))&*==!&" $#&$ #"..vw??!--fh??   $# 
  $# 
  $#   K& & & & & & &N r   c                 
  K   |                      |           d {V }g }|                     |di           }|                     |dg           }t          dt	          |                    D ]}||         }|                     |d          }|                     |d          }	|                     |d          }
|                     |	          }|                     |
          }|                     |
          }|                     |d          }|dz   |z   }|                    |                     i d	|d|d
z   |z   d|d|d|	d|
ddddddddddddd|dk    ddd| 	                    |d          d| 	                    |d          dd d | 	                    |d          | 	                    |d           d!d"| 	                    |d#          | 	                    |d$          d%i|d&                     |S )'Nr   r  r   r   r  r  r   r  r*   :r  r  r  r  r7   Fr8   r9   Tr:   r   r;   r   Openr*  r  r  r  r  r  r  r  r  r  minLeveragemaxLeverager   r  )
publicSwapGetV1MarketMarketsr   r   r   r   r   r   r   safe_market_structurer  )r   r   r   r   r   r  r   r  r*   r  r  r  r  settler   r   s                   r   r   zzebpay.fetch_swap_markets  s     ::6BBBBBBBB0 ~~h33..y"55q#g,,'' (	 (	AQZF!!&(33B%%fk::F&&v|<<G**622D++G44E,,W55F%%fh77FCZ%'FMM$44 6b6&3,/6 6 	6
 &6 76 6 %6 6 %6 6 %6 6V+6 D6 ))&*==6  ))&*==!6" $#6$ #"..vw??!--fh?? 
 #//FF#//FF! ! ;6 6 6      > r   c                    |d d d}|                      |dg           }t          dt          |                    D ]}||         }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d<   |                     |d          }|                     |          }|||<   |                     |          S )N)r   r   rN  r   r   totalfreeusedr   )r   r   r   accountr   r   safe_balance)	r   r   r   currencyListr   entryr  r   r   s	            r   r[  zzebpay.parse_balance_  s    
 

 ~~h;;q#l++,, 	# 	#A OEllnnG#//w??GG"..uf==GFO"..uf==GFO))%<<J**:66D"F4LL  (((r   positionc                 h   |                      |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S )Nr  rN  r   r   r   initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalunrealizedPnl	contractscontractSizemarginRatioliquidationPrice	markPriceisolatedrJ  )
collateral
marginTyperJ  
percentage)r  r   rP  	parse8601)r   r  r  r  rN  rT  s         r   parse_positionzzebpay.parse_positionq  s    ##Hj99##Hj99##Hh77!!(F33
H
h
 11
 	

 T--hHH
 &t
  
 *4
 $**8\BB
 ((:>>
 
 T
 ))(K@@
 D,,V^DD
 4
   0 0;M N N!
" #
$ $$$Xv66+
 
 
 	
r   c                     |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                      |d          }|||||dS )Nr   r   longLeverageshortLeverage
marginMode)r   r   r  r  r  )r   r   r   )r   r  r  rT  r   leverageValueleverageValueShortr  s           r   r  zzebpay.parse_leverage  s    ##Hh77~~h//))(NCC!..xII%%h==
$)/
 
 	
r   r   c                     |                      |d          }|                     ||          }|||                     |dd          |                     |dd          d d dS )Nr   makerFeeRater  takerFeeRater  )r   r   r  r  r  	tierBased)r   safe_symbolsafe_number_2)r   r   r  rT  r   s        r   r  zzebpay.parse_trading_fee  sq    ##C22!!(F33''^ZHH''^ZHH
 
 	
r   tickerc           	         |                      |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|          S )Nr   tsr   closelastr  	bidVolume	askVolumer*   rN  highlowbidaskvwapopenpreviousClosechanger  
baseVolumequoteVolume)r  r  r  r  r   )r/  r   rP  safe_tickerrS  )
r   r  r  r   rT  r  r  r  r  r  s
             r   r  zzebpay.parse_ticker  s]   & ''T4HH	##FH55!!(++  $7755%%fl;;
$$V[99	$$V[99	 !
(!
fX&!
 !
 Y//	!

 D$$VV44!
 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D!
 U!
 D!
 T--foFF!
  d&&vx88!!
" *#!
$ ''	::**6<@@++FMBB-!
 !
 !
. /  	r   c                     |                                  }||d         d d |                     |d          d |                     |d          |                     |d          ||                     |          d
S )Nr*   r   r   r   )
r   r   r   r  r   r  r   r   r   rN  )millisecondsr  r   rS  )r   r   r  r   s       r   r  z zebpay.parse_margin_modification  s     %%''	Tl&&tX66$$T622&&tX66"Y//
 
 	
r   r   GETc                 R   |                      |d          }|                    d          dk    }|rdnd}| j        d         |         }	d|                     ||          z   }
|	|
z  }	t	          |                                           }d}|                      ||                     |                    }|}|                     |d	d
          }|d
k    rF|dk    s|dk    r|r|	d|                     |          z   z  }	n%t          j
        |          }ddd}n
|                                  |dk    }||d<   |dk    s|dk    rm|rk|                     |          }|                     |                     |          |                     | j                  t          j        d          }|	d|z   z  }	nb| 	                    |          }|                     |                     |          |                     | j                  t          j        d          }d| j        |d}d|d<   |	|||dS )Nr   zv1/r9   r7   rv   z/api/ r   r   r  DELETE?ccxtzapplication/json)ReferrerContent-Typer   hex)r  zX-AUTH-APIKEYzX-AUTH-SIGNATUREr  )r   methodbodyheaders)r0  findrt   implode_paramsstrr  extract_paramsr   	urlencodejsondumpscheck_required_credentialshmacencoder   hashlibsha256r   )r   pathrv   r   r   r"  r!  isV1
marketTyper   tailr   	signaturequeryqueryLengthaccessr   queryStrings                     r   signzzebpay.sign  sC   6=11yy"$#/VV
iz*,,T6:::t))++,,				&$"5"5d";";<<!!#q(33X&H"4"4 73!6!666Cz&)) &$6 
 ++---6)F"+F;6X#5#5&#5"nnV44 IIdkk+&>&>DK@X@XZaZhjopp	s[(( yy(( IIdkk$&7&7T[9Q9QSZSachii	"!%$- G
 '9GN#fdwOOOr   r   reasonr   r   r"  r!  c
                    |s$|                      | j        d         ||           d S |                     |dd          }
|                     |dd          }| j        dz   |z   }|                      | j        d         ||           |                     | j        d         ||           |                     | j        d         |
|           d S )Nr   r   
statusCodemsgstatusDescription r   )throw_broadly_matched_exceptionr   r   r*   throw_exactly_matched_exception)r   r   r9  r   r   r"  r!  r   requestHeadersrequestBody	errorCodemessagefeedbacks                r   handle_errorszzebpay.handle_errors*  s     	001I4QUVVV4 &&xFF	$$Xu6IJJ7S=7*,,T_W-EwPXYYY,,T_W-EwPXYYY,,T_W-EyRZ[[[tr   )N)F__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r%  r   r	  r   r  r   r  r   r  r   r   r&  listr5  r   r:  r   r>  rC  dictrW  r   r\  r   r   floatr   rq  re  r  r  r   r  r  rm  r  r
   r  r	   r  intr  r  r   r  r  r   r   r[  r  r  r  r  r  r8  rF  __classcell__)r   s   @r   r'   r'      s       G# G G G G G GR )+ '
 '
 '
 '
R ') ! !S ! ! ! !F *, = =V = = = =6 -/ w w: w w w wr ;= 54 54c 54AT 54 54 54 54n /1 $ $[ $ $ $ $L @DB ' 'S ' 'S\ ' ' ' 'R 68 (/ (/ (/F (/ (/ (/ (/T 6:" $7 $77 $7 $7 $7 $7 $7L 8<$]ajl LH LH LHC LHWZ LHquvzq{ LH LH LH LH\ <@d[] &= &= &=S &= &=bfglbm &= &= &= &=P 37TX\eg > >C >s >RU >lpqvlw > > > >6 ?CQUdhqs )) ))3 )) ))3 ))^a )) )) )) ))V8 8 8v 8 8 8 8 8t *, %, %, %, %, %, %,N mqy{ ?. ?. ?.I ?.Y ?.X] ?.fi ?. ?. ?. ?.B BFb ! ! ! !* 9=R #B #BS #B# #B #B #B #BJ 59  c    : 59tZ^gi <> <>c <> <>TW <>nrsxny <> <> <> <>| 8<B 26 26C 26 26 26 26 26h8 8 8v 8 8 8 8 8t CGr . .3 .i .V[ . . . .* 8<B L LW L9 L L L L6 8: 1 13 1h 1 1 1 10 ?C2  3     2 8<B P PW P P P P@ CE * *s *E *I[ * * * *X FH $ $# $u $L^ $ $ $ $L /1 F FT&\ F F F FP /1 E ET&\ E E E EN) ) ) ) )$&
 &
t &
V &
 &
 &
 &
P
 
t 
V 
x 
 
 
 


 

T 

6 

EX 

 

 

 

2 24 2 26 2 2 2 2h
 
f 
HZ 
 
 
 
0 &eBSW )P )P )P )PV# s  c TX `c        r   r'   ). ccxt.async_support.base.exchanger   ccxt.abstract.zebpayr   r   r-  r(  ccxt.base.typesr   r   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#   ccxt.base.decimal_to_precisionr$   ccxt.base.preciser%   r'    r   r   <module>rW     sx   6 5 5 5 5 5 , , , , , ,    a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a  a       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) . . . . . . 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %` ` ` ` `X{ ` ` ` ` `r   