
    iw                         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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dl m!Z!  G d dee          Z"dS )    )Exchange)ImplicitAPIN)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)	TICK_SIZEc                       e Zd Z fdZd Zi 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d0d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d0dedefdZddi fd	eded
edee         fdZd0dedefdZdddi fd	eded
edee         fdZd Zd0d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%fd&Z,d0d'e-de*fd(Z.d) Z/di fd*ee         fd+Z0d,d-i ddfd.Z1d/ Z2 xZ3S )1indodaxc                 B   |                      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	d	d	ddLdMdNdOdPdQdRdSdTdUdVdWdWdWdWdWdWdWdWdWdX	idYdZdZd[dZdZdZdZdZdZdZdZdZdZd\idQd]d	dd^d_d`it          t
          t          t          t          dat          t          dbdcddd^d	dedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdyt          dz          S ){Nr   INDODAXIDd   CORSspotTmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositfetchDepositAddressemulatedfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTicker	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMargin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getOrderr+   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broadi  zStellar Tokenbep20trc20polygon)XLMBSCTRC20MATIC11530602401D3D1W)1m15m30m1h4h1d3d1w)
recvWindowtimeDifferenceadjustForTimeDifferencenetworks
timeframesr   BCHBSVDASHXEM)STRBCHABCBCHSVDRKNEM)idname	countries	rateLimithasversionurlsrn   fees
exceptionsoptionscommonCurrenciesprecisionMode)
deep_extendsuperr   describer   r   r   r   r   r   )self	__class__s    `/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/async_support/indodax.pyr   zindodax.describe   s   gt 4 4 = = ? ? HHH %H 	H
 %H %H UH "5H tH H $UH  H 'H tH (H  '!H" (#H H$ "5%H& 'H( +E)H* )%+H, $T-H. '/H0 (1H2 3H4 &z5H6 (7H8 1%9H:  ;H< +D=H> &u?H@ #EAHB *5CHD $UEH H HF "5GHH *5IHJ +EKHL  MHN %eOHP "5QHR SHT !%UHV +EWHX "4YHZ d[H\ !$]H^ u_H`  aHb $UcHd !%eHf %egH H Hh )%iHj tkHl TmHn toHp "5qHr #EsHt &tuHv 'wHx $ZyHz  {H| !%}H~ "5H@ #EAHB CHD uEHF UGHH  IH HJ $)! OH H HR ~39  1KG	 	 +,%&01)*-.*+-.,-23
 
 #$()!"()&'()$%'('(()())*)*  B !&"&"	  %.->&3Re6I  &2%1   '"#+0*"$&	 & 	 	-   D ! ! 'szB
 zB
 z z z	    c                 F    |                                  | j        d         z
  S )Nr   )millisecondsr   )r   s    r   noncezindodax.nonce   s!      ""T\2B%CCCr   c                 h   K   |                      |           d{V }|                     |d          S )a}  
        fetches the current integer timestamp in milliseconds from the exchange server
        :see: 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
        Nserver_time)publicGetApiServerTimesafe_integerr   paramsresponses      r   
fetch_timezindodax.fetch_time   sE       44V<<<<<<<<   =999r   returnc                   K   |                      |           d{V }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 )%a;  
        retrieves data on all markets for indodax
        :see: 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
        Nr   	ticker_idtraded_currencybase_currencyis_maintenancer   symbol/basequotesettlebaseIdquoteIdsettleIdtyper$   Tr%   Fr&   r'   r(   activecontractlineartrade_fee_percentz1e-8price_roundvolume_precision)amountpricecost)minmaxtrade_min_traded_currencytrade_min_base_currency)leverager   r   r   )inverser   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_markets   s      //777777776 q#h--(( ;	 ;	Aa[F!!&+66B%%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   balancesr  r	  r  r   currencyIdsr   
currencyIdcoder  s               r   parse_balancezindodax.parse_balanceI  s)   ??8Xr::xB77x<<''-@@	"Y//
 

 499;;''q#k**++ 	# 	#A$QJ**:66DllnnG"..tZ@@GFO"..tZ@@GFO"F4LL  (((r   c                    K   |                                   d{V  |                     |           d{V }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: 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>`
        N)load_marketsprivatePostGetInfor  r   s      r   fetch_balancezindodax.fetch_balance]  sg       !!!!!!!!!0088888888> !!(+++r   Nr   limitc                 &  K   |                                   d{V  |                     |          }d|d         |d         z   i}|                     |                     ||                     d{V }|                     ||d         ddd          S )aX  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: 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
        Npairr   r   r   buysell)r  r   publicGetApiDepthPairextendparse_order_book)r   r   r  r   r   request	orderbooks          r   fetch_order_bookzindodax.fetch_order_book  s       !!!!!!!!!V$$F6NVG_4
 44T[[&5Q5QRRRRRRRR	$$Yx0@$vVVVr   r   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   r  r  highlowbidr  	bidVolumeaskr  	askVolumevwapopenclosepreviousClosechanger   average)
baseVolumequoteVolumer   )safe_symbolr  lowerr   safe_tickerr  )r   tickerr   r   r  r4  r5  r'  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                 B  K   |                                   d{V  |                     |          }d|d         |d         z   i}|                     |                     ||                     d{V }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://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>`
        Nr  r   r   r9  )r  r   publicGetApiTickerPairr   	safe_dictr:  )r   r   r   r   r"  r   r9  s          r   fetch_tickerzindodax.fetch_ticker  s       !!!!!!!!!V$$F6NVG_4
 44T[[&5Q5QRRRRRRRR (B77  000r   symbolsc                    K   |                                   d{V  |                     |           d{V }|                     |d          }|                     ||          S )a;  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: 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>`
        Ntickers)r  publicGetApiTickerAll	safe_listparse_tickers)r   r?  r   r   rA  s        r   fetch_tickerszindodax.fetch_tickers  s|       !!!!!!!!!" 33F;;;;;;;;..955!!'7333r   c                 d   |                      |d          }|                     |                     |d          |||                     |          |                     d |          d |                     |d          d d |                     |d          |                     |d          d d d|          S )Ndatetidr   r   r   )r   r   r  r  r   r   sideordertakerOrMakerr   r   r   fee)r  
safe_trader   r  r6  )r   ry   r   r  s       r   parse_tradezindodax.parse_trade  s    ''v66	""5%00"Y//&&tV44$$UF33 %%eW55&&uh77 
  
   	r   sincec                   K   |                                   d{V  |                     |          }d|d         |d         z   i}|                     |                     ||                     d{V }|                     ||||          S )aC  
        get the list of most recent trades for a particular symbol
        :see: 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>`
        Nr  r   r   )r  r   publicGetApiTradesPairr   parse_trades)r   r   rO  r  r   r   r"  r   s           r   fetch_tradeszindodax.fetch_trades  s       !!!!!!!!!V$$F6NVG_4
 44T[[&5Q5QRRRRRRRR  65%@@@r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )NTimeOpenHighLowCloseVolume)r  r   )r   ohlcvr   s      r   parse_ohlcvzindodax.parse_ohlcv   s     v..UF++UF++UE**UG,,UH--
 	
r   r   c                   K   |                                   d{V  |                     |          }| j        d         }|                     |||          }|                                 }	|                     |dd|	          }
|                     |ddg          }|
||d         |d         z   d}|d}|(t          t          j	        |dz                      |d	<   n#| 
                    |          }|	||z  z
  d
z
  |d	<   |                     |                     ||                     d{V }|                     |||||          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
        Nr   untiltillr   r   )totfr   i  fromrv   )r  r   r   r   secondssafe_integer_2omitintmathfloorparse_timeframepublicGetTradingviewHistoryV2r   parse_ohlcvs)r   r   	timeframerO  r  r   r   r   selectedTimeframenowr^  r"  durationr   s                 r   fetch_ohlcvzindodax.fetch_ohlcv4  sq      !!!!!!!!!V$$\,/
 ,,ZINNllnn##FGVSAA6GV#455#Vnvg6
 

 =E!$*UT\":":;;GFOO++I66H!EH$44q8GFO;;DKKQW<X<XYYYYYYYY   69eUKKKr   c                 <    dddd}|                      |||          S )Nr/  closedcanceled)r/  filled	cancelledr   r   statusstatusess      r   parse_order_statuszindodax.parse_order_statusa  s1    #
 

 &&999r   c           	         d }d|v r|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 d          S ) Nr   rx  r/  r   r   r   r   idrorder_rprp	remain_rporder_remain_submit_timeorder_idr   r   clientOrderIdr  r  lastTradeTimestampr  timeInForcepostOnlyrI  	stopPricetriggerPricer   r3  r   )rt  	remainingrx  rL  trades)rz  r   r   
safe_orderr  )r   rJ  r   rI  rx  r   r   r   r   r  r   r   r  rL  r   s                  r   parse_orderzindodax.parse_orderi  s`   0 U??=D(()9)9%6)R)RSS  00	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 
 	 

 Y// 
 !$ 
 f 
 G 
 4 
  
 D 
 U 
  
 D 
 D 
  t! 
" f# 
$ "- 
  
  
   	r   r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d         |d}|                     |                     ||                     d{V }|d         }|                     |                     d|i|d                   |          }||d<   |S )a  
        fetches information on an order made by the user
        :see: https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-order-endpoints
        :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   )r  r  r   rJ  r   )r   r   r  r   privatePostGetOrderr   r  )	r   r   r   r   r   r"  r   ordersrJ  s	            r   fetch_orderzindodax.fetch_order  s       >#DG.X$XYYY!!!!!!!!!V$$4L
 
 11$++gv2N2NOOOOOOOO(#  dBZ!I!I6RR fr   c                 l  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |                     |                     ||                     d{V }|d         d         }|sg S ||                     ||||          S t          |                                          }	g }
t          dt          |	                    D ]U}|	|         }||         }| 	                    |          }|                     ||||          }| 
                    |
|          }
V|
S )a>  
        fetch all unfilled currently open orders
        :see: 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   r  r   r  r   )r  r   privatePostOpenOrdersr   parse_ordersr  r  r   r   safe_marketarray_concat)r   r   rO  r  r   r   r"  r   	rawOrders	marketIdsexchangeOrdersr   marketIdmarketOrdersparsedOrderss                  r   fetch_open_orderszindodax.fetch_open_orders  sb      !!!!!!!!![[((F$TlGFO33DKK4P4PQQQQQQQQ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                   K   |t          | j        dz             |                                  d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d         d         |          }|                     |dd          }|                     ||||          S )	ab  
        fetches information on multiple closed orders made by the user
        :see: 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 argumentr  r   r   r  rx  rr  )	r   r   r  r   privatePostOrderHistoryr   r  	filter_byfilter_by_symbol_since_limit)	r   r   rO  r  r   r   r"  r   r  s	            r   fetch_closed_orderszindodax.fetch_closed_orders  s       >#DG._$_```!!!!!!!!!V$$F4L
 55dkk'66R6RSSSSSSSS""8H#5h#?HH(;;00NNNr   r   rI  r   r   c                   K   |dk    rt          | j        dz             |                                  d{V  |                     |          }|d         ||d}|d         }	|dk    r||z  ||d         <   n|||d         <   |||	<   |                     |                     ||                     d{V }
|                     |
d	i           }|                     |d
          }|                     |
|d|          S )a  
        create a trade order
        :see: 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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  z' createOrder() allows limit orders onlyNr   )r  r   r   r   r  r   r   r  )r   r   )	r   r   r  r   privatePostTrader   r
  r   r  )r   r   r   rI  r   r   r   r   r"  currencyr   datar   s                r   create_orderzindodax.create_order  sA      7??*S STTT!!!!!!!!!V$$4L
 

 (#5==)/%GF9%&&(.GF8$%",,T[[&-I-IJJJJJJJJvx44dJ// 
  
   	r   c                 j  K   |t          | j        dz             |                     |d          }|t          | j        dz             |                                  d{V  |                     |          }||d         |d}|                     |                     ||                     d{V S )a  
        cancels an open order
        :see: 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 argumentrI  z- cancelOrder() requires an extra "side" paramr   )r  r  r   )r   r   r
  r  r   privatePostCancelOrderr   )r   r   r   r   rI  r   r"  s          r   cancel_orderzindodax.cancel_order$  s       >#DG.Y$YZZZvv..<#DG.]$]^^^!!!!!!!!!V$$4L
 

 00Wf1M1MNNNNNNNNNr   r  c                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |di           }|                     |d          }||                     |d          |                     ||          dS )a  
        fetch the fee for a transaction
        :see: 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>`
        Nr  r   r   withdraw_fee)r   rater  )r  r  privatePostWithdrawFeer   r
  r   r   r   )r   r  r   r  r"  r   r  r  s           r   fetch_transaction_feezindodax.fetch_transaction_fee;  s       !!!!!!!!!==&&
 44T[[&5Q5QRRRRRRRR x266%%dJ77
$$T>:://
HEE
 
 	
r   c                 n  K   |                                   d{V  i }|T|                     |          dd         }||d<   |                     |                                           dd         |d<   |                     |                     ||                     d{V }|                     |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
        :see: 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   rj   depositr   )r  r  r   privatePostTransHistoryr   r
  r  r  r   r   r  r  parse_transactions)r   r  rO  r  r   r"  	startTimer   r  rj   r  transactionsr  r  r   key	withdrawsdepositss                     r   fetch_deposits_withdrawalsz"indodax.fetch_deposits_withdrawals[  s7      !!!!!!!!!U++AbD1I(GG!\\$*;*;*=*=>>qtDGEN55dkk'66R6RSSSSSSSS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   c                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|                                 }|d         ||t          |          d}|r||d<   |                     |                     ||                     d{V }	|                     |	|          S )a  
        make a withdrawal
        :see: 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>`
        Nr   )r  withdraw_amountwithdraw_address
request_idwithdraw_memo)	handle_withdraw_tag_and_paramscheck_addressr  r  r   strprivatePostWithdrawCoinr   parse_transaction)
r   r  r   addresstagr   r  	requestIdr"  r   s
             r   rj   zindodax.withdraw  s       99#vFFV7###!!!!!!!!!==&&
 %%''	 !% 'i..	
 
  	+'*GO$55dkk'66R6RSSSSSSSS  %%h999r   r  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 )Nrx  success_timer  
deposit_idrL  )r  r   r  r   withdraw_idtxidtxr  r  networkaddressFromr  r  	addressTor   )r   r  deposit_amountr   rj   r  r  updatedtagFromr  tagTocommentr  )internalrL  r   )r   safe_timestamp_2r   r   safe_string_2r  safe_number_nparse_transaction_status)r   transactionr  rx  r  	depositIdfeeCostrL  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okrv  rw  s      r   r  z indodax.parse_transaction_status6  s(    t
 &&999r   codesc                   K   |                                   d{V  |                     |           d{V }|                     |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
        :see: 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>`
        Nr   r  r  r   r   ,)r   r  r  r  r  )r  r  r=  r  r  r   r   r   r   in_arrayr  findsplitr   network_id_to_codeupper)r   r  r   r   r  	addressesr   addressKeysr   r   r  r  r  r  	networkId
networkIdsjs                    r   fetch_deposit_addresseszindodax.fetch_deposit_addresses<  s-      !!!!!!!!!0088888888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   rk   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 )
Nrn   rk   r   ?r   )methodr  r   z!application/x-www-form-urlencoded)zContent-TypeKeySign)urlr  bodyheaders)r   re  extract_paramsimplode_paramsurlencode_with_array_repeatcheck_required_credentials	urlencoder   r   r   apiKeyhmacencodesecrethashlibsha512)
r   pathrn   r  r   r  r  r  queryrequestPaths
             r   signzindodax.sign  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   c
                    |d S t          |t                    rd S |                     |dd          }
d|vr|
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error r  r   rv   r   z: malformed response:  r   r   )

isinstancer  r
  r   r   r   jsonthrow_exactly_matched_exceptionr   throw_broadly_matched_exception)r   r  reasonr  r  r  r  r   requestHeadersrequestBodyr
  feedbacks               r   handle_errorszindodax.handle_errors  s   4 h%% 	4'266X%%5B;;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)4__name__
__module____qualname__r   r   r   r   r   r  r   r  r  r  r   r   r$  r   r:  r>  r   r   rE  r   rN  rS  r  r\  rp  rz  r
   r  r   r  r  r  r   r   floatr	   r  r  r  r   r  rj   r   r  r  r  r  r  __classcell__)r   s   @r   r   r      s{       { { { { {zD D D ') : : : :  *, _ _V _ _ _ _B) ) ) ) )( *, ', ', ', ', ', ',R @DB W WS W WS\ W W W W"' '6 'V ' ' ' 'R 68 1 1 1F 1 1 1 1> 6:" 4 47 4 4 4 4 4:  5    $ <@d[] A A AS A Abfglbm A A A A$
 
 
4 
 
 
 
( 8<$]ajl +L +L +LC +LWZ +Lquvzq{ +L +L +L +LZ: : :G G G5 G G G GR 8<B  C     , 59tZ^gi ! !c ! !TW !nrsxny ! ! ! !F 7;\`ik O O O3 OVY Optuzp{ O O O O, mqy{ ! ! !I !Y !X] !fi ! ! ! !F 9=R O OS O# O O O O. =? 
 
 
 
 
 
@ <@daenp ]M ]MS ]M ]M[^ ]Muy  {F  vG ]M ]M ]M ]M~ EIQS .: .:3 .: .: .: .: .:`J
 J
x J
; J
 J
 J
 J
X: : : @DB K K49 K K K KZ &eBSW P P P P,& & & & & & &r   r   )# ccxt.async_support.base.exchanger   ccxt.abstract.indodaxr   r  rg  ccxt.base.typesr   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   r    r   r   <module>r"     s   6 5 5 5 5 5 - - - - - -   \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \  \       * * * * * * 0 0 0 0 0 0 . . . . . . & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * 4 4 4 4 4 4]& ]& ]& ]& ]&h ]& ]& ]& ]& ]&r   