
    ia                         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 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)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrTickerTradeTransaction)List)ExchangeError)ArgumentsRequired)InvalidOrder)	TICK_SIZEc                   :    e Zd Z fdZi fdee         fdZdi fdedede	fdZ
d)dedefd	Zi fdedefd
Zd)dedefdZddi fdededede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dedef
dZdi fdedefdZd Zd)dedefdZdi fdedefdZdi fdedefdZd)de de!fdZ"d)dede#fdZ$dddi fdedededee#         fd Z%dddi fdedededee         fd!Z&dddi fdedededee         fd"Z'dddi fdededefd#Z(d$ Z)d%d&i ddfd'Z*d( Z+ xZ,S )*mercadoc                 R   |                      t          t          |                                           dddgddi ddddd	d
dd
dd
dd
dd
dddd
dd
dddddd
dd
dd
dd
ddi dd
dd
dd
dd
dd
dd
dd
d d
d!d
d"d
d#d
d$d
d%d
d&d
d'd
d(d
d)di d*d
d+d,d-dd.d
d/dd0dd1dd2dd3d
d4d
d5d
d6d
d7d
d8dd9d
d:dd;d
d
d
d
d
d
dd<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLgdMdNg dOidPg dQidNdRgidNdSgidIdTdUdVdWidXdYdYdZdZd[d\it          d]          S )^Nr   zMercado BitcoinBR  v3CORSTspotmarginFswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTradesemulated
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickersfetchTradesfetchTradingFee)fetchTradingFeesreduceMarginsetLeveragesetMarginModesetPositionModewithdraw15m1h3h1d1w1M)rW   rX   rY   rZ   r[   r\   zchttps://user-images.githubusercontent.com/1294454/27837060-e7c58714-60ea-11e7-9192-f05e86adb83f.jpgz"https://www.mercadobitcoin.net/apiz#https://www.mercadobitcoin.net/tapiz$https://www.mercadobitcoin.com.br/v4z%https://api.mercadobitcoin.net/api/v4)publicprivatev4Publicv4PublicNetz!https://www.mercadobitcoin.com.brz)https://www.mercadobitcoin.com.br/api-docz+https://www.mercadobitcoin.com.br/trade-api)logoapiwwwdocget)coinsz{coin}/orderbook/z{coin}/ticker/z{coin}/trades/z{coin}/trades/{from}/z{coin}/trades/{from}/{to}z({coin}/day-summary/{year}/{month}/{day}/post)cancel_orderget_account_info	get_orderget_withdrawallist_system_messageslist_orderslist_orderbookplace_buy_orderplace_sell_orderplace_market_buy_orderplace_market_sell_orderwithdraw_coinz{coin}/candle/candlestradingg~jth?gy&1|?)makertakerlimitsgMbP?g{Gz?g?)BTCBCHETHLTCXRP)idname	countries	rateLimitversionhas
timeframesurlsrb   feesoptionsprecisionMode)deep_extendsuperr   describer   )self	__class__s    `/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/mercado.pyr   zmercado.describe   s   gt 4 4 = = ? ?%::: %: 	:
 %: %: U: t: $U:  : $T: t: (: ': (:  "5!:" #: :$ )%%:& '':( ():* &u+:, (-:. 1%/:0 &u1:2 #E3:4 *55:6 $U7:8 "59:: *5;:< +E=:>  ?:@ %eA:B "5C:D E: : :F !%G:H  I:J dK:L +EM:N "4O:P dQ:R !$S:T tU:V  W:X $UY:Z !%[:\ %e]:^ )%_:` ta:b c:d te:f "5g: :h %* %$!&#( s: : :x   ~BD F#J	  ;?A      
    " ( ! C& &P ""      '[NB
 NB
 N N N	    returnc                   K   |                      |           d{V }g }|                     | j        di           }t          dt	          |                    D ]}||         }|}d}|                     |          }	|                     |          }
|
|	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ddddddd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 )z
        retrieves data on all markets for mercado
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nrx   r   BRLr~   symbol/basequotesettlebaseIdquoteIdsettleIdtyper   Tr   Fr    r!   r"   activecontractlinearz1e-8z1e-5)amountprice)minmax)leverager   r   cost)
inversecontractSizeexpiryexpiryDatetimestrike
optionType	precisionrx   createdinfo)	publicGetCoins
safe_valuer   rangelensafe_currency_codeappendparse_numbersafe_number)r   paramsresponseresultamountLimitsicoinr   r   r   r   r~   s               r   fetch_marketszmercado.fetch_markets   sm      ,,V44444444, t|XrBBq#h--(( 7	 7	AA;DFG**622D++G44EBMM 0b0$*u,0 0 	0
 $0 &0 70 D0 0 0 %0 0 %0 %0 $0  E!0" $#0$   $"&""//77!..v66   $#! !
  $//fEE# 
  $0088# 
  $#  $  _0 0 0 0 0 0 0b r   Nr   limitc                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||d                   S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr   r   r   )load_marketsmarketpublicGetCoinOrderbookextendparse_order_book)r   r   r   r   r   requestr   s          r   fetch_order_bookzmercado.fetch_order_book   s       !!!!!!!!!V$$F6N
 44T[[&5Q5QRRRRRRRR$$Xvh/?@@@r   r   c                    |                      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|          S )Ndatelastr   	timestampdatetimehighlowbidbuy	bidVolumeasksell	askVolumevwapopenclosepreviousClosechange
percentageaveragevol)
baseVolumequoteVolumer   )safe_symbolsafe_timestampsafe_stringsafe_tickeriso8601)r   tickerr   r   r   r   s         r   parse_tickerzmercado.parse_ticker  s    !!$//''77	// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FF33!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6599)!
 !
 !
* +  	r   c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     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
        :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   r   )r   r   publicGetCoinTickerr   r   r   )r   r   r   r   r   r   r   s          r   fetch_tickerzmercado.fetch_ticker3  s       !!!!!!!!!V$$F6N
 11$++gv2N2NOOOOOOOO8R88   000r   c                    |                      |dd          }|                     d |          }|                     |dd          }d }|                     |d          }|                     |d          }|                     |dd          }|                     |d	          }	d }
|	|	d d
}
|                     ||||                     |          |d         d ||d ||d |
d|          S )Nr   executed_timestamptidoperation_idr   r   r   quantityfee_rater   currencyr   )r~   r   r   r   r   orderr   sidetakerOrMakerr   r   r   fee)safe_timestamp_2safe_marketsafe_string_2r   
safe_trader   )r   trader   r   r~   r   r   r   r   feeCostr   s              r   parse_tradezmercado.parse_tradeQ  s   ))%9MNN	!!$//un==v..  00##E8Z@@""5*55  C "Y//X&  
  
   	r   sincec                   K   |                                   d{V  |                     |          }d}d|d         i}| |dz  }|                     |dz            |d<   |                     |d          }||d	z  } t	          | |          |                     ||                     d{V }	|                     |	|||          S )
a  
        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>`
        NpublicGetCoinTradesr   r   Fromr   fromtoTo)r   r   parse_to_intsafe_integergetattrr   parse_trades)
r   r   r   r   r   r   methodr   r   r   s
             r   fetch_tradeszmercado.fetch_tradesp  s       !!!!!!!!!V$$&F6N
 fF"//==GFOvt,,>dNF.v..t{{7F/K/KLLLLLLLL  65%@@@r   c                    |                      |di           }|                      |di           }d|i}t          |                                          }t          dt	          |                    D ]}||         }|                     |          }||v rb|                      ||i           }	|                                 }
|                     |	d          |
d<   |                     |	d          |
d<   |
||<   |                     |          S )Nresponse_databalancer   r   	availablefreetotal)	r   listkeysr   r   r   accountr   safe_balance)r   r   databalancesr   currencyIdsr   
currencyIdcoder	  r  s              r   parse_balancezmercado.parse_balance  s   x"==??4B77(#8==??++q#k**++ 	' 	'A$QJ**:66DX%%//(JCC,,.."&"2"27K"H"H#'#3#3GW#E#E &t  (((r   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )a!  
        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>`
        N)r   privatePostGetAccountInfor  )r   r   r   s      r   fetch_balancezmercado.fetch_balance  se       !!!!!!!!!77????????!!(+++r   r   r   r   r   c                   K   |                                   d{V  |                     |          }d|d         i}|                     |          dz   }	|dk    rDd|	z   }	|                     |d         |          |d<   |                     |d         |          |d	<   nfd
|	z   }	|dk    r<|t          | j        dz             |                     |d         ||z            |d<   n|                     |d         |          |d	<    t          | |	          |                     ||                     d{V }
| 	                    |
t          |
d         d         d                   d|          S )a`  
        create a trade 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 fullfilled, 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>`
        N	coin_pairr~   r
   r   privatePostPlacer   limit_pricer   privatePostPlaceMarketr   a    createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amountr   r  r   order_id)r   r~   )r   r   
capitalizeprice_to_precisionamount_to_precisionr   r~   r  r   
safe_orderstr)r   r   r   r   r   r   r   r   r   r  r   s              r   create_orderzmercado.create_order  s      !!!!!!!!!V$$
 &&07??'&0F%)%<%<VH=Mu%U%UGM""&":":6(;KV"T"TGJ-6Fu}}=&tw  2t  (t  u  u  u"&"9"9&:JFUZN"["[&*&>&>vh?OQW&X&X
#.v..t{{7F/K/KLLLLLLLLh/8DEE 
  
   	r   r~   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|                     |di           }|                     |di           }|                     ||          S )aD  
        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>`
        Nz) cancelOrder() requires a symbol argumentr~   r  r  r  r   )	r   r~   r   r   privatePostCancelOrderr   r   	safe_dictparse_order	r   r~   r   r   r   r   r   responseDatar   s	            r   rh   zmercado.cancel_order  s       >#DG.Y$YZZZ!!!!!!!!!V$$
 
 44T[[&5Q5QRRRRRRRR0 x"EE|Wb99v...r   c                 <    dddd}|                      |||          S )Nr   canceledclosed)234)r   )r   statusstatusess      r   parse_order_statuszmercado.parse_order_status  s1    
 

 &&999r   c           	      l   |                      |d          }|                      |d          }d }d|v r
|dk    rdnd}|                     |                      |d                    }|                      |d          }|                     ||          }|                     |d          }|                      |d	          |d
         d}	|                      |d          }
|                      |d          }|                      |d          }|                      |d          }|                     |d          }|                     |dg           }|                     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$|          S )%Nr  
order_type1r   r   r3  r  created_timestampr   r   r   r  executed_price_avgr   executed_quantityupdated_timestamp
operationsr   r~   clientOrderIdr   r   lastTradeTimestampr   r   r   timeInForcepostOnlyr   r   	stopPricetriggerPricer   r   r   )filled	remainingr3  r   trades)r   r5  r   r   r   r#  r   )r   r   r   r~   r7  r   r3  marketIdr   r   r   r   r   rD  r?  	rawTradess                   r   r*  zmercado.parse_order  sx   4 eZ00%%e\::
5  '3..55VD(()9)9%)J)JKK##E;77!!(F33''/BCC	$$UE22w
 
   66""5*>??!!%44!!%)<==!008KLLOOE<<<	  
E 
" 
 T 
 	 

 Y// 
 !"4 
 fX& 
 G 
 4 
  
 D 
 U 
  
 D 
 D 
  w! 
" f# 
$ - 
  
  
. /  	r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         t	          |          d}|                     |                     ||                     d{V }|                     |di           }|                     |d          }| 	                    ||          S )a?  
        fetches information on an order made by the user
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nz( fetchOrder() requires a symbol argumentr~   r'  r  r   )
r   r~   r   r   intprivatePostGetOrderr   r   r)  r*  r+  s	            r   fetch_orderzmercado.fetch_orderA  s       >#DG.X$XYYY!!!!!!!!!V$$B
 
 11$++gv2N2NOOOOOOOOx"EE|W55v...r   r  c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|d         t	          |d          |d}|dk    r!d|v }|st          | j        dz   |z             nR|dk    rLd	|v }	|	st          | j        d
z   |z             |dk    r&|d|vrt          | j        dz   |z             n||d<   |                     |                     ||                     d{V }
| 	                    |
di           }| 
                    |d          }|                     ||          S )a  
        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~   z.10f)r   r   addressr   account_refz7 withdraw() requires account_ref parameter to withdraw r|   tx_feez2 withdraw() requires tx_fee parameter to withdraw r}   destination_tagzM withdraw() requires a tag argument or destination_tag parameter to withdraw r  
withdrawal)handle_withdraw_tag_and_paramscheck_addressr   r   formatr   r~   privatePostWithdrawCoinr   r   r)  parse_transaction)r   r  r   rN  tagr   r   r   rO  rP  r   r,  rR  s                r   rV   zmercado.withdrawU  s      99#vFFV7###!!!!!!!!!==&&TNvv..
 

 5==(F2K t'2k(knr(rssstU]]&(F o'2f(fim(mnnnu}};-77/  ;J  1J  MQ  1Q  R  R  R 8 25G-.55dkk'66R6RSSSSSSSS( x"EE^^L,??
%%j(;;;r   r   c                     |                      d |          }i d|                     |d          dd dd dd dd dd dd dd d	d d
d d|d         dd dd dd dd dd dd d d |dS )Nr~   txidr   r   networkaddressFromrN  	addressTor   r   r   r  r3  updatedtagFromrX  tagTocomment)internalr   r   )safe_currencyr   )r   transactionr   s      r   rW  zmercado.parse_transaction  s    %%dH55
$"";55
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 
 
 	
r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr                  )r  r   )r   ohlcvr   s      r   parse_ohlcvzmercado.parse_ohlcv  s~    eQ''UA&&UA&&UA&&UA&&UA&&
 	
r   rW   c           	        K   |                                   d{V  |                     |          }|                     | j        ||          |d         dz   |d         z   d}|d}|Q|                     |dz            |d<   |                     |d         ||                     |          z            |d	<   n;|                                 |d	<   |d	         ||                     |          z  z
  |d<   |                     | 	                    ||                     d{V }| 
                    |d
ddddd          }	|                     |	||||          S )aQ  
        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
        Nr   -r   )
resolutionr   d   r   r   r   tohlcv)r   r   r   r   r  sumparse_timeframesecondsv4PublicNetGetCandlesr   convert_trading_view_to_ohlcvparse_ohlcvs)
r   r   	timeframer   r   r   r   r   r   rt   s
             r   fetch_ohlcvzmercado.fetch_ohlcv  sy      !!!!!!!!!V$$**4?IyQQVns*VG_<
 
 =E"//==GFO HHWV_ed>R>RS\>]>]6]^^GDMM LLNNGDM%dmut7K7KI7V7V/VWGFO33DKK4P4PQQQQQQQQ44XsCcSVX[\\  &)UEJJJr   c                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          S )a  
        fetches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentr  r~   r  orders	r   r~   r   r   privatePostListOrdersr   r   	safe_listparse_orders
r   r   r   r   r   r   r   r   r,  r  s
             r   fetch_orderszmercado.fetch_orders  s       >#DG.Y$YZZZ!!!!!!!!!V$$
 33DKK4P4PQQQQQQQQx"EEh;;  >>>r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         dd}|                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          S )a  
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of open order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- fetchOpenOrders() requires a symbol argumentr~   z[2])r  status_listr  r  r  r  s
             r   fetch_open_orderszmercado.fetch_open_orders  s       >#DG.]$]^^^!!!!!!!!!V$$ 
 
 33DKK4P4PQQQQQQQQx"EEh;;  >>>r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         dd}|                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          }
|                     |
          }| 	                    ||d         ||          S )	a  
        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr~   T)r  	has_fillsr  r  r   )
r   r~   r   r   r  r   r   r  orders_to_tradesfilter_by_symbol_since_limit)r   r   r   r   r   r   r   r   r,  	ordersRawr  rF  s               r   fetch_my_tradeszmercado.fetch_my_trades  s      >#DG.[$[\\\!!!!!!!!!V$$
 
 33DKK4P4PQQQQQQQQx"EEOOL(B??	""9feUCC&&v..009I5RWXXXr   c                     g }t          dt          |                    D ]Z}|                     ||         dg           }t          dt          |                    D ]}|                    ||                    [|S )Nr   rF  )r   r   r   r   )r   r  r   r   rF  ys         r   r  zmercado.orders_to_trades  s    q#f++&& 	) 	)A__VAY"==F1c&kk** ) )fQi(((()r   r]   GETc                    | j         d         |         dz   }|                     ||                     |                    }|dk    s|dk    s|dk    r7||                     ||          z  }|r|d|                     |          z   z  }n|                                  || j        dz   z  }|                                 }	|                     |                     ||	d|                    }d| j        z   dz   dz   |z   }
d	| j	        | 
                    |                     |
          |                     | j                  t          j                  d
}||||dS )Nrb   r   r]   r_   r`   ?)tapi_method
tapi_noncez/tapi/z!application/x-www-form-urlencoded)zContent-TypezTAPI-IDzTAPI-MAC)urlr  bodyheaders)r   omitextract_paramsimplode_params	urlencodecheck_required_credentialsr   noncer   apiKeyhmacencodesecrethashlibsha512)r   pathrb   r  r   r  r  r  queryr  auths              r   signzmercado.sign%  sr   is#c)		&$"5"5d";";<<8OO
!2!2}8L8L4&&tV444C 3sT^^E2222++---4<#%%CJJLLE>>$++##/ / # #  D dl*S036=D C; IIdkk$&7&7T[9Q9QSZSabb G
 fdwOOOr   c
                     |d S |                      |d          }
|
-t          | j        dz   |                     |          z             d S )Nerror_message )r   r   r~   json)r   httpCodereasonr  r  r  r  r   requestHeadersrequestBodyerrorMessages              r   handle_errorszmercado.handle_errors<  sR    4 xAA##		(0C0C CDDDtr   )N)-__name__
__module____qualname__r   r   r   r   r$  r   r   r   r   r   r   r   r   r  r   r  r  r   r   floatr	   r%  r   rh   r5  r
   r*  rL  rV   r   r   rW  r  rl  r~  r  r  r  r  r  r  __classcell__)r   s   @r   r   r      s       O O O O Ob *, V VV V V V Vp @DB A AS A AS\ A A A A % %6 %V % % % %N 68 1 1 1F 1 1 1 1<  5    > <@d[] A A AS A Abfglbm A A A A0) ) ) ) )  *, , , , , , , mqy{ " " "I "Y "X] "fi " " " "H 9=R */ */S */# */ */ */ */X: : :E E E5 E E E EN 8<B / /C / / / / /( EIQS 7< 7<3 7< 7< 7< 7< 7<r$
 $
x $
; $
 $
 $
 $
L
 
 
4 
 
 
 
 8=4^bkm K K KS KX[ Krvw{r| K K K K8 04$UYbd ? ? ?C ?s ?imnsit ? ? ? ?* 59tZ^gi ? ?c ? ?TW ?nrsxny ? ? ? ?, 37TX\eg Y YC Ys YRU Y Y Y Y0   &eBSW P P P P.      r   r   ) ccxt.async_support.base.exchanger   ccxt.abstract.mercador   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   ccxt.base.decimal_to_precisionr   r    r   r   <module>r     s   6 5 5 5 5 5 - - - - - -  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J       * * * * * * . . . . . . ) ) ) ) ) ) 4 4 4 4 4 4v v v v vh v v v v vr   