
    ei                    p   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dlm)Z) d dl*m+Z+ d dl*m,Z, d dl-m.Z.  G d dee          Z/dS )    )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)TRUNCATE)	TICK_SIZE)Precisec                       e Zd Zdef f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dPd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dPdededefdZi fdefdZdPdZd
i fdededefdZdPd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'Z.d
d
i fd&eded e(d!e)d"e+d#e+fd(Z/d
i fd&e de fd)Z0d
i fd&ede fd*Z1d
i fde fd+Z2d
i fd&ede fd,Z3d
d
d
i fde dedefd-Z4d
d
d
i fde dededee5         fd.Z6d
d
d
i fde dededee5         fd/Z7d0e fd1Z8dPd2edede5fd3Z9d
d
d
i fde dedefd4Z:d
d
d
i fde dededee         fd5Z;d
i fde fd6Z<d
i fded"e*d7ed8e de=f
d9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
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=ZBd0e fd>ZCdPd?ed@eDde=fdAZEdPd@eDfdBZFd
i fdCefdDZGdEdFi d
d
fdGZHdHeIdIedJedKedLedMefdNZJi fdOZK xZLS )Qbitvavoreturnc                     |                      t          t          |                                           i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5d6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i dUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddedi dfddgddhddiddjddkddlddmddnddoddpddqddrddsddtdduddvdddddwdxdydzd{d|d}d~dddddddddddddddddddddddddddddd	idddddddddddddddddddddddddddiddddddddddd|                     d          |                     d          |                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          gg	|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     d          g|                     d          |                     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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 d gddt&          ddidd          S (  Nidr+   nameBitvavo	countriesNL	rateLimit<   versionv2	certifiedFproThasCORSspotmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMargin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subaccountssubaccounts/transfersz"subaccounts/transfers/{transferId}z!institutional/subaccounts/balancez!institutional/subaccounts/historyz%institutional/subaccounts/orders/open)r   
withdrawalr   r   r   )r   r   zinstitutional/subaccounts/orderz institutional/subaccounts/orders)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)EXPIRE_MAKEREXPIRE_TAKEREXPIRE_BOTHNONE)
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     )	sandboxrH   createOrdersr|   r   r   r   fetchClosedOrdersr}   )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MIOTAIOTAg     L@)commonCurrenciesrollingWindowSize)deep_extendsuperr+   describeparse_numberr   r   r$   r   r%   r   r"   r    r#   r   r   r&   r!   r'   r(   )self	__class__s    X/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/bitvavo.pyrZ  zbitvavo.describe    s   gt 4 4 = = ? ? BB
)BB
IBB
 $BB
 	BB

 tBB
 BB
 4BB
  jjj %j 	j
 %j %j Uj $Uj 'j j "4j tj $Uj  j tj  7!j" 9%#j j$ &u%j& ('j( ')j* (+j, "4-j. T/j0 1j2 &u3j4 "55j6 +E7j8 )%9j: #E;j< ,U=j> '?j@ (AjB "4CjD &tEj j jF (GjH 1%IjJ  KjL *:MjN +DOjP &uQjR 'SjT (UjV #EWjX *5YjZ $U[j\ u]j^ "5_j` *5ajb +Ecjd )%ejf  gj j jh !%ijj %ekjl $Umjn &uojp -eqjr /sjt "5ujv #Ewjx +Eyjz {j| !%}j~ "5j@ &uAjB +ECjD  EjF dGjH $UIj j jJ +EKjL %eMjN "4OjP uQjR #ESjT dUjV !$WjX tYjZ  [j\ ']j^ $U_j` !%ajb *5cjd (ejf %egjh )%ijj )%kj j jl tmjn ojp Tqjr tsjt "5ujv #Dwjx  yjz !%{j| )%}j~ #Dj@ AjB #ECjD &uEjF uGjH uIjJ UKjL  Mj jN $)! Sj j jBB
f  gBB
@ i78  .25?
 
ABB
V  !#$"#)*+,,-()'(/0b&A&A
 
 $%!""#/0b&A&A"##$#$*+-.'(12>?=>=>JKY[A\A\ $ "#&''(12	    "#"#;<<=	 7! !0 0WBB
x !%"&!..x88!..w77 "..s33T5F5Fx5P5PQ!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX
" "..s33T5F5Fx5P5PQ!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..x88$:K:KH:U:UV!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..y994;L;LX;V;VW!..z::D<M<Mh<W<WX!..z::D<M<Mh<W<WX
"  yBB
x "$ $yBB
@ $&+(,,0,0)-+/6:#'#'"&#(	( ( #($)$)27+/,1,1+/$)	0 0 $)3$ $6 %)&+!%$*%+*.& & ',#($)*.	# # ',!%#($)*.( ( '+!%$*%+#($)*.$ $ *.#y? ?B ## 
 ## KI IABB
T	 @=@:@ ,@ ,	@
 +@ /@ /@ /@ :@ :@ :@ :@ 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 HU	BB
f 3;).""  ##('	 	gBB
z Y{BB
~ ! ")CBB
 BB
 BB
 B B B	    c                 h   K   |                      |           d{V }|                     |d          S )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r\  paramsresponses      r^  
fetch_timezbitvavo.fetch_time  sE       ++F33333333   6222r_  c                 f   K   |                      |           d{V }|                     |          S )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_marketsrc  s      r^  fetch_marketszbitvavo.fetch_markets  sC       ..v66666666( !!(+++r_  c                 b   g }| j         }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |          }	|                     |          }
|                     |d          }|                    |                     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         |                     |                     |                     |d                              | 	                    |d          |                     |                     |                     |d                              dd d d| 	                    |d           | 	                    |d!          dd d d| 	                    |d"          | 	                    |d#          dd$d |d%                     |S )&Nr   marketbasequotestatusr.   symbol/settlebaseIdquoteIdsettleIdtyper;   Tr<   Fr=   r>   r?   activer   contractr  r   r   quantityDecimalstickSizenotionalDecimals)amountpricer   minmaxminOrderInBaseAssetmaxOrderInBaseAssetminOrderInQuoteAssetmaxOrderInQuoteAsset)r   r|  r}  r   )r  contractSizeexpiryexpiryDatetimestrike
optionTyper   r   	precisionlimitscreatedinfo)
r   rangelensafe_stringsafe_currency_codeappendsafe_market_structurer[  parse_precisionsafe_number)r\  r   resultr   irl  r.   rs  rt  rm  rn  ro  s               r^  ri  zbitvavo.parse_markets  s   yq#g,,'' ;	 ;	AQZF!!&(33B%%ff55F&&vw77G**622D++G44E%%fh77FMM$44 36b36$*u,36 36 	36
 $36 &36 736 D36 36 36 %36 36 %36 %36 6Y.36  E!36" $#36$   $"&"i1i1"//0D0DTEUEUV\^pEqEq0r0rss!--fjAA --d.B.B4CSCSTZ\nCoCo.p.pqq   $#! !
  $//8MNN#//8MNN 
  $# 
  $//8NOO#//8NOO  $  e36 36 36 3 3 3 3 3 3h r_  c                 f   K   |                      |           d{V }|                     |          S )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_customrc  s      r^  fetch_currencieszbitvavo.fetch_currencies  sD       --f55555555D ++H555r_  c                    |                      | j        dg           }i }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     ||          }i }	|                      |dg           }
|                     |d          dk    }|                     |d          dk    }|o|}|                     |d          }|                     |d	d
          }|                     |d          }t          dt          |
                    D ]Y}|
|         }|                     |          }|||||||| 	                    | 
                    |                    d|d did	|	|<   Z|                     ||||                     |d          ||||	|d |rdndd d dd d d|d ddd          ||<   |S )NrR  r   rp  rP  depositStatusOKwithdrawalStatuswithdrawalFeedecimals8withdrawalMinAmountr   r~  )	r  r.   networkrw  r   r   feer  r  r/   fiatcrypto)r|  r   r   )r  r.   coder/   rw  r   r   rP  r  r  rv  r  )	safe_listrH  r  r  r  r  in_arrayr  network_id_to_coder[  r  safe_currency_structure)r\  
currenciesrR  r  r  currencyr.   r  isFiatrP  networksArrayr   r   rw  withdrawFeer  minWithdrawj	networkIdnetworkCodes                       r^  r  zbitvavo.parse_currencies_custom>  sf   D 6FKKq#j//** ;	 ;	A!!}H!!(H55B**2..D]]488FH NN8ZDDM&&xAATIG))(4FGG4OJ+F**8_EEK((:sCCI**85JKKK1c-0011  )!,	"55i@@$#*$& *&!%!2!243G3G	3R3R!S!S"#.#'% %) )%%   77 ((6:: "&$"!"(6h  $# 
  $#   
  +#! ! 9 9  F4LL6 r_  rp  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||          S )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>`
        Nrl  r.   )load_marketsrl  publicGetTicker24hextendparse_ticker)r\  rp  rd  rl  requestre  s         r^  fetch_tickerzbitvavo.fetch_ticker  s       !!!!!!!!!V$$fTl
 00Wf1M1MNNNNNNNN"   6222r_  Ntickerrl  c                    |                      |d          }|                     ||d          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }	|                     i d|d|d	|                     |          d
|                      |d
          d|                      |d          d|                      |d          d|                      |d          d|                      |d          d|                      |d          dd d|	d|d|dd dd dd dd |||d|          S )Nrl  -	timestamplastvolumevolumeQuoteopenrp  datetimehighlowbid	bidVolumebidSizeask	askVolumeaskSizevwapclosepreviousClosechanger   average)
baseVolumequoteVolumer  )r  safe_symbolrb  safe_tickeriso8601)
r\  r  rl  marketIdrp  r  r  r  r  r  s
             r^  r  zbitvavo.parse_ticker  s	   & ##FH55!!(FC88%%fk::	//%%fh77
&&v}==// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 ))&)<<!
 4##FE22!
 ))&)<<!
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r_  symbolsc                    K   |                                   d{V  |                     |           d{V }|                     ||          S )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)r\  r  rd  re  s       r^  fetch_tickerszbitvavo.fetch_tickers  si       !!!!!!!!!0088888888& !!(G444r_  sincer   c                   K   |                                   d{V  |                     |          }d}|                     |dd          \  }}|r|                     d||||           d{V S d|d         i}|t	          |d          |d<   |||d	<   |                     d
||          \  }}|                     |                     ||                     d{V }|                     ||||          S )al  

        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>`
        NFr   paginaterl  r.   r   r   startend)	r  rl  handle_option_and_paramsfetch_paginated_call_dynamicr  handle_until_optionpublicGetMarketTradesr  parse_trades)	r\  rp  r  r   rd  rl  r  r  re  s	            r^  fetch_tradeszbitvavo.fetch_trades  s?      !!!!!!!!!V$$88PZ[[& 	h::=&RWY^`fgggggggggfTl
 "5$//GG$GG225'6JJ33DKK4P4PQQQQQQQQ   65%@@@r_  tradec                    |                      |d          }|                      |d          }|                     |d          }|                      |d          }|                     |dd          }|                      |d          }|                     ||d          }	|                     |d	          }
d }|
|
rd	nd
}|                      |d          }d }|0|                      |d          }|                     |          }||d}|                      |d          }|                     |||	||                     |          |d ||||d |d|          S )Nr}  r|  r  sider.   fillIdrl  r  r   r   r  feeCurrencyr   r  orderId)r  r.   rp  r  r  r   rv  r  takerOrMakerr}  r|  r   r  )r  rb  safe_string_2r  
safe_valuer  
safe_trader  )r\  r  rl  priceStringamountStringr  r  r.   r  rp  r   r  feeCostStringr  feeCurrencyIdfeeCurrencyCoder  s                    r^  parse_tradezbitvavo.parse_trade?  s   r &&ug66''x88%%e[99	v..tX66##E844!!(FC88w//&+877L((66$ ,,UMBBM"55mDDO%+ C ""5)44"Y//( " 
  
   	r_  c                    K   |                                   d{V  |                     |           d{V }|                     |          S )aR  

        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_feesrc  s      r^  fetch_trading_feeszbitvavo.fetch_trading_fees  sg       !!!!!!!!!//77777777 &&x000r_  c                 
   |                      |d          }|                     |d          }|                     |d          }i }t          dt          | j                            D ]}| j        |         }||||ddd||<   |S )Nr   r   r   r   T)r  rp  r   r   r   r   )r  r  r  r  r  )	r\  r   rl  	feesValuer   r   r  r  rp  s	            r^  r  zbitvavo.parse_trading_fees  s     OOD&11	  G44  G44q#dl++,, 		 		A\!_F "! F6NN r_  c                 R  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||d                   }|                     |d          |d<   |S )a@  

        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
        Nrl  r.   depthrp  nonce)r  rl  publicGetMarketBookr  parse_order_bookrb  )r\  rp  r   rd  rl  r  re  	orderbooks           r^  fetch_order_bookzbitvavo.fetch_order_book  s       !!!!!!!!!V$$fTl
 $GG11$++gv2N2NOOOOOOOO" ))(F84DEE	!..xAA	'r_  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r            r   )rb  r  )r\  ohlcvrl  s      r^  parse_ohlcvzbitvavo.parse_ohlcv  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
r_  r   c                    |                      |          }|d         |                     | j        ||          d}|N|                     |          }||d<   |d}nt	          |d          }|                     |||z  dz            |d<   |                     d||          \  }}|||d<   |                     ||          S )Nr.   )rl  intervalr  r  r   r  r   )rl  r  r   parse_timeframer  sumr  r  )	r\  rp  	timeframer  r   rd  rl  r  durations	            r^  fetch_ohlcv_requestzbitvavo.fetch_ohlcv_request  s    V$$Tl(()YOO
 
 ++I66H$GG}E4((!XXeUX-=-DEEGEN225'6JJ$GG{{7F+++r_  c           	      |  K   |                                   d{V  |                     |          }d}|                     |dd          \  }}|r!|                     d|||||d           d{V S |                     |||||          }|                     |           d{V }	|                     |	||||          S )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
        NFr}   r  r  )r  rl  r  "fetch_paginated_call_deterministicr  publicGetMarketCandlesparse_ohlcvs)
r\  rp  r  r  r   rd  rl  r  r  re  s
             r^  fetch_ohlcvzbitvavo.fetch_ohlcv  s       !!!!!!!!!V$$88zZZ& 	~@@vW\^cenpvx|}}}}}}}}}**69eUFSS44W========   69eUKKKr_  c                 t   |d d d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )N)r  r  r  r   rp  	availablefreeinOrderused)r  r  r  r  r   safe_balance)r\  re  r  r  r   
currencyIdr  r   s           r^  parse_balancezbitvavo.parse_balance?  s    
 

 q#h--(( 	# 	#AqkG))'8<<J**:66DllnnG"..wDDGFO"..w	BBGFO"F4LL  (((r_  c                    K   |                                   d{V  |                     |           d{V }|                     |          S )ac  

        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  rc  s      r^  fetch_balancezbitvavo.fetch_balanceO  sg       !!!!!!!!!//77777777 !!(+++r_  r  c                 h  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d          }|                     |d          }|                     |           ||d||dS )a7  
        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>`
        Nrp  r.   address	paymentId)r  r  r  r$  tag)r  r  privateGetDepositr  r  check_address)r\  r  rd  r  r  re  r$  r&  s           r^  fetch_deposit_addresszbitvavo.fetch_deposit_addresse  s       !!!!!!!!!==&&htn
 //GV0L0LMMMMMMMM ""8Y77x557###
 
 	
r_  rv  r  r|  r}  c                     |                      |          }|d         ||d}|dk    p|dk    p|dk    }	|dk    p|dk    p|dk    }
|                     |d	          }|                     |g d
          }|                     |	d|          }|                     |d          }|                     |d          }|                     |g d          }|	rd }|U|                     |          }|                     |          }t          j        ||          }| 	                    |          }n| 
                    |d          }|G|                     |d                   d         }|                     |t          || j                  |d<   n|                     ||          |d<   |                     |dg          }n4|
r2|                     ||          |d<   |                     ||          |d<   |d up|dk    p|dk    }|d up|d ur| p|dk    p|dk    }|r||}|	rdnd|d<   n|r||}|	rdnd|d<   |#|                     ||          |d<   d|d<   d|d<   ||dk    r||d	<   |rd|d<   d }|                     |dd          \  }}||                     |          |d<   nt'          | j        dz             d }|                     |dd           \  }}||d!k    rd"|d <   n||d <   |                     ||          S )#Nr.   )rl  r  	orderTyperl  stopLoss
takeProfitr   stopLossLimittakeProfitLimitr   r   	stopPricetriggerAmountFr   r   )r   r   r1  r   r   r   rn  r  amountQuoter|  r}  r+  r2  triggerType	lastTradetriggerReferencer   TpostOnlyrH   rQ  zk createOrder() requires an operatorId in params or options, eg: exchange.options['operatorId'] = 1234567890r   r   
cancelBoth)rl  r  safe_string_nis_post_onlyr  omitnumber_to_stringr)   
string_mulr[  r  r  decimal_to_precisionr'   rS  amount_to_precisionprice_to_precisionr  parse_to_intr   r.   r  )r\  rp  rv  r  r|  r}  rd  rl  r  isMarketOrderisLimitOrderr   r   r7  r   r   r   r  r  quoteAmountr  isTakeProfit
isStopLossrQ  r   s                            r^  create_order_requestzbitvavo.create_order_request  s   V$$Tl
 

 )\tz/A\t|G[dT_-Dd$RcJc&&v}==))&2`2`2`aa$$]E6BB@@//&2CDD6#s#s#stt 	ID "33E::#44V<<%0{KK((55''77 MM&/::;G	)-)B)B4S\^b^p)q)q&&$($<$<VV$L$L!YYvx00FF 	I#66vuEEGG $ 8 8 H HGH't3m9MmSW[lSl#4/  [\5M4eXdTd  [jnr|j|  [  CG  KZ  CZ
 	X(,1>#S::OGK   	X*.3@#W<<FWGK #'+'>'>v|'T'TGO$%,GM"*5G&'#+*=*=%0GM" 	'"&GJ
!::6=R^__
F!$($5$5j$A$AGL!!#DG  /^  %^  _  _  _"&*&C&CFM[p&q&q#V*"m331=-..1D-.{{7F+++r_  c                    K   |                                   d{V  |                     |          }|                     ||||||          }|                     |           d{V }	|                     |	|          S )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]: one of EXPIRE_BOTH, cancelOldest, cancelNewest or decrementAndCancel
        :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  rl  rG  privatePostOrderparse_order)
r\  rp  rv  r  r|  r}  rd  rl  r  re  s
             r^  create_orderzbitvavo.create_order  s      2 !!!!!!!!!V$$++FD$vVV..w77777777R &111r_  r.   c                    i }|                      |          }	|                     |d          }
|                     |g d          }|                     |g d          }||                     ||          |d<   ||                     ||          |d<   |
|                     ||
          |d<   ||                     ||          |d<   |                     ||          }|                     |          rt          | j	        dz             | 
                    |d          }|||d	<   d }|                     |d
d          \  }}||                     |          |d<   nt          | j	        dz             |	d         |d<   |S )NamountRemainingr0  )rM  r   r1  r2  r}  r|  r2  zR editOrder() requires an amount argument, or a price argument, or non-empty paramsclientOrderIdr  rP   rQ  zi editOrder() requires an operatorId in params or options, eg: exchange.options['operatorId'] = 1234567890r.   rl  )rl  r  r9  r;  r@  r?  r  is_emptyr   r.   r  r  rA  )r\  r.   rp  rv  r  r|  r}  rd  r  rl  rM  r   rN  rQ  s                 r^  edit_order_requestzbitvavo.edit_order_request  s   V$$**63DEE))&2`2`2`aa6#d#d#dee#66vuEEGG $ 8 8 H HGH&)-)A)A&/)Z)ZG%&#'+'>'>v|'T'TGO$++gv..==!! 	D#DG  /C  %C  D  D  D((AA !#GI
!::6;P\]]
F!$($5$5j$A$AGL!!#DG  /\  %\  ]  ]  ]"4Lr_  c           	         K   |                                   d{V  |                     |          }|                     |||||||          }	|                     |	           d{V }
|                     |
|          S )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  rl  rP  privatePutOrderrJ  )r\  r.   rp  rv  r  r|  r}  rd  rl  r  re  s              r^  
edit_orderzbitvavo.edit_order)  s       !!!!!!!!!V$$))"fdD&%QWXX--g66666666&111r_  c                 t   |t          | j        dz             |                     |          }d|d         i}|                     |d          }|||d<   d }|                     |dd          \  }}||                     |          |d<   nt          | j        dz             |                     ||          S )	Nz) cancelOrder() requires a symbol argumentrl  r.   rN  r  rE   rQ  zk cancelOrder() requires an operatorId in params or options, eg: exchange.options['operatorId'] = 1234567890)r   r.   rl  r  r  rA  r  )r\  r.   rp  rd  rl  r  rN  rQ  s           r^  cancel_order_requestzbitvavo.cancel_order_request>  s    >#DG.Y$YZZZV$$fTl
 ((AA !#GI
!::6=R^__
F!$($5$5j$A$AGL!!#DG  /^  %^  _  _  _{{7F+++r_  c                    K   |                                   d{V  |                     |          }|                     |||          }|                     |           d{V }|                     ||          S )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  rl  rU  privateDeleteOrderrJ  )r\  r.   rp  rd  rl  r  re  s          r^  cancel_orderzbitvavo.cancel_orderP  s       !!!!!!!!!V$$++B??0099999999 &111r_  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   d}|                     |dd          \  }}||                     |          |d<   nt	          | j        dz             |                     |                     ||                     d{V }|                     ||          S )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>`
        Nr.   rl  rD   rQ  zn canceAllOrders() requires an operatorId in params or options, eg: exchange.options['operatorId'] = 1234567890)	r  rl  r  rA  r   r.   privateDeleteOrdersr  parse_orders)r\  rp  rd  r  rl  rQ  re  s          r^  cancel_all_orderszbitvavo.cancel_all_ordersi  s      !!!!!!!!![[((F &tGH
!::6CTVbcc
F!$($5$5j$A$AGL!!#DG  /a  %a  b  b  b11$++gv2N2NOOOOOOOO   6222r_  c                 n  K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |d          }|||d<   |                     |                     ||                     d{V }|                     ||          S )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 argumentrl  r.   rN  r  )r   r.   r  rl  r  privateGetOrderr  rJ  )r\  r.   rp  rd  rl  r  rN  re  s           r^  fetch_orderzbitvavo.fetch_order  s       >#DG.X$XYYY!!!!!!!!!V$$fTl
 ((AA !#GI--dkk'6.J.JKKKKKKKKF &111r_  c                     |                      |          }d|d         i}|||d<   |||d<   |                     d||          \  }}|                     ||          S Nrl  r.   r  r   r  rl  r  r  r\  rp  r  r   rd  rl  r  s          r^  fetch_orders_requestzbitvavo.fetch_orders_request  t    V$$fTl
 $GG$GG225'6JJ{{7F+++r_  c                   K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S |                     |          }|                     ||||          }|                     |           d{V }|                     ||||          S )ax  

        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 argumentFr   r  )	r   r.   r  r  r  rl  rd  privateGetOrdersr[  	r\  rp  r  r   rd  r  rl  r  re  s	            r^  fetch_orderszbitvavo.fetch_orders  s      >#DG.Y$YZZZ!!!!!!!!!88PZ[[& 	h::=&RWY^`fgggggggggV$$++FE5&II..w77777777J   65%@@@r_  c                   K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     ||||          S )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>`
        Nr.   rl  )r  rl  privateGetOrdersOpenr  r[  )r\  rp  r  r   rd  r  rl  re  s           r^  fetch_open_orderszbitvavo.fetch_open_orders  s       !!!!!!!!!
 [[((F &tGH224;;w3O3OPPPPPPPPJ   65%@@@r_  ro  c                 P    dddddddddddddd}|                      |||          S )Nr  canceledclosed)newrn  canceledAuctioncanceledSelfTradePreventioncanceledIOCcanceledFOKcanceledMarketProtectioncanceledPostOnlyfilledpartiallyFilledexpiredrejectedawaitingTriggerr  r\  ro  statusess      r^  parse_order_statuszbitvavo.parse_order_statusM  sO    ")+5%%(2 *%!"%
 
 &&999r_  r   c                    |                      |d          }|                     |d          }|                      |d          }|                     ||d          }|d         }|                     |                      |d                    }|                      |d          }|                      |d          }	|                      |d	          }
|                      |d
          }|                      |d          }|                      |d          }|                      |d          }|A|                      |d          }|                      |d          }t	          j        ||          }d }|                     |d          }|0|                      |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!|          S )"Nr  r  rl  r  rp  ro  r  r+  r}  r|  rM  filledAmountfilledAmountQuoter3  amountQuoteRemainingfeePaidr  r  fillsr   r7  r  r.   rN  r  r  lastTradeTimestamprv  r   r   r  rw  )	remainingro  r  r   )r  rb  safe_marketr  r)   
string_subr  r  r  
safe_orderr  )r\  r   rl  r.   r  r  rp  ro  r  rv  r}  r|  r  rw  r   r3  r  r  feeCostr  r  	rawTradesr   r7  s                           r^  rJ  zbitvavo.parse_order_  s   \ eY//%%eY77	##E844!!(FC88!(()9)9%)J)JKKv..{33  00!!%22$$U,=>>	!!%88':;;<**5-@@K#'#3#3E;Q#R#R %k3GHHD""5)44 ,,UMBBM"55mDDO+ C OOE7B77	&&um<<??5*55  
E 
" 
 T 
 	 

 Y// 
 !$ 
 f 
 D 
 ; 
  
 D 
 U 
 D,,UNCC 
 f 
 D 
  t! 
" f# 
$ #+ 
  
  
, -  	r_  c                     |                      |          }d|d         i}|||d<   |||d<   |                     d||          \  }}|                     ||          S ra  rb  rc  s          r^  fetch_my_trades_requestzbitvavo.fetch_my_trades_request  re  r_  c                   K   |t          | j        dz             |                                  d{V  d}|                     |dd          \  }}|r|                     d||||           d{V S |                     |          }|                     ||||          }|                     |           d{V }|                     ||||          S )aA  

        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 argumentFr|   r  )	r   r.   r  r  r  rl  r  privateGetTradesr  rh  s	            r^  fetch_my_tradeszbitvavo.fetch_my_trades  s      >#DG.[$[\\\!!!!!!!!!88R\]]& 	j::?FTY[`bhiiiiiiiiiV$$..vueVLL..w77777777$   65%@@@r_  c                     |                      |          }|d         |                     ||          |d}|||d<   |                     ||          S )Nr.   )rp  r|  r$  r%  )r  currency_to_precisionr  )r\  r  r|  r$  r&  rd  r  r  s           r^  withdraw_requestzbitvavo.withdraw_request  sa    ==&&tn00v>>
 
 ?#&GK {{7F+++r_  r$  r&  c                 T  K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|                     |||||          }|                     |           d{V }|                     ||          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>`
        N)handle_withdraw_tag_and_paramsr(  r  r  r  privatePostWithdrawalparse_transaction)	r\  r  r|  r$  r&  rd  r  r  re  s	            r^  r   zbitvavo.withdraw  s       99#vFFV7###!!!!!!!!!==&&''fgsFKK33G<<<<<<<< %%h999r_  c                     i }d }| |                      |          }|d         |d<   |||d<   |||d<   |                     ||          S Nr.   rp  r  r   r  r  r\  r  r  r   rd  r  r  s          r^  fetch_withdrawals_requestz!bitvavo.fetch_withdrawals_request%  i    
 }}T**H (GH$GG$GG{{7F+++r_  c                   K   |                                   d{V  |                     ||||          }d}||                     |          }|                     |           d{V }|                     ||||ddi          S )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>`
        Nrv  r   )r  r  r  privateGetWithdrawalHistoryparse_transactionsr\  r  r  r   rd  r  r  re  s           r^  fetch_withdrawalszbitvavo.fetch_withdrawals6  s       !!!!!!!!!00ueVLL}}T**H99'BBBBBBBB &&x5%&R^I_```r_  c                     i }d }| |                      |          }|d         |d<   |||d<   |||d<   |                     ||          S r  r  r  s          r^  fetch_deposits_requestzbitvavo.fetch_deposits_requestX  r  r_  c                   K   |                                   d{V  |                     ||||          }d}||                     |          }|                     |           d{V }|                     ||||ddi          S )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>`
        Nrv  r   )r  r  r  privateGetDepositHistoryr  r  s           r^  fetch_depositszbitvavo.fetch_depositsi  s       !!!!!!!!!--dE5&II}}T**H66w???????? &&x5%&R[I\]]]r_  c           
      H    dddddddddd	}|                      |||          S )Npendingokrn  )	awaiting_processingawaiting_email_confirmationawaiting_bitvavo_inspectionapprovedsending
in_mempool	processed	completedrn  r|  r}  s      r^  parse_transaction_statusz bitvavo.parse_transaction_status  sC    #,+4+4! #""

 

 &&999r_  transactionr  c                    d }|                      |d          }|                     |d          }|                     ||          }|                     |                     |d                    }|                     |d          }|                     |d          }	|                     |d          }
d }|                     |d          }|||d}d }d	|v sd|v rd
}n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S )Nr  rp  ro  r|  r$  txIdr  r  successr   r   r%  r  r.   txidr  addressFrom	addressTotagFromr&  tagTorv  r  updated)r  commentinternal)rb  r  r  r  r  r  )r\  r  r  r.   r  r  r  ro  r|  r$  r  r  r  rv  r&  s                  r^  r  zbitvavo.parse_transaction  s   D %%k;??	%%k8<<
&&z8<<..t/?/?X/V/VWW!!+x88"";	::V44"";66  C $$){*B*BDDD{K88
K
"
 D
 	

 Y//
 4
 w
 
 t
 3
 S
 D
 f
 
 f
  t!
" 3#
$ )
 
 
 	
r_  c                 d   ||                      |d          dd|                      |d          ddi d}|                     |d          }|                     |d          }|                     |d          }|d	k    r|}|                     ||          }|d
         |d         d|d         |<   |S )Nr  F)r  r   
depositFee)r  r   r   rP  rP  r   r  Mainnetr   r   )r   r   )r  r  r  r  )r\  r  r  r  rP  r  currencyCoder  s           r^  parse_deposit_withdraw_feez"bitvavo.parse_deposit_withdraw_fee  s    & ''_==# 
 ''\::#  
 
 ??3
33OOHa00	''&99	!!$I--iFFi(z*+
 +
z;' r_  codesc                    K   |                                   d{V  |                     |           d{V }|                     ||d          S )ae  
        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>`
        Nrp  )r  r  parse_deposit_withdraw_fees)r\  r  rd  re  s       r^  fetch_deposit_withdraw_feesz#bitvavo.fetch_deposit_withdraw_fees  sk       !!!!!!!!!--f55555555( //%JJJr_  r   GETc                    |                      ||                     |                    }d| j        z   dz   |                     ||          z   }|dk    p|dk    }	|	r|r|d|                     |          z   z  }|dk    r|                                  d}
|	s|r|                     |          }|}
t          |                                           }||z   |z   |
z   }| 	                    | 
                    |          | 
                    | j                  t          j                  }|                     | j        dd          }| j        |||d	}|	sd
|d<   | j        d         |         |z   }||||dS )Nrq  r  DELETE?r    rO  10000)zBITVAVO-ACCESS-KEYzBITVAVO-ACCESS-SIGNATUREzBITVAVO-ACCESS-TIMESTAMPrO  zapplication/jsonzContent-Typer   )urlmethodbodyheaders)r;  extract_paramsr5   implode_params	urlencodecheck_required_credentialsjsonstrmillisecondshmacencoder   hashlibsha256r  rH  r   r   )r\  pathr   r  rd  r  r  queryr  getOrDeletepayloadr  auth	signatureaccessWindows                  r^  signzbitvavo.sign0  s   		&$"5"5d";";<<DL 3&)<)<T6)J)JJ?Fh,> 	3 3sT^^E2222)++---G # #99U++D"GD--//00Iv%+g5D		$++d"3"3T[[5M5Mw~^^I++DL:QSZ[[L&*k,5,5)5	 G  =*<'is#c)fdwOOOr_  httpCodereasonr  r  r  r  c
                 *   |d S |                      |d          }
|                      |d          }|
`| j        dz   |z   }|                     | j        d         ||           |                     | j        d         |
|           t          |          d S )N	errorCodeerror rG  rF  )r  r.   throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr   )r\  r  r  r  r  r  r  re  requestHeadersrequestBodyr  r  feedbacks                r^  handle_errorszbitvavo.handle_errorsM  s    4 $$X{;;	  733 w}t+H001I5RZ[[[001I9V^___)))tr_  c                 P    d|v rd|vr|d         S |                      |dd          S )Nr   rl  r   r   )r  )r\  r   r  r  rd  configs         r^  calculate_rate_limiter_costz#bitvavo.calculate_rate_limiter_cost^  s8    &  8v+=+=*%%vvq111r_  )N)M__name__
__module____qualname__r   rZ  r
   rf  r   r   rj  ri  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   rG  rK  rP  rS  rU  rX  r\  r_  rd  r   ri  rl  r  rJ  r  r  r  r   r   r  r  r  r  r  r   r  r  r  r  intr  r  __classcell__)r]  s   @r^  r+   r+      s	       C# C C C C C CJ ') 
3 
3S 
3 
3 
3 
3 *, , ,V , , , ,>? ? ?B -/ +6 +6: +6 +6 +6 +6Z` ` `D 68  3  3  3F  3  3  3  3D/ /4 / /6 / / / /b 6:" 5 57 5 5 5 5 5: <@d[] -A -A -AS -A -Abfglbm -A -A -A -A^\ \ \v \ \ \ \ \| /1 1 1[ 1 1 1 1,   4 @DB % %S % %S\ % % % %N
 
 
4 
 
 
 
( :>D_cln , ,# ,c ,Y\ , , , ,. 8<$]ajl L L LC LWZ Lquvzq{ L L L L@) ) ) ) )  *, , , , , , ,, =? 
 
 
> 
 
 
 
< os{} @, @,3 @,i @,y @,Z_ @,hk @, @, @, @,D mqy{ E2 E2 E2I E2Y E2X] E2fi E2 E2 E2 E2N FJQU^`  S    : fjx|  FH 2 23 2 29 2I 2_b 2ru 2 2 2 2* ;?r , ,s ,C , , , ,$ 9=R 2 2S 2# 2 2 2 22 59 3 3c 3 3 3 3@ 8<B 82 82C 82 82 82 82 82t 26DW[df , ,3 ,c ,QT , , , ," 04$UYbd <A <A <AC <As <Aimnsit <A <A <A <A| 59tZ^gi 9A 9Ac 9A 9ATW 9Anrsxny 9A 9A 9A 9Av: : : : :$b b bv b b b b bH 59tZ^gi , ,c , ,TW , , , ," 37TX\eg )A )AC )As )ARU )Alpqvlw )A )A )A )AV @DB , ,S , , , , QU]_ : :3 : : :# :do : : : :2 59tZ^gi , ,c , ,TW , , , ," 37TX\eg  a  aC  as  aRU  alpq|l}  a  a  a  aD 26DW[df , ,3 ,c ,QT , , , ," 04$UYbd ^ ^ ^C ^s ^imnyiz ^ ^ ^ ^@:s : : : :L
 L
T L
X L
Q\ L
 L
 L
 L
\( ( ( ( ( (T BFb K Kw K K K KB &eBSW P P P P:c 3 S # X\ dg    " MO 2 2 2 2 2 2 2 2r_  r+   )0 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(   ccxt.base.preciser)   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  J  J  J  J  J  J  J  J  J  J  J  J       * * * * * * 0 0 0 0 0 0 - - - - - - - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . + + + + + + ) ) ) ) ) ) * * * * * * . . . . . . 1 1 1 1 1 1 * * * * * * 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %C!2 C!2 C!2 C!2 C!2h C!2 C!2 C!2 C!2 C!2r_  