
    ij                    P   d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lm Z  d d
lm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dlm&Z& d dlm'Z' d dlm(Z( d dl)m*Z* d dl+m,Z,  G d dee          Z-dS )    )Exchange)ImplicitAPIN)BalancesBool
CurrenciesCurrencyIntMarket
MarketTypeNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)DDoSProtection)ExchangeNotAvailable)	TICK_SIZE)Precisec                       e Zd Z fdZi fdee         fdZdefdZi fdefdZ	di fdee
         fdZdi fdefd	ZdDd
Zi fdefdZi fde
defdZdEd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dEdedefdZdddi fde
dededee         fdZdEdedefdZ i fdZ!i fdZ"di fde
de#de$de%d e&f
d!Z'di fd"e
defd#Z(de)fd$Z*i fde)fd%Z+dddi fdedededee,         fd&Z-dddi fdedededee,         fd'Z.d( Z/dEdede,fd)Z0dddi fd"e
dededefd*Z1i fd+e
fd,Z2di fd-edefd.Z3i fd+e
de%d/e
d0e
de4f
d1Z5dEd2e6fd3Z7di fd+e
de%fd4Z8dEd2e6de9fd5Z:d6 Z;di fd"e
d+efd7Z<dddi fd+edededee9         fd8Z=ddddi fd+edededefd9Z>dEdefd:Z?i fde
fd;Z@di fdefd<ZAdEdefd=ZBd> ZCd? ZDd@dAi ddfdBZEdC ZF xZGS )Fwhitebitc                    |                      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d0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dddddddd<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRidSdTdPdUdVdWdXdYdZd[d\gid[g d]id^g d_idPdQd[g d`iid[g daid^g dbidPdcdddd|                     de          |                     de          dfig dgdhdidididdjddkdldmiddndot
          t          t          t          t          t          t          t          t          t          t          t          t          t          t          dpt          t          t          t          t          t          dqdrds          S )tNr)   WhiteBitv4EE2   TCORSspotmarginswapFfutureoptioncancelAllOrderscancelOrdercancelOrderscreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrdersfetchOrderBookfetchOrderTradesfetchPositionModefetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFees)fetchTransactionFeesrepayCrossMarginrepayIsolatedMarginsetLeveragetransferwithdraw1m3m5m15m30m1h2h4h6h8h12h1d3d1w1M)ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   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privaterx   z"https://whitebit.com/api/v2/publicz"https://whitebit.com/api/v4/publiczhttps://whitebit.com/api/v4)v1v2r,   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orderbook/{market}r   r   timepingr   futures) zcollateral-account/balancez$collateral-account/positions/historyzcollateral-account/leveragez!collateral-account/positions/openzcollateral-account/summaryz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trade-account/balanceztrade-account/executed-historyztrade-account/orderztrade-account/order/historyzorder/collateral/limitzorder/collateral/marketzorder/collateral/trigger_marketr   zorder/marketzorder/stock_marketzorder/stop_limitzorder/stop_marketr   r   zprofile/websocket_token)webrz   r{   r,   tradingz0.001)	tierBased
percentagetakermaker)EURUSDRUBUAHaccountmain
collateral)fundingr   r0   r1   tradeBEP20BSCccxt)fiatCurrenciesr=   accountsByTypenetworksByIddefaultTypebrokerId)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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precisionMode
exceptions)deep_extendsuperr)   describeparse_numberr&   r   r   r   r!   r    r   r"   r%   )self	__class__s    a/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/whitebit.pyr   zwhitebit.describe   s\   h 5 5 > > @ @::: $: 	:
 %: %: "5: t: : t: ': (: "4: U: :  +E!:" )%#: :$ $T%:& '':( ():* "4+:, -:. &t/:0  1:2 *:3:4 +D5:6 &u7:8 #D9:: *5;:< $T=:> "5?:@ *5A:B +EC:D "5E: : :F G:H !%I:J  K:L dM:N +EO:P "4Q:R !$S:T #DU:V $UW:X )%Y:Z t[:\ t]:^ _:` Ta:b tc:d "5e:f #Dg: :h )-$)',#  s: : :x  $ ~ #G#@ 
 !"F #G#@   2F;`% , (       
  	! 	! 	!  4       	         !! !! !!# 3 3W_ _B !&"&!..w77!..w77	  #?">">v!  &""*## # U!  &"! $ ' .A5>/8(25A+<7C*;4DN^7D5?/( " 4D<H*60<7G@Q # E|C
 |C
 | | |	    returnc                 d   K   |                                   d{V }|                     |          S )a  
        retrieves data on all markets for whitebit
        :see: 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
        N)v4PublicGetMarketsparse_markets)r   paramsr   s      r   fetch_marketszwhitebit.fetch_markets  sA       //111111110 !!'***r   c                    |                      |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!|||                     |          |                     |          |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:r2   Tr0   takerFee100makerFeer   symbolbasequotesettlebaseIdquoteIdsettleIdr1   r3   r4   activecontractlinear	moneyPrec)amountpriceminmax	minAmountminTotalmaxTotal)leverager   r   cost)inverser   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_code
safe_valuer   parse_precisionr'   
string_divsafe_number)r   marketr   r   r   r   r   r   r   typeIdr   r   r   r2   r1   r   amountPrecisionr   r   r   r   takerFeeRater   makerFeeRater   s                            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
 H2
 f2
 D2
 e2
 e2
 f2
  !2
" f#2
$ &&u--&&u--(")**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d          }|                     |dd          }	|o|	}
|                     |          }|||d|
||	ddddd|                     |d          |                     |d          dd	d

||<   |S )a  
        fetches all available currencies on an exchange
        :see: 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   can_depositTcan_withdrawr   min_withdrawmax_withdraw)r   rh   )
r   coder   r   r   depositrh   r   r   r   )v4PublicGetAssetslistkeysrangelen	safe_boolr   r   )r   r   responseidsresultir   currency
canDepositcanWithdrawr   r  s               r   fetch_currencieszwhitebit.fetch_currencies  sE      //77777777 8==??##q#c((## 	 	AQB|H -FFJ..>4HHK/KF**2..D  %'!  $# 
  $//.II#//.II! !	 	 F4LL* r   Ncodesc                   K   |                                   d{V  |                     |           d{V }t          |                                          }i }i }t	          dt          |                    D ]}||         }||         }	|                     |          }
|                     |	di           }|                     |d          ||
<   |                     |	di           }|                     |d          ||
<   |||dS )a  
         * @deprecated
        please use fetchDepositWithdrawFees instead
        :see: 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   rh   fixedr  )rh   r  r   )	load_marketsv4PublicGetFeer	  r
  r  r  r   r   r   )r   r  r   r  currenciesIdswithdrawFeesdepositFeesr  r  datar  rh   r  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 )ah  
        fetch deposit and withdraw fees
        :see: 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   r  r   r  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      rh   r  r  F)r   r   )rh   r  networks)market_codesr	  r
  r  r  splitr   in_arrayr   deposit_withdraw_feer   r   network_id_to_coder  $assign_default_deposit_withdraw_fees)r   r  r  currencyIdKeydepositWithdrawFeescurrencyIdsr  entry
splitEntry
currencyIdfeeInfor  depositWithdrawFee	networkIdrh   r  withdrawFee
depositFeewithdrawResultdepositResultnetworkLengthnetworkCodedepositWithdrawCodesr  s                           r   r!  z$whitebit.parse_deposit_withdraw_fees7  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 )aZ  
        fetch the trading fees for multiple markets
        :see: 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  r  r  r  r   r   r   r   r'   r   r   )
r   r   r  r  r  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                 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
        :see: 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   r  )r  r   v1PublicGetTickerextend	safe_dictparse_ticker)r   r   r   r   requestr  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           	      H   |                      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          |                     |dd          |d|          S )N
last_pricer   	timestampdatetimehighlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechanger   averagebase_volumevolumequote_volumedeal)
baseVolumequoteVolumer   )safe_marketr   safe_tickersafe_string_2)r   r   r   rU  s       r   rE  zwhitebit.parse_ticker  s   8 !!$//55 !
fX&!
!
 !
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D$$VV44!
 T!
 D!
 T!
 d!
  $**68<<!!
" t#!
$ ,,V]HMM--fnfMM)!
 !
 !
* +  	r   r   c                   K   |                                   d{V  |                     |          }|                     |           d{V }t          |                                          }i }t          dt          |                    D ]H}||         }|                     |          }|                     ||         |          }	|	d         }
|	||
<   I| 	                    |d|          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.whitebit.com/public/http-v4/#market-activity
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   )
r  market_symbolsv4PublicGetTickerr	  r
  r  r  r_  rE  filter_by_array_tickers)r   r   r   r  	marketIdsr  r  marketIdr   r   r   s              r   fetch_tickerszwhitebit.fetch_tickers  s      !!!!!!!!!%%g..//77777777 ))	q#i..)) 	$ 	$A |H%%h//F&&x'96BBFH%F#F6NN++FHgFFFr   limitc                 >  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     |d          }|                     |||          S )a5  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: 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   ri  rJ  )r  r   v4PublicGetOrderbookMarketrC  safe_timestampparse_order_book)r   r   ri  r   r   rF  r  rJ  s           r   fetch_order_bookzwhitebit.fetch_order_book3  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
        :see: 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   v4PublicGetTradesMarketrC  parse_tradesr   r   ro  ri  r   r   rF  r  s           r   fetch_tradeszwhitebit.fetch_tradesZ  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
        :see: 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   _rJ  )r  r   (v4PrivatePostTradeAccountExecutedHistoryrC  
isinstancer	  rr  r
  r  r  r_  r   array_concat	sort_by_2filter_by_since_limit)r   r   ro  ri  r   r   rF  r  resultsr
  r  rg  	marketNew	rawTradesparseds                  r   fetch_my_tradeszwhitebit.fetch_my_tradesx  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   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dealOrderIdorderIdr\  r   r   r[  r   tradeIDr   sider   roler%  r   r   r   r   r   r  )r   rJ  rK  r   r   orderr   takerOrMakerr  r   r   r   r   )r_  safe_timestamp_2ra  r   safe_integer
safe_tradeiso8601)r   r   r   rJ  r  r   r   r   r   r  r   r  r  r   feeCosts                  r   parse_tradezwhitebit.parse_trade  s   T !!$//))%9JKK	$$UM9EEv..  00##E8^DDtY77!!%88!  // '+qyy77wL""5%00"7O C "Y//( 
  
   	r   ri   c                    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
        :see: 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   intervali  i  startri  r  )
r  r   r   r   r   parse_to_intv1PublicGetKlinerC  	safe_listparse_ohlcvs)r   r   	timeframero  ri  r   r   rF  maxLimitr  r  r  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%              )rl  r   )r   ohlcvr   s      r   parse_ohlcvzwhitebit.parse_ohlcv3  s     q))UA&&UA&&UA&&UA&&UA&&
 	
r   c                    K   |                      |           d{V }|                     |d          }|dk    rdn|ddd|dS )aU  
        the latest known information on the availability of the exchange API
        :see: 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   r  r  s       r   fetch_statuszwhitebit.fetch_statusH  sp       --f55555555 !!(A..%//ddf
 
 	
r   c                 h   K   |                      |           d{V }|                     |d          S )aV  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: 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   )v4PublicGetTimer  )r   r   r  s      r   
fetch_timezwhitebit.fetch_time^  sE       --f55555555   6222r   r   r  r   r   c                 h  K   |                                   d{V  |                     |          }|d         ||                     ||          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 }nA|r1|                     |                     ||                     d{V }n|                     |                     ||                     d{V }n|r{|                     ||          |d<   |r0|                     |                     ||                     d{V }n|                     |                     ||                     d{V }na|r0|                     |                     ||                     d{V }n/|                     |                     ||                     d{V }|                     |          S )a  
        create a trade order
        :see: https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
        :see: https://docs.whitebit.com/private/http-trade-v4/#create-market-order
        :see: https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
        :see: https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
        :see: 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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   )r   r  r   clOrdIdclientOrderIdr   r   ri  r   )triggerPrice	stopPriceactivation_priceFr8   TpostOnlycrossz1 createOrder() is only available for cross margin)r  r  r  r2   r  r   )r  r   amount_to_precisionra  r   r   uuid16omitsafe_number_nis_post_onlyhandle_margin_mode_and_paramsr#   r   price_to_precisionv4PrivatePostOrderStopLimitrC  )v4PrivatePostOrderCollateralTriggerMarketv4PrivatePostOrderStopMarket!v4PrivatePostOrderCollateralLimitv4PrivatePostOrderNew"v4PrivatePostOrderCollateralMarketv4PrivatePostOrderStockMarketparse_order)r   r   r   r  r   r   r   r   rF  r  r   
marketTypeisLimitOrderisMarketOrderr  isStopOrderr  
marginModequeryuseCollateralEndpointr  s                        r   create_orderzwhitebit.create_orderm  s       !!!!!!!!!V$$Tl..vv>>
 

 **69oNN ''jAAH#+3dkkmm+C('4GO$YYv'899F%%ff55
w(&&v/`/`/`aa	 ,$$]E6BB >>}fUU
E 	'"&GJ!jG&;&;tw)\\]]]5"K"K"KLL *$ 6 N*:N 	f*.*A*A&)*T*TG&' 	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 f#'#:#:65#I#I ( ^%)%K%KDKKX_agLhLh%i%iiiiiiiHH%)%?%?GU[@\@\%]%]]]]]]]HH ) f%)%L%LT[[Y`bhMiMi%j%jjjjjjjHH%)%G%GT[]cHdHd%e%eeeeeeeH)))r   r   c                 $  K   |t          | j        dz             |                                  d{V  |                     |          }|d         t	          |          d}|                     |                     ||                     d{V S )a  
        cancels an open order
        :see: 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v4PrivatePostOrderCancelrC  )r   r   r   r   r   rF  s         r   cancel_orderzwhitebit.cancel_order  s       >#DG.Y$YZZZ!!!!!!!!!V$$Tl2ww
 
 224;;w3O3OPPPPPPPPPr   c                 0   t          |                                          }i }t          dt          |                    D ]}||         }|                     |          }||         }t          |t                    rg|e|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d          |d<   |||<   |                                 }||d<   |||<   | 	                    |          S )Nr   	availablefreefreezeusedmain_balancetotal)
r	  r
  r  r  r   rx  dictr   r   safe_balance)	r   r  balanceKeysr  r  r   r  balancer   s	            r   parse_balancezwhitebit.parse_balance  s   8==??++q#k**++ 	' 	'AQB**2..DrlG'4(( 	'W-@,,.."&"2"27K"H"H"&"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
        :see: https://docs.whitebit.com/private/http-main-v4/#main-balance
        :see: 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>`
        Nr=   r2   r   r   r   r   )r  handle_market_type_and_params%v4PrivatePostCollateralAccountBalancer   r   r   ra  r  v4PrivatePostMainAccountBalance v4PrivatePostTradeAccountBalancer  )r   r   r  r  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                 h  K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|t	          |d          |d<   |                     |                     ||                     d{V }|                     ||||ddi          S )	a#  
        fetch all unfilled currently open orders
        :see: 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>`
        Nz- fetchOpenOrders() requires a symbol argumentr   r   d   ri  r  rS  )r   r   r  r   r   v4PrivatePostOrdersrC  parse_ordersrs  s           r   fetch_open_orderszwhitebit.fetch_open_orders  s       >#DG.]$]^^^!!!!!!!!!V$$fTl
 "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 )aI  
        fetches information on multiple closed orders made by the user
        :see: 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  ri  r   rv  r  closedrJ  )r  r   r   %v4PrivatePostTradeAccountOrderHistoryrC  r	  r
  r  r  r_  r  appendsort_byfilter_by_symbol_since_limit)r   r   ro  ri  r   rF  r   r  rf  r|  r  rg  r}  r   jr  s                   r   fetch_closed_orderszwhitebit.fetch_closed_orders5  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 )Nri  r   )ri  r   stop marketz
stop limitzstock marketzmargin limitzmargin marketr   )r   r   typess      r   parse_order_typezwhitebit.parse_order_typeg  s=    #!$#%
 
 tT222r   c           	         |                      |d          }|                     ||d          }|d         }|                      |d          }|                      |d          }|                      |d          }|                      |d          }|dk    rd }|                      |d	          }	|                     |d
          }
|                     |dd          }|                      |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   rv  r   r  	dealStockleftr   r   r  r  r   r   r   	dealMoneybuyr  dealFeer   r  ctimerJ  ftimer   rK  lastTradeTimestamptimeInForcer  r  r  r  filled)	remainingrX  r   r   trades)
r   r_  r   ra  r   r  rl  
safe_orderr  r  )r   r  r   rg  r   r  r  r  r  r   r  r  r   r   r   r  r   rJ  r  s                      r   r  zwhitebit.parse_orders  s   N ##E844!!(FC88!v..!!%55$$UF33	((@@B M  00$$U,>??	$$UIt<<v..!!%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 
 U 
 D))$// 
  
 I 
  f! 
" f# 
$ #- 
  
  
. /  	r   c                   K   |                                   d{V  dt          |          i}d}| |                     |          }|d         |d<   |t          |d          |d<   |                     |                     ||                     d{V }|                     |dg           }	|                     |	|          S )a0  
        fetch all the trades made from a single order
        :see: 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  ri  records)r  r  r   r   v4PrivatePostTradeAccountOrderrC  r  rr  )
r   r   r   ro  ri  r   rF  r   r  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   r  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
        :see: https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
        :see: 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  r  tagnetworkr   )r  r  is_fiatr   r   r   r   r   &v4PrivatePostMainAccountFiatDepositUrlrC  v4PrivatePostMainAccountAddresscheck_address)r   r  r   r  rF  r  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   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
        :see: 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%     z2 setLeverage() leverage should be between 1 and 20r   )r  r#   r   r   &v4PrivatePostCollateralAccountLeveragerC  )r   r   r   r   rF  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 )al  
        transfer currency internally between wallets on the same account
        :see: 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  r  r   r   r   currency_to_precision v4PrivatePostMainAccountTransferrC  parse_transfer)r   r  r   r  r  r   r  r   fromAccountIdtoAccountIdamountStringrF  r  s                r   rg   zwhitebit.transferT  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   rJ  rK  r  r   r  r  r  )r   )r   rg   r  s      r   r   zwhitebit.parse_transferq  s>    
 //h??

 

 
	
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
        :see: 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  r  r  r   uuid22r  r   r    v4PrivatePostMainAccountWithdrawrC  parse_transaction)r   r  r   r  r  r   r  rF  r  r
  r  s              r   rh   zwhitebit.withdraw  sR      !!!!!!!!!==&&tn00v>>
 

 ??6:66{{}}H&
?!GFO<< 	+vz::H'2k(klll"*GJ>>t{{7TZ?[?[\\\\\\\\ {{D(+T-C-CHh-W-WXXXr   c                 B   |                      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   r  methodr   r  txidtransactionHashrJ  rK  r  addressFrom1	addressTo2r   r   r  
withdrawalr  r  tagFromr  tagTocommentdescriptionr   r  )internalr   r   )safe_currencyr   rl  r  r   r   parse_transaction_status)r   transactionr  r  rJ  r2  r  r+  s           r   r(  zwhitebit.parse_transaction  s<   < %%dH55"";	::''[AA	%%k8<<
!!+x88!!+x88
$"";
;;
D$$[2CDD
 
 Y//	

 t''Y??
 v}}774
 w
 Vs]]
 d&&{H==
 &C--IIl
 //
HEE
 d33F;;
 t
 t
 4
  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/  pendingr1  3r  4canceled56791011121314151617r  )r   r  statusess      r   r9  z!whitebit.parse_transaction_status  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
        :see: 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   )transactionMethodr  ri  offsetr   r   r  )r  r  v4PrivatePostMainAccountHistoryrC  r   rD  r(  )	r   r   r  r   r  rF  r  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
        :see: 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   )rN  ri  rO  r   r   ri  r  )r  r  r   rP  rC  r  parse_transactions)	r   r  ro  ri  r   r  rF  r  r  s	            r   fetch_depositszwhitebit.fetch_deposits8  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 )au  
        fetch the interest owed by the user for borrowing currency for margin trading
        :see: 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   +v4PrivatePostCollateralAccountPositionsOpenrC  parse_borrow_interestsfilter_by_currency_since_limit)
r   r  r   ro  ri  r   rF  r   r  interests
             r   fetch_borrow_interestzwhitebit.fetch_borrow_interestw  s       !!!!!!!!![[((F &tGHII$++V]_eJfJfgggggggg, ..x@@228T5%PPPr   c           
         |                      |d          }|                     ||d          }|                     |d          }|dd|                     |d          d|                     |d          ||                     |          |d		S )
Nr   rv  
modifyDater  r   unrealizedFundinggXjP?r   )	r   r  r  rZ  interestRateamountBorrowedrJ  rK  r   )r   safe_symbolrl  r   r  )r   r   r   rg  r   rJ  s         r   parse_borrow_interestzwhitebit.parse_borrow_interest  s    ( ##D(33!!(FC88''l;;	!((/BCC#"..tX>>"Y//

 

 
	
r   c                    K   |                                   d{V  |                     |          }|                     |g|           d{V }|                     ||          S )at  
        :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
        fetch the current funding rate
        :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   r  s       r   fetch_funding_ratezwhitebit.fetch_funding_rate  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           }|                     |          }|                     |d|          S )a  
        :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
        fetch the funding rate for multiple markets
        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
        Nr  r   )r  rc  v4PublicGetFuturesr   parse_funding_ratesfilter_by_array)r   r   r   r  r  r  s         r   rd  zwhitebit.fetch_funding_rates  s       !!!!!!!!!%%g..0088888888Z x266))$//##FHg>>>r   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 S )N	ticker_id	markPrice
indexPricer_  funding_ratenext_funding_rate_timestampr   r   rJ  rK  fundingRatefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatepreviousFundingTimestamppreviousFundingDatetime)r   ra  r   r  r  )
r   r   r   rg  r   rl  rm  r_  rp  nextFundingTimes
             r   parse_funding_ratezwhitebit.parse_funding_rate  sw   B ##Hk::!!(F33$$X{;;	%%h==
''.AA&&x@@++H6STT
H
f
 
 *	

 L
 
 
 ;
 
 t||D11
 t
 #O
 "4<<#@#@
 "4
 '
  &t!
 	
r   c                 f    |                      | j        dg           }|                     ||          S )Nr   )r   r   r)  )r   r  r   s      r   r  zwhitebit.is_fiatG  s.    7GLL}}X~666r   c                 *    |                                  S N)milliseconds)r   s    r   noncezwhitebit.nonceK  s      """r   rx   GETc                 &   |                      ||                     |                    }|                     |d          }|                     |d          }	d|                     ||          z   }
| j        d         |         |	         |
z   }|	dk    r|r|d|                     |          z   z  }|	dk    r|                                  t          |                                           }| 	                    | j
                  }d|z   |
z   }|                     |                     ||d	|                    }|                     |          }|                     | 	                    |          |t          j                  }d
| j        ||d}||||dS )Nr   r%  r   r}   rx   ?ry   z/api/)rF  r  zapplication/json)zContent-TypezX-TXC-APIKEYzX-TXC-PAYLOADzX-TXC-SIGNATURE)r  r+  bodyheaders)r  extract_paramsr   implode_paramsr   	urlencodecheck_required_credentialsstrr  encodesecretjsonrC  string_to_base64hmachashlibsha512apiKey)r   pathr}   r+  r   r  r  r  r   accessibilitypathWithParamsr  r  r  rF  payload	signatures                    r   signzwhitebit.signN  s   		&$"5"5d";";<<//#q))Q//t224@@@iw'6GH$$ 3sT^^E2222I%%++---

%%E[[--F''1NBG99T[[Wu)M)MvVVWWD++D11G		$++g"6"6OOI 2 $!(#,	 G fdwOOOr   c
                 B   |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 uo|
d	k    }|s|| j        dz   |z   }|}|r|
}nu|                     |d
          }|]t          |                                          d         }|                     ||g           }t          |          }|dk    r|d         n|}| 
                    | j        d         ||           |                     | j        d         ||           t          |          d S )Ni  i  r$  i  z endpoint not foundr  messager  200errorsr   r   r   )r$   r   r  r   r   r  r   r	  r
  r  throw_exactly_matched_exceptionr   throw_broadly_matched_exception)r   r  reasonr  r+  r  r  r  requestHeadersrequestBodyr  r  codeNewhasErrorStatusfeedback	errorInfoerrorObjecterrorKeyerrorMessageArrayerrorMessageLengths                       r   handle_errorszwhitebit.handle_errorsg  s   CKKTS[[ 3T!:S!@6!IC!ORV!VWWW3;;#D		 9<Q QRRR %%h99F&&x;;G ''&99G#4/CFeON .!47S=4/#	! _ &II"&//(H"E"EK".#'(8(8(:(:#;#;A#>,0OOKSU,V,V)-01B-C-C*=ORS=S=S$5a$8$8Z^	44T_W5MyZbccc44T_W5MtU]^^^#H---tr   )NNr}  )H__name__
__module____qualname__r   r   r
   r   r   r   r  r  r  r   r"  r!  r   r@  r   rG  rE  r   rh  r	   r   rn  r   rt  r   r  r  r	  r  r  r  r  r   r   floatr   r  r  r   r  r  r   r  r  r  r  r  r  r  r   rg   r   r   rh   r   r(  r9  rR  rU  r[  rb  re  rd  rz  r  r  r  r  __classcell__)r   s   @r   r)   r)      si       } } } } }~ *, + +V + + + +BU
f U
 U
 U
 U
n -/ 6 6: 6 6 6 6p ?C2 3
 3
$s) 3
 3
 3
 3
j BFb 4A 4Aw 4A 4A 4A 4AlV# V# V# V#p /1 + +[ + + + +Z 68  1  1  1F  1  1  1  1D3 36 3V 3 3 3 3j 6:" G G7 G G G G G@ @DB %B %BS %B %BS\ %B %B %B %BN <@d[] A A AS A Abfglbm A A A A< 37TX\eg BR BRC BRs BRRU BR BR BR BRHL L L5 L L L L\ 8<$]ajl 'J 'J 'JC 'JWZ 'Jquvzq{ 'J 'J 'J 'JR
 
 
4 
 
 
 
* )+ 
 
 
 
, ') 3 3 3 3 mqy{ G* G* G*I G*Y G*X] G*fi G* G* G* G*R 9=R Q QS Q# Q Q Q Q&) ) ) ) )& *, -, -, -, -, -, -,^ 59tZ^gi (U (Uc (U (UTW (Unrsxny (U (U (U (UT 7;\`ik 0 0 03 0VY 0ptuzp{ 0 0 0 0d
3 
3 
3X X X5 X X X Xt ?CQUdhqs */ */3 */ */3 */^a */ */ */ */X =? C
 C
 C
 C
 C
 C
J ?C2 _ _3 _ _ _ _ _, ac 7 73 7 7C 7TW 7gt 7 7 7 7:
 
 
 
 
 
  EIQS $Y $Y3 $Y $Y $Y $Y $YL<
 <
x <
; <
 <
 <
 <
|: : :* 8<B <7 <7c <7 <7 <7 <7 <7| 04$UYbd =H =H =HC =Hs =Himnyiz =H =H =H =H~ 7;$]apt} (Q (Q (QC (QWZ (Qjm (Q (Q (Q (QT!
 !
& !
 !
 !
 !
F <> 1 1s 1 1 1 1 <@ 9? 9? 9? 9? 9? 9?v9
 9
6 9
 9
 9
 9
v7 7 7# # # &eBSW P P P P2      r   r)   ). ccxt.async_support.base.exchanger   ccxt.abstract.whitebitr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r    r!   r"   r#   r$   r%   ccxt.base.decimal_to_precisionr&   ccxt.base.preciser'   r)    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       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) + + + + + + 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %j! j! j! j! j!x j! j! j! j! j!r   