
    ei                        d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dl"m#Z# d dl$m%Z%  G d dee          Z&dS )    )Exchange)ImplicitAPIN)AnyBalancesCurrencyDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)	TICK_SIZE)Precisec                       e Zd Zdef fdZd Zi fdefdZi fdee	         fdZ
defdZi fdefdZdi fd	ed
edefdZd=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=dede	defdZddi fd	eded
edee         fdZd=de	defdZdddi fd	ededed
edee         f
dZdefdZd=dede	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%d#e&d$e'd%e(f
d&Z)di f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i fd(ed$e'd+ed,ede,f
d-Z.d=d.ed/e/de,fd0Z0defd1Z1di fd2edee2         fd3Z3d4d5i ddfd6Z4d(e5d7ed8ed9ed:ed;efd<Z6 xZ7S )>indodaxreturnc                     |                      t          t          |                                           dddgdi dd dddd	d
d	dd	dd	dd	dd	dd	dd	dd	dddd	dd	dd	dd	ddi dd	dd	dd	dd	dd	dddd	dd	d d	d!d	d"d	d#d	d$dd%d	d&d	d'd	d(d	i d)d*d+dd,d	d-d	d.dd/d	d0d	d1d	d2d	d3d	d4d	d5d	d6d	d7d	d8d	d9d	d:d	i d;d	d<d	d=d	d>d	d?d	d@d	dAd	dBd	dCd	dDddEd	dFd	dGd	dHd	dId	dJd	dKd	i dLd	dMddNd	dOd	dPddQddRd	dSd	dTd	dUd	dVd	dWd	dXd	dYd	dZd	d[d	d\d	i d]d	d^dd_dd`ddad	dbd	dcdddd	ded*dfd	dgd	dhd	did	djd	dkd	dld	dmd	d	d	d	d	d	d	ddndodpdqdrdsdtdudvdwdxdydydydydydydydydydz	id{d|d|d}d|d|d|d|d|d|d|d|d|d|d~idsdd	ddddit          t
          t          t          t          dt          t          dddddddddddddd	ddddd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	ddd}d d	d	ddddid	d d dd d ddddddddt          d          S )Nr!   INDODAXID2   CORSspotTmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionForSymbolWsfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsForSymbolWsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTicker	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalfetchWithdrawalsreduceMarginrepayCrossMargin)repayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawz2.0zdhttps://user-images.githubusercontent.com/51840849/87070508-9358c880-c221-11ea-8dc5-5391afbbb422.jpgzhttps://indodax.comzhttps://indodax.com/tapi)publicprivatezhttps://www.indodax.comz2https://github.com/btcid/indodax-official-api-docsz)https://indodax.com/ref/testbitcoincoid/1)logoapiwwwdocreferralget   )	zapi/server_timez	api/pairszapi/price_incrementszapi/summarieszapi/ticker/{pair}zapi/ticker_allzapi/trades/{pair}zapi/depth/{pair}ztradingview/history_v2post      )getInfotransHistorytradetradeHistory
openOrdersorderHistorygetOrderr2   withdrawFeewithdrawCoinlistDownlinecheckDownlinecreateVouchertradingr   g~jth?)	tierBased
percentagemakertaker)invalid_pairzInsufficient balance.zinvalid order.z:Invalid credentials. API not found or session has expired.zInvalid credentials. Bad sign.)zMinimum pricezMinimum order)exactbroad11530602401D3D1W)1m15m30m1h4h1d3d1wi  zStellar Tokenbep20trc20polygon)XLMBSCTRC20MATIC)
recvWindowtimeDifferenceadjustForTimeDifferencenetworks)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceiceberg)r   triggerr   symbolRequired)r   limitr   r   r     i )r   r   daysBackdaysBackCanceled	untilDaysr   r   r   r   i  )	sandboxr7   createOrdersfetchMyTradesrp   rm   rr   rD   
fetchOHLCV)linearinverse)r(   r*   r+   r   BCHBSVDASHXEM)STRBCHABCBCHSVDRKNEM)idname	countries	rateLimithasversionurlsr   fees
exceptions
timeframesoptionsfeaturescommonCurrenciesprecisionMode)
deep_extendsuperr!   describer   r   r   r   r   r   )self	__class__s    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/indodax.pyr	  zindodax.describe   s   gt 4 4 = = ? ? nnn %n 	n
 %n %n Un $Un 'n n "5n tn n $Un  n  '!n" t#n n$ (%n& ''n( ()n* "5+n, !%-n. /n0 &u1n2 "53n4 +E5n6 )%7n8 #E9n: ,U;n< $T=n> '?n@ (AnB "5CnD En n nF &zGnH (InJ 1%KnL  MnN +DOnP &uQnR 'SnT (UnV #EWnX *5YnZ $U[n\ u]n^ "5_n` *5anb +Ecnd )%enf  gn n nh !%inj %eknl $Umnn &uonp -eqnr /snt "5unv #Ewnx +Eynz {n| !%}n~ !%n@ "5AnB &uCnD +EEnF $UGnH +EIn n nJ %eKnL "4MnN uOnP #EQnR dSnT !$UnV uWnX  YnZ +E[n\ ']n^ $U_n` !%anb *5cnd ,Uenf (gnh %einj )%kn n nl )%mnn tonp Tqnr tsnt "5unv #Ewnx &tynz '{n| $Z}n~  n@ !%AnB (CnD )%EnF "5GnH #EInJ KnL #EMn nN (-$"!&#(! [n n n^ ~39  1KG	 	 +,%&01)*-.*+-.,-23
 
 #$()!"()&'()$%'('(()())*)*  B !&"&"	  %.->&3Re6I  &2%1   	 	 '"#+0*"$&	 	 2  %&+(-,0,1).+06:#'#("'#(	( ( #(/4$)$)+027#()$ $, %)%)&+#($)*.	# # ',!%#($)*/( ( $(&+!%$*,-%)#($)*.	* 	*  #e5 5n ## 
 ## w? ?B ! ! '`B
 `B
 ` ` `	    c                 F    |                                  | j        d         z
  S )Nr   )millisecondsr  )r
  s    r  noncezindodax.nonce<  s!      ""T\2B%CCCr  c                 X    |                      |          }|                     |d          S )ay  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#server-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        server_time)publicGetApiServerTimesafe_integerr
  paramsresponses      r  
fetch_timezindodax.fetch_time?  s/     ..v66   =999r  c                    |                      |          }g }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |d          }|                     |          }	|                     |          }
|                     |d          }|                    i 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|rdn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 )$a7  
        retrieves data on all markets for indodax

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#pairs

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r   traded_currencybase_currencyis_maintenancesymbol/basequotesettleNbaseIdquoteIdsettleIdtyper(   Tr)   Fr*   r+   r,   activecontractr   trade_fee_percentz1e-8price_roundvolume_precision)amountpricecost)minmaxtrade_min_traded_currencytrade_min_base_currency)r   r+  r,  r-  )r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper   	precisionlimitscreatedinfo)
publicGetApiPairsrangelensafe_stringsafe_currency_coder  appendsafe_numberparse_numberparse_precision)r
  r  r  resultimarketr   r"  r#  r  r   isMaintenances               r  fetch_marketszindodax.fetch_marketsQ  s    ))&116 q#h--(( ;	 ;	Aa[F!!&$//B%%f.?@@F&&v??G**622D++G44E --f6FGGMMM 3b3$*u,3 3 	3
 $3 &3 73 D3 3 3 %3 3 %3 %3 =:%%d3  E!3" $#3$  ))&2EFF $"&"""//77!..t/C/CDDTDTU[]jDkDk/l/lmm --d.B.B4CSCSTZ\nCoCo.p.pqq   $#! !
  $//8STT# 
  $//8QRR# 
  $#  $  e3 3 3 3 3 3 3h r  c                 f   |                      |di           }|                      |di           }|                      |di           }|                     |d          }|||                     |          d}t          |                                          }t          dt          |                    D ]j}||         }	|                     |	          }
|                                 }| 	                    ||	          |d<   | 	                    ||	          |d<   |||
<   k| 
                    |          S )	Nr"   balancebalance_holdr  )r:  	timestampdatetimer   freeused)
safe_valuesafe_timestampiso8601listkeysr<  r=  r?  accountr>  safe_balance)r
  r  balancesrN  rO  rL  rD  currencyIdsrE  
currencyIdcoderU  s               r  parse_balancezindodax.parse_balance  s)   ??8Xr::xB77x<<''-@@	"Y//
 

 499;;''q#k**++ 	# 	#A$QJ**:66DllnnG"..tZ@@GFO"..tZ@@GFO"F4LL  (((r  c                 ~    |                                   |                     |          }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-info-endpoint

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        )load_marketsprivatePostGetInfor[  r  s      r  fetch_balancezindodax.fetch_balance  s?     	**622> !!(+++r  Nr  r   c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||d         ddd          S )aR  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#depth

        :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
        pairr   r  Nbuysell)r]  rF  publicGetApiDepthPairextendparse_order_book)r
  r  r   r  rF  request	orderbooks          r  fetch_order_bookzindodax.fetch_order_book  s{     	V$$F4L
 ..t{{7F/K/KLL	$$Yx0@$vVVVr  tickerrF  c                    |                      d |          }|                     |d          }d|d                                         z   }d|d                                         z   }|                     |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|          S )Nr  vol_r"  r#  lastr  rL  rM  highlowbidrb  	bidVolumeaskrc  	askVolumevwapopenclosepreviousClosechanger   average)
baseVolumequoteVolumer:  )safe_symbolrQ  lowerr>  safe_tickerrR  )r
  rj  rF  r  rL  rz  r{  rm  s           r  parse_tickerzindodax.parse_ticker  s    !!$//''>>	fX.44666
vi066888// !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FF33!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6:>>++FK@@)!
 !
 !
* +  	r  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#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>`
        ra  r   rj  )r]  rF  publicGetApiTickerPairre  	safe_dictr  )r
  r  r  rF  rg  r  rj  s          r  fetch_tickerzindodax.fetch_ticker/  s     	V$$F4L
 ..t{{7F/K/KLL (B77  000r  symbolsc                    |                                   |                     |          }|                     |di           }t          |                                          }i }t          dt          |                    D ]X}||         }||         }	|                    dd          }
|                     |
          }| 	                    |	|          }|||
<   Y| 
                    |d|          S )a5  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#ticker-all

        :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>`
        tickersr   _ r  )r]  publicGetApiTickerAllr  rS  rT  r<  r=  replacesafe_marketr  filter_by_array)r
  r  r  r  r  rT  parsedTickersrE  key	rawTickermarketIdrF  parseds                r  fetch_tickerszindodax.fetch_tickersP  s     	" --f55..9b99GLLNN##q#d))$$ 	- 	-Aq'CI{{3++H%%h//F&&y&99F&,M(####M8WEEEr  r   c                 d   |                      |d          }|                     |                     |d          |||                     |          |                     d |          d |                     |d          d d |                     |d          |                     |d          d d d|          S )Ndatetidr%  r,  r+  )r   r:  rL  rM  r  r%  sideordertakerOrMakerr,  r+  r-  fee)rQ  
safe_trader>  rR  r|  )r
  r   rF  rL  s       r  parse_tradezindodax.parse_tradex  s    ''v66	""5%00"Y//&&tV44$$UF33 %%eW55&&uh77 
  
   	r  sincec                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||||          S )a=  
        get the list of most recent trades for a particular symbol

        https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#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>`
        ra  r   )r]  rF  publicGetApiTradesPairre  parse_trades)r
  r  r  r   r  rF  rg  r  s           r  fetch_tradeszindodax.fetch_trades  st     	V$$F4L
 ..t{{7F/K/KLL  65%@@@r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )NTimeOpenHighLowCloseVolume)rQ  rA  )r
  ohlcvrF  s      r  parse_ohlcvzindodax.parse_ohlcv  s     v..UF++UF++UE**UG,,UH--
 	
r  r   	timeframec                 N   |                                   |                     |          }|                     | j        ||          }|                                 }|                     |d|          }	|                     |dg          }|	||d         d}
|d}|(t          t          j	        |dz                      |
d<   n#| 
                    |          }|||z  z
  dz
  |
d<   |                     |                     |
|                    }|                     |||||          S )a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :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
        untilr   )totfr  Nr   fromr   )r]  rF  r>  r  secondsr  omitintmathfloorparse_timeframepublicGetTradingviewHistoryV2re  parse_ohlcvs)r
  r  r  r  r   r  rF  selectedTimeframenowr  rg  durationr  s                r  fetch_ohlcvzindodax.fetch_ohlcv  s0    	V$$ ,,T_iSSllnn!!&'3776G9--#Tl
 

 =E!$*UT\":":;;GFOO++I66H!EH$44q8GFO55dkk'66R6RSS   69eUKKKr  statusc                 <    dddd}|                      |||          S )Nru  closedcanceled)ru  filled	cancelledr>  r
  r  statusess      r  parse_order_statuszindodax.parse_order_status  s1    #
 

 &&999r  r  c                 d   d }d|v r|d         }|                      |                     |dd                    }d }d }|                     |d          }d }d }	|                     |d          }
|                     |
|          }||d         }|d         }|d         }|d         d	k    rd
|v rd}|d         d	k    rd|v rd}|                     |d|z             }|s2|                     |d|z             }|                     |d|z             }	|                     |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!          S )"Nr%  r  ru  r,  ra  r  r#  r"  idrorder_rprp	remain_rporder_remain_submit_timeorder_idr:  r   clientOrderIdclient_order_idrL  rM  lastTradeTimestampr   r   postOnlyr  r   r-  ry  r+  r  )	remainingr  r  trades)r  r>  r  r  
safe_orderrR  )r
  r  rF  r  r  r  r-  r,  r+  r  r  r#  r"  rL  r  r   s                   r  parse_orderzindodax.parse_order  s   T U??=D(()9)9%6)R)RSS  00	##E622!!(F33H%FY'GH%Fy!U**u1D1Dx E))u0D0D##E8g+=>>D H))%F1BCC ,,UI4FGG	%%e];;	eZ00  
E 
" 
 T--e5FGG 
 	 

 Y// 
 !$ 
 f 
 G 
 4 
  
 D 
 U 
 D 
 D 
 t 
  f! 
" d# 
$ #+ 
  
  
   	r  r   c                 p   |t          | j        dz             |                                  |                     |          }|d         |d}|                     |                     ||                    }|d         }|                     |                     d|i|d                   |          }||d<   |S )a  
        fetches information on an order made by the user

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-order-endpoints

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nz( fetchOrder() requires a symbol argumentr   )ra  r  r"   r  r:  )r   r   r]  rF  privatePostGetOrderre  r  )	r
  r   r  r  rF  rg  r  ordersr  s	            r  fetch_orderzindodax.fetch_orderB  s     >#DG.X$XYYYV$$4L
 
 ++DKK,H,HII(#  dBZ!I!I6RR fr  c                 P   |                                   d}i }| |                     |          }|d         |d<   |                     |                     ||                    }|d         d         }|sg S ||                     ||||          S t          |                                          }	g }
t          dt          |	                    D ]U}|	|         }||         }| 	                    |          }|                     ||||          }| 
                    |
|          }
V|
S )a8  
        fetch all unfilled currently open orders

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#open-orders-endpoints

        :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>`
        Nr   ra  r"   r  r   )r]  rF  privatePostOpenOrdersre  parse_ordersrS  rT  r<  r=  r  array_concat)r
  r  r  r   r  rF  rg  r  	rawOrders	marketIdsexchangeOrdersrE  r  marketOrdersparsedOrderss                  r  fetch_open_orderszindodax.fetch_open_orders[  s:    	[[((F$TlGFO--dkk'6.J.JKKX&x0	 	I$$YuEEE))**	q#i..)) 	M 	MA |H$X.L%%h//F,,\65%PPL!..~|LLNNr  c                    |t          | j        dz             |                                  |                     |          }d|d         i}|                     |                     ||                    }|                     |d         d         |          }|                     |dd          }|                     ||||          S )	a\  
        fetches information on multiple closed orders made by the user

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#order-history

        :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>`
        Nz/ fetchClosedOrders() requires a symbol argumentra  r   r"   r  r  r  )	r   r   r]  rF  privatePostOrderHistoryre  r  	filter_byfilter_by_symbol_since_limit)	r
  r  r  r   r  rF  rg  r  r  s	            r  fetch_closed_orderszindodax.fetch_closed_orders  s     >#DG._$_```V$$F4L
 //GV0L0LMM""8H#5h#?HH(;;00NNNr  r%  r  r+  r,  c                 N   |                                   |                     |          }|d         ||d}d}	d}
|dk    r|dk    rd}|                     |d          }|                     |d          }||                     ||          }nn|t          | j        dz             |                     |          }|                     |          }t          j	        ||          }|                     ||          }|||d	         <   njd
}
ng|dk    rad
}	d
}
|dk    rW| 
                    t          j	        |                     |          |                     |                              ||d	         <   |	r$|t          | j        dz   |z   dz             ||d<   |
r|                     ||          ||d         <   |                     |                     ||                    }|                     |di           }|                     |d          }|                     ||d|          S )a  
        create a trade order

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#trade-endpoints

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r   )ra  r%  r,  FrF  rb  Nr-  zv createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price).r#  Tr   z/ createOrder() requires a price argument for a z orderr,  r"  r"   r  )r:  r   )r]  rF  rA  r  cost_to_precisionr   r   number_to_stringr   
string_mulparse_to_numericamount_to_precisionprivatePostTradere  rP  r>  r  )r
  r  r%  r  r+  r,  r  rF  rg  priceIsRequiredquantityIsRequiredquoteAmountr-  amountStringpriceStringcostRequestrD  datar   s                      r  create_orderzindodax.create_order  s    	V$$4L
 

  "8u}}"''776622#"&"8"8"F"FKK}*47  6n  ,n  o  o  o#'#8#8#@#@L"&"7"7">">K")"4\;"O"OK"&"8"8"M"MK-8y)**%)""W__"O!%u}}-1-B-B7CUVZVkVklrVsVsuy  vK  vK  LQ  vR  vR  DS  DS  .T  .Ty)* 	%}"47-^#^ae#ehp#pqqq$GG 	Q(,(@(@(P(PGF8$%&&t{{7F'C'CDDvx44dJ// 
  
   	r  c                    |t          | j        dz             |                     |d          }|t          | j        dz             |                                  |                     |          }||d         |d}|                     |                     ||                    }|                     |d          }|                     |          S )a  
        cancels an open order

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#cancel-order-endpoints

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nz) cancelOrder() requires a symbol argumentr  z- cancelOrder() requires an extra "side" paramr   )r  ra  r%  r"   )	r   r   rP  r]  rF  privatePostCancelOrderre  r  r  )	r
  r   r  r  r  rF  rg  r  r  s	            r  cancel_orderzindodax.cancel_order  s     >#DG.Y$YZZZvv..<#DG.]$]^^^V$$4L
 

 ..t{{7F/K/KLL( ~~h11%%%r  rZ  c                 p   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     |d          }||                     |d          |                     ||          dS )a{  
        fetch the fee for a transaction

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-fee-endpoints

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `fee structure <https://docs.ccxt.com/?id=fee-structure>`
        currencyr   r"   withdraw_fee)r:  rater  )r]  r  privatePostWithdrawFeere  rP  r>  rA  r?  )r
  rZ  r  r  rg  r  r  rY  s           r  fetch_transaction_feezindodax.fetch_transaction_fee  s     	==&&
 ..t{{7F/K/KLL x266%%dJ77
$$T>:://
HEE
 
 	
r  c                 R   |                                   i }|T|                     |          dd         }||d<   |                     |                                           dd         |d<   |                     |                     ||                    }|                     |di           }|                     |di           }	|                     |di           }
g }d}|t          |	                                          }t          dt          |                    D ]&}||         }| 
                    ||	|                   }'t          |
                                          }t          dt          |                    D ]&}||         }| 
                    ||
|                   }'ne|                     |          }|                     |	|d	         g           }|                     |
|d	         g           }| 
                    ||          }|                     ||||          S )
a  
        fetch history of deposits and withdrawals

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#transaction-history-endpoints

        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nr   
   startendr"   r   depositr   )r]  rR  r  privatePostTransHistoryre  rP  rS  rT  r<  r=  r  r  parse_transactions)r
  rZ  r  r   r  rg  	startTimer  r  r   r  transactionsr  rT  rE  r  	withdrawsdepositss                     r  fetch_deposits_withdrawalsz"indodax.fetch_deposits_withdrawals#  s    	U++AbD1I(GG!\\$*;*;*=*=>>qtDGEN//GV0L0LMMt x266??4R88//$	266<((D1c$ii(( N N1g#00x}MM''D1c$ii(( M M1g#00ws|LLM }}T**H(4."EEIwCCH,,YAAL&&|XueLLLr  addresstagc                    |                      ||          \  }}|                     |           |                                  |                     |          }|                                 }|d         ||t          |          d}|r||d<   |                     |                     ||                    }	|                     |	|          S )a  
        make a withdrawal

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-coin-endpoints

        :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   )r  withdraw_amountwithdraw_address
request_idwithdraw_memo)	handle_withdraw_tag_and_paramscheck_addressr]  r  r  strprivatePostWithdrawCoinre  parse_transaction)
r
  rZ  r+  r  r  r  r  	requestIdrg  r  s
             r  r   zindodax.withdraw  s     99#vFFV7###==&&
 %%''	 !% 'i..	
 
  	+'*GO$//GV0L0LMM  %%h999r  transactionr  c                    |                      |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|                     |g d          d|dndd|                     d |          d|                     |          dd dd dd dd d|                      |d          d ||dS )Nr  success_timer  
deposit_idr  )r  r-  r  r   withdraw_idtxidtxrL  rM  networkaddressFromr  r  	addressTor+  )r+  r  deposit_amountr%  r   r  r  updatedtagFromr  tagTocommentr  )internalr  r:  )r>  safe_timestamp_2rA  r?  safe_string_2rR  safe_number_nparse_transaction_status)r
  r  r  r  rL  	depositIdfeeCostr  s           r  r  zindodax.parse_transaction  s   T !!+x88))+~}UU	$$[,??	"";66 33D(CC C

$$$[-NN
D&&{FDAA
 
 Y//	

 t
 4
 t''5GHH
 
 d((6e6e6eff
 9#4JJ9
 //h??
 d33F;;
 t
 t
 4
  T!
" t''_EE#
$ )
 
 
 	
r  c                 8    ddi}|                      |||          S )Nsuccessokr  r  s      r  r.  z indodax.parse_transaction_status  s(    t
 &&999r  codesc                    |                                   |                     |          }|                     |d          }|                     |di           }|                     |di           }t          |                                          }d|i}t          dt          |                    D ]E}	||	         }
|                     |
          }|                     ||
          }||| 	                    ||          r| 
                    |           d}|
|v r|                     ||
          }|                    d          dk    rxg }|                    d          }t          dt          |                    D ]B}|                    |                     ||                                                              Cn'|                     |                                          }i |||dd||<   G|S )	a  
        fetch deposit addresses for multiple currencies and chain types

        https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#general-information-on-endpoints

        :param str[] [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"   r  r"  r:  r   N,)r:  r  r"  r  r  )r]  r^  r  rS  rT  r<  r=  r?  r>  in_arrayr  findsplitr@  network_id_to_codeupper)r
  r4  r  r  r  	addressesr   addressKeysrD  rE  r  rZ  r  r"  	networkId
networkIdsjs                    r  fetch_deposit_addresseszindodax.fetch_deposit_addresses  s    	**622H ~~h11NN4B77	>>$	2669>>++,,D
 q#k**++ 	 	A"1~H**844D&&y(;;G#5=dmmDRW>X>X=""7+++x'' $ 0 08 D DI ~~c**a//"$%.__S%9%9
!&q#j//!:!: [ [A#NN4+B+B:a=+Q+Q+W+W+Y+YZZZZ[ #'"9"9)"D"D"J"J"L"L $&&   t r  r   GETc                 r   | j         d         |         }|dk    re|                     ||                     |                    }d|                     ||          z   }	||	z   }|r|d|                     |          z   z  }n|                                  |                     |                     ||                                 | j	        d         d|                    }d| j
        |                     |                     |          |                     | j                  t          j                  d}||||d	S )
Nr   r   r  ?r   )methodrL  r   z!application/x-www-form-urlencoded)zContent-TypeKeySign)urlrE  bodyheaders)r   r  extract_paramsimplode_paramsurlencode_with_array_repeatcheck_required_credentials	urlencodere  r  r  apiKeyhmacencodesecrethashlibsha512)
r
  pathr   rE  r  rJ  rI  rH  queryrequestPaths
             r  signzindodax.signW  s>   is#(??IIfd&9&9$&?&?@@E 3 3D& A AAK#C EsT==eDDDD++--->>$++!ZZ\\"l<8/ / 	# #  D !D{		$++d"3"3T[[5M5Mw~^^ G
 fdwOOOr  reasonrH  rE  rJ  rI  c
                    |d S t          |t                    rd S |                     |dd          }
d|vr|
dk    rd S |                     |d          }|dk    rd S |                     |dd          dk    r3d|vr-t          | j        dz   |                     |          z             d S | j        d	z   |z   }|                     | j	        d
         |
|           | 
                    | j	        d         |
|           t          |          )Nerrorr  r2  approvedr   r   r"   z: malformed response:  r   r   )
isinstancerS  rP  r>  r  r   r   jsonthrow_exactly_matched_exceptionr  throw_broadly_matched_exception)r
  rZ  rZ  rH  rE  rJ  rI  r  requestHeadersrequestBodyr\  r  feedbacks                r  handle_errorszindodax.handle_errorsm  s)   4
 h%% 	4'266X%%5B;;4!!(I66Z4Xy!4499((#DG.F$FS[I\I\$\]]]t7S=4',,T_W-EuhWWW,,T_W-EuhWWWH%%%r  )N)8__name__
__module____qualname__r   r	  r  r	   r  r   r
   rH  r   r[  r_  r  r   ri  dictr   r  r  r   r   r  r   r  r  rS  r  r  r   r  r   r  r  r  r  r   r   floatr   r  r  r  r   r  r   r   r  r.  r   rA  rY  r  rf  __classcell__)r  s   @r  r!   r!      s       a# a a a a a aF	D D D !# : :s : : : :$ $& a a$v, a a a aF) ) ) ) )( $& ), ),( ), ), ), ),V :>b W Ws W3 WY W W W W&' '4 ' '6 ' ' ' 'R 02 1 13 1f 1 1 1 1B 04B &F &FW &F7 &F &F &F &FP  v     $ 6:UW A A3 As A# A\`af\g A A A A(
 
 
4 
 
 
 
( 9=4^bkm *L *L# *L# *LS *LX[ *Lrvw{r| *L *L *L *LX: : : : :Z Z Zv Z Z Z Z Zx 26b  c 3    2 /3TXac # # #3 #c #hlmrhs # # # #J 154VZce O O# OS OPS Ojnotju O O O O0 gksu 9 93 9i 9y 9RW 9`c 9 9 9 9v 37r ,& ,&s ,&C ,& ,& ,& ,&\ 79  
  
#  
  
  
  
D 6:[_hj _M _Ms _M# _MUX _Most  pA _M _M _M _MB KOWY 0: 0:S 0:% 0:# 0:C 0:^i 0: 0: 0: 0:dJ
 J
T J
X J
Q\ J
 J
 J
 J
X:s : : : : 8<B M MW M4P^K_ M M M M^ &eBSW P P P P,&# &s & &c &TX &`c & & & & & & & &r  r!   )'ccxt.base.exchanger   ccxt.abstract.indodaxr   rT  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>ru     s   ( ' ' ' ' ' - - - - - -   q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q  q       * * * * * * 0 0 0 0 0 0 . . . . . . & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * 4 4 4 4 4 4 % % % % % %n& n& n& n& n&h n& n& n& n& n&r  