
    E#i                        S SK Jr  S SKJr  S SKrS SKrS SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJ r   S SKJ!r!  S SK"J#r#  S SK$J%r%   " S S\\5      r&g)    )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                   8  ^  \ rS rSrS\4U 4S jjrS r0 4S\4S jjr0 4S\	\
   4S jjrS\4S jr0 4S\4S jjrS	0 4S
\S\S\4S jjrS?S\S\
S\4S jjr0 4S
\S\4S jjrS	0 4S\S\4S jjrS?S\S\
S\4S jjrS	S	0 4S
\S\S\S\	\   4S jjrS?S\
S\4S jjrSS	S	0 4S
\S\S\S\S\	\   4
S jjrS\4S jr S?S\S\
S\!4S jjr"S	0 4S\S
\4S  jjr#S	S	S	0 4S
\S\S\S\	\!   4S! jjr$S	S	S	0 4S
\S\S\S\	\!   4S" jjr%S	0 4S
\S#\&S$\'S%\(S&\)4
S' jjr*S	0 4S\S
\4S( jjr+0 4S)\4S* jjr,S	S	S	0 4S)\S\S\S\	\-   4S+ jjr.S	0 4S)\S%\(S,\S-\S\-4
S. jjr/S?S/\S0\0S\-4S1 jjr1S\4S2 jr2S	0 4S3\S\	\3   4S4 jjr4S5S60 S	S	4S7 jr5S)\6S8\S9\S:\S;\S<\4S= jr7S>r8U =r9$ )@indodax   returnc                  \  > U R                  [        [        U ]  5       SSS/S0 SS _SS_SS	_S
S	_SS	_SS	_SS	_SS	_SS	_SS	_SS	_SS_SS	_SS	_SS	_SS	_SS_0 SS	_SS	_SS	_SS	_SS	_SS_SS	_SS	_S S	_S!S	_S"S	_S#S	_S$S_S%S	_S&S	_S'S	_S(S	_E0 S)S*_S+S_S,S	_S-S	_S.S_S/S	_S0S	_S1S	_S2S	_S3S	_S4S	_S5S	_S6S	_S7S	_S8S	_S9S	_S:S	_E0 S;S	_S<S	_S=S	_S>S	_S?S	_S@S	_SAS	_SBS	_SCS	_SDS_SES	_SFS	_SGS	_SHS	_SIS	_SJS	_SKS	_E0 SLS	_SMS_SNS	_SOS	_SPS_SQS_SRS	_SSS	_STS	_SUS	_SVS	_SWS	_SXS	_SYS	_SZS	_S[S	_S\S	_E0 S]S	_S^S_S_S_S`S_SaS	_SbS	_ScS_SdS	_SeS*_SfS	_SgS	_ShS	_SiS	_SjS	_SkS	_SlS	_SmS	_ES	S	S	S	S	S	SSn.ESoSpSqSrSs.StSuSvSw.SxSySySySySySySySySySz.	0S{S|S|S}S|S|S|S|S|S|S|S|S|S|S~.0Ss.SS	SSSS.0[        [
        [        [        [        S.[        [        S.S.SSSSSSSSS.SSS	SSSSS.S.S	S	S	S S	S	S	S SS	S	S	S.S	S	S	S	S	S	S	S.S S S	S	S	SS.S	S S	S	S	S.S S	SSS}S S	S	SS.SS0S.	S S S.S S S.S.SSSSSS.[        S.5      $ )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getOrderr3   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  )	sandboxr8   createOrdersfetchMyTradesrq   rn   rs   rE   
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    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/indodax.pyr
  indodax.describe   s   gt = ? 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* "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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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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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^ ~39 1KG	 +,%&01)*-.*+-.,-23
 #$()!"()&'()$%'('(()())*)*B !&"&"	 %.->&3Re6I &2%1 	 '"#+0*"$&		2  %&+(-,0,1).+06:#'#("'#(	( #(/4$)$)+027#()$, %)%)&+#($)*.	# ',!%#($)*/( $(&+!%$*,-%)#($)*.	*  #e5n ##
 ##w?B ! '`B
 ` `	    c                 B    U R                  5       U R                  S   -
  $ )Nr   )millisecondsr  )r  s    r  nonceindodax.nonce<  s       "T\\2B%CCCr  c                 H    U R                  U5      nU R                  US5      $ )aQ  
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_timeindodax.fetch_time?  s)     ..v6   =99r  c                 h   U R                  U5      n/ n[        S[        U5      5       GH  nX$   nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  U5      n	U R	                  U5      n
U R                  US5      nUR                  0 SU_SU	S-   U
-   _SU	_S	U
_S
S_SU_SU_SS_SS_SS_SS_SS_SS_SS_SU(       a  SOS_SS_SS_SU R                  US5      SSSSSSU R                  S5      U R                  U R                  U R                  US5      5      5      U R                  U R                  U R                  US5      5      5      S.SSS.U R                  US 5      SS.U R                  US!5      SS.SSS.S".SUS#.E5        GM     U$ )$a  
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/  r0  r1  )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_marketsindodax.fetch_marketsQ  s}    ))&16 q#h-(A[F!!&$/B%%f.?@F&&v?G**62D++G4E --f6F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 $"&"""//7!..t/C/CDDTDTU[]jDk/lm --d.B.B4CSCSTZ\nCo.pq  $#!
  $//8ST#
  $//8QR#
  $#$  e3 3 )x r  c                    U R                  US0 5      nU R                  US0 5      nU R                  US0 5      nU R                  US5      nUUU R                  U5      S.n[        UR	                  5       5      n[        S[        U5      5       HT  nXx   n	U R                  U	5      n
U R                  5       nU R                  X95      US'   U R                  XI5      US'   XU
'   MV     U R                  U5      $ )	Nr#   balancebalance_holdr  )r>  	timestampdatetimer   freeused)
safe_valuesafe_timestampiso8601listkeysr@  rA  rC  accountrB  safe_balance)r  r  balancesrS  rT  rQ  rH  currencyIdsrI  
currencyIdcoderZ  s               r  parse_balanceindodax.parse_balance  s    ??8Xr:xB7x<''-@	"Y/

 499;'q#k*+A$J**:6DllnG"..t@GFO"..t@GFO"4L ,   ((r  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )ag  
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_balanceindodax.fetch_balance  s3     	**62> !!(++r  Nr!  r   c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XS5      5      nU R	                  XdS   SSS5      $ )a  
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)rc  rJ  publicGetApiDepthPairextendparse_order_book)r  r!  r   r  rJ  request	orderbooks          r  fetch_order_bookindodax.fetch_order_book  se     	V$F4L
 ..t{{7/KL	$$Yx0@$vVVr  tickerrJ  c                 6   U R                  S U5      nU R                  US5      nSUS   R                  5       -   nSUS   R                  5       -   nU R                  US5      nU R	                  0 SU_SU_SU R                  U5      _S	U R                  US	5      _S
U R                  US
5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SS _SU_SU_SS _SS _SS _SS _U R                  X5      U R                  X5      US.EU5      $ )Nr  vol_r&  r'  lastr!  rQ  rR  highlowbidri  	bidVolumeaskrj  	askVolumevwapopenclosepreviousClosechanger   average)
baseVolumequoteVolumer>  )safe_symbolrV  lowerrB  safe_tickerrW  )r  rr  rJ  r!  rQ  r  r  ru  s           r  parse_tickerindodax.parse_ticker  s    !!$/''>	fX.4466
vi06688/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FF3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6>++F@)!
* + 	r  c                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )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>`
rh  r   rr  )rc  rJ  publicGetApiTickerPairrl  	safe_dictr  )r  r!  r  rJ  rn  r  rr  s          r  fetch_tickerindodax.fetch_ticker/  sn     	V$F4L
 ..t{{7/KL (B7  00r  symbolsc                 ~   U R                  5         U R                  U5      nU R                  US0 5      n[        UR	                  5       5      n0 n[        S[        U5      5       HC  nXW   nXH   n	UR                  SS5      n
U R                  U
5      nU R                  X5      nXU
'   ME     U R                  USU5      $ )a  
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!  )rc  publicGetApiTickerAllr  rX  rY  r@  rA  replacesafe_marketr  filter_by_array)r  r  r  r  r  rY  parsedTickersrI  key	rawTickermarketIdrJ  parseds                r  fetch_tickersindodax.fetch_tickersP  s     	" --f5..9b9GLLN#q#d)$A'CI{{3+H%%h/F&&y9F&,(# % ##M8WEEr  r   c                 $   U R                  US5      nU R                  U R                  US5      UUU R                  U5      U R	                  S U5      S U R                  US5      S S U R                  US5      U R                  US5      S S S.U5      $ )Ndatetidr)  r0  r/  )r   r>  rQ  rR  r!  r)  sideordertakerOrMakerr0  r/  r1  fee)rV  
safe_traderB  rW  r  )r  r   rJ  rQ  s       r  parse_tradeindodax.parse_tradex  s    ''v6	""5%0"Y/&&tV4$$UF3 %%eW5&&uh7 
  	r  sincec                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  Xd5      5      nU R	                  XuX#5      $ )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>`
rh  r   )rc  rJ  publicGetApiTradesPairrl  parse_trades)r  r!  r  r   r  rJ  rn  r  s           r  fetch_tradesindodax.fetch_trades  s\     	V$F4L
 ..t{{7/KL  5@@r  c           	          U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      U R                  US5      /$ )NTimeOpenHighLowCloseVolume)rV  rE  )r  ohlcvrJ  s      r  parse_ohlcvindodax.parse_ohlcv  sn     v.UF+UF+UE*UG,UH-
 	
r  r   	timeframec                    U R                  5         U R                  U5      nU R                  U R                  X"5      nU R	                  5       nU R                  USU5      n	U R                  US/5      nU	UUS   S.n
Uc  SnUb&  [        [        R                  " US-  5      5      U
S'   OU R                  U5      nXU-  -
  S-
  U
S'   U R                  U R                  X5      5      nU R                  XX#U5      $ )aZ  
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!  r   fromr   )rc  rJ  rB  r  secondsr  omitintmathfloorparse_timeframepublicGetTradingviewHistoryV2rl  parse_ohlcvs)r  r!  r  r  r   r  rJ  selectedTimeframenowr  rn  durationr  s                r  fetch_ohlcvindodax.fetch_ohlcv  s     	V$ ,,T__iSlln!!&'376G9-#Tl

 =E!$**UT\":;GFO++I6H!H$44q8GFO55dkk'6RS   9UKKr  statusc                 2    SSSS.nU R                  X!U5      $ )Nr}  closedcanceled)r}  filled	cancelledrB  r  r  statusess      r  parse_order_statusindodax.parse_order_status  s'    #

 &99r  r  c                    S nSU;   a  US   nU R                  U R                  USS5      5      nS nS nU R                  US5      nS nS n	U R                  US5      n
U R                  X5      nUbw  US   nUS   nUS   nUS   S	:X  a  S
U;   a  SnUS   S	:X  a  SU;   a  SnU R                  USU-   5      nU(       d*  U R                  USU-   5      nU R                  USU-   5      n	U R                  US5      nS nU R                  US5      nU R	                  0 SU_SU_SU R                  US5      _SU_SU R                  U5      _SS _SU_SS_SS _SS _SU_SU_SS _SU_SS _SU_S S _U	UUS S!.E5      $ )"Nr)  r  r}  r0  rh  r!  r'  r&  idrorder_rprp	remain_rporder_remain_submit_timeorder_idr>  r   clientOrderIdclient_order_idrQ  rR  lastTradeTimestampr   r   postOnlyr  r   r1  r  r/  r  )	remainingr  r  trades)r  rB  r  r  
safe_orderrW  )r  r  rJ  r  r  r!  r1  r0  r/  r  r  r'  r&  rQ  r  r   s                   r  parse_orderindodax.parse_order  sP   T U?=D(()9)9%6)RS  0	##E62!!(3H%FY'GH%Fy!U*u1Dx E)u0D##E8g+=>D))%F1BC ,,UI4FG	%%e];	eZ0  
E 
" 
 T--e5FG 
 	 

 Y/ 
 !$ 
 f 
 G 
 4 
  
 D 
 U 
 D 
 D 
 t 
  f! 
" d# 
$ #+ 
  	r  r   c                 .   Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nUS   US.nU R	                  U R                  XS5      5      nUS   nU R                  U R                  SU0US   5      U5      nXhS'   U$ )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>`
z( fetchOrder() requires a symbol argumentr   )rh  r  r#   r  r>  )r   r   rc  rJ  privatePostGetOrderrl  r  )	r  r   r!  r  rJ  rn  r  ordersr  s	            r  fetch_orderindodax.fetch_orderB  s     >#DGG.X$XYYV$4L
 ++DKK,HI(#  dBZ!I6R fr  c                    U R                  5         Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  Xd5      5      nUS   S   nU(       d  / $ Ub  U R	                  XX#5      $ [        UR                  5       5      n	/ n
[        S[        U	5      5       H?  nX   nX   nU R                  U5      nU R	                  XX#5      nU R                  X5      n
MA     U
$ )a  
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   rh  r#   r  r   )rc  rJ  privatePostOpenOrdersrl  parse_ordersrX  rY  r@  rA  r  array_concat)r  r!  r  r   r  rJ  rn  r  	rawOrders	marketIdsexchangeOrdersrI  r  marketOrdersparsedOrderss                  r  fetch_open_ordersindodax.fetch_open_orders[  s     	[[(F$TlGFO--dkk'.JKX&x0	I$$YEE)*	q#i.)A |H$.L%%h/F,,\5PL!..~LN * r  c                 B   Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nSUS   0nU R	                  U R                  Xd5      5      nU R                  US   S   U5      nU R                  USS5      nU R                  XX#5      $ )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>`
z/ fetchClosedOrders() requires a symbol argumentrh  r   r#   r  r  r  )	r   r   rc  rJ  privatePostOrderHistoryrl  r  	filter_byfilter_by_symbol_since_limit)	r  r!  r  r   r  rJ  rn  r  r  s	            r  fetch_closed_ordersindodax.fetch_closed_orders  s     >#DGG._$_``V$F4L
 //G0LM""8H#5h#?H(;00NNr  r)  r  r/  r0  c                    U R                  5         U R                  U5      nUS   UUS.nSn	Sn
US:X  a  US:X  a  SnU R                  US5      nU R                  US5      nUb  U R	                  X5      nOdUc  [        U R                  S-   5      eU R                  U5      nU R                  U5      n[        R                  " X5      nU R	                  X5      nXUS	   '   O\S
n
OYUS:X  aS  S
n	S
n
US:X  aI  U R                  [        R                  " U R                  U5      U R                  U5      5      5      XS	   '   U	(       a%  Uc  [        U R                  S-   U-   S-   5      eXXS'   U
(       a  U R                  X5      XS   '   U R                  U R                  X5      5      nU R                  US0 5      nU R                  US5      nU R!                  UUS.U5      $ )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   )rh  r)  r0  FrJ  ri  Nr1  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 orderr0  r&  r#   r  )r>  r   )rc  rJ  rE  r  cost_to_precisionr   r   number_to_stringr   
string_mulparse_to_numericamount_to_precisionprivatePostTraderl  rU  rB  r  )r  r!  r)  r  r/  r0  r  rJ  rn  priceIsRequiredquantityIsRequiredquoteAmountr1  amountStringpriceStringcostRequestrH  datar   s                      r  create_orderindodax.create_order  s    	V$4L

  "8u}"''7662#"&"8"8"FK}*477  6n  ,n  o  o#'#8#8#@L"&"7"7">K")"4"4\"OK"&"8"8"MK-8y)*%)"W_"O!%u}-1-B-B7CUCUVZVkVklrVsuy  vK  vK  LQ  vR  DS  .Ty)*}"477-^#^ae#ehp#pqq$G(,(@(@(PG8$%&&t{{7'CDvx4dJ/ 
  	r  c                 l   Uc  [        U R                  S-   5      eU R                  US5      nUc  [        U R                  S-   5      eU R                  5         U R	                  U5      nUUS   US.nU R                  U R                  Xc5      5      nU R                  US5      nU R                  U5      $ )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>`
z) cancelOrder() requires a symbol argumentr  z- cancelOrder() requires an extra "side" paramr   )r  rh  r)  r#   )	r   r   rU  rc  rJ  privatePostCancelOrderrl  r  r  )	r  r   r!  r  r  rJ  rn  r  r  s	            r  cancel_orderindodax.cancel_order  s     >#DGG.Y$YZZvv.<#DGG.]$]^^V$4L

 ..t{{7/KL( ~~h1%%r  r_  c                 &   U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  US5      nUU R                  US5      U R                  Xs5      S.$ )aM  
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  )rc  r  privatePostWithdrawFeerl  rU  rB  rE  rC  )r  r_  r  r  rn  r  r  r^  s           r  fetch_transaction_feeindodax.fetch_transaction_fee  s     	==&
 ..t{{7/KL x26%%dJ7
$$T>://
E
 	
r  c                 Z   U R                  5         0 nUb=  U R                  U5      SS nXeS'   U R                  U R                  5       5      SS US'   U R                  U R	                  XT5      5      nU R                  US0 5      nU R                  US0 5      n	U R                  US0 5      n
/ nSnUc  [        U	R                  5       5      n[        S[        U5      5       H  nX   nU R                  XU   5      nM     [        U
R                  5       5      n[        S[        U5      5       H  nX   nU R                  XU   5      nM     OMU R                  U5      nU R                  XS	   / 5      nU R                  XS	   / 5      nU R                  UU5      nU R                  XX#5      $ )
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   )rc  rW  r  privatePostTransHistoryrl  rU  rX  rY  r@  rA  r  r  parse_transactions)r  r_  r  r   r  rn  	startTimer  r  r   r  transactionsr  rY  rI  r  	withdrawsdepositss                     r  fetch_deposits_withdrawals"indodax.fetch_deposits_withdrawals#  s    	U+Ab1I(G!\\$*;*;*=>qDGEN//G0LMt x26??4R8//$	26<(D1c$i(g#00}M ) 'D1c$i(g#00s|L ) }}T*H4."EIwCH,,YAL&&|uLLr  addresstagc                 J   U R                  XE5      u  pEU R                  U5        U R                  5         U R                  U5      nU R	                  5       nUS   UU[        U5      S.nU(       a  XHS'   U R                  U R                  X5      5      n	U R                  X5      $ )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_addressrc  r  r  strprivatePostWithdrawCoinrl  parse_transaction)
r  r_  r/  r&  r'  r  r  	requestIdrn  r  s
             r  r   indodax.withdraw  s     99#F7#==&
 %%'	 !% 'i.	
 '*O$//G0LM  %%h99r  transactionr  c                 N   U R                  US5      nU R                  USS5      nU R                  US5      nU R                  US5      nS nUb  U R                  S U5      US S.n0 SU R	                  USS5      _S	U R	                  US	S
5      _SU_SU R                  U5      _SS _SS _SU R                  US5      _SS _SU R                  U/ SQ5      _SUc  SOS_SU R                  S U5      _SU R                  U5      _SS _SS _SS _SS _SU R                  US5      _S UUS.E$ )Nr  success_timer  
deposit_idr  )r  r1  r  r   withdraw_idtxidtxrQ  rR  networkaddressFromr&  r*  	addressTor/  )r/  r)  deposit_amountr)  r   r  r  updatedtagFromr'  tagTocommentr,  )internalr  r>  )rB  safe_timestamp_2rE  rC  safe_string_2rW  safe_number_nparse_transaction_status)r  r4  r  r  rQ  	depositIdfeeCostr  s           r  r1  indodax.parse_transaction  s   T !!+x8))+~}U	$$[,?	"";6 33D(CC

$$$[-N
D&&{FDA
 
 Y/	

 t
 4
 t''5GH
 
 d((6ef
 9#4J9
 //h?
 d33F;
 t
 t
 4
  T!
" t''_E#
$ )
 	
r  c                 .    SS0nU R                  X!U5      $ )Nsuccessokr  r  s      r  rG   indodax.parse_transaction_status  s#    t
 &99r  codesc                 J   U R                  5         U R                  U5      nU R                  US5      nU R                  US0 5      nU R                  US0 5      n[        UR	                  5       5      nSU0n[        S[        U5      5       GH  n	Xy   n
U R                  U
5      nU R                  XZ5      nUc  M/  Ub  U R                  X5      (       d  MJ  U R                  U5        SnX;   a  U R                  Xj5      nUR                  S5      S:  aa  / nUR                  S5      n[        S[        U5      5       H4  nUR                  U R                  UU   5      R                  5       5        M6     OU R                  U5      R                  5       n0 UUUSS.X'   GM     U$ )	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'  )rc  rd  r  rX  rY  r@  rA  rC  rB  in_arrayr.  findsplitrD  network_id_to_codeupper)r  rO  r  r  r  	addressesr   addressKeysrH  rI  r  r_  r&  r;  	networkId
networkIdsjs                    r  fetch_deposit_addressesindodax.fetch_deposit_addresses  s    	**62H ~~h1NN4B7	>>$	269>>+,D
 q#k*+A"~H**84D&&y;G#5=dmmD>X>X""7+' $ 0 0 DI ~~c*a/"$%.__S%9
!&q#j/!:A#NN4+B+B:a=+Q+W+W+YZ "; #'"9"9)"D"J"J"L $&& ! ,. r  r   GETc                 8   U R                   S   U   nUS:X  aW  U R                  X@R                  U5      5      nSU R                  X5      -   n	Xy-   nU(       a  USU R	                  U5      -   -  nOU R                  5         U R                  U R                  UU R                  5       U R                  S   S.U5      5      nSU R                  U R                  U R                  U5      U R                  U R                  5      [        R                  5      S.nXsXeS	.$ )
Nr   r   r"  ?r   )methodrQ  r   z!application/x-www-form-urlencoded)zContent-TypeKeySign)urlra  bodyheaders)r   r  extract_paramsimplode_paramsurlencode_with_array_repeatcheck_required_credentials	urlencoderl  r  r  apiKeyhmacencodesecrethashlibsha512)
r  pathr   ra  r  rf  re  rd  queryrequestPaths
             r  signindodax.signW  s   iis#(?IIf&9&9$&?@E 3 3D AAK#CsT==eDDD++->>$++!ZZ\"ll<8/ 	# D !D{{		$++d"3T[[5Mw~~^G
 dOOr  reasonrd  ra  rf  re  c
                    Uc  g [        U[        5      (       a  g U R                  USS5      n
SU;  a  U
S:X  a  g U R                  US5      nUS:X  a  g U R	                  USS5      S:X  a1  SU;  a*  [        U R                  S-   U R                  U5      -   5      eg U R                  S	-   U-   nU R                  U R                  S
   X5        U R                  U R                  S   X5        [        U5      e)Nerrorr  rL  approvedr   r   r#   z: malformed response:  r   r   )
isinstancerX  rU  rB  r  r   r   jsonthrow_exactly_matched_exceptionr  throw_broadly_matched_exception)r  r_  rw  rd  ra  rf  re  r  requestHeadersrequestBodyry  r  feedbacks                r  handle_errorsindodax.handle_errorsm  s    
 h%%'26X%5B;!!(I6ZXy!49(#DGG.F$FS[I\$\]]77S=4',,T__W-EuW,,T__W-EuWH%%r   )N):__name__
__module____qualname____firstlineno__r   r
  r  r	   r  r   r
   rL  r   r`  re  r/  r   rp  dictr   r  r  r   r   r  r   r  r  rX  r  r  r   r  r   r  r  r  r  r   r   floatr   r  r  r  r   r$  r   r   r1  rG  r   r\  ru  r  r  __static_attributes____classcell__)r  s   @r  r!   r!      s   a# aF	D !# :s :$ $& a$v, aF) )( $& ),( ),V :>b Ws W3 WY W&'4 ' '6 'R 02 13 1f 1B 04B &FW &F7 &FP v  $ 6:UW A3 As A# A\`af\g A(
 
4 
( 9=4^bkm *L# *L# *LS *LX[ *Lrvw{r| *LX: :Z Zv Z Zx 26b c 3 2 /3TXac # #3 #c #hlmrhs #J 154VZce O# OS OPS Ojnotju O0 gksu 93 9i 9y 9RW 9`c 9v 37r ,&s ,&C ,&\ 79  
#  
D 6:[_hj _Ms _M# _MUX _Most  pA _MB KOWY 0:S 0:% 0:# 0:C 0:^i 0:dJ
T J
X J
Q\ J
X:s : 8<B MW M4P^K_ M^ &eBSW P,&# &s & &c &TX &`c & &r  r!   )'ccxt.base.exchanger   ccxt.abstract.indodaxr   rp  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  r  <module>r     s_    ( -   q  q  q  q  q  * 0 . & . ) * 4 %n&h n&r  