
    ei                       d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ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'm0Z0 d dl'm1Z1 d dl'm2Z2 d dl'm3Z3 d dl4m5Z5 d dl6m7Z7  G d dee          Z8dS )    )Exchange)ImplicitAPIN)AccountAnyBalancesBorrowInterestBool
ConversionCrossBorrowRate
CurrenciesCurrencyDepositAddressFundingHistoryIntMarket
MarketTypeNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsTickerTickersFundingRateFundingRatesTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee         fdZdedefdZ	i fde
fdZdi fdefd	Zdi fdefd
ZdzdZi fdefdZdi fdedefdZdi fdefdZi fdedefdZd{dededefdZdi fdededefdZdi fdedefdZdi fdededefdZddi fdedededee          fdZ!dddi fdededefdZ"d{dedede fdZ#dddi fdededededee$         f
d Z%d{dede$fd!Z&i fd"Z'i fdefd#Z(i fded$e)d%e*fd&Z+i f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ded(e-d$e)d)e.d*e.fd,Z0di fdedefd-Z1di fdefd.Z2dddi fdedededee         fd/Z3i fd0efd1Z4de5fd2Z6i fde5fd3Z7dddi fdedededee         fd4Z8dddi fdedededee         fd5Z9d(efd6Z:d{d7ededefd8Z;d9efd:Z<dddi fde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dee>         fd>Z@i fd<edeAfd?ZBi fd<edeAfd@ZCd{dAeDdeAfdBZEi fdeeF         fdCZGdi fdDeHdefdEZIi fd<ed)e*dFedGedeJf
dHZKd{dIedAeDdeJfdJZLdi fd<ed)e*dKedLede>f
dMZMd{dNedAeDde>fdOZNd9efdPZOdi fded<efdQZPdddi fd<edededee>         fdRZQddddi fd<ededededeeR         f
dSZSd{dTededeRfdUZTi fdedeUfdVZVdi fdedeWfdWZXd{dedeUfdXZYdddi fdedededeeZ         fdYZ[d{defdZZ\d|dededeeZ         fd[Z]dddi fd<edededee>         fd\Z^di fd]ed^ed)e.de_fd_Z`di fded]ed^ed)e.de_f
d`Zadddi fd<edededee_         fdaZbdzdbedceDddeDde_fdeZcddi fdedededeed         fdfZedi fdedeed         fdgZfi fdededfdhZgd{diedededfdjZhi fd<edeifdkZjd{dAeDfdlZkdAedelfdmZmdddi fdededefdnZnd{defdoZodp Zpdqdri ddfdsZqd<eHdteduedvedwedxefdyZr xZsS )}whitebitreturnc                  <   |                      t          t          |                                           ddddgddi dd ddd	dd
dddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$dd%dd&dd'dd(dd)di d*dd+dd,dd-dd.dd/d0d1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;di d<dd=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJddKddLddddddddddddddddMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcidddedadfdgdhdidjdkdldmgidlg dnidog dpidadbdlg dqiidlg dridog dsidadtdudd|                     dv          |                     dv          dwidxdg dyddzdi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dd d dddddddddddddddddd d ddddddd d d ddddddiddd d ddd
ddiddiddidd d ddt
          t          t          t          t          t          t          t          t          t          t          t          t          t          t          dt          t          t          t          t          t          t          ddd          S )Nr3   WhiteBitv4EE   TCORSspotmarginswapfutureFoptioncancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreatePostOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrdercreateTriggerOrder	editOrderfetchAccountsfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingLimitsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLedgerfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPremiumIndexOHLCVfetchStatusfetchTicker)fetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeesfetchTransactionsfetchWithdrawalsrepayCrossMarginrepayIsolatedMarginsetLeveragetransferwithdraw1m3m5m15m30m1h2h4h6h8h12h1d3d1w1M)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zchttps://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpgz"https://whitebit.com/api/v1/publiczhttps://whitebit.com/api/v1)publicprivater   z"https://whitebit.com/api/v2/publicz"https://whitebit.com/api/v4/publiczhttps://whitebit.com/api/v4)v1v2r7   zhttps://www.whitebit.comz-https://github.com/whitebit-exchange/api-docsz!https://whitebit.com/fee-schedulezBhttps://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963)logoapiwwwdocfeesreferralgetzv1/healthcheck)marketstickerstickersymbolszdepth/resulthistoryklinepost)zaccount/balance	order/neworder/cancelorderszaccount/order_historyzaccount/executed_historyzaccount/executed_history/allzaccount/order)r   r   assetsfeezdepth/{market}trades/{market})r   zcollateral/marketsr   zfunding-history/{market}zorderbook/depth/{market}zorderbook/{market}r   r   timepingr   futureszplatform/statuszmining-pool)Kzcollateral-account/balancez"collateral-account/balance-summaryz$collateral-account/positions/historyzcollateral-account/leveragez!collateral-account/positions/openzcollateral-account/summaryz"collateral-account/funding-historyzmain-account/addresszmain-account/balancezmain-account/create-new-addresszmain-account/codeszmain-account/codes/applyzmain-account/codes/myzmain-account/codes/historyzmain-account/fiat-deposit-urlzmain-account/historyzmain-account/withdrawzmain-account/withdraw-payzmain-account/transferzmain-account/smart/planszmain-account/smart/investmentz#main-account/smart/investment/closezmain-account/smart/investmentszmain-account/feez+main-account/smart/interest-payment-historyztrade-account/balanceztrade-account/executed-historyztrade-account/order/historyztrade-account/orderzorder/collateral/limitzorder/collateral/marketzorder/collateral/stop-limitzorder/collateral/trigger-marketzorder/collateral/bulkr   zorder/marketzorder/stock_marketzorder/stop_limitzorder/stop_marketr   zorder/cancel/allzorder/kill-switchzorder/kill-switch/statusz
order/bulkzorder/modifyzorder/conditional-cancelr   z
oco-orderszorder/collateral/ocozorder/oco-cancelzorder/oto-cancelzprofile/websocket_tokenzconvert/estimatezconvert/confirmzconvert/historyzsub-account/createzsub-account/deletezsub-account/editzsub-account/listzsub-account/transferzsub-account/blockzsub-account/unblockzsub-account/balanceszsub-account/transfer/historyzsub-account/api-key/createzsub-account/api-key/editzsub-account/api-key/deletezsub-account/api-key/listzsub-account/api-key/resetz#sub-account/api-key/ip-address/listz%sub-account/api-key/ip-address/createz%sub-account/api-key/ip-address/deletezmining/rewardsz
market/feezconditional-orders)webr   r   r7   tradingz0.001)	tierBased
percentagetakermakerr   )EURUSDRUBUAHaccountmain
collateral)fundingr   r;   r<   tradeccxt)	timeDifferenceadjustForTimeDifferencefiatCurrenciesnonceWindowrQ   accountsByTypenetworksByIddefaultTypebrokerId)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergd   )r   limitdaysBack	untilDayssymbolRequired)checkActivecheckExecutedr   r   triggerr   )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r     )
sandboxrI   createOrdersrp   rt   rs   rv   rT   rq   r   extendsdefault)linearinverse)r   r;   r=   r>   )zUnauthorized request.zThe market format is invalid.zMarket is not availablezInvalid payload.zAmount must be greater than 0zNot enough balance.zThe order id field is required.zNot enough balancezThis action is unauthorized.z6This API Key is not authorized to perform self action.zUnexecuted order was not found.zThe selected from is invalid.503422)zThis action is unauthorizedz$Given amount is less than min amountzMin amount stepzTotal is less thanzfee must be no less thanzEnable your key in API settingsz'You don't have such amount for transfer)exactbroad)idnameversion	countries	rateLimitprohas
timeframesurlsr   r   optionsfeaturesprecisionMode
exceptions)deep_extendsuperr3   describeparse_numberr0   r%   r)   r(   r+   r*   r&   r,   r/   )self	__class__s    Y/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/whitebit.pyr  zwhitebit.describe   s3   h 5 5 > > @ @SSS $S 	S
 %S %S "4S 'S tS S %dS 'S /S ,US 0S  t!S" &t#S S$ '%S& ('S( "4)S* %d+S, T-S.  /S0 1S2 +E3S4 )%5S6 $T7S8 $T9S: $U;S< +D=S> '?S@ (ASB "4CSD ES S SF &tGSH (ISJ 1%KSL  MSN +DOSP *:QSR +DSST &tUSV %dWSX #DYSZ *4[S\ $T]S^ "5_S` *5aSb +EcSd ueSf "5gS S Sh iSj !%kSl  mSn doSp +EqSr "4sSt duSv !$wSx tySz #D{S|  }S~ 'S@ $UASB !$CSD )%ESF tGSH tIS SJ !%!##($(&*(,%)$($)',#  eS S Sj  $ ~ #G#@ 
 !"F #G#@   2F;`% , (       
  	! 	! 	!  4       	       &  L! L! L!N 'b bWN N` !&"&!..w77!..w77	  #$+0">">">$v!  &""*## # !#%"# *  %&*(,,1,0).+06:#'#("&#(	( ( #($)$)+/27/4#()$ $, %)&+!$$(%)*/& & (,)-*/&+#($)# # ',!$#($)*/( ( ',!$$(%)#($)*/$ $ ',!$$(,0%)#($)*/	* 	*  # ',!$$(%)*/) )KL L\ y
 "9 "9 	  ## s] ]| ' .A5>/8(25A+<7C*;4DN^7D5?/( " 4D<H'3*60<7G@Q # SdC
 dC
 d d d	    c                    K   | j         d         r|                                  d{V  |                                  d{V }|                     |          S )a  
        retrieves data on all markets for whitebit

        https://docs.whitebit.com/public/http-v4/#market-info

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   N)r   load_time_differencev4PublicGetMarketsparse_markets)r  paramsr   s      r	  fetch_marketszwhitebit.fetch_markets  su       <12 	.++---------//111111110 !!'***r
  marketc                 "   |                      |d          }|                      |d          }|                      |d          }|dk    rdn|}|                     |          }|                     |          }|                     |d          }|                     |d          }|                      |d          }	d }
d }|d	z   |z   }|	d
k    }|o| }d}|                     |                     |                      |d                              }|}d }d }|r(|}|                     |          }
|dz   |
z   }d}d}d}d}nd}|                      |d          }t          j        |d          }|                      |d          }t          j        |d          }| }i d|d|d|d|d|
d|d|d|d|d|d|d|ddddd|d |d!|||                     |          |                     |          |rd n|d d d d ||                     |                     |                      |d"                              d#d d d$|                     |d%          d d$d d d$|                     |d&          |                     |d'          d$d(d |d)S )*Nr   stockmoneyPERPUSDTtradesEnabledisCollateraltype/r   F	stockPrec:r=   Tr;   takerFee100makerFeer   symbolbasequotesettlebaseIdquoteIdsettleIdr<   r>   r?   activecontractr   	moneyPrec)amountpriceminmax	minAmountminTotalmaxTotal)r   r*  r+  cost)r   r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_code
safe_valuer  parse_precisionr1   
string_divsafe_number)r  r  r   r$  r%  r!  r"  r'  r  typeIdr#  r&  r   r=   r<   r(  amountPrecisionr3  r   r   r  takerFeeRater   makerFeeRater   isSpots                             r	  parse_marketzwhitebit.parse_market  s   ff--!!&'22""6733$..&&W&&v..''0099v~>>!!&&11e#"*d(++D,@,@AQAQRXZeAfAf,g,ghh& 		H,,X66Fc\F*FDHFGGD''
;;"<77''
;;"<772
"2
f2
 D2
 U	2

 f2
 f2
 w2
 2
 D2
 F2
 f2
 D2
 e2
 e2
 f2
  !2
" f#2
$ &&u--&&u--$*<DD")**4+?+?@P@PQWYd@e@e+f+fgg    
  ++FK@@ 
   
  ++FJ??++FJ??  $ c2
 2
 2
 2	
r
  c                 $  K   |                      |           d{V }t          |                                          }i }t          dt	          |                    D ]}||         }||         }|                     |          }d|v }	i }
|                     |di           }|                     |dg           }|                     |dg           }|                     |di           }|                     |di           }|                     |d	i           }|                     ||          }t          dt	          |                    D ]}||         }| 	                    |          }|                     ||i           }|                     ||i           }||d| 
                    ||          | 
                    ||          dd|                     |d
          |                     |d          d|                     |d
          |                     |d          ddd|
|<   |                     |||dd|                     |d          |                     |d          d|
|	rdnd|                     |                     |                     |d                              ddd|                     |d          |                     |d          d|                     |d          |                     |d          ddd          ||<   |S )a  
        fetches all available currencies on an exchange

        https://docs.whitebit.com/public/http-v4/#asset-status-list

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr   	providersnetworksdeposits	withdrawsr9  depositr   r-  r.  r,  rM  r   )r   networkr'  rM  r   r   r8  r9  can_depositcan_withdrawfiatcryptocurrency_precisionmin_withdrawmax_withdrawmin_depositmax_deposit)r*  r   rM  )r   coder;  r   r'  rM  r   r   rJ  r  r8  r9  )v4PublicGetAssetslistkeysrangelenr=  	safe_dict	safe_listarray_concatnetwork_id_to_codein_arrayrA  safe_currency_structure	safe_boolr  r?  r<  )r  r  responseidsresultir   currencyrY  hasProviderrJ  rawNetworksdepositsNetworkswithdrawsNetworksnetworkLimitsdepositLimitswithdrawLimitsallNetworksj	networkIdnetworkCodenetworkDepositLimitsnetworkWithdrawLimitss                          r	  fetch_currencieszwhitebit.fetch_currenciesB  s|      //77777777D 8==??##q#c((## @	 @	AQB|H**2..D&(2KH..:rBBK#~~k:rJJ ${K L L NN8XrBBM NN=)RHHM!^^M:rJJN++,<>OPPK1c+..//  'N	"55i@@'+~~mYPR'S'S$(,~yRT(U(U%#*"#}}Y8HII $i9J K K!% $(#3#34H%#P#P#'#3#34H%#P#P$ $
 $(#3#34I5#Q#Q#'#3#34I5#Q#Q% %	 	) )%%&  77 >>(MBB NN8^DD$"-;8!..t/C/CDDTDTU]_sDtDt/u/uvv  $# 
  $//.II#//.II! !
  $//-HH#//-HH    9 9  F4LL6 r
  Ncodesc                   K   |                                   d{V  |                     |           d{V }t          |                                          }i }i }t	          dt          |                    D ]}||         }||         }	|                     |          }
|                     |	di           }|                     |d          ||
<   |                     |	di           }|                     |d          ||
<   |||dS )aw  
 @deprecated
        please use fetchDepositWithdrawFees instead

        https://docs.whitebit.com/public/http-v4/#fee

        :param str[]|None codes: not used by fetchTransactionFees()
        :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   fixedrM  )r   rM  r;  )	load_marketsv4PublicGetFeer[  r\  r]  r^  r=  r>  r<  )r  ry  r  rf  currenciesIdswithdrawFeesdepositFeesri  rj  datarY  r   rM  s                r	  fetch_transaction_feeszwhitebit.fetch_transaction_fees  s5      !!!!!!!!!,,V444444444 X]]__--q#m,,-- 	C 	CA$Q'HH%D**844DtZ<<H!%!1!1(G!D!DLoodIr::G $ 0 0' B BK$"
 
 	
r
  c                    K   |                                   d{V  |                     |           d{V }|                     ||          S )ab  
        fetch deposit and withdraw fees

        https://docs.whitebit.com/public/http-v4/#fee

        :param str[]|None codes: not used by fetchDepositWithdrawFees()
        :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>`
        N)r|  r}  parse_deposit_withdraw_fees)r  ry  r  rf  s       r	  fetch_deposit_withdraw_feesz$whitebit.fetch_deposit_withdraw_fees	  sj       !!!!!!!!!,,V44444444V //%@@@r
  c                    i }|                      |          }t          |                                          }t          dt	          |                    D ]~}||         }|                    d          }|d         }	||         }
|                     |	          }||                     ||          r |                     ||          }|| 	                    i           ||<   |
||         d         |<   | 
                    |d          }|                     |
d          }|                     |
d          }|                     |d          }|                     |d          }||dnd d	}||dnd d	}|Gt	          |          }|d|dz
           }|                     |          }||d
||         d         |<   h|||         d<   |||         d<   t          |                                          }t          dt	          |                    D ]>}||         }|                     |          }|                     ||         |          ||<   ?|S )Nr    r;     r   rM  r{  F)r   r   )r   rM  rJ  )market_codesr[  r\  r]  r^  splitr=  rc  r>  deposit_withdraw_feer<  rA  rb  rj  $assign_default_deposit_withdraw_fees)r  rf  ry  currencyIdKeydepositWithdrawFeescurrencyIdsri  entry
splitEntry
currencyIdfeeInforY  depositWithdrawFeert  r   rM  withdrawFee
depositFeewithdrawResultdepositResultnetworkLengthru  depositWithdrawCodesrj  s                           r	  r  z$whitebit.parse_deposit_withdraw_feesA  s   V %'!!%((8==??++q#k**++ "	I "	IANES))J#AJuoG**:66D4==u#=#=%)__5H$%O%O"%-040I0I"0M0M'-;B#D)&1%8 ,,Z;;	??7J??//'9=="..xAA!--gw??
&,7,C%%$( (
 &,6,B%%' ' ($'	NNM )!MA,=*= >I"&"9"9)"D"DK$2#0J J'-j9+FF
 =K'-j9;H'-i8#$7$<$<$>$>??q#23344 	w 	wA'*D}}T**H(,(Q(QRefjRkmu(v(v%%""r
  c           	      \  K   |                                   d{V  |                     |           d{V }i }t          dt          | j                            D ]}| j        |         }|                     |          }|                     ||d         i           }|                     |d          }|                     |d          }	t          j	        |d          }t          j	        |	d          }	||d         dd	| 
                    |          | 
                    |	          d
||<   |S )aT  
        fetch the trading fees for multiple markets

        https://docs.whitebit.com/public/http-v4/#asset-status-list

        :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
        Nr   r$  	maker_fee	taker_feer  r   TF)r;  r   r   r   r   r   )r|  rZ  r]  r^  r   r  r>  r<  r1   r@  r  )
r  r  rf  rh  ri  r   r  r   r  r  s
             r	  fetch_trading_feeszwhitebit.fetch_trading_fees  sK      !!!!!!!!!//77777777$ q#dl++,, 	 	A\!_F[[((F//(F8,<bAAC''[99H''[99H)(E::H)(E::H *""**844**844 F6NN r
  r   c           	        K   |                                   d{V  i }t          | j                                                  }t	          dt          |                    D ]}||         }| j        |         }|r|d         s#|d         }|r5d}	t	          dt          |                    D ]}
||
         |k    rd}	 n|	sb|                     |d          }|                     |d          }|                     |d          }|                     |d	          }|o/|                     |d
          duo|                     |d          du}|o/|                     |d
          duo|                     |d          du}|o/|                     |d
          duo|                     |d          du}|r|r|r||                     |d
          |                     |d          d|                     |d
          |                     |d          d|                     |d
          |                     |d          ddd||<   |S )an  
        fetch the trading limits for a market

        https://docs.whitebit.com/public/http-v4/#market-info

        :param str[]|None symbols: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `trading limits structure <https://docs.ccxt.com/?id=trading-limits-structure>`
        Nr   r   FTr9  r*  r+  r2  r-  r.  r,  )r*  r+  r2  r;  r9  )r|  r[  r   r\  r]  r^  r_  rA  )r  r   r  rh  	marketIdsri  marketIdr  r   symbolFoundrs  r9  amountLimitspriceLimits
costLimitshasAmountLimitshasPriceLimitshasCostLimitss                     r	  fetch_trading_limitszwhitebit.fetch_trading_limits  s$      !!!!!!!!!Z **,,--	q#i..)) )	 )	A |H\(+F !1 H%F #q#g,,//  AqzV++&* , # ^^FH55F>>&(;;L..99K77J*  Wt/?/?e/T/T\`/`  Weieueu  wC  EJ  fK  fK  SW  fWO(  ST-=-=k5-Q-QY]-]  Sbfbrbrs~  AF  cG  cG  OS  cSN&  O4+;+;J+N+NVZ+Z  O_c_o_opz  }B  `C  `C  KO  `OM > m " $(#3#3L%#H#H#'#3#3L%#H#H# #
 $(#3#3K#G#G#'#3#3K#G#G" "
 $(#3#3J#F#F#'#3#3J#F#F! ! " "v" r
  c                 x  K   |                                   d{V  t          j        |                                 |                     |          g  d{V \  }}i }t          |                                          }t          dt          |                    D ]}||         }||         }	|	s|| 	                    ||          s/d}
t          |                                          }t          dt          |                    D ]$}||         }||         }|r|d         |k    r|}
 n%|	d         d         d         |	d         d         d         d|	d         d	         d         |	d         d	         d         dd
}|
r|
d         }|
d	         }|rd| 
                    |d          i}|d         rW| 
                    |d         d          | 
                    |d         d          | 
                    |d         d          d|d<   ||d         d<   |rd| 
                    |d          i}|d         rW| 
                    |d         d          | 
                    |d         d          | 
                    |d         d          d|d<   ||d	         d<   |	d         r|	d         |d<   |	|d||<   |S )a  
        fetch the deposit and withdrawal limits for a currency

        https://docs.whitebit.com/public/http-v4/#asset-status-list
        https://docs.whitebit.com/public/http-v4/#fee

        :param str[]|None codes: unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding limits structure <https://docs.ccxt.com/?id=funding-limits-structure>`
        Nr   r   r9  rM  r-  r.  r,  r   rN  r{  flexmin_feemax_feepercent)r-  r.  r  r   rJ  r  )r|  asynciogatherrx  r}  r[  r\  r]  r^  rc  rA  )r  ry  r  currenciesDatafeesDatarh  currencyKeysri  rY  rj  feeDatafeeKeysrs  feeKeyr   r9  r  r  depositFeeDatawithdrawFeeDatas                       r	  fetch_funding_limitszwhitebit.fetch_funding_limits.  sk      !!!!!!!!!)0!!##'':
 * $ $ $ $ $ $ x N//1122q#l++,, =	 =	A?D%d+H  tU)C)C G8==??++G1c'll++   v& 3x=D00!GE $H-i8?#H-i8? 
 $H-j9%@#H-j9%@ 	 	F  @$Y/
%j1 
>!1!1*g!F!F&N "&) #'#3#3Jv4F	#R#R#'#3#3Jv4F	#R#R'+'7'7
68JI'V'V2 2v.
 0>F9%e, 
@!1!1+w!G!G'O #6* #'#3#3K4G#S#S#'#3#3K4G#S#S'+'7'7F8KY'W'W3 3/
 1@F:&u-
# :%-j%9z"   F4LL r
  r   c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://docs.whitebit.com/public/http-v4/#market-activity

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
        Nr  r   rh  )r|  r  v1PublicGetTickerextendr_  parse_ticker)r  r   r  r  requestrf  r   s          r	  fetch_tickerzwhitebit.fetch_ticker  s       !!!!!!!!!V$$fTl
 //GV0L0LMMMMMMMM$ (B77  000r
  r   c           	         |                      |dd          }|                     ||          }|                     |g d          }|                     |d|          }|                     i d|d         dd dd d|                     |d          d	|                     |d	          d
|                      |d
d          dd d|                      |dd          dd dd d|                     |d          d|d|dd dd d|                     |d          dd |                     |g d          |                     |g d          |                     |d          |d|          S )NtradingPairs	ticker_id)last
last_price	lastPricecloser   	timestampdatetimehighlowbid
highestBid	bidVolumeask	lowestAsk	askVolumevwapopenr  previousClosechanger   average)base_volumevolumebaseVolume24hstock_volume)quote_volumedealquoteVolume24hmoney_volumeindex_price)
baseVolumequoteVolume
indexPricer;  )safe_string_2safe_marketsafe_string_nr<  safe_ticker)r  r   r  r  r  r  s         r	  r  zwhitebit.parse_ticker  s   j %%fnkJJ!!(F33!!&*M*M*MNN  $77 !
fX&!
!
 !
 D$$VV44	!

 4##FE22!
 4%%fe\BB!
 !
 4%%fe[AA!
 !
 D!
 D$$VV44!
 U!
 D!
 T!
 d!
  $**68<<!!
" t#!
$ ,,V5o5o5opp--f6p6p6pqq**6=AA+!
 !
 !
, -  	r
  r   c                 >  K   |                                   d{V  |                     |dd          }|                     |dd          }d|i}d}| |                     |          }|d         |d<   |r	 |                     |                     ||                     d{V }t          dt          |                    D ]k}	||	         }
|                     |
d          }||k    rE|                     |
d          }|                     |dd	          }| 	                    |
|          c S ln.# t          $ r!}t          |t                    s|Y d}~nd}~ww xY w|r%	 |                     |                     ||                     d{V }t          |                                          }t          dt          |                    D ]}	||	         }|                     |dd	          }||         }t          dt          |                    D ]@}||         }
|                     |
d          }||k    r| 	                    |
|          c c S An.# t          $ r!}t          |t                    s|Y d}~nd}~ww xY wt          | j        d
z   |z             )a  
        fetches information on an order by the id

        https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
        https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.checkActive]: whether to check active orders(default: True)
        :param boolean [params.checkExecuted]: whether to check executed orders(default: True)
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   Tr   orderIdr   r  r   _z fetchOrder() order not found: )r|  re  r  v4PrivatePostOrdersr  r]  r^  r<  r  parse_order	Exception
isinstancer,   %v4PrivatePostTradeAccountOrderHistoryr[  r\  r   )r  r   r   r  r   r   r  r  rf  ri  orderr  r  	marketNewerrorr  r   rs  s                     r	  fetch_orderzwhitebit.fetch_orderP  sG      !!!!!!!!!nnV]DAAvEEr
 [[((F &tGH 	  !%!9!9$++gv:V:V!W!WWWWWWWq#h--00 B BA$QKE"..ui@@G"}}#'#3#3E8#D#D$($4$4XtS$I$I	#//yAAAAA %B       "5-88  K            	  !%!K!KDKKX_agLhLh!i!iiiiiii 11	q#i..11 F FA(|H $ 0 04 E EI%h/F"1c&kk22 F F &q	"&"2"25$"?"?"b==#'#3#3E9#E#EEEEEE )F	F       "5-88  K           DG&GG"LMMMs>   6B6D/ -D/ /
E9EE!C2I I 
J!I==Jc                   K   |                                   d{V  |                     |          }d}|Jt          dt          |                    D ]+}||         }|                     |          }|d         sd} n,nd}d}|                     dd|          \  }}d}|                     |dd|          \  }}||s|dk    rd	}nd
}d}	|d
k    r|                     |           d{V }	n=|d	k    r|                     |           d{V }	n| 	                    |           d{V }	| 
                    |	d          }
|
|                     |
|          S t          |	                                          }i }t          dt          |                    D ]H}||         }|                     |          }|                     |	|         |          }|d         }|||<   I|                     |d|          S )aN  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.whitebit.com/public/http-v4/#market-activity

        :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.type]: 'spot' or 'swap' - default is 'spot'. If type is 'swap', it will call v4PublicGetFutures
        :param str [params.method]: either v2PublicGetTicker or v4PublicGetTicker or v4PublicGetFutures - default is v4PublicGetTicker for spot and mixed markets, and v4PublicGetFutures for swap
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        NTr   r(  Fr   methodr=   v4PublicGetFuturesv4PublicGetTickerrh  r   )r|  market_symbolsr]  r^  r  handle_market_type_and_paramshandle_option_and_paramsr  r  v2PublicGetTickerr`  parse_tickersr[  r\  r  r  filter_by_array_tickers)r  r   r  onlyContractSymbolsri  r   r  
marketTyper  rf  
resultListr  rh  r  r   s                  r	  fetch_tickerszwhitebit.fetch_tickers  ss      !!!!!!!!!%%g.."1c'll++   V,,z* */'E #(
!??PTV\]]
F66v~xY_``>" -zV';';-,((( "33F;;;;;;;;HH+++P "44V<<<<<<<<HH!33F;;;;;;;;H^^Hh77
!%%j':::))	q#i..)) 	$ 	$A |H%%h//F&&x'96BBFH%F#F6NN++FHgFFFr
  r   c                 >  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |d          }|                     |||          S )a/  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.whitebit.com/public/http-v4/#orderbook

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/?id=order-book-structure>` indexed by market symbols
        Nr  r   r   r  )r|  r  v4PublicGetOrderbookMarketr  safe_timestampparse_order_book)r  r   r   r  r  r  rf  r  s           r	  fetch_order_bookzwhitebit.fetch_order_book  s       !!!!!!!!!V$$fTl
 $GG88Wf9U9UVVVVVVVV( ''+>>	$$XvyAAAr
  sincec                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||||          S )a  
        get the list of most recent trades for a particular symbol

        https://docs.whitebit.com/public/http-v4/#recent-trades

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr  r   )r|  r  v4PublicGetTradesMarketr  parse_tradesr  r   r  r   r  r  r  rf  s           r	  fetch_tradeszwhitebit.fetch_trades  s       !!!!!!!!!V$$fTl
 55dkk'66R6RSSSSSSSS   65%@@@r
  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   |                     |                     ||                     d{V }t	          |t
                    r|                     ||||          S g }t          |                                          }	t          dt          |	                    D ]f}
|	|
         }| 
                    |dd          }|                     ||g           }|                     ||||          }|                     ||          }g|                     |dd          }|                     |||d          S )a  
        fetch all trades made by the user

        https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
        Nr   r  r   r  r  )r|  r  (v4PrivatePostTradeAccountExecutedHistoryr  r  r[  r	  r\  r]  r^  r  r>  ra  	sort_by_2filter_by_since_limit)r  r   r  r   r  r  r  rf  resultsr\  ri  r  r  	rawTradesparseds                  r	  fetch_my_tradeszwhitebit.fetch_my_trades>  s      !!!!!!!!![[((F &tGHFFt{{SZ\bGcGcddddddddL h%% 	R$$XvueDDDG((D1c$ii(( = =7 ,,XtSAA	 OOHhCC	**9iNN++GV<<nnWk4@@G--gue[QQQr
  r   c                    |                      d |          }|                     |dd          }|                     |dd          }|                     |d          }|                     |d          }|                     |dd          }|                     |d	d
          }|                     |dd          }	|d         }
|                     |d          }d }|
|dk    rdnd}d }|                     |d          }|,||                     |                     |d                    d}|                     |||                     |          |
||d ||	||||d|          S )Nr   trade_timestampdealOrderIdr  r  r+  r*  r  r   tradeIDr  sider   roler  r   r   r   feeAssetr2  rj  )r;  r  r  r   r   r  r  takerOrMakerr  r+  r*  r2  r   )r  safe_timestamp_2r  r<  safe_integerr=  
safe_tradeiso8601)r  r   r  r  r  r2  r+  r*  r   r  r   r  r  r   feeCosts                  r	  parse_tradezwhitebit.parse_trade  s   X !!$//))%9JKK	$$UM9EEv..  00##E8^DDtY77!!%88!  // '+qyy77wL""5%00 33D4D4DUJ4W4WXX C "Y//( 
  
   	r
  r   	timeframec                    K   |                                   d{V  |                     |          }|d         |                     | j        ||          d}|3d}||}t	          ||          }|                     |dz            }	|	|d<   |t	          |d          |d<   |                     |                     ||                     d{V }
|                     |
dg           }| 	                    |||||          S )	a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://docs.whitebit.com/public/http-v1/#kline

        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        Nr   )r  intervalr     startr   rh  )
r|  r  r<  r   r-  parse_to_intv1PublicGetKliner  r`  parse_ohlcvs)r  r   r#  r  r   r  r  r  maxLimitr'  rf  rh  s               r	  fetch_ohlcvzwhitebit.fetch_ohlcv  s.      !!!!!!!!!V$$Tl(()YOO
 
 H} x((E%%edl33E$GG"5$//GG..t{{7F/K/KLLLLLLLL (B77  E5IIIr
  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   r              )r  rA  )r  ohlcvr  s      r	  parse_ohlcvzwhitebit.parse_ohlcv  s     q))UA&&UA&&UA&&UA&&UA&&
 	
r
  c                    K   |                      |           d{V }|                     |d          }|dk    rdn|ddd|dS )aO  
        the latest known information on the availability of the exchange API

        https://docs.whitebit.com/public/http-v4/#server-status

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>`
        Nr   pongok)statusupdatedetaurlr;  )v4PublicGetPingr<  )r  r  rf  r7  s       r	  fetch_statuszwhitebit.fetch_status  sp       --f55555555 !!(A..%//ddf
 
 	
r
  c                 j   K   |                      |           d{V }|                     |dd          S )aR  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://docs.whitebit.com/public/http-v4/#server-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Nr   r&  )v4PublicGetTimesafe_integer_product)r  r  rf  s      r	  
fetch_timezwhitebit.fetch_time,  sG       --f55555555 ((64@@@r
  r  r2  c                 v   K   d|i}|                      |d|dd|                     ||                     d{V S )a  
        create a market order by providing the symbol, side and cost
        :param str symbol: unified symbol of the market to create an order in
        :param str side: 'buy' or 'sell'
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r2  r  r   N)create_orderr  )r  r   r  r2  r  reqs         r	  create_market_order_with_costz&whitebit.create_market_order_with_cost=  sV       D
 &&vxq$TWY_H`H`aaaaaaaaar
  c                 B   K   |                      |d||           d{V S )a  
        create a market buy order by providing the symbol and cost
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        buyN)rD  )r  r   r2  r  s       r	  !create_market_buy_order_with_costz*whitebit.create_market_buy_order_with_costL  s4       77tVTTTTTTTTTr
  r  r*  r+  c                   K   |                                   d{V  |                     |          }|d         |d}d}	|                     |d          \  }	}|	=|dk    s|dk    rt          | j        dz             |                     ||	          |d<   n|                     ||          |d<   |                     |d	d
          }
|
8|                     | j	        d          }||| 
                                z   |d
<   n|
|d
<   |                     |d
g          }|                     |d          }|dk    }|dk    }|                     |g d          }|du}|                     |d|          }|                     d|          \  }}|rd|d<   ||dk    rt          | j        dz             |                     |g d          }|dup|dk    }d}|r|                     ||          |d<   |rJ|                     ||          |d<   |                     |                     ||                     d{V }nt|r1|                     |                     ||                     d{V }nA|                     |                     ||                     d{V }n|r{|                     ||          |d<   |r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|r0|                     |                     ||                     d{V }na|	0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |          S )a!  
        create a trade order

        https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
        https://docs.whitebit.com/private/http-trade-v4/#create-market-order
        https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
        https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
        https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *market orders only* the cost of the order in units of the base currency
        :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 str [params.clientOrderId]: a unique id for the order
        :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   )r  r  r2  rF  r  z; createOrder() cost is only supported for market buy ordersr*  clOrdIdclientOrderIdr   r  r   )r   	stopPriceactivation_priceFrI   TpostOnlycrossz1 createOrder() is only available for cross margin)rM  r   rK  r=   rL  r+  )r|  r  handle_param_stringr+   r   cost_to_precisionamount_to_precisionr  r<  r   uuid16omitsafe_number_nis_post_onlyhandle_margin_mode_and_paramsr-   price_to_precisionv4PrivatePostOrderStopLimitr  )v4PrivatePostOrderCollateralTriggerMarketv4PrivatePostOrderStopMarket!v4PrivatePostOrderCollateralLimitv4PrivatePostOrderNew"v4PrivatePostOrderCollateralMarketv4PrivatePostOrderMarketv4PrivatePostOrderStockMarketr  )r  r   r  r  r*  r+  r  r  r  r2  rJ  r   r  isLimitOrderisMarketOrderr   isStopOrderrM  r   queryuseCollateralEndpointrf  s                         r	  rB  zwhitebit.create_orderV  s     . !!!!!!!!!V$$Tl
 
 //??f48#3#3"47-j#jkkk $ 6 6vt D DGH $ 8 8 H HGH**69oNN ''jAAH#+3dkkmm+C('4GO$YYv'899F%%ff55
w())&2c2c2cdd#4/$$]E6BB >>}fUU
E 	'"&GJ!jG&;&;tw)\\]]]5"K"K"KLL *$ 6 N*:N 	j*.*A*A&,*W*WG&' 	e#'#:#:65#I#I !%!A!A$++gW]B^B^!_!_______ ) e%)%S%STXT_T_`gioTpTp%q%qqqqqqqHH%)%F%Ft{{SZ\bGcGc%d%dddddddHH j#'#:#:65#I#I ( ^%)%K%KDKKX_agLhLh%i%iiiiiiiHH%)%?%?GU[@\@\%]%]]]]]]]HH ) j%)%L%LT[[Y`bhMiMi%j%jjjjjjjHH')-)F)Ft{{SZ\bGcGc)d)d#d#d#d#d#d#d)-)K)KDKKX_agLhLh)i)i#i#i#i#i#i#i)))r
  c                   K   |                                   d{V  |                     |          }d|d         i}	|                     |d          }
|
|
|	d<   n||	d<   |                     |g d          }|du}|r|                     ||          |	d<   |dk    }|                     |d	          }||                     ||          |	d	<   n]|[|r|                     ||          |	d
<   n?|dk    r |dk    r|                     ||          |	d	<   n|                     ||          |	d
<   ||                     ||          |	d<   |dup|dup|dup|du}|st          | j        dz             | 	                    |g d          }| 
                    |                     |	|                     d{V }|                     |          S )a  
        edit a trade order

        https://docs.whitebit.com/private/http-trade-v4/#modify-order

        :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 exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr  r   rJ  r  )r   rK  activationPricerL  r   totalr*  rF  r+  zZ editOrder() requires at least one of: amount, price, activationPrice, or total parameters)rJ  r   rK  rf  rg  )r|  r  r<  rT  rW  rA  rQ  r'   r   rS  v4PrivatePostOrderModifyr  r  )r  r   r   r  r  r*  r+  r  r  r  rJ  r   rb  r`  rg  hasModifiableParamrf  s                    r	  
edit_orderzwhitebit.edit_order  s_      !!!!!!!!!V$$fTl
 ((AA$'4GO$$!#GI))&2b2b2bcc#4/ 	X*.*A*A&,*W*WG&'w  11#77FFGG M$($<$<VV$L$L!!!!demm#'#;#;FF#K#K   %)$<$<VV$L$L!#66vuEEGG$D0}e46G}\aeMe}kpx|k|! 	L#DG  /K  %K  L  L  L6#m#m#mnn66t{{7F7S7STTTTTTTT)))r
  c                 N  K   |t          | j        dz             |                                  d{V  |                     |          }|d         t	          |          d}|                     |                     ||                     d{V }|                     |          S )a  
        cancels an open order

        https://docs.whitebit.com/private/http-trade-v4/#cancel-order

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr   )r  r  )r'   r   r|  r  intv4PrivatePostOrderCancelr  r  )r  r   r   r  r  r  rf  s          r	  cancel_orderzwhitebit.cancel_order  s       >#DG.Y$YZZZ!!!!!!!!!V$$Tl2ww
 
 66t{{7F7S7STTTTTTTT( )))r
  c                 j  K   |                                   d{V  d}i }| |                     |          }|d         |d<   d}|                     d||          \  }}g }|dk    rKd}|                     |ddd          \  }}|r|                    d           nO|                    d           n9|d	k    r|                    d
           nt          | j        dz   |z   dz             ||d<   |                     |                     ||                     d{V }| 	                    ||          S )a0  
        cancel all open orders

        https://docs.whitebit.com/private/http-trade-v4/#cancel-all-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
        :param str [params.type]: market type, ['swap', 'spot']
        :param boolean [params.isMargin]: cancel all margin orders
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr   r  r@   r;   isMarginFr<   r=   r   z$ cancelAllOrders() does not support z typer  )
r|  r  r  r  appendr-   r   v4PrivatePostOrderCancelAllr  parse_orders)	r  r   r  r  r  r  requestTyperp  rf  s	            r	  cancel_all_orderszwhitebit.cancel_all_orders  s}      !!!!!!!!![[((F &tGH99:KVU[\\f6>>H#<<VEVXbdijjHf +""8,,,,""6****V^^y))))tw)OORVVY``aaa%99$++gv:V:VWWWWWWWW   6222r
  c           	      `  K   |                                   d{V  t          j        |                     ||||          |                     ||||          g  d{V \  }}|                     ||          }|                     |dd          }|t          |          |k    r
|d|         S |S )a  
        fetches information on multiple orders made by the user(combines open and closed orders)

        https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
        https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr  Tr   )r|  r  r  fetch_open_ordersfetch_closed_ordersra  sort_byr^  )	r  r   r  r   r  
openOrdersclosedOrders	allOrderssortedOrderss	            r	  fetch_orderszwhitebit.fetch_orders9  s       !!!!!!!!!)0""65%@@$$VUE6BB:
 * $ $ $ $ $ $ 
L %%j,??	||I{DAA\!2!2U!:!:%((r
  timeoutc                   K   |                                   d{V  |                     |d          }|t          | j        dz             |                     |          }|                     |d          }|dk    }d|d         i}|r|                     |dz            |d<   nd	|d<   |                     |                     ||                     d{V }|S )
a/  
        dead man's switch, cancel all orders after the given timeout

        https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer

        :param number timeout: time in milliseconds, 0 represents cancel the timer
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.types]: Order types value. Example: "spot", "margin", "futures" or None
        :param str [params.symbol]: symbol unified symbol of the market the order was made in
        :returns dict: the api result
        Nr   z< cancelAllOrdersAfter() requires a symbol argument in paramsr   r  r   r&  r  null)	r|  r<  r'   r   r  rS  number_to_stringv4PrivatePostOrderKillSwitchr  )r  r  r  r   r  isBiggerThanZeror  rf  s           r	  cancel_all_orders_afterz whitebit.cancel_all_orders_afterT  s      !!!!!!!!!!!&(33>#DG.l$lmmmV$$68,,#aKfTl
  	(!%!6!6w~!F!FGI!'GI::4;;wPV;W;WXXXXXXXX r
  c                 2   t          |                                          }i }t          dt          |                    D ]}||         }|                     |          }||         }t          |t                    rh|f|                                 }|                     |dd          |d<   | 	                    |d          |d<   | 	                    |d          |d<   |||<   |                                 }||d<   |||<   | 
                    |          S )Nr   	availablemain_balancefreefreezeusedrg  )r[  r\  r]  r^  r=  r  dictr   r  r<  safe_balance)	r  rf  balanceKeysrh  ri  r   rY  balancer   s	            r	  parse_balancezwhitebit.parse_balancez  s   8==??++q#k**++ 	' 	'AQB**2..DrlG'4(( 	'W-@,,.."&"4"4Wk>"Z"Z"&"2"27H"E"E#'#3#3G^#L#L &t,,..#* &t  (((r
  c                 .  K   |                                   d{V  d}|                     dd|          \  }}d}|dk    r|                     |           d{V }n|                     | j        di           }|                     |d          }|                     |dd|          }|                     |ddg          }|dk    s|dk    r|                     |           d{V }n| 	                    |           d{V }| 
                    |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.whitebit.com/private/http-main-v4/#main-balance
        https://docs.whitebit.com/private/http-trade-v4/#trading-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        NrQ   r=   r   r  r   r   )r|  r  %v4PrivatePostCollateralAccountBalancer>  r   r<  r  rS  v4PrivatePostMainAccountBalance v4PrivatePostTradeAccountBalancer  )r  r  r  rf  r   defaultAccountr   s          r	  fetch_balancezwhitebit.fetch_balance  sZ      !!!!!!!!!
!??PTV\]]
F!GGOOOOOOOOHHoodlNBGGG!--gyAAN((FNSSGYYv	6':;;F&  Gy$8$8!%!E!Ef!M!MMMMMMM!%!F!Fv!N!NNNNNNN. !!(+++r
  c                 D  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |t          |d          |d<   |                     |                     ||                     d{V }|                     ||||ddi          S )a  
        fetch all unfilled currently open orders

        https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders

        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of open order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr   r  r   r   r7  r  )r|  r  r-  r  r  rs  r
  s           r	  rw  zwhitebit.fetch_open_orders  s       !!!!!!!!![[((F &tGH"5#GG11$++gv2N2NOOOOOOOO*   65%(FASTTTr
  c           	         K   |                                   d{V  i }d}|(|                     |          }|d         }|d         |d<   |t          |d          |d<   |                     |                     ||                     d{V }t          |                                          }g }	t          dt          |                    D ]}
||
         }| 	                    |dd          }||         }t          dt          |                    D ]I}| 
                    ||         |          }|	                    |                     |d	d
i                     J|                     |	d          }	|                     |	|||          }	|	S )aC  
        fetches information on multiple closed orders made by the user

        https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr   r   r  r   r   r   r  r7  closedr  )r|  r  r-  r  r  r[  r\  r]  r^  r  r  rq  ry  filter_by_symbol_since_limit)r  r   r  r   r  r  r  rf  r  r  ri  r  r  r   rs  r  s                   r	  rx  zwhitebit.fetch_closed_orders  s      !!!!!!!!![[((FH%F &tGH"5#GGCCDKKPWY_D`D`aaaaaaaa$ ))	q#i..)) 	I 	IA |H((4==Ih'F1c&kk** I I((I>>t{{58X2FGGHHHHI ,,w4433GVUERRr
  c                 D    dddddddd}|                      |||          S )Nr   r  )r   r  stop marketz
stop limitzstock marketzmargin limitzmargin marketr<  )r  r  typess      r	  parse_order_typezwhitebit.parse_order_type	  s=    #!$#%
 
 tT222r
  r  c           
      v   |                      |d          }|                     ||d          }|d         }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|dk    rd }|                      |d	          }	|                     |d
          }
|                     |dd          }|                      |d          }|                     |          }|dk    rd }|                      |d          }|                      |d          }|dk    r|dk    s|dk    r|}|                      |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!|          S )"Nr  r  r   r  	dealStockleftrJ   r+  rL  r  r   r  r*  	dealMoneyrF  r  dealFeer"  r  ctimer  ftimer;  r  lastTradeTimestampr   rM  r7  r   filled	remaining)r  r2  r   trades)r<  r  rA  r  r  r  r  r  
safe_orderr   parse_order_status)r  r  r  r  r   r  r  r  rJ  r+  r   r  r  	orderTyper*  r2  r  r   r  r  s                       r	  r  zwhitebit.parse_order)	  s   P ##E844!!(FC88!v..!!%55$$UF33	((@@B M  00''/ABB$$UIt<<v..))$//	  I!!%22{33EMM!1!1t}7L7LF""5)44))'22"7O C ))%+FF	!00@@  
E 
' 
 f 
 ]	 

  
 Y// 
 !"4 
 4 
  
 d--d.>.>uh.O.OPP 
 D 
 U 
 I 
 L 
 f 
  f! 
" # 
$ + 
  
  
, -  	r
  r7  c                 >    ddddd}|                      |||          S )Ncanceledr  r  )CANCELEDOPENPARTIALLY_FILLEDFILLED)safe_string_lowerr  r7  statusess      r	  r  zwhitebit.parse_order_status	  s4    " &	
 
 %%h???r
  c                   K   |                                   d{V  dt          |          i}d}| |                     |          }|d         |d<   |t          |d          |d<   |                     |                     ||                     d{V }|                     |dg           }	|                     |	|          S )a*  
        fetch all the trades made from a single order

        https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals

        :param str id: order id
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nr  r   r  r   r   records)r|  rl  r  r-  v4PrivatePostTradeAccountOrderr  r`  r	  )
r  r   r   r  r   r  r  r  rf  r  s
             r	  fetch_order_tradeszwhitebit.fetch_order_trades	  s       !!!!!!!!!s2ww
 [[((F &tGH"5#GG<<T[[RX=Y=YZZZZZZZZ( ~~h	266  v...r
  rY  c                   K   |                                   d{V  d}i }| |                     |          }|d         |d<   ||                     |dz            |d<   ||dk    rd}|||d<   d|d	<   |                     |                     ||                     d{V }|                     |                     |d
g           |||          S )a  
        fetch all withdrawals made from an account

        https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history

        :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 exchange API endpoint
        :param str [params.transactionMethod]: transaction method(1=deposit, 2=withdrawal) - automatically set to '2' for withdrawals
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   r   r&  	startDater   r   2transactionMethodr  )r|  rj  r(  v4PrivatePostMainAccountHistoryr  parse_transactionsr`  r  rY  r  r   r  rj  r  rf  s           r	  fetch_withdrawalszwhitebit.fetch_withdrawals	  s      !!!!!!!!!}}T**H (GH#'#4#4UT\#B#BGK =ECKKE$GG'*#$==dkk'SY>Z>Z[[[[[[[[& &&t~~h	2'N'NPXZ_afgggr
  c                 p  K   |                                   d{V  d}i }| |                     |          }|d         |d<   ||                     |dz            |d<   ||dk    rd}|||d<   |                     |                     ||                     d{V }|                     ||||          S )a  
        fetch history of deposits and withdrawals

        https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history

        :param str [code]: unified currency code
        :param int [since]: the earliest time in ms to fetch transactions for
        :param int [limit]: the maximum number of transactions structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.transactionMethod]: transaction method(1=deposit, 2=withdrawal) - automatically set to '1' for deposits
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   r   r&  r  r   r   )r|  rj  r(  r  r  r  r  s           r	  fetch_transactionszwhitebit.fetch_transactions	  s       !!!!!!!!!}}T**H (GH#'#4#4UT\#B#BGK =ECKKE$GG==dkk'SY>Z>Z[[[[[[[[& &&x5%HHHr
  c                   K   |                                   d{V  |                     |          }d|d         i}d}|                     |          r|                     |d          }|t	          | j        dz             ||d<   |                     |d          }|t	          | j        dz             ||d<   |                     |d          }|t	          | j        d	z             |                     | 	                    ||                     d{V }n/| 
                    | 	                    ||                     d{V }|                     |d
          }	|                     |di           }
|                     |
d|	          }|                     |
d          }|                     |           ||d||dS )a  
        fetch the deposit address for a currency associated with self account

        https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
        https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address

        :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   r   providerzB fetchDepositAddress() requires a provider when the ticker is fiatr*  zA fetchDepositAddress() requires an amount when the ticker is fiatuniqueIdzC fetchDepositAddress() requires an uniqueId when the ticker is fiatr:  r   addressmemor;  rj  rO  r  tag)r|  rj  is_fiatr<  r'   r   rA  r>  &v4PrivatePostMainAccountFiatDepositUrlr  v4PrivatePostMainAccountAddresscheck_address)r  rY  r  rj  r  rf  r  r*  r  r:  r   r  r  s                r	  fetch_deposit_addresszwhitebit.fetch_deposit_address
  s      !!!!!!!!!==&&htn
 << 	`''
;;H'2v(vwww"*GJ%%fh77F~'2u(uvvv &GHvz::H'2w(wxxx!HHU\^dIeIeffffffffHH!AA$++gW]B^B^________H6 x////(Ir::""7Is;;w//7###
 
 	
r
  c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )aA  
        create a currency deposit address

        https://docs.whitebit.com/private/http-main-v4/#create-new-address-for-deposit

        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.network]: the blockchain network to create a deposit address on
        :param str [params.type]: address type, available for specific currencies
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        Nr   r   r   )r|  rj  (v4PrivatePostMainAccountCreateNewAddressr  r_  parse_deposit_addressr  rY  r  rj  r  rf  r  s          r	  create_deposit_addresszwhitebit.create_deposit_addressc
  s       !!!!!!!!!==&&htn
 FFt{{SZ\bGcGcdddddddd& ~~h	266))$999r
  rj  c                     ||                      d |          d |                     |d          |                     |d          dS )Nr  r  r  )r=  r<  )r  depositAddressrj  s      r	  r  zwhitebit.parse_deposit_address
  sR     #//h??''	BB##NF;;
 
 	
r
  c           	        K   |                                   d{V  g }|                     |           d{V }|rt          |t                    rt	          dt          |                    D ]f}|                     ||          }|                     |d          }|                     |d          }|r |                    |d|pd|z   d|d           g|S )aH  
        fetch all the accounts associated with a profile

        https://docs.whitebit.com/private/http-main-v4/#sub-account-list

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `account structures <https://docs.ccxt.com/?id=account-structure>`
        Nr   r   r   
subaccountzSubAccount )r   r  r   rY  r;  )	r|  v4PrivatePostSubAccountListr  r[  r]  r^  r>  r<  rq  )r  r  accountssubAccountsri  
subAccount	accountIdaccountNames           r	  fetch_accountszwhitebit.fetch_accounts
  s      !!!!!!!!! !<<VDDDDDDDD 	:k488 	1c+..//  !__[!<<
 ,,Z>>	"..z6BB OO' , + H}y/H $ *% %    r
  r   c                   K   |                                   d{V  |t          | j        dz             |dk     s|dk    rt          | j        dz             d|i}|                     |                     ||                     d{V S )a  
        set the level of leverage for a market

        https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-leverage

        :param float leverage: the rate of leverage
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        Nz/ setLeverage() does not allow to set per symbolr  r9   z2 setLeverage() leverage should be between 1 and 20r   )r|  r-   r   r(   &v4PrivatePostCollateralAccountLeverager  )r  r   r   r  r  s        r	  set_leveragezwhitebit.set_leverage
  s       !!!!!!!!!tw)ZZ[[[qLLhmmTW'[[\\\
 @@WV\A]A]^^^^^^^^^r
  fromAccount	toAccountc                   K   |                                   d{V  |                     |          }|                     | j        d          }|                     |||          }|                     |||          }	|                     ||          }
|d         |
||	d}|                     |                     ||                     d{V }|                     ||          S )af  
        transfer currency internally between wallets on the same account

        https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from - main, spot, collateral
        :param str toAccount: account to transfer to - main, spot, collateral
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
        Nr   r   )r   r*  fromto)	r|  rj  r>  r   r<  currency_to_precision v4PrivatePostMainAccountTransferr  parse_transfer)r  rY  r*  r  r  r  rj  r   fromAccountIdtoAccountIdamountStringr  rf  s                r	  r   zwhitebit.transfer
  s       !!!!!!!!!==&&7GHH((kRR&&~y)LL11$??tn"!	
 
 >>t{{7TZ?[?[\\\\\\\\ ""8X666r
  r   c           
      B    |d d d |                      d |          d d d d d	S )N)	r;  r   r  r  rj  r*  r  r  r7  )r=  )r  r   rj  s      r	  r  zwhitebit.parse_transfer
  s>    
 //h??

 

 
	
r
  r  r  c                 \  K   |                                   d{V  |                     |          }|d         |                     ||          |d}|                     |d          }||                                 }||d<   |||d<   |                     |          r4|                     |d          }	|	t          | j        dz             |	|d<   |                     | 	                    ||                     d{V }
| 	                    | 
                    |
|          d|i          S )a  
        make a withdrawal

        https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   )r   r*  r  r  r  r  z7 withdraw() requires a provider when the ticker is fiat)r|  rj  r  r>  uuid22r  r'   r    v4PrivatePostMainAccountWithdrawr  parse_transaction)r  rY  r*  r  r  r  rj  r  r  r  rf  s              r	  r   zwhitebit.withdraw  sR      !!!!!!!!!==&&tn00v>>
 

 ??6:66{{}}H&
?!GFO<< 	+vz::H'2k(klll"*GJ>>t{{7TZ?[?[\\\\\\\\ {{411(HEEhGWXXXr
  transactionc                 j   |                      d |          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }i d|                     |d          d|                     |d	          d
|d|                     |          d|                     |d          d|dk    r|nd d|d|dk    r|nd d|                     |d          d|dk    rdndd|                     ||          d|                     |          dd dd d|                     |d          dd d|                     |d          d |                     |d          |                     ||          d|dS ) Nr  	createdAtr   r7  r  r   r  txidtransactionIdr  r  rO  addressFrom1	addressTor  r*  r  rM  
withdrawalrj  r8  tagFromr  r  tagTocommentdescriptionr   r  )internalr   r;  )safe_currencyr<  r  r   rA  r=  parse_transaction_status)r  r  rj  r  r  r  r7  r  s           r	  r  zwhitebit.parse_transaction.  sL   @ %%dH55"";	::''[AA	%%k8<<
!!+x88!!+x88
$"";
;;
D$$[/BB
 
 Y//	

 t''Y??
 v}}774
 w
 Vs]]
 d&&{H==
 &C--IIl
 //
HEE
 d33F;;
 t
 t
 4##K88
  T!
" t'']CC#
$ ((e<< 33JII   /
 
 
 	
r
  c                     i ddddddddddd	dd
ddddddddddddddddddd}|                      |||          S )Nr  pendingr  3r6  4r  56791011121314151617r  r  s      r	  r  z!whitebit.parse_transaction_statusn  s    


 
 	

 
 
 
 
 )
 )
 )
 )
 )
 )
 )
  )!
$ &&999r
  c                 v  K   |                                   d{V  d}d|ddd}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch information on a deposit

        https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history

        :param str id: deposit id
        :param str code: not used by whitebit fetchDeposit()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r   )r  r  r   offsetr   r   r  )r|  rj  r  r  r>  r_  r  )	r  r   rY  r  rj  r  rf  r  firsts	            r	  fetch_depositzwhitebit.fetch_deposit  s       !!!!!!!!!!"	
 
 }}T**H (GH==dkk'SY>Z>Z[[[[[[[[L //(Ir::w2..%%eX666r
  c                 t  K   |                                   d{V  d}dddd}| |                     |          }|d         |d<   |t          |d          |d<   |                     |                     ||                     d{V }|                     |d	g           }|                     ||||          S )
a  
        fetch all deposits made to an account

        https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history

        :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 exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r   r   )r  r   r  r   r   r   r  )r|  rj  r-  r  r  r`  r  )	r  rY  r  r   r  rj  r  rf  r  s	            r	  fetch_depositszwhitebit.fetch_deposits  s       !!!!!!!!!!"
 

 }}T**H (GH"5#GG==dkk'SY>Z>Z[[[[[[[[L ..9b99&&w%GGGr
  c                 @  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     ||          }	|                     |	|||          S )ao  
        fetch the interest owed by the user for borrowing currency for margin trading

        https://docs.whitebit.com/private/http-trade-v4/#open-positions

        :param str code: unified currency code
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch borrrow interest for
        :param int [limit]: the maximum number of structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/?id=borrow-interest-structure>`
        Nr   r  )r|  r  +v4PrivatePostCollateralAccountPositionsOpenr  parse_borrow_interestsfilter_by_currency_since_limit)
r  rY  r   r  r   r  r  r  rf  interests
             r	  fetch_borrow_interestzwhitebit.fetch_borrow_interest  s       !!!!!!!!![[((F &tGHII$++V]_eJfJfgggggggg, ..x@@228T5%PPPr
  r;  c                    |                      |d          }|                     ||d          }|                     |d          }||d|                     |d          d|                     |d          d||                     |          d		S )
Nr  r  
modifyDater  unrealizedFundinggXjP?r*  rN  )	r;  r   rj  r  interestRateamountBorrowedr   r  r  )r<  safe_symbolr  rA  r   )r  r;  r  r  r   r  s         r	  parse_borrow_interestzwhitebit.parse_borrow_interest0  s    ( ##D(33!!(FC88''l;;	((/BCC#"..tX>>!"Y//

 

 
	
r
  c                    K   |                                   d{V  |                     |          }|                     |g|           d{V }|                     ||          S )an  
        fetch the current funding rate

        https://docs.whitebit.com/public/http-v4/#available-futures-markets-list

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/?id=funding-rate-structure>`
        N)r|  r   fetch_funding_ratesr>  )r  r   r  rf  s       r	  fetch_funding_ratezwhitebit.fetch_funding_rateS  sz       !!!!!!!!!V$$116(FCCCCCCCCx000r
  c                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     ||          S )a  
        fetch the funding rate for multiple markets

        https://docs.whitebit.com/public/http-v4/#available-futures-markets-list

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rates-structure>`, indexed by market symbols
        Nrh  )r|  r  r  r`  parse_funding_rates)r  r   r  rf  r  s        r	  r)  zwhitebit.fetch_funding_ratesb  s       !!!!!!!!!%%g..0088888888Z ~~h"55''g666r
  c                    |                      |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 S )Nr  	markPricer  r$  funding_ratenext_funding_rate_timestampr;  r   r  r  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetimer%  )r<  r&  rA  r  r   )
r  r(  r  r  r   r.  r  r$  r1  fundingTimes
             r	  parse_funding_ratezwhitebit.parse_funding_rate  sw   B ##Hk::!!(F33$$X{;;	%%h==
''.AA&&x@@''2OPP
H
f
 
 *	

 L
 
 
 ;
 
 t||K88
 t
 #D
 "4
 "4
 '
  &t!
" #
 	
r
  c                   K   |                                   d{V  |t          | j        dz             |                     |          }d|d         i}|||d<   |||d<   |                     d||          \  }}|                     |           d{V }|                     |dg           }|                     ||||          S )	aw  
        fetch the history of funding payments paid and received on self account

        https://docs.whitebit.com/private/http-trade-v4/#funding-history

        :param str [symbol]: unified market symbol
        :param int [since]: the starting timestamp in milliseconds
        :param int [limit]: the number of entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch funding history for
        :returns dict[]: a list of `funding history structures <https://docs.ccxt.com/?id=funding-history-structure>`
        Nz1 fetchFundingHistory() requires a symbol argumentr  r   r  r   endDater  )r|  r'   r   r  handle_until_option,v4PrivatePostCollateralAccountFundingHistoryr`  parse_funding_histories)	r  r   r  r   r  r  r  rf  r  s	            r	  fetch_funding_historyzwhitebit.fetch_funding_history  s       !!!!!!!!!>#DG.a$abbbV$$fTl
 #(GK $GG229gvNNJJ7SSSSSSSS$ ~~h	266++D&%GGGr
  c           
          |                      |d          }|                     |d          }||                     ||d d          d ||                     |          d |                     |d          dS )Nr  r:  r=   fundingAmount)r;  r   rY  r  r  r   r*  )r<  r  r&  r   rA  )r  r(  r  r  r  s        r	  parse_funding_historyzwhitebit.parse_funding_history  s     ##Hh77%%h>>	&&xvFF"Y//&&xAA
 
 	
r
  c                    g }t          dt          |                    D ]3}||         }|                    |                     ||                     4|                     |d          }|                     |||          S )Nr   r  )r]  r^  rq  rD  ry  r  )	r  	contractsr  r  r   rh  ri  r(  sorteds	            r	  r@  z whitebit.parse_funding_histories   s    q#i..)) 	H 	HA |HMM$44XvFFGGGGfk22))&%???r
  c                 N  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                     d{V }|                     |d          }|                     ||||          S )a  
        fetch history of deposits and withdrawals

        https://github.com/whitebit-exchange/api-docs/blob/main/pages/private/http-main-v4.md#get-depositwithdraw-history

        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default = 50, Min: 1, Max: 100
        :param dict [params]: extra parameters specific to the exchange API endpoint

 EXCHANGE SPECIFIC PARAMETERS
        :param number [params.transactionMethod]: Method. Example: 1 to display deposits / 2 to display withdraws. Do not send self parameter in order to receive both deposits and withdraws.
        :param str [params.address]: Can be used for filtering transactions by specific address or memo.
        :param str[] [params.addresses]: Can be used for filtering transactions by specific addresses or memos(max: 20).
        :param str [params.uniqueId]: Can be used for filtering transactions by specific unique id
        :param int [params.offset]: If you want the request to return entries starting from a particular line, you can use OFFSET clause to tell it where it should start. Default: 0, Min: 0, Max: 10000
        :param str[] [params.status]: Can be used for filtering transactions by status codes. Caution: You must use self parameter with appropriate transactionMethod and use valid status codes for self method. You can find them below. Example: "status": [3,7]
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   r   r   r  )r|  rj  r  r  r`  r  )	r  rY  r  r   r  r  rj  rf  r  s	            r	  fetch_deposits_withdrawalsz#whitebit.fetch_deposits_withdrawals(  s      ( !!!!!!!!!}}T**H (GH$GG==dkk'SY>Z>Z[[[[[[[[N ..955&&w%GGGr
  fromCodetoCodec                 N  K   |                                   d{V  |                     |          }|                     |          }|||                     |          dd}|                     |                     ||                     d{V }|                     |||          S )aB  
        fetch a quote for converting from one currency to another

        https://docs.whitebit.com/private/http-trade-v4/#convert-estimate

        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float amount: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
        Nr  )r  r  r*  	direction)r|  rj  r  v4PrivatePostConvertEstimater  parse_conversion)	r  rJ  rK  r*  r  fromCurrency
toCurrencyr  rf  s	            r	  fetch_convert_quotezwhitebit.fetch_convert_quoten  s       !!!!!!!!!}}X..]]6**
++F33	
 
 ::4;;wPV;W;WXXXXXXXX $$X|ZHHHr
  c                 "  K   |                                   d{V  |                     |          }|                     |          }d|i}|                     |                     ||                     d{V }	|                     |	||          S )ao  
        convert from one currency to another

        https://docs.whitebit.com/private/http-trade-v4/#convert-confirm

        :param str id: the id of the trade that you want to make
        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
        Nr%  )r|  rj  v4PrivatePostConvertConfirmr  rO  )
r  r   rJ  rK  r*  r  rP  rQ  r  rf  s
             r	  create_convert_tradezwhitebit.create_convert_trade  s       !!!!!!!!!}}X..]]6**
r
 99$++gv:V:VWWWWWWWW $$X|ZHHHr
  c                   K   |                                   d{V  i }|||d<   |0|                     |dz            }|                     |          |d<   |||d<   |                     d||d          \  }}|                     |                     ||                     d{V }|                     |dg           }|                     ||d	d
||          S )a[  
        fetch the users history of conversion trades

        https://docs.whitebit.com/private/http-trade-v4/#convert-history

        :param str [code]: the unified currency code
        :param int [since]: the earliest time in ms to fetch conversions for
        :param int [limit]: the maximum number of conversion structures to retrieve, default 20, max 200
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.until]: the end time in ms
        :param str [params.fromTicker]: the currency that you sold and converted from
        :param str [params.toTicker]: the currency that you bought and converted into
        :param str [params.quoteId]: the quote id of the conversion
        :returns dict[]: a list of `conversion structures <https://docs.ccxt.com/?id=conversion-structure>`
        N
fromTickerr&  r  r   r  MbP?r  rP  rQ  )r|  r(  r  r>  v4PrivatePostConvertHistoryr  r`  parse_conversions)	r  rY  r  r   r  r  r'  rf  rowss	            r	  fetch_convert_trade_historyz$whitebit.fetch_convert_trade_history  s       !!!!!!!!!$(GL!%%edl33E"33E::GFO$GG224&%PP99$++gv:V:VWWWWWWWW0 ~~h	266%%dD.,PUW\]]]r
  
conversionrP  rQ  c                 |   |                      |dg           }|                     |di           }|                     |d          }|                     |d          }|                     |dd          }|                     |d|          }	|                     |	|          }
|                     |d|          }|                     ||          }|||                     |          |                     |d          |
|                     |dd	          ||                     |d
d          |                     |d          d d
S )Npathr   r  r  dateexpireAtr   give	finalGivereceivefinalReceiverate)
r;  r  r  r   rP  
fromAmountrQ  toAmountr+  r   )r`  r_  r<  r  r=  r   safe_number_2rA  )r  r]  rP  rQ  r_  r  fromPathtoPathr  fromCoinrJ  toCoinrK  s                r	  rO  zwhitebit.parse_conversion  sE   L ~~j&"55tQ++##E622!!%..))*fjII	##JAA**8\BB!!*dF;;((<<"Y//"":t44$,,ZMM **:y.QQ%%j&99
 
 	
r
  c                   K   |                                   d{V  |                     |          }d|d         i}|||d<   |||d<   |                     d||          \  }}|                     |                     ||                     d{V }|                     |          }|                     ||||          S )aB  
        fetches historical positions

        https://docs.whitebit.com/private/http-trade-v4/#positions-history

        :param str symbol: unified contract symbol
        :param int [since]: the earliest time in ms to fetch positions for
        :param int [limit]: the maximum amount of records to fetch
        :param dict [params]: extra parameters specific to the exchange api endpoint
        :param int [params.positionId]: the id of the requested position
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
        Nr  r   r  r   r=  )r|  r  r>  .v4PrivatePostCollateralAccountPositionsHistoryr  parse_positionsr  )	r  r   r  r   r  r  r  rf  	positionss	            r	  fetch_position_historyzwhitebit.fetch_position_history  s       !!!!!!!!!V$$fTl
 #(GK $GG229gvNNLLT[[Y`bhMiMijjjjjjjj0 ((22	00FE5QQQr
  c                    K   |                                   d{V  |                     |          }|                     |           d{V }|                     ||          S )ap  
        fetch all open positions

        https://docs.whitebit.com/private/http-trade-v4/#open-positions

        :param str[] [symbols]: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `position structures <https://docs.ccxt.com/?id=position-structure>`
        N)r|  r  r  rp  )r  r   r  rf  s       r	  fetch_positionszwhitebit.fetch_positionsP  s|       !!!!!!!!!%%g..II&QQQQQQQQ, ##Hg666r
  c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetch data on a single open contract trade position

        https://docs.whitebit.com/private/http-trade-v4/#open-positions

        :param str symbol: unified market symbol of the market the position is held in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `position structure <https://docs.ccxt.com/?id=position-structure>`
        Nr   r   r   )r|  r  r  r  r_  parse_position)r  r   r  r  r  rf  r  s          r	  fetch_positionzwhitebit.fetch_positiont  s       !!!!!!!!!V$$fTl
 II$++V]_eJfJfgggggggg, ~~h2..""4000r
  positionc                 @   |                      |d          }|                     |d          }|                     |di           }|                     |di           }|                     i d|d|                      |d          d|                     ||          d	d d
d d|                     |d          d|                     |d          d|                     |d          d|                     |d          d|                     |d          dd dd dd dd dd dd d||                     |          |                     |d          d d |                     |d          d d d d |                     |d          |                     |d          d          S )Nr  openDatetpslorderDetailr;  r   
positionIdr   notionalr   liquidationPrice
entryPrice	basePriceunrealizedPnlpnlrealizedPnlr   
pnlPercentrF  r3  r.  r  r  r   r  r"  r<   stopLoss
takeProfit)r  lastUpdateTimestampmaintenanceMarginmaintenanceMarginPercentager   initialMargininitialMarginPercentager   marginRatior   r   )r<  r  r_  safe_positionr&  rA  r   )r  rx  r  r  r  r{  r|  s          r	  rv  zwhitebit.parse_position  s-   X ##Hh77''*==	~~h33nnX}bAA!! #
H#
$""8\::#
 d&&x88#
 	#

 $#
  0 0;M N N#
 $**8[AA#
 T--h>>#
 4++KGG#
 $**8\BB#
 #
 D#
 #
 #
 D#
  d!#
" ##
$ Y//#'#6#6x#N#N!%+/**8X>>!'+!--dJ??#//lCC9#
 #
 #
   	r
  c                 0  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |dg           }|                     ||          S )a  
        fetch the rate of interest to borrow a currency for margin trading

        https://docs.whitebit.com/private/http-main-v4/#get-plans

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `borrow rate structure <https://docs.ccxt.com/?id=borrow-rate-structure>`
        Nr   r   r   )r|  rj  "v4PrivatePostMainAccountSmartPlansr  r`  parse_borrow_rater  s          r	  fetch_cross_borrow_ratez whitebit.fetch_cross_borrow_rate  s       !!!!!!!!!==&&htn
 @@WV\A]A]^^^^^^^^ ~~h2..%%dH555r
  c                    |                      |d          }|                      |d          }|                     ||          |                     t          j        |d                    |                     |d          d d |dS )Nr   r  r  duration)rj  rf  periodr  r  r;  )r<  r=  r  r1   r@  r  )r  r;  rj  r  r  s        r	  r  zwhitebit.parse_borrow_rate   s     %%dH55
""433//
HEE%%g&8%&H&HII''j99
 
 	
r
  c                 f    |                      | j        dg           }|                     ||          S )Nr   )r>  r   rc  )r  rj  r   s      r	  r  zwhitebit.is_fiat  s.    7GLL}}X~666r
  c           	      F  K   |t          | j        dz             d}d}|                     |dd          \  }}|r!|                     d|||d||           d{V S |                                  d{V  |                     |          }d|d	         i}|"t          t          |dz                      |d
<   |                     d||d          \  }}|||d<   | 	                    | 
                    ||                     d{V }	|                     |	|||          S )a  
        fetches historical funding rate prices

        https://docs.whitebit.com/api-reference/market-data/funding-history

        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>` to fetch(default 100, max 1000)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding rate
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/?id=funding-rate-history-structure>`
        Nz5 fetchFundingRateHistory() requires a symbol argumentr&  Frg   paginater   r  r   r  until_timestamprX  r   )r'   r   r  "fetch_paginated_call_deterministicr|  r  rl  roundr>  v4PublicGetFundingHistoryMarketr  parse_funding_rate_histories)
r  r   r  r   r  r+  r  r  r  rf  s
             r	  fetch_funding_rate_historyz#whitebit.fetch_funding_rate_history  s      >#DG.e$efff88AZ\fgg& 	J@@AZ\bdikprvx~  AI  J  J  J  J  J  J  J  J  J!!!!!!!!!V$$fTl
 #&uUT\':':#;#;GK 223DgvW\]]$GG==dkk'SY>Z>Z[[[[[[[[ 0065%PPPr
  c                     |                      |d          }|                     ||          }|                     |d          }||d         |                     |d          ||                     |          dS )Nr  r:  r   r1  )r;  r   r1  r  r  )r<  r  r  rA  r   )r  r;  r  r  r  s        r	  parse_funding_rate_historyz#whitebit.parse_funding_rate_history>  s    ##D(33!!(F33''m<<	X&++D-@@"Y//
 
 	
r
  c                 F    |                                  | j        d         z
  S )Nr   )millisecondsr   )r  s    r	  noncezwhitebit.nonceJ  s!      ""T\2B%CCCr
  r   GETc                    |                      ||                     |                    }|                     |d          }|                     |d          }	|i }d| j        z   dz   | j        z   |d<   d|                     ||          z   }
| j        d         |         |	         |
z   }|	dk    r|r|d	|                     |          z   z  }|	d
k    r|                                  t          | 
                                          }|                     | j                  }d|z   |
z   }|                     |ddd          \  }}|                     |                     |||d|                    }|                     |          }|                     |                     |          |t$          j                  }d| j        ||d}||||dS )Nr   r  zccxt/-z
User-Agentr  r   r   ?r   z/api/signr   F)r  r  r   zapplication/json)zContent-TypezX-TXC-APIKEYzX-TXC-PAYLOADzX-TXC-SIGNATURE)r:  r  bodyheaders)rS  extract_paramsr>  r   r   implode_paramsr   	urlencodecheck_required_credentialsstrr  encodesecretr  jsonr  string_to_base64hmachashlibsha512apiKey)r  r_  r   r  r  r  r  rc  r   accessibilitypathWithParamsr:  r  r  r  r   requestParamspayload	signatures                      r	  r  zwhitebit.signM  s   		&$"5"5d";";<<//#q))Q//?G '$' 1C 7$, Ft224@@@iw'6GH$$ 3sT^^E2222I%%++---

%%E[[--F''1NBG)-)F)FvvWdfk)l)l&K99T[[Wu]h)i)ikxyyzzD++D11G		$++g"6"6OOI 2 $!(#,	 G fdwOOOr
  reasonr:  r  r  r  c
                    |dk    s|dk    r3t          | j        dz   t          |          z   dz   |z   dz   |z             |dk    r*t          | j        dz   t          |          z   dz             |\|                     |d          }
|                     |d          }|                     |d          }|                     |d	          }|
d uo	|
d
k    o|d u}|s|| j        dz   |z   }|}|r|
}n|                     |di           }t          |	                                          }t          |          }|dk    r>|d         }|                     ||g           }t          |          }|dk    r|d         n|}|                     | j        d         ||           |                     | j        d         ||           t          |          d S )Ni  i  r  i  z endpoint not foundr7  errorsmessagerY  200r   r   r   )r.   r   r  r$   r<  r>  r  r_  r[  r\  r^  throw_exactly_matched_exceptionr  throw_broadly_matched_exception)r  rY  r  r:  r  r  r  rf  requestHeadersrequestBodyr7  r  r  codeNewhasErrorStatusfeedback	errorInfoerrorObject	errorKeyserrorsLengtherrorKeyerrorMessageArrayerrorMessageLengths                          r	  handle_errorszwhitebit.handle_errorsj  s   CKKTS[[ 3T!:S!@6!IC!ORV!VWWW3;;#D		 9<Q QRRR %%h99F__Xx88F&&x;;G ''&99G#4/ZFeOZVZHZN .!47S=4/#	! 
_ &II"&..8R"H"HK $[%5%5%7%7 8 8I#&y>>L#a''#,Q<,0OOKSU,V,V)-01B-C-C*=ORS=S=S$5a$8$8Z^	44T_W5MyZbccc44T_W5MtU]^^^#H---tr
  )NN)N)NNN)t__name__
__module____qualname__r   r  r#   r   r  r  rG  r   rx  r   r  r  r  r    r  r  r  r  r   r  r  r   r   r  r   r   r   r   r  r   r  r  r"  r[  r,  r3  r<  r@  r   floatrD  rG  r   r   rB  rj  rn  ru  r~  r  r   r  r  rw  rx  r  r  r  r  r!   r  r  r   r  r  r   r  r   r  rl  r  r"   r   r  r   r  r  r  r  r   r   r'  r   r*  r   r)  r;  r   rA  rD  r@  rI  r
   rR  rU  r\  rO  r   rr  rt  rw  rv  r   r  r  boolr  r  r  r  r  r  __classcell__)r  s   @r	  r3   r3      s       e# e e e e e eN *, #+ #+V #+ #+ #+ #+JV
4 V
F V
 V
 V
 V
p -/ N N: N N N N` =A 5
 5
' 5
 5
 5
 5
n BFb 6A 6Aw 6A 6A 6A 6ApV# V# V# V#p /1 - -[ - - - -^ =A d d' dPS d d d dL ;?r I I I I I IV 68 "1 "1 "1F "1 "1 "1 "1Hq q4 q q6 q q q qf 8<B ;N ;NC ;N ;N5 ;N ;N ;N ;Nz 6:" fG fG7 fG fG fG fG fGP @DB 'B 'BS 'B 'BS\ 'B 'B 'B 'BR <@d[] A A AS A Abfglbm A A A A@ 37TX\eg DR DRC DRs DRRU DR DR DR DRLN N Nv N N N N N` ?CQUdhqs )J )J )J )J3 )J^a )Jx|  ~B  yC )J )J )J )JV
 
 
4 
 
 
 
* )+ 
 
 
 
0 ') A AS A A A A" eg b b# bY bV[ b b b b XZ U Uc U U^c U U U U mqy{ X* X* X*I X*Y X*X] X*fi X* X* X* X*t fjx|  FH 7* 7*3 7* 7*9 7*I 7*_b 7*ru 7* 7* 7* 7*r 9=R '* '*S '*# '* '* '* '*R 59 %3 %3c %3 %3 %3 %3N 04$UYbd   C s imnsit    6 BD $ $S $ $ $ $L) ) ) ) )& *, /, /, /, /, /, /,b 59tZ^gi )U )Uc )U )UTW )Unrsxny )U )U )U )UV 7;\`ik 2 2 23 2VY 2ptuzp{ 2 2 2 2h
3S 
3 
3 
3 
3[ [ [v [ [ [ [ [z@ @ @ @ @ ?CQUdhqs ,/ ,/3 ,/ ,/3 ,/^a ,/ ,/ ,/ ,/\ 37TX\eg .h .hC .hs .hRU .hlpq|l} .h .h .h .h` 48dY]fh -I -IS -I -ISV -Imqr}m~ -I -I -I -I^ =? E
 E
 E
> E
 E
 E
 E
N >@ %: %: %:N %: %: %: %:N
 
h 
R` 
 
 
 
 +- $ $g $ $ $ $L ?C2 _ _3 _ _ _ _ _0 ac 7 73 7 7C 7TW 7gt 7 7 7 7>
 
t 
x 
= 
 
 
 
  QU]_ &Y &Y3 &Y &Y &Y# &Ydo &Y &Y &Y &YP>
 >
T >
X >
Q\ >
 >
 >
 >
@:s : : : :* 8<B >7 >7c >7 >7 >7 >7 >7@ 04$UYbd ?H ?H ?HC ?Hs ?Himnyiz ?H ?H ?H ?HB 7;$]apt} *Q *Q *QC *QWZ *Qjm *Q  EI  JX  EY *Q *Q *Q *QX!
 !
$ !
 !
. !
 !
 !
 !
F <> 1 1s 1+ 1 1 1 1 <@ :7 :7 :7| :7 :7 :7 :7x:
 :
6 :
[ :
 :
 :
 :
x 9=4^bkm ,H ,H# ,HS ,HX[ ,Hrv  xF  sG ,H ,H ,H ,H\
 
f 
 
 
 
0@ @S @X[ @gklzg{ @ @ @ @ <@daenp DH DHS DH DH[^ DHuy  {F  vG DH DH DH DHL SW_a !I !I# !Is !IC !Ifp !I !I !I !IF ]aik I IS IC I IVY Ipz I I I I8 =Atbfoq 3^ 3^c 3^ 3^\_ 3^vz  |F  wG 3^ 3^ 3^ 3^j:
 :
4 :
x :
\d :
pz :
 :
 :
 :
x FJX\eg 0R 0R3 0Rs 0RRU 0Rlpqylz 0R 0R 0R 0Rd 8<B "7 "7W "74PX> "7 "7 "7 "7H 8: &1 &13 &1h &1 &1 &1 &1PM Mt MV Mx M M M M^ ?A 6 6# 6_ 6 6 6 6*
 
 
 
 
 
7 7 7 7 7 7 >BPTcgpr *Q *Qs *Q# *Q]` *Q *Q *Q *QX

 

v 

 

 

 

D D D &eBSW P P P P:!# !s ! !c !TX !`c ! ! ! ! ! ! ! !r
  r3   )9 ccxt.async_support.base.exchanger   ccxt.abstract.whitebitr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   typingr#   ccxt.base.errorsr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   ccxt.base.decimal_to_precisionr0   ccxt.base.preciser1   r3    r
  r	  <module>r     s   6 5 5 5 5 5 . . . . . .   V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V  V       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) + + + + + + 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %o= o= o= o= o=x o= o= o= o= o=r
  