
    !:hgv                       d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dl*m+Z+ d dl*m,Z, d dl*m-Z- d dl*m.Z. d dl/m0Z0  G d dee      Z1y)    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidAddress)InvalidOrder)OrderNotFound)RateLimitExceeded)ExchangeNotAvailable)OnMaintenance)ROUND)TRUNCATE)DECIMAL_PLACES)SIGNIFICANT_DIGITS)Precisec                       e Zd Zdef fdZd Zd Zi fdefdZi fde	e
   fdZd Zi fdefdZd	 Zi fd
edefdZdQdede
defdZdi fdedefdZddi fd
ededede	e   fdZdQdede
defdZi fdefdZdQdZdi fd
ededefdZdQde
de fdZ!dddi fd
e"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e%fdZ&i fde%fdZ'i fd e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*d#e+d$e,d%e-f
d'Z/ddi fd(efd)Z0ddi fd(ed
ed"e*d#e+d$e-d%e-fd*Z1di fd(e"d
e"fd+Z2di fd(ed
e"fd,Z3di fd
e"fd-Z4di fd(ed
e"fd.Z5dddi fd
e"dedefd/Z6dddi fd
e"dedede	e7   fd0Z8dddi fd
e"dedede	e7   fd1Z9d2e"fd3Z:dQd4ede
de7fd5Z;dddi fd
e"dedefd6Z<dddi fd
e"dedede	e   fd7Z=di fd e"fd8Z>di fd ed$e,d9ede?fd:Z@dddi fd e"dedefd;ZAdddi fd e"dedede	e?   fd<ZBdddi fd e"dedefd=ZCdddi fd e"dedede	e?   fd>ZDd2e"fd?ZEdQd@edAeFde?fdBZGdQdAeFfdCZHdi fdDefdEZIdFdGi ddfdHZJdIeKdJedKedLedMedNefdOZLi fdPZM xZNS )Rbitvavoreturnc                    | j                  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d0dd1dd2di d3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBddCdi dDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSddTdddddUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddededfdgdhdidjdkdldmdndndndndodndndndndpdqdr	idndndodndpdqdododndodods	dndndtdudnidndndvdwdfdxdydd| j	                  dz      | j	                  d{      | j	                  d|      | j	                  dz      g| j	                  d}      | j	                  d~      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg	| j	                  d|      | j	                  d      g| j	                  d}      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      g| j	                  d      | j	                  d      gg	ddiddddddddd d ddd dddddddddddddd ddddddddddddd ddddddddddddd ddid	d d dd d dddi dt
        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        i dt        dt        dt        dt        dt        dt        dt        dt
        dt
        dt        dt        dt        dt
        dt        dt        dt        dt        i dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt
        dt
        dt        dt        t         t
        t        t
        t        t"        t
        t        t"        t"        t
        d՜t        t        t        t        d֜dלdt$        ddddܜd dgdޜdt&        dddii      S )Nidr-   nameBitvavo	countriesNL	rateLimit<   versionv2	certifiedFproThasCORSspotmarginswapfutureoption	addMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchWithdrawalsreduceMarginsetLeveragesetMarginMode)setPositionModetransferwithdraw
timeframes1m5m15m30m1h2h4h6h8h12h1d)r   r   r   r   r   r   r   r   r   r   r   urlszOhttps://github.com/user-attachments/assets/d213155c-8c71-4701-9bd5-45351febc2a8zhttps://api.bitvavo.com)publicprivatezhttps://bitvavo.com/zhttps://docs.bitvavo.com/zhttps://bitvavo.com/en/feesz!https://bitvavo.com/?a=24F34952F7)logoapiwwwdocfeesreferralr   get         )costnoMarket)	timemarketsassetsz{market}/bookz{market}/tradesz{market}/candleszticker/pricezticker/bookz
ticker/24h)	accountorderorders
ordersOpentradesbalancedepositdepositHistorywithdrawalHistory)r   
withdrawalr   )r   r   )r   postputdeleter   tradingz0.0025z0.0020100000z0.0020250000z0.0016500000z0.00121000000z0.00102500000z0.00085000000z0.000610000000z0.000525000000z0.0004z0.0015z0.0003)takermaker)	tierBased
percentager   r   tiersrequiredCredentials)apiKeysecretfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventioniceberg  i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r     )	sandboxrG   createOrdersrf   rj   ri   rl   fetchClosedOrdersrg   )linearinverse)r=   r?   r@   
exceptions101102103104105107108109110200201202203204205206210211212213214215216217230231232233234235236240300301302303304305306307308309310311312315317400401402403)404405406407408409410411412413414)zstart parameter is invalidzsymbol parameter is invalidzamount parameter is invalidzorderId parameter is invalid)exactbroadoptionsi'  ETHTRX)ERC20TRC20EUR)currencyToPrecisionRoundingModeBITVAVO-ACCESS-WINDOWnetworks
operatorIdfiatCurrenciesprecisionModecommonCurrenciesMIOTAIOTA)deep_extendsuperr-   describeparse_numberr   r   r$   r   r%   r   r"   r    r#   r   r   r&   r!   r(   r*   )self	__class__s    T/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/bitvavo.pyr3  zbitvavo.describe"   sO   gt = ? PB
)PB
IPB
 $PB
 	PB

 tPB
 PB
 4PB
  HHH %H 	H
 %H %H UH "4H tH $UH  H tH (H 'H (H  "4!H" T#H$ %H& +E'H( )%)H* '+H, (-H. "4/H0 &t1H2 (3H4 1%5H6  7H8 *:9H: +D;H< &u=H> #E?H@ *5AHB $UCHD "5EHF *5GHH +EIHJ  KHL %eMHN "5OHP QHR !%SHT  UHV dWHX +EYHZ "4[H\ d]H^ !$_H` taHb  cHd 'eHf $UgHh !%iHj *5kHl (mHn %eoHp )%qHr tsHt uHv TwHx tyHz "5{H| #D}H~  H@ !%AHB #DCHD EHF uGHH  IHJ $)! OHPB
b cPB
| i78 .25?
}PB
R  !#$"#)*+,,-()'(/0b&A
 $%!""#/0b&A"##$#$*+-.
 "#&'
   "#"#'&SPB
` !%"&!..x8!..w7 "..s3T5F5Fx5PQ!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX
" "..s3T5F5Fx5PQ!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mh<WX!..z:D<M<Mh<WX
"aPB
` "$aPB
h $&+(,,0,0)-+/6:#'#'"&#(	( #($)$)27+//3#()$, %)&+!%$*%+*.& ',#($)*.	# ',!%#($)*.( '+!%$*%+#($)*.$ *.#o:x ##
 ##ADiPB
r @=@:@ ,@ ,	@
 +@ /@ /@ /@ :@ :@ :@ :@ 9@ :@ :@  :!@" <#@$ <%@& <'@( <)@* <+@, <-@. ,/@0 <1@2 =3@4 =5@6 :7@8 <9@: <;@< ==@> :?@@ =A@B .C@D .E@F .G@H .I@J .K@N .O@P .Q@R +S@T .U@V .W@X +Y@Z +[@\ +]@^ :_@` +a@b =c@d =e@f +g@h +i@j )(%(,)(%))(@D 3=3<3?4@	EHsPB
D
 3;)."" ##('	E
PB
X
 /Y
PB
Z
 ![
PB
 P P	    c                 `    | j                  |t        | j                  |   d   d   t              S )N	precisionamount)decimal_to_precisionr(   r   r)   )r5  symbolr;  s      r7  amount_to_precisionzbitvavo.amount_to_precisionu  s1     ((4<<;OP[;\]e;fhvwwr8  c                     | j                  |t        | j                  |   d   d   | j                        }| j                  |t        dt
              S )Nr:  price   )r<  r'   r   r-  r(   r)   )r5  r=  r@  s      r7  price_to_precisionzbitvavo.price_to_precision{  sL    ))%V8L[8YZa8bdhdvdvw
 ((!^LLr8  c                 d   K   | j                  |       d{   }| j                  |d      S 7 w)a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Nr   )publicGetTimesafe_integerr5  paramsresponses      r7  
fetch_timezbitvavo.fetch_time  s5      ++F33   622	 4s   0.0c                 b   K   | j                  |       d{   }| j                  |      S 7 w)a  

        https://docs.bitvavo.com/#tag/General/paths/~1markets/get

        retrieves data on all markets for bitvavo
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        N)publicGetMarketsparse_marketsrF  s      r7  fetch_marketszbitvavo.fetch_markets  s3      ..v66 !!(++ 7   /-/c                 T   | j                   }| j                  |d      }g }| j                  }t        dt	        |            D ]b  }||   }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |	      }| j                  |
      }| j                  |d      }| j                  ||	      }| j                  |d      }|j                  | j                  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k(  dddd d d d d d d |d   d   |d   d   | j                  |d|      | j                  |d      dd d d| j                  |d       d dd d d| j                  |d!      d dd"d |d#             e |S )$Nr0   r   marketbasequotestatusr:  r=  /settlebaseIdquoteIdsettleIdtyper=   Tr>   Fr?   r@   rA   activer   contractr   r   r   decimalspricePrecision)r;  r@  minmaxminOrderInBaseAssetminOrderInQuoteAsset)r   r;  r@  r   )r   contractSizeexpiryexpiryDatetimestrike
optionTyper   r   r:  limitscreatedinfo)
currenciesindex_byr   rangelensafe_stringsafe_currency_code
safe_valuerE  appendsafe_market_structuresafe_number)r5  r   rk  currenciesByIdresultr   irP  r0   rV  rW  rQ  rR  rS  baseCurrencybasePrecisions                   r7  rL  zbitvavo.parse_markets  s   __
z48yyq#g,' <	AQZF!!&(3B%%ff5F&&vw7G**62D++G4E%%fh7F??>6BL --lKHMMM$44 26b26$*u,26 26 	26
 $26 &26 726 D26 26 26 %26 26 %26 %26 6Y.26  E!26" $#26$   $"&"i1i1"//j-X!..v7GH  $#!
  $//8MN#
  $#
  $//8NO#$  c26 2 2<	z r8  c                 b   K   | j                  |       d{   }| j                  |      S 7 w)a  

        https://docs.bitvavo.com/#tag/General/paths/~1assets/get

        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        N)publicGetAssetsparse_currencies_customrF  s      r7  fetch_currencieszbitvavo.fetch_currencies  s5      --f55D ++H55E 6rN  c                 6   | j                  | j                  dg       }i }t        dt        |            D ]?  }||   }| j	                  |d      }| j                  |      }| j                  ||      }i }	| j                  |dg       }
| j	                  |d      dk(  }| j	                  |d      dk(  }|xr |}| j                  |d      }| j                  |d	d
      }| j                  |d      }t        dt        |
            D ],  }|
|   }| j                  |      }||||||||d|d did	|	|<   . | j                  |||| j	                  |d      ||||	|||rdndd d dd d d|d ddd      ||<   B | j                  | j                  |      | _        |S )Nr,  r   r=  r*  depositStatusOKwithdrawalStatuswithdrawalFeer\  rA  withdrawalMinAmountr   r^  )	rj  r0   networkrZ  r   r   feer:  rh  r1   fiatcrypto)r;  r   r   )rj  r0   coder1   rZ  r   r   r*  r  r:  rY  rh  )	safe_listr"  rm  rn  ro  rp  in_arrayrt  rE  network_id_to_codesafe_currency_structurer1  rk  )r5  rk  r,  rv  rw  currencyr0   r  isFiatr*  networksArrayr   r   rZ  withdrawFeer:  minWithdrawj	networkIdnetworkCodes                       r7  r|  zbitvavo.parse_currencies_custom  s   D 6FKq#j/* ;	A!!}H!!(H5B**2.D]]48FH NN8ZDM&&xATIG))(4FG4OJ+F**8_EK))(JBI**85JKK1c-01 )!,	"55i@$#*$& *&!*"#.#'%)%&  77 ((6: "&$"&"(h  $#
  $# 
  +#!9 F4LC;	z **4??FCr8  r=  c                    K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  ||      S 7 W7 w)a  

        https://docs.bitvavo.com/#tag/Market-Data/paths/~1ticker~124h/get

        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>`
        NrP  r0   )load_marketsrP  publicGetTicker24hextendparse_ticker)r5  r=  rG  rP  requestrH  s         r7  fetch_tickerzbitvavo.fetch_ticker~  sy      !!!V$fTl
 00Wf1MNN"   622- 	"
 O"   A2A.A A2A0A20A2NtickerrP  c                 t   | j                  |d      }| j                  ||d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  i d|d|d	| j	                  |      d
| j                  |d
      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      d| j                  |d      dd d|	d|d|dd dd dd dd |||d|      S )NrP  -	timestamplastvolumevolumeQuoteopenr=  datetimehighlowbid	bidVolumebidSizeask	askVolumeaskSizevwapclosepreviousClosechanger   average)
baseVolumequoteVolumerj  )ro  safe_symbolrE  safe_tickeriso8601)
r5  r  rP  marketIdr=  r  r  r  r  r  s
             r7  r  zbitvavo.parse_ticker  s   & ##FH5!!(FC8%%fk:	/%%fh7
&&v}=/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 ))&)<!
 4##FE2!
 ))&)<!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r8  symbolsc                    K   | j                          d{    | j                  |       d{   }| j                  ||      S 7 /7 w)a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        N)r  r  parse_tickers)r5  r  rG  rH  s       r7  fetch_tickerszbitvavo.fetch_tickers  sK      !!!0088& !!(G44) 	"8s   A
AA
AA
A
sincer   c                   K   | j                          d{    | j                  |      }d}| j                  |dd      \  }}|r| j                  d||||       d{   S d|d   i}|t	        |d      |d<   |||d	<   | j                  d
||      \  }}| j                  | j                  ||             d{   }| j                  ||||      S 7 7 x7 w)an  

        https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1trades/get

        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
        :param int [params.until]: the latest time in ms to fetch entries for
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        NFrx   paginaterP  r0   r   r   startend)	r  rP  handle_option_and_paramsfetch_paginated_call_dynamicr_  handle_until_optionpublicGetMarketTradesr  parse_trades)	r5  r=  r  r   rG  rP  r  r  rH  s	            r7  fetch_tradeszbitvavo.fetch_trades  s     !!!V$88PZ[&::=&RWY^`fgggfTl
 "5$/GG$GG225'6J33DKK4PQQ   65%@@? 	"
 h Rs5   CCACCAC<C=CCCtradec                 8   | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  |d      }| j                  ||d      }	| j	                  |d	      }
d }|
|
rd	nd
}| j                  |d      }d }|(| j                  |d      }| j                  |      }||d}| j                  |d      }| j                  |||	|| j                  |      |d ||||d |d|      S )Nr@  r;  r  sider0   fillIdrP  r  r   r   r  feeCurrencyr   r  orderId)rj  r0   r=  r  r  r   rY  r  takerOrMakerr@  r;  r   r  )ro  rE  safe_string_2r  rq  rp  
safe_trader  )r5  r  rP  priceStringamountStringr  r  r0   r  r=  r   r  feeCostStringr  feeCurrencyIdfeeCurrencyCoder  s                    r7  parse_tradezbitvavo.parse_trade  sV   r &&ug6''x8%%e[9	v.tX6##E84!!(FC8w/&+7L((6$ ,,UMBM"55mDO%+C ""5)4"Y/( " 
  	r8  c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)aT  

        https://docs.bitvavo.com/#tag/Account/paths/~1account/get

        fetch the trading fees for multiple markets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        N)r  privateGetAccountparse_trading_feesrF  s      r7  fetch_trading_feeszbitvavo.fetch_trading_fees{  sI      !!!//77 &&x00 	"7   A	AA	AA	A	c                     | j                  |d      }| j                  |d      }| j                  |d      }i }t        dt        | j                              D ]  }| j                  |   }||||ddd||<    |S )Nr   r   r   r   T)rj  r=  r   r   r   r   )rq  rt  rm  rn  r  )	r5  r   rP  	feesValuer   r   rv  rw  r=  s	            r7  r  zbitvavo.parse_trading_fees  s     OOD&1	  G4  G4q#dll+, 		A\\!_F "!F6N		 r8  c                 *  K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }| j	                  ||d         }| j                  |d      |d<   |S 7 x7 2w)aB  

        https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1book/get

        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
        NrP  r0   depthr=  nonce)r  rP  publicGetMarketBookr  parse_order_bookrE  )r5  r=  r   rG  rP  r  rH  	orderbooks           r7  fetch_order_bookzbitvavo.fetch_order_book  s      !!!V$fTl
 $GG11$++gv2NOO" ))(F84DE	!..xA	'5 	" Ps"   BBABB1BBc           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr   r            r   )rE  rt  )r5  ohlcvrP  s      r7  parse_ohlcvzbitvavo.parse_ohlcv  sn     eQ'UA&UA&UA&UA&UA&
 	
r8  r   c                 P   | j                  |      }|d   | j                  | j                  ||      d}|B| j                  |      }||d<   |d}nt	        |d      }| j                  |||z  dz        |d<   | j                  d||      \  }}|||d<   | j                  ||      S )Nr0   )rP  intervalr  r   r   r  r   )rP  ro  r   parse_timeframer_  sumr  r  )	r5  r=  	timeframer  r   rG  rP  r  durations	            r7  fetch_ohlcv_requestzbitvavo.fetch_ohlcv_request  s    V$Tl(()YO
 ++I6H$GG}E4(!XXeUX-=-DEGEN225'6J$GG{{7F++r8  c           	      `  K   | j                          d{    | j                  |      }d}| j                  |dd      \  }}|r| j                  d|||||d       d{   S | j	                  |||||      }| j                  |       d{   }	| j                  |	||||      S 7 7 I7 w)a  

        https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1candles/get

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NFrg   r  r   )r  rP  r  "fetch_paginated_call_deterministicr  publicGetMarketCandlesparse_ohlcvs)
r5  r=  r  r  r   rG  rP  r  r  rH  s
             r7  fetch_ohlcvzbitvavo.fetch_ohlcv  s      !!!V$88zZ&@@vW\^cenpvx|}}}**69eUFS44W==   69eUKK 	"
 ~=s4   B.B(A	B. B*!-B.B,B.*B.,B.c                 2   |d d d}t        dt        |            D ]i  }||   }| j                  |d      }| j                  |      }| j	                         }| j                  |d      |d<   | j                  |d      |d<   |||<   k | j                  |      S )N)rj  r  r  r   r=  	availablefreeinOrderused)rm  rn  ro  rp  r   safe_balance)r5  rH  rv  rw  r   
currencyIdr  r   s           r7  parse_balancezbitvavo.parse_balance  s    

 q#h-( 	#AqkG))'8<J**:6DllnG"..wDGFO"..w	BGFO"F4L	#   ((r8  c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)ae  

        https://docs.bitvavo.com/#tag/Account/paths/~1balance/get

        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  privateGetBalancer  rF  s      r7  fetch_balancezbitvavo.fetch_balance-  sI      !!!//77 !!(++ 	"7r  r  c                 >  K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  |d      }| j	                  |d      }| j                  |       ||d||dS 7 7 Cw)a9  
        fetch the deposit address for a currency associated with self account
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        Nr=  r0   address	paymentId)rj  r  r  r  tag)r  r  privateGetDepositr  ro  check_address)r5  r  rG  r  r  rH  r  r  s           r7  fetch_deposit_addresszbitvavo.fetch_deposit_addressC  s      !!!==&htn
 //GV0LMM ""8Y7x57#
 	
 	"
 Ns#   BBA BBABBrY  r  r;  r@  c                    | j                  |      }|d   ||d}|dk(  xs |dk(  xs |dk(  }	|dk(  xs |dk(  xs |dk(  }
| j                  |d	      }| j                  |g d
      }| j                  |	d|      }| j	                  |d      }| j	                  |d      }| j                  |g d      }|	rd }|J| j                  |      }| j                  |      }t        j                  ||      }| j                  |      }n| j                  |d      }|=| j                  |d         d   }| j                  |t        || j                        |d<   n| j                  ||      |d<   | j                  |dg      }n,|
r*| j!                  ||      |d<   | j                  ||      |d<   |d uxs |dk(  xs |dk(  }|d uxs |d uxr | xs |dk(  xs |dk(  }|r||}|	rdnd|d<   n|r||}|	rdnd|d<   || j!                  ||      |d<   d|d<   d|d<   |
|dk7  r||d	<   |rd|d<   d }| j#                  |dd      \  }}|| j%                  |      |d<   | j'                  ||      S )Nr0   )rP  r  	orderTyperP  stopLoss
takeProfitr   stopLossLimittakeProfitLimitr   r   	stopPricetriggerAmountFr   r   )r   r   r  r   r   r   rR  r:  amountQuoter;  r@  r  r  triggerType	lastTradetriggerReferencer   TpostOnlyrG   r+  )rP  ro  safe_string_nis_post_onlyrq  omitnumber_to_stringr+   
string_mulr4  rt  r  r<  r(   r-  r>  rB  r  parse_to_intr  )r5  r=  rY  r  r;  r@  rG  rP  r  isMarketOrderisLimitOrderr   r   r  r   r   r   r  r  quoteAmountr:  isTakeProfit
isStopLossr+  s                           r7  create_order_requestzbitvavo.create_order_requesta  s   V$Tl

 )\tz/A\t|G[dT_-Dd$RcJc&&v}=))&2`a$$]E6B@//&2CD6#stD "33E:#44V<%00{K((5''7 MM&/:;G	)-)B)B4S\^b^p^p)q&$($<$<VV$L!YYvx0F#66vuEGG $ 8 8 HGH't3m9MmSW[lSl#4/  [\5M4eXdTd  [jnr|j|  [  CG  KZ  CZ
(,1>:OGK *.3@<FWGK #'+'>'>v|'TGO$%,GM"*5G&'#+*=%0GM""&GJ
!::6=R^_
F!$($5$5j$AGL!{{7F++r8  c                    K   | j                          d{    | j                  |      }| j                  ||||||      }| j                  |       d{   }	| j	                  |	|      S 7 V7 w)a3  
        create a trade order

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/post

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float price: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the bitvavo api endpoint
        :param str [params.timeInForce]: "GTC", "IOC", or "PO"
        :param float [params.stopPrice]: Alias for triggerPrice
        :param float [params.triggerPrice]: The price at which a trigger order is triggered at
        :param bool [params.postOnly]: If True, the order will only be posted to the order book and not executed immediately
        :param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
        :param float [params.takeProfitPrice]: The price at which a take profit order is triggered at
        :param str [params.triggerType]: "price"
        :param str [params.triggerReference]: "lastTrade", "bestBid", "bestAsk", "midPrice" Only for stop orders: Use self to determine which parameter will trigger the order
        :param str [params.selfTradePrevention]: "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
        :param bool [params.disableMarketProtection]: don't cancel if the next fill price is 10% worse than the best fill price
        :param bool [params.responseRequired]: Set self to 'false' when only an acknowledgement of success or failure is required, self is faster.
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        N)r  rP  r#  privatePostOrderparse_order)
r5  r=  rY  r  r;  r@  rG  rP  r  rH  s
             r7  create_orderzbitvavo.create_order  sw     2 !!!V$++FD$vV..w77R &11Y 	" 8s!   A1A-?A1A/A1/A1r0   c                 l   i }| j                  |      }	| j                  |d      }
| j                  |g d      }| j                  |g d      }|| j	                  ||      |d<   || j                  ||      |d<   |
| j                  ||
      |d<   || j	                  ||      |d<   | j                  ||      }| j                  |      rt        | j                  dz         | j                  |d      }|||d	<   d }| j                  |d
d      \  }}|| j                  |      |d<   |	d   |d<   |S )NamountRemainingr  )r)  r   r  r  r@  r;  r  zR editOrder() requires an amount argument, or a price argument, or non-empty paramsclientOrderIdr  rL   r+  r0   rP  )rP  rt  r  r  rB  r>  r  is_emptyr   r0   ro  r  r  )r5  r0   r=  rY  r  r;  r@  rG  r  rP  r)  r   r*  r+  s                 r7  edit_order_requestzbitvavo.edit_order_request  sm   V$**63DE))&2`a6#de#66vuEGG $ 8 8 HGH&)-)A)A&/)ZG%&#'+'>'>v|'TGO$++gv.==!#DGG  /C  %C  D  D((A !#GI
!::6;P\]
F!$($5$5j$AGL!"4Lr8  c           	         K   | j                          d{    | j                  |      }| j                  |||||||      }	| j                  |	       d{   }
| j	                  |
|      S 7 W7 w)a  
        edit a trade order

        https://docs.bitvavo.com/#tag/Orders/paths/~1order/put

        :param str id: cancel order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float [amount]: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the bitvavo api endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        N)r  rP  r,  privatePutOrderr&  )r5  r0   r=  rY  r  r;  r@  rG  rP  r  rH  s              r7  
edit_orderzbitvavo.edit_order  sv      !!!V$))"fdD&%QWX--g66&11	 	" 7r  c                    |t        | j                  dz         | j                  |      }d|d   i}| j                  |d      }|||d<   d }| j	                  |dd      \  }}|| j                  |      |d<   | j                  ||      S )Nz) cancelOrder() requires a symbol argumentrP  r0   r*  r  rD   r+  )r   r0   rP  ro  r  r  r  )r5  r0   r=  rG  rP  r  r*  r+  s           r7  cancel_order_requestzbitvavo.cancel_order_request  s    >#DGG.Y$YZZV$fTl
 ((A !#GI
!::6=R^_
F!$($5$5j$AGL!{{7F++r8  c                    K   | j                          d{    | j                  |      }| j                  |||      }| j                  |       d{   }| j	                  ||      S 7 S7 w)a  

        https://docs.bitvavo.com/#tag/Orders/paths/~1order/delete

        cancels an open order

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/delete

        :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>`
        N)r  rP  r1  privateDeleteOrderr&  )r5  r0   r=  rG  rP  r  rH  s          r7  cancel_orderzbitvavo.cancel_order!  so      !!!V$++B?0099 &11 	" :s!   A.A*<A.A,A.,A.c                    K   | j                          d{    i }d}|| j                  |      }|d   |d<   | j                  | j                  ||             d{   }| j	                  ||      S 7 ^7 w)a  

        https://docs.bitvavo.com/#tag/Orders/paths/~1orders/delete

        cancel all open orders
        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr0   rP  )r  rP  privateDeleteOrdersr  parse_orders)r5  r=  rG  r  rP  rH  s         r7  cancel_all_orderszbitvavo.cancel_all_orders:  s      !!![[(F &tGH11$++gv2NOO   622 	" Ps"   A9A5AA9A7A97A9c                 N  K   |t        | j                  dz         | j                          d{    | j                  |      }d|d   i}| j	                  |d      }|||d<   | j                  | j                  ||             d{   }| j                  ||      S 7 p7 w)a  
        fetches information on an order made by the user

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/get

        :param str id: the 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( fetchOrder() requires a symbol argumentrP  r0   r*  r  )r   r0   r  rP  ro  privateGetOrderr  r&  )r5  r0   r=  rG  rP  r  r*  rH  s           r7  fetch_orderzbitvavo.fetch_orderT  s      >#DGG.X$XYY!!!V$fTl
 ((A !#GI--dkk'6.JKKF &11W 	" Ls"   .B%B!AB%
B#B%#B%c                     | j                  |      }d|d   i}|||d<   |||d<   | j                  d||      \  }}| j                  ||      S NrP  r0   r  r   r  rP  r  r  r5  r=  r  r   rG  rP  r  s          r7  fetch_orders_requestzbitvavo.fetch_orders_request  k    V$fTl
 $GG$GG225'6J{{7F++r8  c                   K   |t        | j                  dz         | j                          d{    d}| j                  |dd      \  }}|r| j	                  d||||       d{   S | j                  |      }| j                  ||||      }| j                  |       d{   }| j                  ||||      S 7 7 X7 w)az  

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1orders/get

        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
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz) fetchOrders() requires a symbol argumentFrl   r  )	r   r0   r  r  r  rP  r@  privateGetOrdersr7  	r5  r=  r  r   rG  r  rP  r  rH  s	            r7  fetch_orderszbitvavo.fetch_orders  s      >#DGG.Y$YZZ!!!88PZ[&::=&RWY^`fgggV$++FE5&I..w77J   65%@@Y 	" h 83   .CB>6C'C (=C%C&C CCc                    K   | j                          d{    i }d}|| j                  |      }|d   |d<   | j                  | j                  ||             d{   }| j	                  ||||      S 7 `7 w)a  

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1ordersOpen/get

        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr0   rP  )r  rP  privateGetOrdersOpenr  r7  )r5  r=  r  r   rG  r  rP  rH  s           r7  fetch_open_orderszbitvavo.fetch_open_orders  s      !!!
 [[(F &tGH224;;w3OPPJ   65%@@[ 	" Qs"   A;A7AA;A9A;9A;rS  c                 H    dddddddddddddd}| j                  |||      S )Nr  canceledclosed)newrK  canceledAuctioncanceledSelfTradePreventioncanceledIOCcanceledFOKcanceledMarketProtectioncanceledPostOnlyfilledpartiallyFilledexpiredrejectedawaitingTriggerro  r5  rS  statusess      r7  parse_order_statuszbitvavo.parse_order_status  sG    ")+5%%(2 *%!"%
 &&99r8  r   c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  ||d      }|d   }| j                  | j                  |d            }| j                  |d      }| j                  |d      }	| j                  |d	      }
| j                  |d
      }| j                  |d      }| j                  |d      }| j                  |d      }|:| j                  |d      }| j                  |d      }t	        j
                  ||      }d }| j                  |d      }|(| j                  |d      }| j                  |      }||d}| j                  |dg       }| j                  |d      }| j                  |d      }| j                  i d|d|dd d|d| j                  |      dd d|d|	d|d|d|d	|
d| j                  |d      d
|d|dd d |||||d!|      S )"Nr  ri  rP  r  r=  rS  r  r  r@  r;  r)  filledAmountfilledAmountQuoter  amountQuoteRemainingfeePaidr  r  fillsr   r  rj  r0   r*  r  r  lastTradeTimestamprY  r   r   r  rT  )	remainingrS  r  r   )ro  rE  safe_marketr\  r+   
string_subrt  rp  rq  
safe_orderr  )r5  r   rP  r0   r  r  r=  rS  r  rY  r@  r;  rd  rT  r   r  r`  r  feeCostr  r  	rawTradesr   r  s                           r7  r&  zbitvavo.parse_order*  s   \ eY/%%eY7	##E84!!(FC8!(()9)9%)JKv.{3  0!!%2$$U,=>	!!%8':;<**5-@K#'#3#3E;Q#R %%k3GHD""5)4 ,,UMBM"55mDO+C OOE7B7	&&um<??5*5  
E 
" 
 T 
 	 

 Y/ 
 !$ 
 f 
 D 
 ; 
  
 D 
 U 
 D,,UNC 
 f 
 D 
  t! 
" f# 
$ #+ 
, - 	r8  c                     | j                  |      }d|d   i}|||d<   |||d<   | j                  d||      \  }}| j                  ||      S r=  r>  r?  s          r7  fetch_my_trades_requestzbitvavo.fetch_my_trades_request  rA  r8  c                   K   |t        | j                  dz         | j                          d{    d}| j                  |dd      \  }}|r| j	                  d||||       d{   S | j                  |      }| j                  ||||      }| j                  |       d{   }| j                  ||||      S 7 7 X7 w)aC  

        https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1trades/get

        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
        :param int [params.until]: the latest time in ms to fetch entries for
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentFrf   r  )	r   r0   r  r  r  rP  rk  privateGetTradesr  rD  s	            r7  fetch_my_tradeszbitvavo.fetch_my_trades  s      >#DGG.[$[\\!!!88R\]&::?FTY[`bhiiiV$..vueVL..w77$   65%@@3 	" j 8rF  c                     | j                  |      }|d   | j                  ||      |d}|||d<   | j                  ||      S )Nr0   )r=  r;  r  r  )r  currency_to_precisionr  )r5  r  r;  r  r  rG  r  r  s           r7  withdraw_requestzbitvavo.withdraw_request  sS    ==&tn00v>
 ?#&GK {{7F++r8  r  c                 0  K   | j                  ||      \  }}| j                  |       | j                          d{    | j                  |      }| j	                  |||||      }| j                  |       d{   }| j                  ||      S 7 U7 w)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>`
        N)handle_withdraw_tag_and_paramsr  r  r  rq  privatePostWithdrawalparse_transaction)	r5  r  r;  r  r  rG  r  r  rH  s	            r7  r   zbitvavo.withdraw  s      99#vFV7#!!!==&''fgsFK33G<< %%h99 	" =s!   :BB>B;B<BBc                     i }d }|| j                  |      }|d   |d<   |||d<   |||d<   | j                  ||      S Nr0   r=  r  r   r  r  r5  r  r  r   rG  r  r  s          r7  fetch_withdrawals_requestz!bitvavo.fetch_withdrawals_request  c    
 }}T*H (GH$GG$GG{{7F++r8  c                    K   | j                          d{    | j                  ||||      }d}|| j                  |      }| j                  |       d{   }| j	                  ||||ddi      S 7 ]7 w)a  

        https://docs.bitvavo.com/#tag/Account/paths/~1withdrawalHistory/get

        fetch all withdrawals made from an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the bitvavo api endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NrY  r   )r  rz  r  privateGetWithdrawalHistoryparse_transactionsr5  r  r  r   rG  r  r  rH  s           r7  fetch_withdrawalszbitvavo.fetch_withdrawals  s      !!!00ueVL}}T*H99'BB &&x5%&R^I_``) 	"
 C"   A8A4AA8A6A86A8c                     i }d }|| j                  |      }|d   |d<   |||d<   |||d<   | j                  ||      S rw  rx  ry  s          r7  fetch_deposits_requestzbitvavo.fetch_deposits_request#  r{  r8  c                    K   | j                          d{    | j                  ||||      }d}|| j                  |      }| j                  |       d{   }| j	                  ||||ddi      S 7 ]7 w)a  

        https://docs.bitvavo.com/#tag/Account/paths/~1depositHistory/get

        fetch all deposits made to an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the bitvavo api endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        NrY  r   )r  r  r  privateGetDepositHistoryr~  r  s           r7  fetch_depositszbitvavo.fetch_deposits4  s      !!!--dE5&I}}T*H66w?? &&x5%&R[I\]]% 	"
 @r  c           
      @    dddddddddd	}| j                  |||      S )NpendingokrK  )	awaiting_processingawaiting_email_confirmationawaiting_bitvavo_inspectionapprovedsending
in_mempool	processed	completedrK  rY  rZ  s      r7  parse_transaction_statusz bitvavo.parse_transaction_statusT  s;    #,+4+4! #""

 &&99r8  transactionr  c                 ,   d }| j                  |d      }| j                  |d      }| j                  ||      }| j                  | j                  |d            }| j	                  |d      }| j                  |d      }	| j                  |d      }
d }| j	                  |d      }|||d}d }d	|v sd|v rd
}nd}| j                  |d      }i d|d|d|
d|d| j                  |      dd d|	d|	dd d|d|d|d|d|d|dd d|d d d dS )Nr  r=  rS  r;  r  txIdr  r  successr   r   r  rj  r0   txidr  addressFrom	addressTotagFromr  tagTorY  r  updated)r  commentinternal)rE  ro  rp  r  rt  r  )r5  r  r  r0   r  r  r  rS  r;  r  r  r  rh  rY  r  s                  r7  ru  zbitvavo.parse_transactionb  s   D %%k;?	%%k8<
&&z8<..t/?/?X/VW!!+x8"";	:V4"";6 C $){*BDD{K8
K
"
 D
 	

 Y/
 4
 w
 
 t
 3
 S
 D
 f
 
 f
  t!
" 3#
$ )
 	
r8  c                     || j                  |d      dd| j                  |d      ddi d}| j                  |d      }| j                  |d      }| j                  |d      }|d	k(  r|}| j                  ||      }|d
   |d   d|d   |<   |S )Nr  F)r  r   
depositFee)rj  r   r   r*  r*  r   r  Mainnetr   r   )r   r   )rt  rq  ro  r  )r5  r  r  rv  r*  r  currencyCoder  s           r7  parse_deposit_withdraw_feez"bitvavo.parse_deposit_withdraw_fee  s    & ''_=#
 ''\:# 
 ??3
3OOHa0	''&9	!$I--iFi(z*+
z;' r8  codesc                    K   | j                          d{    | j                  |       d{   }| j                  ||d      S 7 07 w)ag  
        fetch deposit and withdraw fees

        https://docs.bitvavo.com/#tag/General/paths/~1assets/get

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
        Nr=  )r  r{  parse_deposit_withdraw_fees)r5  r  rG  rH  s       r7  fetch_deposit_withdraw_feesz#bitvavo.fetch_deposit_withdraw_fees  sM      !!!--f55( //%JJ+ 	"5s   AAAA	A	Ar   GETc                    | j                  || j                  |            }d| j                  z   dz   | j                  ||      z   }|dk(  xs |dk(  }	|	r|r|d| j	                  |      z   z  }|dk(  r| j                          d}
|	s|r| j                  |      }|}
t        | j                               }||z   |z   |
z   }| j                  | j                  |      | j                  | j                        t        j                        }| j                  | j                  dd      }| j                   |||d	}|	sd
|d<   | j"                  d   |   |z   }||||dS )NrT  r  DELETE?r    r)  10000)zBITVAVO-ACCESS-KEYzBITVAVO-ACCESS-SIGNATUREzBITVAVO-ACCESS-TIMESTAMPr)  zapplication/jsonzContent-Typer   )urlmethodbodyheaders)r  extract_paramsr7   implode_params	urlencodecheck_required_credentialsjsonstrmillisecondshmacencoder   hashlibsha256ro  r"  r   r   )r5  pathr   r  rG  r  r  queryr  getOrDeletepayloadr  auth	signatureaccessWindows                  r7  signzbitvavo.sign  s_   		&$"5"5d";<DLL 3&)<)<T6)JJ?Fh,>sT^^E222)++-G99U+D"GD--/0Iv%+g5D		$++d"3T[[5Mw~~^I++DLL:QSZ[L&*kk,5,5)5	G *<'iis#c)fdwOOr8  httpCodereasonr  r  r  r  c
                    |y | j                  |d      }
| j                  |d      }|
]| j                  dz   |z   }| j                  | j                  d   ||       | j	                  | j                  d   |
|       t        |      y )N	errorCodeerror r!  r   )ro  r0   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r5  r  r  r  r  r  r  rH  requestHeadersrequestBodyr  r  feedbacks                r7  handle_errorszbitvavo.handle_errors  s     $$X{;	  73 ww}t+H001I5RZ[001I9V^_))r8  c                 B    d|v r	d|vr|d   S | j                  |dd      S )Nr   rP  r   r   )rq  )r5  r   r  r  rG  configs         r7  calculate_rate_limiter_costz#bitvavo.calculate_rate_limiter_cost)  s/    & 8v+=*%%vvq11r8  )N)O__name__
__module____qualname__r   r3  r>  rB  r
   rI  r   r   rM  rL  r   r}  r|  r  r   r  dictr  r   r   r  r   r  r  r   r  r  r   r  listr  r   r  r  r   r  r  r	   r	  r   r   floatr   r#  r'  r,  r/  r1  r4  r8  r;  r@  r   rE  rI  r\  r&  rk  rn  rq  r   r   rz  r  r  r  r  r   ru  r  r  r  intr  r  __classcell__)r6  s   @r7  r-   r-       s   Q# Qf
xM ') 
3S 
3 *, ,V ,4BH -/ +6: +6ZbH 68  3  3F  3D/4 / /6 /b 6:" 57 5 5: <@d[] -A -AS -A -Abfglbm -A^\ \v \ \| /1 1[ 1,4 @DB %S % %S\ %N
 
4 
( :>D_cln ,# ,c ,Y\ ,. 8<$]ajl L LC LWZ Lquvzq{ L@) )  *, , ,, =? 
 
> 
< os{} 7,3 7,i 7,y 7,Z_ 7,hk 7,r mqy{ E2 E2I E2Y E2X] E2fi E2N FJQU^` S 6 fjx|  FH 23 2 29 2I 2_b 2ru 2* ;?r ,s ,C ,  9=R 2S 2# 22 59 3c 34 8<B 82C 82 82t 26DW[df ,3 ,c ,QT ," 04$UYbd <A <AC <As <Aimnsit <A| 59tZ^gi 9Ac 9A 9ATW 9Anrsxny 9Av: :$b bv b bH 59tZ^gi ,c , ,TW ," 37TX\eg )AC )As )ARU )Alpqvlw )AV @DB ,S , JNVX :3 : : :]h :2 59tZ^gi ,c , ,TW ," 37TX\eg  aC  as  aRU  alpq|l}  aD 26DW[df ,3 ,c ,QT ," 04$UYbd ^ ^C ^s ^imnyiz ^@:s :L
T L
X L
Q\ L
\( (T BFb Kw KB &eBSW P:c 3 S # X\ dg " MO 2r8  r-   )2 ccxt.async_support.base.exchanger   ccxt.abstract.bitvavor   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   ccxt.base.decimal_to_precisionr'   r(   r)   r*   ccxt.base.preciser+   r-    r8  r7  <module>r     s    6 -  J  J  J  J  J  J  * 0 - - . ' & . + ) * . 1 * 0 3 9 = %L 2h L 2r8  