
    !:h@                       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'  G d dee      Z(y)    )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)	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dEdededefdZddi fd	edededee   fdZdEd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e   fdZdEd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*dEd#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,Z3dEd-e4de5fd.Z6di fd/e
dee5   fd0Z7dddi fd1e#dededee8   fd2Z9di fded1e#fd3Z:dddi fd1e#dededee8   fd4Z;dEd5ed-e4de8fd6Z<di fd1ed'e.d7ede8fd8Z=dEd-e4fd9Z>di fd/e
fd:Z?d; Z@d<d=i ddfd>ZAd1eBd?ed@edAedBedCefdDZC xZDS )Fhollaexreturnc                    | j                  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        dt        t
        t        t        t        t        t        t        ddd| j                  | 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     )	ru   r?   createOrdersr\   ra   r`   rd   rH   r]   )linearinverse)r3   r5   r6   feestradinggMbP?)	tierBased
percentagetakermaker
exceptions)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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    parse_to_inttimeout)self	__class__s    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/hollaex.pyr   zhollaex.describe   s   gt = ? WB
)WB
IWB
 $WB

 WB
 tWB
 4W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& "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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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J "'#(! QIWB
d eWB
v }= 5 -4TwWB
N YOWB
P "$QWB
X   !#Q q  	
 !! "1 $Q %a !!   !! %a ( &q  %a!" &q#$ &q%0 !"())*,-/0'("#!"	 ,-!"
 &'!"/+YWB
p #&+(,,0,1).+06:#(#("&#(	( #(/4$)$)+027#()$, %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( ',!$$*%+#($)*/$ ',!$$*,-%+#($)*/	*  #ACJ ##
 ##SMqWB
L !%"&""	MWB
\ %8'4,= vN	 &.%%%%''	]WB
@ #001DE  " "   $
 #"$""$!AWB
 W W	    c                    | j                  |      }| j                  |di       }t        |j                               }g }t	        dt        |            D ]y  }||   }||   }| j                  |d      }	| j                  |d      }
| j                  |	j                               }| j                  |
j                               }|j                  i d| j                  |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| j                  |d      dddddddddd| j                  |d      | j                  |d      dddd| j                  |d      | j                  |d       d| j                  |d!      | j                  |d"      ddddd#| j                  | j                  |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typer3   Tr4   Fr5   r6   r7   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_markets2  s    **62Z '26EJJL!q#d)$ 7	Aq'C3ZF%%fk:F&&vx8G,,V\\^<D--gmmo>EMM 0d&&vv60$*u,0 0 	0
 $0 &0 70 D0 0 0 %0 0 %0 %0 $//&(;0  E!0" $#0$   $"&""..v7GH!--f6GH  $#!
  $//
C#//
C
  $//D#//D
  $#$  >>$*:*:6<*PQ_0 07	p r   c                 P   | j                  |      }| j                  |di       }t        |j                               }i }t	        dt        |            D ]  }||   }||   }| j                  |d      }	| j                  |	      }
| j                  |dg       }| j                  |d      }|dk(  rdnd}| j                  |d	i       }i }t        |j                               }t	        dt        |            D ]^  }||   }| j                  ||      }| j                  |      }||| j                  |d
      dd| j                  |d      dddddi|d	||<   ` | j                  |	| j                  |d      |
|| j                  |d      | j                  |d
      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      dd| j                  |d      dd||d      ||
<    |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valuerz   r  )	r'   networkr   depositrz   feer  r  r  r'   fullnameallow_depositallow_withdrawalwithdrawal_feeincrement_unitr  r  )r  rz   )r'   	numericIdcoder  r(   r   r2  rz   r3  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  se    **62F x"5EJJL!q#d)$ 6	Aq'CSzH!!(H5B**2.D#~~h8KRP&&x8G '< 78gD..3DbIKHk..01J1c*o. &qM	#~~k9E"55i@#*"nn\8D# $++L'B!%"#'#'% ))%	(  77!..x> ((:>..8<>>(OD NN85GH''2BC!--h8HI  $//%@#//%@
  $#/?C!	 %-9 F4L?6	n r   Nsymbolsr   c                 `   | j                          | j                  |      }i }t        |j                               }t	        dt        |            D ]Y  }||   }||   }	| j                  |dd      }
| j                  | j                  |	d            }| j                  ||   |
|      ||
<   [ |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   rL  r   r"  r#  r$  	marketIdsr%  marketIdr   r   rO  s               r   fetch_order_bookszhollaex.fetch_order_books-  s     	++F3)	q#i.) 	ZA |H *I%%hc:Ft'7'7	;'OPI!228H3EvyYF6N	Z r   r   c                 ,   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||d         }| j                  | j                  |d            }| j                  ||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'   rO  )rP  r'  publicGetOrderbookextendr  r!  r  rS  )	r   r   r   r"  r'  requestr#  r   rO  s	            r   fetch_order_bookzhollaex.fetch_order_bookD  s     	V$fTl
 **4;;w+GH( OOHfTl;	NN4#3#3I{#KL	$$Yx0@)LLr   c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      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'   )rP  r'  publicGetTickerrY  parse_ticker)r   r   r"  r'  rZ  r#  s         r   fetch_tickerzhollaex.fetch_tickerl  s`     	V$fTl
 ''GV(DE   622r   c                     | j                          | j                  |      }| j                  |      }| j                  ||      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>`
        )rP  market_symbolspublicGetTickersparse_tickers)r   rL  r"  r#  s       r   fetch_tickerszhollaex.fetch_tickers  sE     	%%g.((0  !!(G44r   c                 F   i }t        |j                               }t        dt        |            D ]\  }||   }||   }| j	                  |d|      }	| j                  |	d d      }
|
d   }| j                  | j                  ||
      |      ||<   ^ | j                  |d|      S )Nr   r   rN  )	r  r  r  r  r  safe_marketrY  r^  filter_by_array_tickers)r   r   rL  r"  r$  r  r%  r&  r   rU  r'  r   s               r   rc  zhollaex.parse_tickers  s    GLLN#q#d)$ 	TAq'CS\F''#>H%%hc:FH%F![[):):66)JFSF6N	T ++FHgFFr   r   r'  c           	         | j                  |d      }| j                  ||d      }|d   }| j                  | j                  |dd            }| j                  |d      }| j	                  i d|d|d|d| j                  |      d| j                  |d      d	| j                  |d	      d
d dd dd dd dd d| j                  |d      d|d| j                  |d|      dd dd dd d | j                  |d      d d|      S )Nr   rN  timerO  closer  datetimehighlowbid	bidVolumeask	askVolumevwapopenlastpreviousClosechanger   volume)average
baseVolumequoteVolume)r  rf  r!  safe_string_2safe_tickeriso8601)r   r   r'  rU  r   rO  rj  s          r   r^  zhollaex.parse_ticker  s   6 ##FH5!!(FC8!NN4#5#5ffk#RS	  1 !
f!
F!
 !
 Y/	!

 D$$VV4!
 4##FE2!
 4!
 !
 4!
 !
 D!
 D$$VV4!
 U!
 D$$VVU;!
 T!
  d!!
" $#!
$ **68<)!
* + 	r   sincec                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||d   g       }| j                  ||||      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'   )rP  r'  publicGetTradesrY  r=  parse_trades)	r   r   r~  r   r"  r'  rZ  r#  r   s	            r   fetch_tradeszhollaex.fetch_trades  sz     	V$fTl
 ''GV(DE &,;  >>r   tradec                    | j                  |d      }| j                  ||d      }|d   }| j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d      }d }|||d	   d
}| j                  |d ||||d |d |	|
d |d|      S )Nr   rN  rO  sideorder_idr  sizer3  r   )r  rB  )r  r'   rO  rk  r   r   r   r  takerOrMakerr  r  r  r3  )r  rf  r!  
safe_trade)r   r  r'  rU  r   rk  rO  r  orderIdpriceStringamountStringfeeCostStringr3  s                r   parse_tradezhollaex.parse_trade  s   , ##E84!!(FC8!##E;7NN8,	v.""5*5&&ug6''v6((6$%"7OC "   " 
  	r   c           
      d   | j                          | j                  |      }| j                  |di       }| j                  |di       }| j                  |di       }| j                  |di       }i }t        dt	        | j
                              D ]  }| j
                  |   }	| j                  |	      }
| j                  ||
d         }| j                  ||
d         }||	| j                  t        j                  |d            | j                  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   )rP  publicGetTiersr  r  r  rL  r'  r  parse_numberr"   
string_div)r   r"  r#  	firstTierr   	makerFees	takerFeesr$  r%  r   r'  makerStringtakerStrings                r   fetch_trading_feeszhollaex.fetch_trading_feesB  s)    	&&v.: OOHc26	y&"5OOD'26	OOD'26	q#dll+, 	A\\!_F[[(F**9fTlCK**9fTlCK **7+=+=k5+QR**7+=+=k5+QR"!F6N	 r   r|   c                    | j                          | j                  |      }|d   | j                  | j                  ||      d}| j	                  |d      }| j                         }	|| j                  |dz        }	d}
|| j                  |dz        |d<   n|	|
z
  |d<   |	|d<   | j                  |d      }| j                  | j                  ||            }| j                  |||||      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
        :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   
resolutionuntilr   i ' fromto)rP  r'  r  r{   rA  secondsr   omitpublicGetChartrY  parse_ohlcvs)r   r   	timeframer~  r   r"  r'  rZ  r  enddefaultSpanr#  s               r   fetch_ohlcvzhollaex.fetch_ohlcv}  s     	V$Tl**4??IyQ
 !!&'2lln##EDL1C"//=GFO!K/GFO67+&&t{{7F'CD   69eUKKr   c           	          | j                  | j                  |d            | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nri  rs  rl  rm  rj  rw  )r!  r  r   )r   ohlcvr'  s      r   parse_ohlcvzhollaex.parse_ohlcv  sw     NN4++E6:;UF+UF+UE*UG,UH-
 	
r   c                    | j                  | j                  |d            }||| j                  |      d}t        | j                  j                               }t        dt        |            D ]]  }||   }| j                  |      }| j                         }| j                  ||dz         |d<   | j                  ||dz         |d<   |||<   _ | j                  |      S )N
updated_at)r  rO  rk  r   
_availablefree_balancetotal)r!  r  r}  r  currencies_by_idr  r  r  r<  accountsafe_balance)	r   r#  rO  r$  currencyIdsr%  
currencyIdr:  r  s	            r   parse_balancezhollaex.parse_balance  s    NN4#3#3Hl#KL	"Y/

 4005578q#k*+ 	#A$QJ**:6DllnG"..xl9RSGFO#//*z:QRGG"F4L	#   ((r   c                 f    | j                          | j                  |      }| j                  |      S )aT  
        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>`
        )rP  privateGetUserBalancer  )r   r"  r#  s      r   fetch_balancezhollaex.fetch_balance  s3     	--f5 !!(++r   r'   c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )ap  
        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  )rP  privateGetOrderrY  parse_orderr   r'   r   r"  rZ  r#  s         r   fetch_open_orderzhollaex.fetch_open_order  sL     	
 ''GV(DE2 ))r   c           	      R    ddi}| j                  |||| j                  ||            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>`
        rs  Tfetch_ordersrY  r   r   r~  r   r"  rZ  s         r   fetch_open_orderszhollaex.fetch_open_orders  s4     D
   t{{7F7STTr   c           	      R    ddi}| j                  |||| j                  ||            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>`
        rs  Fr  r  s         r   fetch_closed_orderszhollaex.fetch_closed_orders&  s4     E
   t{{7F7STTr   c                     | j                          d|i}| j                  | j                  ||            }|}|t        | j                  dz   |z         | j                  |      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  z& fetchOrder() could not find order id )rP  r  rY  r   r'   r  )r   r'   r   r"  rZ  r#  r   s          r   fetch_orderzhollaex.fetch_order7  sq     	
 ''GV(DE. =*R RUW WXX&&r   c                 *   | j                          d}i }|| j                  |      }|d   |d<   || j                  |      |d<   |||d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      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)rP  r'  r}  privateGetOrdersrY  r=  parse_orders)	r   r   r~  r   r"  r'  rZ  r#  r  s	            r   r  zhollaex.fetch_ordersb  s     	
 [[(F &tGH$(LL$7GL!$GG((Wf)EF< ~~h3  vue<<r   statusc                 6    ddddd}| j                  |||      S )Nrs  closedcanceled)newpfilledfilledr  )r  )r   r  statusess      r   parse_order_statuszhollaex.parse_order_status  s,    "	
 &&99r   r   c                    | j                  |d      }| j                  ||d      }| j                  |d      }| j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d	      }| j                  | j                  |d
            }| j	                  |di       }| j                  |dd      }| j                  i d|dd d|d| j                  |      dd d
|d|d|dd d|d|d|	d| j                  |d      d|
d	|dd dd d d |d d|      S )Nr   rN  r'   r  r   r  r  r  r  r  meta	post_onlyFclientOrderIdrO  rk  lastTradeTimestampr   postOnlyr   stopr  	remainingr  )r   r3  r  rx  )r  rR  r!  r  r  r?  
safe_orderr}  )r   r   r'  rU  r   r'   rO  r   r  r  r  r  r  r  r  s                  r   r  zhollaex.parse_order  s   : ##E84!!(FC8eT*NN4#3#3E<#HI	v.v.  0!!%0!!%2(()9)9%)JKufb1>>$U;  
" 
T 
  
 Y/	 

 !$ 
 f 
 f 
 D 
 4 
  
 D 
 U 
 D,,UF; 
 f 
 f 
  ! 
" D# 
$ + 
, - 	r   r   r  r  r  c                    | j                          | j                  |      }t        | j                  ||            }|d   || j	                  |      |d}	| j                  |g d      }
| j                  |di       }| j                  |dd      }|dk(  }| j                  |||      }|s/t        | j                  ||            }| j	                  |      |	d<   |
-| j	                  t        | j                  ||
                  |	d	<   |rdd
i|	d<   | j                  |g d      }| j                  | j                  |	|            }| j                  ||      S )ao  
        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  r  T)r  r   r  r   r  )rP  r'  floatamount_to_precisionnormalize_number_if_neededsafe_number_nr  r?  is_post_onlyprice_to_precisionr  privatePostOrderrY  r  )r   r   r   r  r  r  r"  r'  convertedAmountrZ  r   r  exchangeSpecificParamisMarketOrderr  convertedPricer#  s                    r   create_orderzhollaex.create_order  s_     	V$ 8 8 HITl33OD	
 ))&2WXvvr2 $t[% H($$]4I6R"4#:#:65#IJN#>>~NGG#"==eDD[D[\bdpDq>rsGFO*D1GFO6#cd((Wf)EF0 &11r   c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )ax  
        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  )rP  privateDeleteOrderrY  r  r  s         r   cancel_orderzhollaex.cancel_order0  sL     	
 **4;;w+GH ))r   c                     |t        | j                  dz         | j                          i }d}| j                  |      }|d   |d<   | j	                  | j                  ||            }| j                  ||      S )ay  
        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'   rP  r'  privateDeleteOrderAllrY  r  )r   r   r"  rZ  r'  r#  s         r   cancel_all_orderszhollaex.cancel_all_ordersO  s     >#DGG.]$]^^V$"4L--dkk'6.JK    622r   c                 *   | j                          i }d}|| j                  |      }|d   |d<   |||d<   || j                  |      |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      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  )rP  r'  r}  privateGetUserTradesrY  r=  r  )	r   r   r~  r   r"  rZ  r'  r#  r  s	            r   fetch_my_tradeszhollaex.fetch_my_tradesr  s     	
 [[(F &tGH$GG$(LL$7GL!,,T[[&-IJ  ~~h3  vue<<r   rB  c                 <   | j                  |d      }d }|5|j                  d      }| j                  |d      }| j                  |d      }| j                  |       | j                  |d      }| j                  ||      }| j                  |d      }||d   |||dS )	Naddress:r   r   rB  r1  r:  )r  rB  r1  r  tag)r  splitcheck_addresssafe_currency)r   depositAddressrB  r  r  partsr  r1  s           r   parse_deposit_addresszhollaex.parse_deposit_address  s     "">9=MM#&E&&ua0G""5!,C7#%%njA
%%j(;"">9=" (
 	
r   codesc                    | j                          | j                  |d      }| j                  |d      }| j                  |      }| j	                  |dg       }||n| j                  |d|      }| j                  ||      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>`
        r1  wallet)rP  r  r  privateGetUserr  	filter_byparse_deposit_addresses)r   r   r"  r1  r#  r  	addressess          r   fetch_deposit_addresseszhollaex.fetch_deposit_addresses  s     	""69569-&&v.\ 8R8&FT^^FIW^5_	++Iu==r   r:  c                 *   | j                          i }d}|| j                  |      }|d   |d<   |||d<   || j                  |      |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      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'   rB  r   r  r  )rP  rB  r}  privateGetUserDepositsrY  r=  parse_transactions	r   r:  r~  r   r"  rZ  rB  r#  r  s	            r   fetch_depositszhollaex.fetch_deposits  s     	
 }}T*H"*4.GJ$GG$(LL$7GL!..t{{7F/KL0 ~~h3&&tXueDDr   c                    | j                          d|i}d}|| j                  |      }|d   |d<   | j                  | j                  ||            }| j	                  |dg       }| j                  |di       }| j                  ||      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'   rB  r  r   )rP  rB  privateGetUserWithdrawalsrY  r  r;  parse_transaction)	r   r'   r:  r"  rZ  rB  r#  r  transactions	            r   fetch_withdrawalzhollaex.fetch_withdrawal8  s     	b
 }}T*H"*4.GJ11$++gv2NO0 x4nnT1b1%%k8<<r   c                 *   | j                          i }d}|| j                  |      }|d   |d<   |||d<   || j                  |      |d<   | j                  | j	                  ||            }| j                  |dg       }| j                  ||||      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'   rB  r   r  r  )rP  rB  r}  r  rY  r=  r
  r  s	            r   fetch_withdrawalszhollaex.fetch_withdrawalsg  s     	
 }}T*H"*4.GJ$GG$(LL$7GL!11$++gv2NO0 ~~h3&&tXueDDr   r  c                    | j                  |d      }| j                  |d      }| j                  | j                  |d            }| j                  | j                  |d            }| j                  |d      }| j                  |d      }| j                  |d      }	d }
d }d }d }d }|	9|	j                  d      }| j                  |d	      }	| j                  |d
      }|	}
|}| j                  |d      }| j	                  ||      }| j                  |d      }| j                  |d      }| j                  |d      }|rd}n|rd}n|rd}nd}| j                  |d      }| j                  ||      }| j                  |d      }d }|||d}i d|d|d|d|d| j                  |      dd d|d|	d|
d|d|d|d|d|d|d    d|d!|| j                  |d"      d |d#S )$Nr'   r  r  r  r   r  r  r  r   r   rB  r  	dismissedrejectedokr  failedpendingfee_coinr3  )rB  r  r  txidrO  rk  r1  addressFrom	addressTotagFromr  tagTor:  updatedmessage)commentinternalr3  )r  r!  r   r  r  r  r<  r}  )r   r  rB  r'   r  rO  r!  r   r  r  r  r  r  r   r  r  r  r  r  r  feeCurrencyIdfeeCurrencyCodefeeCostr3  s                           r   r  zhollaex.parse_transaction  s   @ k40-=>NN4#3#3K#NO	..!1!1+|!LMV4!!+x8"";	:	MM#&E&&ua0G""5!,CIE%%k:>
%%j(;h7OOK=	??;
;FFFF((jA11-J"";6+C
K
"
 D
 	

 Y/
 t
 ;
 w
 
 w
 3
 U
 D
 f
 (
  f!
" w#
$ ''Y?)
 	
r   r  c                    | j                  ||      \  }}| j                  |       | j                          | j                  |      }||d|z   z  }| j	                  |d      }|t        | j                  dz         | j                  |d      }|d   ||| j                  ||      d}| j                  | j                  ||            }	| j                  |	|      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>`
        r  r1  z( withdraw() requires a network parameterr'   )rB  r  r  r1  )handle_withdraw_tag_and_paramsr  rP  rB  r  r   r'   r  network_code_to_idprivatePostUserWithdrawalrY  r  )
r   r:  r  r  r  r"  rB  r1  rZ  r#  s
             r   rz   zhollaex.withdraw  s     99#vFV7#==&?sSy G""695?#DGG.X$XYY69- ..w=	
 11$++gv2NO %%h99r   c                    |d d dd d di d}| j                  |d      }|r| j                  |d      dd|d<   | j                  |d      }|t        |j                               }t	        |      }t        d|      D ]n  }||   }	||	   }
| j                  |
d	      }| j                  |      }| j                  |	|      }|j                         }| j                  |
d
      }d |d|d   |<   p |S )N)r3  r   )r  rz   r2  r   r6  r7  Frz   r/  r   r   r0  )r2  rz   r   )
r  r   r  r  r  r  r  r<  r>  r  )r   r3  rB  r$  allowWithdrawalwithdrawalFeesr  
keysLengthr%  r&  r0  r  currencyCoderJ  networkCodeUpperwithdrawalFees                   r   parse_deposit_withdraw_feez"hollaex.parse_deposit_withdraw_fee)  s0   @ "
 " 
 //#/AB)-)9)9#?O)P`e!fF:.?@%++-.DTJ1j) 1g&s+!--eX>
#66zB"55c<H#.#4#4#6  $ 0 0 @# -8z"#34 r   c                 p    | j                  |      }| j                  |di       }| j                  ||d      S )aU  
        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_feesi  s>     **62H x"5//uhGGr   c                 >    | j                  |      rt        |      }|S N)is_round_numberint)r   numbers     r   r  z"hollaex.normalize_number_if_needed  s    '[Fr   r   GETc           	         | j                  || j                  |            }d| j                  z   dz   | j                  ||      z   }|dk(  s|dk(  r|r|d| j	                  |      z   z  }| j
                  d   d   |z   }|dk(  r| j                          | j                  | j                  dd	| j                  | j                  d
z              }	| j                  | j                         |	      }
t        |
      }||z   |z   }| j                  |d}|dk(  rd|d<   |r| j                  |      }||z  }| j!                  | j#                  |      | j#                  | 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   sumr  strr   jsonhmacencoder   hashlibsha256)r   pathr   rC  r"  rE  rD  queryrB  defaultExpiresr@  expiresStringauth	signatures                 r   signzhollaex.sign  s~   		&$"5"5d";<T\\!C'$*=*=dF*KKeO8!3dnnU333iiv&-)++-!00}iY]YjYjkokwkwz~k~Y  ANhht||~~>GLMD==0D;;,G *<'99U+DDLD		$++d"3T[[5Mw~~^I'0GO$fdwOOr   reasonrB  rC  rE  rD  c
                     |y |dk\  rt|dk  ro| j                   dz   |z   }
| j                  |d      }| j                  | j                  d   ||
       t	        |      }| j                  | j                  d   ||
       y )Ni  i   r"  r   r   )r'   r  throw_broadly_matched_exceptionr   rL  throw_exactly_matched_exception)r   r:  rY  rB  rC  rE  rD  r#  requestHeadersrequestBodyfeedbackr"  r  s                r   handle_errorszhollaex.handle_errors  s    CKdck ww}t+H&&x;G001I7T\]YF001I6S[\r   r8  )E__name__
__module____qualname__r   r   r   r   r(  r   rK  r   r
   r   rV  rL  r   r[  r   r_  r   rd  rc  dictr^  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   r	   r  r  r   r  r  r  r  rz   r3  r6  r  rX  r:  ra  __classcell__)r   s   @r   r$   r$      s   X# Xt $& q$v, qf ') FZ FP 48dSU   Zd . :>b &Ms &M3 &MY &MP 02 33 3f 3: 04B 5W 57 5< 9=R 
Gg 
GG 
G54 5 56 5n 6:UW  ?3  ?s  ?#  ?\`af\g  ?D4 4v 4 4l )+ 9{ 9v 26DW[df -L# -Lc -LQT -Lkoptku -L^
 
4 
*) )" $& ,( ,2 7;2 (*3 (* (*T /3TXac U U3 Uc Uhlmrhs U" 154VZce U# US UPS Ujnotju U" 26b )'c )'3 )'V *.Dt\^ @=3 @=c @= @=cghmcn @=D: :? ?v ? ?B gksu @23 @2i @2y @2RW @2`c @2D 37r *s *C *> /32 !3 !3F -1tRV_a /=c /= /=C /=b
h 
R` 
: 8<B =>W =>4P^K_ =>~ *.Dt\^ 7E3 7Ec 7E 7Ecghsct 7Er 59 -=3 -=c -=^ -1tRV_a 7Ec 7E 7EC 7Efjkvfw 7Er]
T ]
X ]
Q\ ]
~ DHPR (:S (:% (:# (:Wb (:T> >@ <@ /H /Hb
 &eBSW 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    ccxt.base.decimal_to_precisionr!   ccxt.base.preciser"   r$    r   r   <module>ro     sb    ( -  V  V  V  V  V  V  0 . ' . * 5 ) 4 %vh vr   