
    iu(                       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 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
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeesTransaction)List)AuthenticationError)ArgumentsRequired)
BadRequest)InsufficientFunds)OrderNotFound)OrderImmediatelyFillable)NetworkError)	TICK_SIZE)Precisec                       e Zd Z 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
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	fdZd: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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e         fdZd:d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 Z'd:dede"fd Z(di fd	ed!e)d"e*d#e+d$e,f
d%Z-di fded	e fd&Z.di fd	e fd'Z/dddi fd	e de
de
fd(Z0d:d)e1fd*Z2di fd+ee         fd,Z3dddi fd-e de
de
dee4         fd.Z5di fded-e fd/Z6dddi fd-e de
de
dee4         fd0Z7d:d)e1de4fd1Z8di fd-ed#e+fd2Z9d:d)e1fd3Z:di fd+e	fd4Z;d5 Z<d6d7i ddfd8Z=d9 Z> xZ?S );hollaexc                    |                      t          t          |                                           dddg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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i d<dd=dd>dd?dd@ddAddBddCddDddEddFddGddHddIddJddKddLddddMdNdOdPdQdRdSdTdUdVdWdXidWdYidZd[d\d]t          ddd^d_i d`dadbdadcdadddadedadfdadgdadhdadidadjdadkdadldadmdadndadodadpdadqdaidadadadadadadadadrdadadsdadadtdudvdwdddxdxdyit
          t          t          t          dzt          t
          t          t          t          t          t          t          d{d||                     | j        d}z            d~ddddddddd	dd          S )Nr!   HollaExKR   v2T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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setLeveragesetMarginModesetPositionMode)transferwithdraw1m5m15m1h4h1d1w)rn   ro   rp   rq   rr   rs   rt   zchttps://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)apiKeysecret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tradinggMbP?)	tierBased
percentagetakermaker)z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  btcethtrxxrpxlmbnbmatic)	BTCETHERC20TRXTRC20XRPXLMBNBMATIC)api-expiresnetworks)idname	countries	rateLimitversionprohas
timeframesurlsprecisionModerequiredCredentialsrx   fees
exceptionsoptions)deep_extendsuperr!   describer   r   r   r   r   r   r   parse_to_inttimeout)self	__class__s    R/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/hollaex.pyr   zhollaex.describe   s   gt 4 4 = = ? ?GGG $G 	G
 %G %G UG "4G tG &tG 'G 'G (G tG &tG  (!G" '#G G$ (%G& "4'G( )G* +E+G, )%-G. $T/G0 '1G2 (3G4 "45G6 &z7G8 (9G:  ;G< &u=G> #E?G@ *5AGB $UCGD "5EG G GF *5GGH +EIGJ  KGL "5MGN OGP !%QGR  SGT dUGV +EWGX !$YGZ "4[G\ d]G^ !$_G` "4aGb tcGd  eGf $UgG G Gh !%iGj %ekGl )%mGn toGp qGr tsGt "5uGv #DwGx $UyGz  {G| !%}G~ "4G@ #DAGB CGD uEGF  GGH "5IG GJ " MG G GR   ~= 5 -4T  '$ $   !#Q q  	
 !! "1 $Q %a !!   !! %a ( &q  %a!" &q#$ &q%0 !"())*,-/0'("#!"	 	 ,-!" 
 &'!"  /+ +Z !%"&""	  &9'4,= vN	  &.%%%%''	 	 (  $001DEE  " "   $
 
 aB
 B
   	    returnc                 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
        :see: 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typer(   Tr)   Fr*   r+   r,   activecontractlinearincrement_sizeincrement_price)amountpriceminmaxmin_sizemax_size	min_price	max_price)leverager   r   cost
created_at)
inverse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_markets   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                 v   |                      |          }|                     |di           }t          |                                          }i }t	          dt          |                    D ]J}||         }||         }|                     |d          }	|                     |d          }
|                     |	          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|o|o|}| 	                    |d	          }|                     |d
g           }|	|
|||||||| 	                    |d          | 	                    |d          | 	                    |d          dd|                     |d          ddi d||<   L|S )a
  
        fetches all available currencies on an exchange
        :see: 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   r   fullnameallow_depositallow_withdrawalr   withdrawal_feewithdrawal_limitsincrement_unitr   r   r   N)r   rm   )r   	numericIdcoder   r   r   depositrm   feer   r   r   )
r   r   r   r   r   r   r   safe_integersafe_currency_coder   )r   r  r  r	  r   r  r  r  currencyr   r  r  r   depositEnabledwithdrawEnabledisActiver   r  withdrawalLimitss                      r   fetch_currencieszhollaex.fetch_currenciesK  s    **622H '266EJJLL!!q#d))$$ #	 #	Aq'CSzH!!(H55B))(D99I**2..D##Hj99D!__XGGN"ooh8JKKOx::HD.D_F""8-=>>C#x9LbQQ&  )+!--h8HII  $//%@@#//%@@ 
  $#/?CC! !	 	 + F4LL. r   Nsymbolslimitc                    |                                   |                     |          }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
        :see: 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   r  r  r  r  r  	marketIdsr  marketIdr   r   r   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
        :see: 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   r   )r!  r  publicGetOrderbookextendr   r   r   r$  )	r   r   r  r  r  requestr  r   r   s	            r   fetch_order_bookzhollaex.fetch_order_book  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
        :see: 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   )r!  r  publicGetTickerr*  parse_ticker)r   r   r  r  r+  r  s         r   fetch_tickerzhollaex.fetch_ticker  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
        :see: 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>`
        )r!  market_symbolspublicGetTickersparse_tickers)r   r  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   r  )	r   r   r   r   r   safe_marketr*  r/  filter_by_array_tickers)r   r  r  r  r  r   r  r  r   r&  r  r   s               r   r4  zhollaex.parse_tickers  s    HMMOO$$q#d))$$ 	T 	TAq'Cc]F''#>>H%%hc::FH%F![[):):66)J)JFSSF6NN++FHgFFFr   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   r  timer   closer   datetimehighlowbid	bidVolumeask	askVolumevwapopenlastpreviousClosechanger   volume)average
baseVolumequoteVolume)r   r7  r   safe_string_2safe_tickeriso8601)r   r   r  r&  r   r   r;  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
        :see: 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   )r!  r  publicGetTradesr*  	safe_listparse_trades)	r   r   rO  r  r  r  r+  r  r   s	            r   fetch_tradeszhollaex.fetch_tradesT  s     	V$$fTl
 ''GV(D(DEE &,;;  >>>r   c                    |                      |d          }|                     ||d          }|d         }|                      |d          }|                     |          }|                      |d          }|                      |d          }|                      |d          }	|                      |d          }
|                      |d          }d }|||d	         d
}|                     |d ||||d |d |	|
d |d|          S )Nr   r  r   sideorder_idr   sizer  r   )r   r  )r   r   r   r<  r   r   r   rV  takerOrMakerr   r   r   r  )r   r7  r   
safe_trade)r   trader  r&  r   r<  r   rV  orderIdpriceStringamountStringfeeCostStringr  s                r   parse_tradezhollaex.parse_tradet  s8   , ##E844!!(FC88!##E;77NN8,,	v..""5*55&&ug66''v66((66$%"7O 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 )
aA  
        fetch the trading fees for multiple markets
        :see: 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   )r!  publicGetTiersr   r   r   r  r  r   parse_numberr   
string_div)r   r  r  	firstTierr   	makerFees	takerFeesr  r  r   r  makerStringtakerStrings                r   fetch_trading_feeszhollaex.fetch_trading_fees  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   rn   c                    |                                   |                     |          }|d         |                     | j        ||          d}|                     |          }|+|d}|                                 }	|	||z  z
  }
|	|d<   |
|d<   nn|3|                     |dz            |d<   |                                 |d<   n9|                     |dz            }
|
|d<   |                     |
||z            |d<   |                     | 	                    ||                    }| 
                    |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: 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
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   )r   
resolutionNr   tofrom)r!  r  r   r   parse_timeframesecondsr   sumpublicGetChartr*  parse_ohlcvs)r   r   	timeframerO  r  r  r  r+  durationendstartr  s               r   fetch_ohlcvzhollaex.fetch_ohlcv  sS    	V$$Tl**4?IyQQ
 
 ''	22=},,..C(U**EGDM#GFOO}"&"3"3EDL"A"A $))%$,77"' $50@ A A&&t{{7F'C'CDD   69eUKKKr   c           	      (   |                      |                     |d                    |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr:  rD  r=  r>  r;  rH  )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   r   r<  r   
_availablefree_balancetotal)r   r   rN  r   currencies_by_idr   r   r   r  accountsafe_balance)	r   r  r   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 )aX  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: 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>`
        )r!  privateGetUserBalancer  )r   r  r  s      r   fetch_balancezhollaex.fetch_balance:  s?     	--f55 !!(+++r   r   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )at  
        fetch an open order by it's id
        :see: 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>`
        rW  )r!  privateGetOrderr*  parse_orderr   r   r   r  r+  r  s         r   fetch_open_orderzhollaex.fetch_open_orderQ  s[     	
 ''GV(D(DEE2 )))r   c           	      b    ddi}|                      ||||                     ||                    S )a  
        fetch all unfilled currently open orders
        :see: 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>`
        rD  Tfetch_ordersr*  r   r   rO  r  r  r+  s         r   fetch_open_orderszhollaex.fetch_open_ordersy  s:     D
   t{{7F7S7STTTr   c           	      b    ddi}|                      ||||                     ||                    S )a.  
        fetches information on multiple closed orders made by the user
        :see: 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>`
        rD  Fr  r  s         r   fetch_closed_orderszhollaex.fetch_closed_orders  s:     E
   t{{7F7S7STTTr   c                     |                                   d|i}|                     |                     ||                    }|}|t          | j        dz   |z             |                     |          S )at  
        fetches information on an order made by the user
        :see: https://apidocs.hollaex.com/#get-order
        :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>`
        rW  Nz& fetchOrder() could not find order id )r!  r  r*  r   r   r  )r   r   r   r  r+  r  r   s          r   fetch_orderzhollaex.fetch_order  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
        :see: 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)r!  r  rN  privateGetOrdersr*  rR  parse_orders)	r   r   rO  r  r  r  r+  r  r  s	            r   r  zhollaex.fetch_orders  s     	
 [[((F &tGH$(LL$7$7GL!$GG((Wf)E)EFF< ~~h33  vue<<<r   c                 >    ddddd}|                      |||          S )NrD  closedcanceled)newpfilledfilledr  )r   )r   statusstatusess      r   parse_order_statuszhollaex.parse_order_status  s4    "	
 
 &&999r   c           	      X   |                      |d          }|                     ||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|          S )Nr   r  r   r   r   rV  r   stoprX  r  r  meta	post_onlyFclientOrderIdr   r<  lastTradeTimestamptimeInForcepostOnly	stopPricetriggerPricer   	remaining)r   r   r  r   rI  )r   r#  r   r  r   	safe_bool
safe_orderrN  )r   r   r  r&  r   r   r   r   rV  r   r  r   r  r  r  r  s                   r   r  zhollaex.parse_order  sE   : ##E844!!(FC88eT**NN4#3#3E<#H#HII	v..v..  00$$UF33	!!%00!!%22(()9)9%)J)JKKufb11>>$U;;  
" 
T 
  
 Y//	 

 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
  
 I 
 f 
  f! 
" # 
$ - 
  
  
. /  	r   r   rV  r   r   c                 P   |                                   |                     |          }t          |                     ||                    }|d         ||                     |          |d}	|                     |g d          }
|                     |di           }|                     |dd          }|dk    }|                     |||          }|s;t          | 	                    ||                    }|                     |          |	d<   |
9|                     t          | 	                    ||
                              |	d
<   |rddi|	d<   | 
                    |g d          }|                     |                     |	|                    }|                     ||          S )at  
        create a trade order
        :see: 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 fullfilled, 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   rV  rX  r   )r  r  r  r  r  Fr  r   Nr  T)r  r  r  r  r  )r!  r  floatamount_to_precisionnormalize_number_if_neededsafe_number_nr   r  is_post_onlyprice_to_precisionomitprivatePostOrderr*  r  )r   r   r   rV  r   r   r  r  convertedAmountr+  r  r  exchangeSpecificParamisMarketOrderr  convertedPricer  s                    r   create_orderzhollaex.create_orderK  s    	V$$ 8 8 H HIITl33ODD	
 
 &&v/T/T/TUU	vvr22 $t[% H H($$]4I6RR 	O"4#:#:65#I#IJJN#>>~NNGG "==eDD[D[\bdmDnDn>o>oppGFO 	2*D1GFO6#c#c#cdd((Wf)E)EFF0 &111r   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )a|  
        cancels an open order
        :see: 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>`
        rW  )r!  privateDeleteOrderr*  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 )a}  
        cancel all open orders in a market
        :see: 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   r!  r  privateDeleteOrderAllr*  r  )r   r   r  r+  r  r  s         r   cancel_all_orderszhollaex.cancel_all_orders  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
        :see: 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  )r!  r  rN  privateGetUserTradesr*  rR  rS  )	r   r   rO  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   r  c                    |                      |d          }d }|A|                    d          }|                      |d          }|                      |d          }|                     |           |                      |d          }|                     ||          }|                      |d          }|d         ||||dS )	Naddress:r   r   r  networkr  )r  r  tagr  r   )r   splitcheck_addresssafe_currency)r   depositAddressr  r  r  partsr  r  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
        :see: 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>`
        r  wallet)r!  r   r  privateGetUserr   	filter_byparse_deposit_addresses)r   r  r  r  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
        :see: 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   r  r  r  r  )r!  r  rN  privateGetUserDepositsr*  rR  parse_transactions	r   r  rO  r  r  r+  r  r  r  s	            r   fetch_depositszhollaex.fetch_depositsR  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
        :see: 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   r  r  r   )r!  r  privateGetUserWithdrawalsr*  r   	safe_dictparse_transaction)	r   r   r  r  r+  r  r  r  transactions	            r   fetch_withdrawalzhollaex.fetch_withdrawal  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
        :see: 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   r  r  r  r  )r!  r  rN  r  r*  rR  r  r  s	            r   fetch_withdrawalszhollaex.fetch_withdrawals  s     	
 }}T**H"*4.GJ$GG$(LL$7$7GL!11$++gv2N2NOO0 ~~h33&&tXueDDDr   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   r  r  	dismissedrejectedokr  failedpendingfee_coinr  )r  r   r   txidr   r<  r  addressFrom	addressTotagFromr  tagTor  updatedmessage)commentinternalr  )r   r   r   r  r  r   r  rN  )r   r  r  r   r  r   r  r   r   r  r  r  r  r  r  r  r  r  r  r  feeCurrencyIdfeeCurrencyCodefeeCostr  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   c                    |                      ||          \  }}|                     |           |                                  |                     |          }||d|z   z  }|                     |d          }|t          | j        dz             |                     |d          }|d         |||                     ||          d}| 	                    | 
                    ||                    }	|                     |	|          S )a  
        make a withdrawal
        :see: 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  r  z( withdraw() requires a network parameterr   )r  r   r  r  )handle_withdraw_tag_and_paramsr  r!  r  r   r   r   r  network_code_to_idprivatePostUserWithdrawalr*  r  )
r   r  r   r  r  r  r  r  r+  r  s
             r   rm   zhollaex.withdrawL  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)r  r   )r   rm   r  r   r  r  Frm   withdrawal_feesr   r   value)r  rm   r   )
r   r   r   r   r   r   r   r  network_id_to_coder   )r   r  r  r  allowWithdrawalwithdrawalFeesr   
keysLengthr  r  r  r  currencyCodenetworkCodenetworkCodeUpperwithdrawalFees                   r   parse_deposit_withdraw_feez"hollaex.parse_deposit_withdraw_feet  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          }|                     ||d          S )aY  
        fetch deposit and withdraw fees
        :see: 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   rR  parse_deposit_withdraw_fees)r   r  r  r  r	  s        r   fetch_deposit_withdraw_feesz#hollaex.fetch_deposit_withdraw_fees  sE     **622H x11//uhGGGr   c                 N    |                      |          rt          |          }|S N)is_round_numberint)r   numbers     r   r  z"hollaex.normalize_number_if_needed  s(    '' 	![[Fr   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?rx   ru   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   rs  rr  strr|   jsonhmacencoder}   hashlibsha256)r   pathrx   r   r  r"  r!  queryr  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   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   r(  throw_exactly_matched_exception)r   r  reasonr  r   r"  r!  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   r  )@__name__
__module____qualname__r   r   r	   r  r   r  r   r   r'  r(  r   r,  r   r0  r   r5  r4  r/  r   rT  r`  r   rl  r   rz  r}  r   r  r  r   r  r   r  r  r  r  r  r  r   r   r  r
   r  r  r  r  r   r  r  r   r  r  r  r  rm   r  r  r  r4  r=  __classcell__)r   s   @r   r!   r!      s       @ @ @ @ @D $& o o$v, o o o ob ') R RZ R R R Rh 48dSU       * :>b $M $Ms $M3 $MY $M $M $M $ML 02 3 33 3f 3 3 3 36 04B 5 5W 57 5 5 5 58 :>b 
G 
Gw 
G 
G 
G 
G5 56 5V 5 5 5 5n 6:UW ? ?3 ?s ?# ?\`af\g ? ? ? ?@4 4 45 4 4 4 4l )+ 7 7{ 7 7 7 7r 26DW[df /L /L# /Lc /LQT /Lkoptku /L /L /L /Lb
 
 
4 
 
 
 
*) ) ) ) )" $& , ,( , , , ,. 7;2 &* &*3 &* &* &* &* &*P /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 &' &' &' &'P *.Dt\^ >= >=3 >=c >= >=cghmcn >= >= >= >=@: : :A A A5 A A A AF gksu >2 >23 >2i >2y >2RW >2`c >2 >2 >2 >2@ 37r * *s *C * * * *: /32 3 3 3 3 3 3B -1tRV_a -= -=c -= -=C -= -= -= -=^
 
h 
 
 
 
: :>b ;> ;>T#Y ;> ;> ;> ;>z *.Dt\^ 5E 5E3 5Ec 5E 5Ecghsct 5E 5E 5E 5En 59 += +=3 +=c += += += +=Z -1tRV_a 5E 5Ec 5E 5EC 5Efjkvfw 5E 5E 5E 5En]
 ]
x ]
; ]
 ]
 ]
 ]
~ ?C2 &: &:S &:% &: &: &: &:P> > > > > >@ <@ -H -H -H -H -H -H^  
 &eBSW P P P P4      r   r!   )&ccxt.base.exchanger   ccxt.abstract.hollaexr   r,  ccxt.base.typesr   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!    r   r   <module>rJ     s   ( ' ' ' ' ' - - - - - -  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u  u       0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' . . . . . . * * * * * * 5 5 5 5 5 5 ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %~ ~ ~ ~ ~h ~ ~ ~ ~ ~r   