
    ei4B                        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(  G d dee          Z)dS )    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickers
OrderBooksTradeTradingFeesTransaction)List)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)OrderNotFound)OrderImmediatelyFillable)NetworkError)InvalidNonce)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee         fdZi fdefdZ	ddi fde
dedefdZdi fd	ededefd
Zi fd	edefdZdi fde
defdZdi fde
defdZdFdededefdZddi fd	edededee         fdZdFdede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dee         f
dZdFdedefdZde fdZ!i fde fdZ"di fded	e#fdZ$dddi fd	e#dededee%         fdZ&dddi fd	e#dededee%         fdZ'di fded	e#fd Z(dddi fd	e#dededee%         fd!Z)d"e#fd#Z*dFd$edede%fd%Z+di f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fd-Z3dFd.e4de5fd/Z6di fd0e
dee5         fd1Z7dddi fd2e#dededee8         fd3Z9di fded2e#fd4Z:dddi fd2e#dededee8         fd5Z;dFd6ed.e4de8fd7Z<di fd2ed(e.d8ed9e#de8f
d:Z=dFd.e4fd;Z>di fd0e
fd<Z?d=d>i ddfd?Z@d2eAd@edAedBedCedDefdEZB xZCS )Ghollaexreturnc                    |                      t          t          |                                           i ddddddgddd	d
dddi dd dddd ddddddddddddddddddddddddddddi d dd!dd"dd#dd$dd%dd&dd'dd(dd)d*d+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSddddddTdUdVdWdXdYdZd[d\d]d^d_d`daid`dbidcdddedfdgt          dhdddidjdki dldmdndmdodmdpdmdqdmdrdmdsdmdtdmdudmdvdmdwdmdxdmdydmdzdmd{dmd|dmd}dmidmdmdmdmdmdmdmdmd~dmdmddmdmdddddddd dddd dddddddddddddd dddddddddddddddddddddddddddddmdddddddid	d d dd d dddddddddidt
          t          t          t          t          dt          t          t          t          t          t          t          t          ddd|                     | j        dz            dddddddddd	dddddddd          S )Nidr%   nameHollaEx	countriesKR	rateLimit   versionv2proThasCORSspotmarginswapFfutureoption	addMargincancelAllOrderscancelOrdercreateLimitBuyOrdercreateLimitSellOrdercreateMarketBuyOrdercreateMarketSellOrdercreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMarginsandboxsetLeverage)setMarginModesetPositionModetransferwithdraw
timeframes1m5m15m1h4h1d1w)r}   r~   r   r   r   r   r   urlszchttps://user-images.githubusercontent.com/1294454/75841031-ca375180-5ddd-11ea-8417-b975674c23cb.jpgrestzhttps://api.sandbox.hollaex.comzhttps://api.hollaex.comzhttps://hollaex.comzhttps://apidocs.hollaex.comz6https://pro.hollaex.com/signup?affiliation_code=QSWA6G)logotestapiwwwdocreferralprecisionModerequiredCredentials)apiKeysecretr   gethealth   	constantskittierstickertickers	orderbook
orderbookstradeschartcharts
minichartszoracle/priceszquick-tradez
udf/configzudf/historyzudf/symbols)userzuser/balancezuser/depositszuser/withdrawalszuser/withdrawal/feezuser/tradesordersorder)zuser/withdrawalr   )z	order/allr   )r   postdelete)publicprivatefeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceicebergd   i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r     )	rv   r@   createOrdersr]   rb   ra   re   rI   r^   )linearinverse)r4   r6   r7   feestradinggMbP?)	tierBased
percentagetakermaker
exceptions)zAPI request is expiredzInvalid tokenzOrder not foundzInsufficient balancez]Error 1001 - Order rejected. Order could not be submitted order was set to a post only order.)400403404405410429500503)broadexactoptionsbtcethtrxxrpxlmbnbmatic)	BTCETHERC20TRXTRC20XRPXLMBNBMATICr   r   )r   r   r   r   r   r   )api-expiresnetworksnetworksById)deep_extendsuperr%   describer"   r!   r   r   r   r   r   r    parse_to_inttimeout)self	__class__s    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/hollaex.pyr   zhollaex.describe   s   gt 4 4 = = ? ? XB
)XB
IXB
 $XB

 XB
 tXB
 4XB
  III $I 	I
 %I %I UI "4I tI &tI 'I 'I (I tI &tI  (!I" '#I I$ (%I& "4'I( )I* +E+I, )%-I. $T/I0 '1I2 (3I4 "45I6 &z7I8 (9I: 1%;I<  =I> &u?I@ #EAIB *5CID $UEI I IF "5GIH *5IIJ +EKIL  MIN "5OIP QIR !%SIT  UIV dWIX +EYIZ !$[I\ "4]I^ d_I` !$aIb "4cId teIf  gI I Ih $UiIj !%kIl %emIn )%oIp tqIr sIt tuIv "5wIx #DyIz $U{I|  }I~ !%I@ "4AIB #DCID EIF 4GIH uII IJ "'#(! QI I IXB
d  eXB
v }= 5 -4T wXB
N YOXB
P "$ $QXB
X   !#Q q  	
 !! "1 $Q %a !!   !! %a ( &q  %a!" &q#$ &q%0 !"())*,-/0'("#!"	 	 ,-!" 
 &'!"  /+ +YXB
p #&+(,,0,1).+06:#(#("&#(	( ( #(/4$)$)+027#()$ $, %)&+!$$*%+*/& & ',#($)*/	# # ',!$#($)*/( ( ',!$$*%+#($)*/$ $ ',!$$*,-%+#($)*/	* 	*  #AC CJ ## 
 ## SM MqXB
L !%"&""	 MXB
\ .:%8'4,= vN  &.%%%%''	 	 ]XB
B #001DEE  " "   $
 
 #"$""$! ! CXB
 X X X	    c                 h   |                      |          }|                     |di           }t          |                                          }g }t	          dt          |                    D ]}||         }||         }|                     |d          }	|                     |d          }
|                     |	                                          }|                     |
                                          }|	                    i d|                     |d          d|dz   |z   d	|d
|ddd|	d|
ddddddddddddddd|                     |d          dddddddddd| 
                    |d          | 
                    |d          dddd| 
                    |d          | 
                    |d           d| 
                    |d!          | 
                    |d"          ddddd#|                     |                     |d$                    |d%
           |S )&a  
        retrieves data on all markets for hollaex

        https://apidocs.hollaex.com/#constants

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        pairsr   	pair_basepair_2r(   r)   symbol/basequotesettleNbaseIdquoteIdsettleIdtyper4   Tr5   Fr6   r7   r8   activecontractr   increment_sizeincrement_price)amountpriceminmaxmin_sizemax_size	min_price	max_price)r   r  r  cost
created_at)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)publicGetConstants
safe_valuelistkeysrangelensafe_stringcommon_currency_codeupperappendsafe_number	parse8601)r   paramsresponser   r  resultikeymarketr   r   r   r   s                r   fetch_marketszhollaex.fetch_markets4  s    **622Z '266EJJLL!!q#d))$$ 7	 7	Aq'C3ZF%%fk::F&&vx88G,,V\\^^<<D--gmmoo>>EMM 0d&&vv660$*u,0 0 	0
 $0 &0 70 D0 0 0 %0 0 %0 %0 $//&(;;0  E!0" $#0$   $"&""..v7GHH!--f6GHH   $#! !
  $//
CC#//
CC 
  $//DD#//DD 
  $#  $  >>$*:*:6<*P*PQQ_0 0 0 0 0 0 0b r   c                 L   |                      |          }|                     |di           }t          |                                          }i }t	          dt          |                    D ]5}||         }||         }|                     |d          }	|                     |	          }
|                     |dg           }|                     |d          }|dk    rdnd}|                     |d	i           }i }t          |                                          }t	          dt          |                    D ]q}||         }|                     ||          }| 	                    |          }||| 
                    |d
          dd|                     |d          dddddi|d	||<   r|                     |	|                     |d          |
||                     |d          | 
                    |d
          | 
                    |d          | 
                    |d          |                     |d          |                     |d          |                     |d          |                     |d          dd|                     |d          dd||d          ||
<   7|S )a  
        fetches all available currencies on an exchange

        https://apidocs.hollaex.com/#constants

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        coinsr   r   withdrawal_limitsr   
blockchaincryptootherwithdrawal_feesr   Nvaluer{   r  )	r(   networkr   depositr{   feer  r  r  r(   fullnameallow_depositallow_withdrawalwithdrawal_feeincrement_unitr  r  )r  r{   )r(   	numericIdcoder  r)   r   r3  r{   r4  r  r  r   r   )r  	safe_dictr  r  r  r  r  safe_currency_code	safe_listnetwork_id_to_code	safe_boolr!  safe_currency_structuresafe_integerr  )r   r#  r$  r+  r  r%  r&  r'  currencyr(   r;  withdrawalLimitsrawTyper   rawNetworksr   
networkIdsj	networkIdnetworkEntrynetworkCodes                        r   fetch_currencieszhollaex.fetch_currencies  s    **622F x"55EJJLL!!q#d))$$ 6	 6	Aq'CSzH!!(H55B**2..D#~~h8KRPP&&x88G '< 7 788gD..3DbIIKHk..0011J1c*oo..  &qM	#~~k9EE"55i@@#*"nn\8DD# $++L'BB!%"#'#'% % )) )%%   77!..x>> ((:>>..8<<>>(ODD NN85GHH''2BCC!--h8HII  $//%@@#//%@@ 
  $#/?CC! !	 	 %-9 9  F4LL0 r   Nsymbolsr   c                    |                                   |                     |          }i }t          |                                          }t	          dt          |                    D ]r}||         }||         }	|                     |dd          }
|                     |                     |	d                    }| 	                    ||         |
|          ||
<   s|S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data for multiple markets

        https://apidocs.hollaex.com/#orderbooks

        :param str[]|None symbols: not used by hollaex fetchOrderBooks()
        :param int [limit]: not used by hollaex fetchOrderBooks()
        :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 symbol
        r   N-	timestamp)
load_marketspublicGetOrderbooksr  r  r  r  safe_symbolr"  r  parse_order_book)r   rM  r   r#  r$  r%  	marketIdsr&  marketIdr   r   rP  s               r   fetch_order_bookszhollaex.fetch_order_books/  s     	++F33))	q#i..)) 	Z 	ZA |H *I%%hc::Ft'7'7	;'O'OPPI!228H3EvyYYF6NNr   r   c                 ~   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||d                   }|                     |                     |d                    }|                     ||d         |          S )a"  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://apidocs.hollaex.com/#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
        r   r(   rP  )rQ  r(  publicGetOrderbookextendr  r"  r  rT  )	r   r   r   r#  r(  requestr$  r   rP  s	            r   fetch_order_bookzhollaex.fetch_order_bookF  s     	V$$fTl
 **4;;w+G+GHH( OOHfTl;;	NN4#3#3I{#K#KLL	$$Yx0@)LLLr   c                     |                                   |                     |          }d|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://apidocs.hollaex.com/#ticker

        :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>`
        r   r(   )rQ  r(  publicGetTickerrZ  parse_ticker)r   r   r#  r(  r[  r$  s         r   fetch_tickerzhollaex.fetch_tickern  sr     	V$$fTl
 ''GV(D(DEE   6222r   c                     |                                   |                     |          }|                     |          }|                     ||          S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://apidocs.hollaex.com/#tickers

        :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>`
        )rQ  market_symbolspublicGetTickersparse_tickers)r   rM  r#  r$  s       r   fetch_tickerszhollaex.fetch_tickers  sT     	%%g..((00  !!(G444r   c                    i }t          |                                          }t          dt          |                    D ]u}||         }||         }|                     |d|          }	|                     |	d d          }
|
d         }|                     |                     ||
          |          ||<   v|                     |d|          S )Nr   r   rO  )	r  r  r  r  r  safe_marketrZ  r_  filter_by_array_tickers)r   r   rM  r#  r%  r  r&  r'  r   rV  r(  r   s               r   rd  zhollaex.parse_tickers  s    GLLNN##q#d))$$ 	T 	TAq'CS\F''#>>H%%hc::FH%F![[):):66)J)JFSSF6NN++FHgFFFr   r   r(  c           	      z   |                      |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|          S )Nr   rO  timerP  closer  datetimehighlowbid	bidVolumeask	askVolumevwapopenlastpreviousClosechanger   volume)average
baseVolumequoteVolume)r  rg  r"  safe_string_2safe_tickeriso8601)r   r   r(  rV  r   rP  rk  s          r   r_  zhollaex.parse_ticker  s   6 ##FH55!!(FC88!NN4#5#5ffk#R#RSS	  11 !
f!
F!
 !
 Y//	!

 D$$VV44!
 4##FE22!
 4!
 !
 4!
 !
 D!
 D$$VV44!
 U!
 D$$VVU;;!
 T!
  d!!
" $#!
$ **68<<)!
 !
 !
* +  	r   sincec                 $   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||d         g           }|                     ||||          S )a	  
        get the list of most recent trades for a particular symbol

        https://apidocs.hollaex.com/#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>`
        r   r(   )rQ  r(  publicGetTradesrZ  r>  parse_trades)	r   r   r  r   r#  r(  r[  r$  r   s	            r   fetch_tradeszhollaex.fetch_trades  s     	V$$fTl
 ''GV(D(DEE &,;;  >>>r   tradec                 J   |                      |d          }|                     ||d          }|d         }|                      |d          }|                     |          }|                      |d          }|                      |d          }|                      |d          }	|                      |d          }
|                      |d          }|                      |d	          }d }|||                     |          d
}|                     |d ||||d |d |	|
d |d|          S )Nr   rO  rP  sideorder_idr  sizer4  fee_coin)r  rC  )r  r(   rP  rl  r   r   r   r  takerOrMakerr  r  r  r4  )r  rg  r"  r=  
safe_trade)r   r  r(  rV  r   rl  rP  r  orderIdpriceStringamountStringfeeCostStringfeeCoinr4  s                 r   parse_tradezhollaex.parse_trade  sW   . ##E844!!(FC88!##E;77NN8,,	v..""5*55&&ug66''v66((66""5*55$% 33G<< C "   " 
  
   	r   c           
         |                                   |                     |          }|                     |di           }|                     |di           }|                     |di           }|                     |di           }i }t          dt	          | j                            D ]}| j        |         }	|                     |	          }
|                     ||
d                   }|                     ||
d                   }||	|                     t          j
        |d                    |                     t          j
        |d                    ddd	||	<   |S )
a;  
        fetch the trading fees for multiple markets

        https://apidocs.hollaex.com/#tiers

        :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
        1r   r   r   r   r(   100T)r  r   r   r   r   r   )rQ  publicGetTiersr  r  r  rM  r(  r  parse_numberr#   
string_div)r   r#  r$  	firstTierr   	makerFees	takerFeesr%  r&  r   r(  makerStringtakerStrings                r   fetch_trading_feeszhollaex.fetch_trading_feesF  sV    	&&v..: OOHc266	y&"55OOD'266	OOD'266	q#dl++,, 	 	A\!_F[[((F**9fTlCCK**9fTlCCK **7+=k5+Q+QRR**7+=k5+Q+QRR"! F6NN r   r}   	timeframec           	         |                                   |                     |          }|d         |                     | j        ||          d}d}d}	|                     |dd|          \  }}|r|                     d||||||	          S |                     |d          }
|                     |          |	z  dz  }|}|                                 }|

||}
|
|z
  }n|
|}
n||
|z
  }| 	                    |dz            |d
<   | 	                    |
dz            |d<   | 
                    |d          }|                     |                     ||                    }|                     |||||          S )a  
        hollaex has large gaps between candles, so it's recommended to specify since

        https://apidocs.hollaex.com/#chart

        :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(max 500)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r(   )r   
resolutionFi  r^   paginateuntilr   Nfromto)rQ  r(  r  r|   handle_option_and_params"fetch_paginated_call_deterministicrB  parse_timeframemillisecondsr   omitpublicGetChartrZ  parse_ohlcvs)r   r   r  r  r   r#  r(  r[  r  maxLimitr  	timeDeltastartnowr$  s                  r   fetch_ohlcvzhollaex.fetch_ohlcv  s    	V$$Tl**4?IyQQ
 
 88z[cdd& 	|::<QVX]_hjprz{{{!!&'22((33h>E	!!=U]EI%EE]EE]I%E++EDL99))%$,7767++&&t{{7F'C'CDD   69eUKKKr   c           	      (   |                      |                     |d                    |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nrj  rt  rm  rn  rk  rx  )r"  r  r!  )r   ohlcvr(  s      r   parse_ohlcvzhollaex.parse_ohlcv  s     NN4++E6::;;UF++UF++UE**UG,,UH--
 	
r   c                    |                      |                     |d                    }|||                     |          d}t          | j                                                  }t          dt          |                    D ]p}||         }|                     |          }| 	                                }|                     ||dz             |d<   |                     ||dz             |d<   |||<   q| 
                    |          S )N
updated_at)r  rP  rl  r   
_availablefree_balancetotal)r"  r  r~  r  currencies_by_idr  r  r  r=  accountsafe_balance)	r   r$  rP  r%  currencyIdsr&  
currencyIdr;  r  s	            r   parse_balancezhollaex.parse_balance  s   NN4#3#3Hl#K#KLL	"Y//
 

 40557788q#k**++ 	# 	#A$QJ**:66DllnnG"..xl9RSSGFO#//*z:QRRGG"F4LL  (((r   c                 ~    |                                   |                     |          }|                     |          S )aR  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://apidocs.hollaex.com/#get-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        )rQ  privateGetUserBalancer  )r   r#  r$  s      r   fetch_balancezhollaex.fetch_balance  s?     	--f55 !!(+++r   r(   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )an  
        fetch an open order by it's id

        https://apidocs.hollaex.com/#get-order

        :param str id: order id
        :param str symbol: not used by hollaex fetchOpenOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r  )rQ  privateGetOrderrZ  parse_orderr   r(   r   r#  r[  r$  s         r   fetch_open_orderzhollaex.fetch_open_order  s[     	
 ''GV(D(DEE2 )))r   c           	      b    ddi}|                      ||||                     ||                    S )a  
        fetch all unfilled currently open orders

        https://apidocs.hollaex.com/#get-all-orders

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        rt  Tfetch_ordersrZ  r   r   r  r   r#  r[  s         r   fetch_open_orderszhollaex.fetch_open_orders!  s:     D
   t{{7F7S7STTTr   c           	      b    ddi}|                      ||||                     ||                    S )a(  
        fetches information on multiple closed orders made by the user

        https://apidocs.hollaex.com/#get-all-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>`
        rt  Fr  r  s         r   fetch_closed_orderszhollaex.fetch_closed_orders2  s:     E
   t{{7F7S7STTTr   c                     |                                   d|i}|                     |                     ||                    }|}|t          | j        dz   |z             |                     |          S )a  
        fetches information on an order made by the user

        https://apidocs.hollaex.com/#get-order

        :param str 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>`
        r  Nz& fetchOrder() could not find order id )rQ  r  rZ  r   r(   r  )r   r(   r   r#  r[  r$  r   s          r   fetch_orderzhollaex.fetch_orderC  s     	
 ''GV(D(DEE. =*R RUW WXXX&&&r   c                 h   |                                   d}i }| |                     |          }|d         |d<   ||                     |          |d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )a!  
        fetches information on multiple orders made by the user

        https://apidocs.hollaex.com/#get-all-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   
start_dater   data)rQ  r(  r~  privateGetOrdersrZ  r>  parse_orders)	r   r   r  r   r#  r(  r[  r$  r  s	            r   r  zhollaex.fetch_ordersn  s     	
 [[((F &tGH$(LL$7$7GL!$GG((Wf)E)EFF< ~~h33  vue<<<r   statusc                 >    ddddd}|                      |||          S )Nrt  closedcanceled)newpfilledfilledr  )r  )r   r  statusess      r   parse_order_statuszhollaex.parse_order_status  s4    "	
 
 &&999r   r   c                 R   |                      |d          }|                     ||d          }|                      |d          }|                     |                      |d                    }|                      |d          }|                      |d          }|                      |d          }	|                      |d          }
|                      |d	          }|                     |                      |d
                    }|                     |di           }|                     |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|          S )Nr   rO  r(   r  r   r  r  r  r  r  meta	post_onlyFclientOrderIdrP  rl  lastTradeTimestampr   postOnlyr   stopr  	remainingr  )r   r4  r  ry  )r  rS  r"  r  r  r@  
safe_orderr~  )r   r   r(  rV  r   r(   rP  r   r  r  r  r  r  r  r  s                  r   r  zhollaex.parse_order  s=   : ##E844!!(FC88eT**NN4#3#3E<#H#HII	v..v..  00!!%00!!%22(()9)9%)J)JKKufb11>>$U;;  
" 
T 
  
 Y//	 

 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
 D,,UF;; 
 f 
 f 
  ! 
" D# 
$ + 
  
  
, -  	r   r   r  r  r  c                    |                                   |                     |          }|d         ||                     ||          |d}|                     |g d          }	|                     |di           }
|                     |
dd          }|dk    }|                     |||          }|s|                     ||          |d<   |	|                     ||	          |d
<   |rddi|d<   |                     |g d          }| 	                    | 
                    ||                    }|                     ||          S )am  
        create a trade order

        https://apidocs.hollaex.com/#create-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.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
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r(   )r   r  r  r   )r   	stopPricer  r  r  Fr(  r  Nr  T)r  r   r  r   r  )rQ  r(  amount_to_precisionsafe_number_nr  r@  is_post_onlyprice_to_precisionr  privatePostOrderrZ  r  )r   r   r   r  r  r  r#  r(  r[  r   r  exchangeSpecificParamisMarketOrderr  r$  s                  r   create_orderzhollaex.create_order  si     	V$$Tl,,VV<<	
 
 ))&2W2W2WXXvvr22 $t[% H H($$]4I6RR 	F#66vuEEGG#"55flKKGFO 	2*D1GFO6#c#c#cdd((Wf)E)EFF0 &111r   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )av  
        cancels an open order

        https://apidocs.hollaex.com/#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>`
        r  )rQ  privateDeleteOrderrZ  r  r  s         r   cancel_orderzhollaex.cancel_order:  s[     	
 **4;;w+G+GHH )))r   c                 "   |t          | j        dz             |                                  i }d}|                     |          }|d         |d<   |                     |                     ||                    }|                     ||          S )aw  
        cancel all open orders in a market

        https://apidocs.hollaex.com/#cancel-all-orders

        :param str symbol: unified market symbol of the market to cancel orders in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nz- cancelAllOrders() requires a symbol argumentr(   r   )r   r(   rQ  r(  privateDeleteOrderAllrZ  r  )r   r   r#  r[  r(  r$  s         r   cancel_all_orderszhollaex.cancel_all_ordersY  s     >#DG.]$]^^^V$$"4L--dkk'6.J.JKK    6222r   c                 h   |                                   i }d}| |                     |          }|d         |d<   |||d<   ||                     |          |d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        fetch all trades made by the user

        https://apidocs.hollaex.com/#get-trades

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nr(   r   r   r  r  )rQ  r(  r~  privateGetUserTradesrZ  r>  r  )	r   r   r  r   r#  r[  r(  r$  r  s	            r   fetch_my_tradeszhollaex.fetch_my_trades|  s     	
 [[((F &tGH$GG$(LL$7$7GL!,,T[[&-I-IJJ  ~~h33  vue<<<r   rC  c                    |                      |d          }d }|A|                    d          }|                      |d          }|                      |d          }|                     |           |                      |d          }|                     ||          }|                      |d          }||d         |||dS )	Naddress:r   r   rC  r2  r;  )r  rC  r2  r  tag)r  splitcheck_addresssafe_currency)r   depositAddressrC  r  r  partsr  r2  s           r   parse_deposit_addresszhollaex.parse_deposit_address  s     "">9==MM#&&E&&ua00G""5!,,C7###%%njAA
%%j(;;"">9==" (
 
 	
r   codesc                 <   |                                   |                     |d          }|                     |d          }|                     |          }|                     |dg           }||n|                     |d|          }|                     ||          S )a  
        fetch deposit addresses for multiple currencies and chain types

        https://apidocs.hollaex.com/#get-user

        :param str[]|None codes: list of unified currency codes, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/?id=address-structure>`
        r2  wallet)rQ  r  r  privateGetUserr  	filter_byparse_deposit_addresses)r   r  r#  r2  r$  r  	addressess          r   fetch_deposit_addresseszhollaex.fetch_deposit_addresses  s     	""695569--&&v..\ 8R88&FFT^^FIW^5_5_	++Iu===r   r;  c                 h   |                                   i }d}| |                     |          }|d         |d<   |||d<   ||                     |          |d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        fetch all deposits made to an account

        https://apidocs.hollaex.com/#get-deposits

        :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(   rC  r   r  r  )rQ  rC  r~  privateGetUserDepositsrZ  r>  parse_transactions	r   r;  r  r   r#  r[  rC  r$  r  s	            r   fetch_depositszhollaex.fetch_deposits	  s     	
 }}T**H"*4.GJ$GG$(LL$7$7GL!..t{{7F/K/KLL0 ~~h33&&tXueDDDr   c                 T   |                                   d|i}d}| |                     |          }|d         |d<   |                     |                     ||                    }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch data on a currency withdrawal via the withdrawal id

        https://apidocs.hollaex.com/#get-withdrawals

        :param str id: withdrawal id
        :param str code: unified currency code of the currency withdrawn, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        transaction_idNr(   rC  r  r   )rQ  rC  privateGetUserWithdrawalsrZ  r  r<  parse_transaction)	r   r(   r;  r#  r[  rC  r$  r  transactions	            r   fetch_withdrawalzhollaex.fetch_withdrawalB  s     	b
 }}T**H"*4.GJ11$++gv2N2NOO0 x44nnT1b11%%k8<<<r   c                 h   |                                   i }d}| |                     |          }|d         |d<   |||d<   ||                     |          |d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        fetch all withdrawals made from an account

        https://apidocs.hollaex.com/#get-withdrawals

        :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
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/?id=transaction-structure>`
        Nr(   rC  r   r  r  )rQ  rC  r~  r  rZ  r>  r  r  s	            r   fetch_withdrawalszhollaex.fetch_withdrawalsq  s     	
 }}T**H"*4.GJ$GG$(LL$7$7GL!11$++gv2N2NOO0 ~~h33&&tXueDDDr   r  c                    |                      |d          }|                      |d          }|                     |                      |d                    }|                     |                      |d                    }|                      |d          }|                     |d          }|                      |d          }	d }
d }d }d }d }|	E|	                    d          }|                      |d	          }	|                      |d
          }|	}
|}|                      |d          }|                     ||          }|                     |d          }|                     |d          }|                     |d          }|rd}n|rd}n|rd}n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#S )$Nr(   r  r  r  r   r  r  r  r   r   rC  r  	dismissedrejectedokr  failedpendingr  r4  )rC  r  r  txidrP  rl  r2  addressFrom	addressTotagFromr  tagTor;  updatedmessage)commentinternalr4  )r  r"  r!  r  r  r  r=  r~  )r   r  rC  r(   r   rP  r%  r   r  r  r"  r!  r  r$  r#  r  r  r  r  r  feeCurrencyIdfeeCurrencyCodefeeCostr4  s                           r   r  zhollaex.parse_transaction  s   @ k400-=>>NN4#3#3K#N#NOO	..!1!1+|!L!LMMV44!!+x88"";	::	MM#&&E&&ua00G""5!,,CIE%%k:>>
%%j(;;h77OOK==	??;
;; 	FF 	FF 	FFF((jAA11-JJ"";66+ C
K
"
 D
 	

 Y//
 t
 ;
 w
 
 w
 3
 U
 D
 f
 (
  f!
" w#
$ ''Y??)
 
 
 	
r   r  r  c                    |                      ||          \  }}|                     |           |                                  |                     |          }||d|z   z  }|                     |d          }|t          | j        dz             |                     |d          }|d         |||                     ||          d}| 	                    | 
                    ||                    }	|                     |	|          S )a  
        make a withdrawal

        https://apidocs.hollaex.com/#withdrawal

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr  r2  z( withdraw() requires a network parameterr(   )rC  r  r  r2  )handle_withdraw_tag_and_paramsr   rQ  rC  r  r   r(   r  network_code_to_idprivatePostUserWithdrawalrZ  r  )
r   r;  r  r  r  r#  rC  r2  r[  r$  s
             r   r{   zhollaex.withdraw	  s    99#vFFV7###==&&?sSy G""6955?#DG.X$XYYY69-- ..w==	
 
 11$++gv2N2NOO %%h999r   c                 P   |d d dd d di d}|                      |d          }|r|                     |d          dd|d<   |                      |d          }|t          |                                          }t	          |          }t          d|          D ]}||         }	||	         }
|                     |
d	          }|                     |          }|                     |	|          }|	                                }|                     |
d
          }d |d|d         |<   |S )N)r4  r   )r  r{   r3  r   r7  r8  Fr{   r0  r   r   r1  )r3  r{   r   )
r  r!  r  r  r  r  r  r=  r?  r  )r   r4  rC  r%  allowWithdrawalwithdrawalFeesr  
keysLengthr&  r'  r1  r  currencyCoderK  networkCodeUpperwithdrawalFees                   r   parse_deposit_withdraw_feez"hollaex.parse_deposit_withdraw_fee3  ss   @ " 
 "  
 
 //#/ABB 	g)-)9)9#?O)P)P`e!f!fF:.?@@%++--..DTJ1j))  1g&s+!--eX>>
#66zBB"55c<HH#.#4#4#6#6  $ 0 0 @ @# -8 8z"#344 r   c                     |                      |          }|                     |di           }|                     ||d          S )aS  
        fetch deposit and withdraw fees

        https://apidocs.hollaex.com/#constants

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `fee structures <https://docs.ccxt.com/?id=fee-structure>`
        r+  r   )r  r<  parse_deposit_withdraw_fees)r   r  r#  r$  r+  s        r   fetch_deposit_withdraw_feesz#hollaex.fetch_deposit_withdraw_feess  sG     **622H x"55//uhGGGr   r   GETc           	      P   |                      ||                     |                    }d| j        z   dz   |                     ||          z   }|dk    s|dk    r|r|d|                     |          z   z  }| j        d         d         |z   }|dk    r|                                  |                     | j        dd	| 	                    | j
        d
z                      }	|                     |                                 |	          }
t          |
          }||z   |z   }| j        |d}|dk    r!d|d<   |r|                     |          }||z  }|                     |                     |          |                     | j                  t&          j                  }||d<   ||||dS )Nr   r;  DELETE?r   r   r   r   expiresr   )zapi-keyr   POSTzapplication/jsonzContent-typezapi-signature)urlmethodbodyheaders)r  extract_paramsr/   implode_params	urlencoder   check_required_credentialssafe_integer_2r   r   r   sumsecondsstrr   jsonhmacencoder   hashlibsha256)r   pathr   rB  r#  rD  rC  queryrA  defaultExpiresr?  expiresStringauth	signatures                 r   signzhollaex.sign  s   		&$"5"5d";";<<T\!C'$*=*=dF*K*KKeOO8!3!3 4dnnU3333iv&-)++---!00}iY]YjYjkokwz~k~YY  A  ANhht||~~~>>GLLMD==0D;, G *<' !99U++DDLD		$++d"3"3T[[5M5Mw~^^I'0GO$fdwOOOr   reasonrA  rB  rD  rC  c
                    |d S |dk    r||dk    rv| j         dz   |z   }
|                     |d          }|                     | j        d         ||
           t	          |          }|                     | j        d         ||
           d S )Ni  i   r&  r   r   )r(   r  throw_broadly_matched_exceptionr   rL  throw_exactly_matched_exception)r   r;  rY  rA  rB  rD  rC  r$  requestHeadersrequestBodyfeedbackr&  r  s                r   handle_errorszhollaex.handle_errors  s    4CKKdckk w}t+H&&x;;G001I7T\]]]YYF001I6S[\\\tr   )N)D__name__
__module____qualname__r   r   r   r   r)  r   rL  r   r
   r   rW  rL  r   r\  r   r`  r   re  rd  dictr_  r   r  r  r   r  r  r  r  r   r  r  r   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{   r7  r:  rX  intra  __classcell__)r   s   @r   r%   r%      s       Y# Y Y Y Y Y Yv $& q q$v, q q q qf ') F FZ F F F FP 48dSU    Zd    . :>b &M &Ms &M3 &MY &M &M &M &MP 02 3 33 3f 3 3 3 3: 04B 5 5W 57 5 5 5 5< 9=R 
G 
Gg 
GG 
G 
G 
G 
G5 54 5 56 5 5 5 5n 6:UW  ?  ?3  ?s  ?#  ?\`af\g  ?  ?  ?  ?D6 6 6v 6 6 6 6 6p )+ 9 9{ 9 9 9 9v 9=4^bkm 5L 5L# 5L# 5LS 5LX[ 5Lrvw{r| 5L 5L 5L 5Ln
 
 
4 
 
 
 
*) ) ) ) )" $& , ,( , , , ,2 7;2 (* (*3 (* (* (* (* (*T /3TXac U U U3 Uc Uhlmrhs U U U U" 154VZce U U# US UPS Ujnotju U U U U" 26b )' )'c )'3 )' )' )' )'V *.Dt\^ @= @=3 @=c @= @=cghmcn @= @= @= @=D: : : : :? ? ?v ? ? ? ? ?B gksu >2 >23 >2i >2y >2RW >2`c >2 >2 >2 >2@ 37r * *s *C * * * *> /32 !3 !3 !3 !3 !3 !3F -1tRV_a /= /=c /= /=C /= /= /= /=b
 
h 
R` 
 
 
 
: 8<B => =>W =>4P^K_ => => => =>~ *.Dt\^ 7E 7E3 7Ec 7E 7Ecghsct 7E 7E 7E 7Er 59 -= -=3 -=c -= -= -= -=^ -1tRV_a 7E 7Ec 7E 7EC 7Efjkvfw 7E 7E 7E 7Er]
 ]
T ]
X ]
Q\ ]
 ]
 ]
 ]
~ KOWY (: (:S (:% (:# (:C (:^i (: (: (: (:T> > > > > >@ <@ /H /H /H /H /H /Hb &eBSW P P P P4# s  c TX `c        r   r%   )*ccxt.base.exchanger   ccxt.abstract.hollaexr   rP  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!   ccxt.base.decimal_to_precisionr"   ccxt.base.preciser#   r%    r   r   <module>rq     sB   ( ' ' ' ' ' - - - - - -  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 . . . . . . ' ' ' ' ' ' . . . . . . * * * * * * 5 5 5 5 5 5 ) ) ) ) ) ) ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %z z z z zh z z z z zr   