
    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    T/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/async_support/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                 d   #    U R                  U5      I Sh  vN nU R                  US5      $  N7f)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
Nserver_time)publicGetApiServerTimesafe_integerr  paramsresponses      r  
fetch_timeindodax.fetch_time?  s4      44V<<   =99 =s   0.0c                   #    U R                  U5      I Sh  vN 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$  GN7f)$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
Nr   r   traded_currencybase_currencyis_maintenancesymbol/basequotesettle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     //77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 q 8s   GF>F'G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                    #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN nU R                  U5      $  N. N7f)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>`
N)load_marketsprivatePostGetInfor`  r  s      r  fetch_balanceindodax.fetch_balance  sH      !!!0088> !!(++A 	"8s   A	AA	AA	A	Nr!  r   c                    #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XS5      5      I Sh  vN nU R	                  XdS   SSS5      $  N[ N7f)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
Npairr   r!  buysell)rc  rJ  publicGetApiDepthPairextendparse_order_book)r  r!  r   r  rJ  request	orderbooks          r  fetch_order_bookindodax.fetch_order_book  s|      !!!V$F4L
 44T[[5QRR	$$Yx0@$vVV 	"
 Ss!   A6A2?A6A4A64A6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       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  Xc5      $  Nh N*7f)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>`
Nrh  r   rr  )rc  rJ  publicGetApiTickerPairrl  	safe_dictr  )r  r!  r  rJ  rn  r  rr  s          r  fetch_tickerindodax.fetch_ticker/  s      !!!V$F4L
 44T[[5QRR (B7  00+ 	"
 Ss!   BA??BB)BBsymbolsc                   #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN 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      $  N N7f)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>`
N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      !!!" 33F;;..9b9GLLN#q#d)$A'CI{{3+H%%h/F&&y9F&,(# % ##M8WEE9 	"" <s    CCCCB"CC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       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  Xd5      5      I Sh  vN nU R	                  XuX#5      $  NV N7f)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>`
Nrh  r   )rc  rJ  publicGetApiTradesPairrl  parse_trades)r  r!  r  r   r  rJ  rn  r  s           r  fetch_tradesindodax.fetch_trades  ss      !!!V$F4L
 44T[[5QRR  5@@ 	"
 Ss!   A1A-?A1A/A1/A1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       I Sh  vN   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      I Sh  vN nU R                  XX#U5      $  N N7f)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
N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;;DKK<XYY   9UKK? 	"$ Zs"   DDCD6D7DD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       I Sh  vN   U R                  U5      nUS   US.nU R	                  U R                  XS5      5      I Sh  vN nUS   nU R                  U R                  SU0US   5      U5      nXhS'   U$  Nw N87f)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   )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
 11$++g2NOO(#  dBZ!I6R f 	" Ps"   /B-B)A B-2B+37B-+B-c                   #    U R                  5       I Sh  vN   Sn0 nUb  U R                  U5      nUS   US'   U R                  U R                  Xd5      5      I Sh  vN 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
$  N N7f)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33DKK4PQQX&x0	I$$YEE)*	q#i.)A |H$.L%%h/F,,\5PL!..~LN * / 	" Rs#   DC>ADD B D Dc                 r  #    Uc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R                  U5      nSUS   0nU R	                  U R                  Xd5      5      I Sh  vN nU R                  US   S   U5      nU R                  USS5      nU R                  XX#5      $  N NC7f)	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 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
 55dkk'6RSS""8H#5h#?H(;00NN 	"
 Ts"   /B7B3?B71B52AB75B7r)  r  r/  r0  c                   #    U R                  5       I Sh  vN   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      I Sh  vN nU R                  US0 5      nU R                  US5      nU R!                  UUS.U5      $  GN NA7f)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>`
Nr   )rh  r)  r0  FrJ  ri  r1  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  s6     !!!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[[-IJJvx4dJ/ 
  	Q 	"J Ks"   G8G3FG84G65?G86G8c                   #    Uc  [        U R                  S-   5      eU R                  US5      nUc  [        U R                  S-   5      eU R                  5       I Sh  vN   U R	                  U5      nUUS   US.nU R                  U R                  Xc5      5      I Sh  vN nU R                  US5      nU R                  U5      $  Ni N)7f)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  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

 44T[[5QRR( ~~h1%%9 	" Ss%   ACCAC C
!(C
Cr_  c                 V  #    U R                  5       I Sh  vN   U R                  U5      nSUS   0nU R                  U R                  XB5      5      I Sh  vN nU R	                  US0 5      nU R                  US5      nUU R                  US5      U R                  Xs5      S.$  N NP7f)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>`
N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      !!!==&
 44T[[5QRR x26%%dJ7
$$T>://
E
 	
% 	"
 Ss"   B)B%?B)B'AB)'B)c                   #    U R                  5       I Sh  vN   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      I Sh  vN 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      $  GN GNB7f)
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55dkk'6RSS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Lg 	" Ts#   GF?A)G GD?GGaddresstagc                 z  #    U R                  XE5      u  pEU R                  U5        U R                  5       I Sh  vN   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      I Sh  vN n	U R                  X5      $  N| N7f)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>`
Nr   )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$55dkk'6RSS  %%h99C 	"" Ts"   8B;B7A&B;!B9"B;9B;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                 ~  #    U R                  5       I Sh  vN   U R                  U5      I Sh  vN 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$  GN GN7f)	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>`
Nr#   r&  r;  r>  r   ,)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     !!!0088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 $&& ! ,. G 	"8s-   F=F7F=F:BF=F=(CF=:F=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 @DB WS W WS\ W&'4 ' '6 'R 68 1 1F 1B 6:" &F7 &F &FP v  $ <@d[] A AS A Abfglbm A(
 
4 
( ?CQUdhqs *L *L *L3 *L^a *Lx|  ~B  yC *LX: :Z Zv Z Zx 8<B C  2 59tZ^gi #c # #TW #nrsxny #J 7;\`ik O O3 OVY Optuzp{ O0 mqy{ 9 9I 9Y 9X] 9fi 9v 9=R ,&S ,&# ,&\ =?  
  
D <@daenp _MS _M _M[^ _Muy  {F  vG _MB QU]_ 0:3 0: 0: 0:# 0:do 0:dJ
T J
X J
Q\ J
X:s : >B" M7 MQUVdQe M^ &eBSW P,&# &s & &c &TX &`c & &r  r!   )' ccxt.async_support.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_    6 -   q  q  q  q  q  * 0 . & . ) * 4 %n&h n&r  