
    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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\\5      r&g)    )Exchange)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyDepositAddress	IndexTypeIntLedgerEntryMarketNumOrder	OrderBook	OrderSide	OrderTypeStrTickerTradeTransaction)List)ExchangeError)AuthenticationError)	BadSymbol)InsufficientFunds)OrderNotFound)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4S jr0 4S\4S jjr0 4S\	\
   4S jjrS\S\
4S jrSMS
\S\S\4S jjrS	0 4S\S\S\4S jjrSNS\S\
S\4S jjr0 4S\S\4S jjrSNS\
S\4S jjrSS	S	0 4S\S\S\S\S\	\   4
S jjrSNS\S\
S\4S jjrS	S	0 4S\S\S\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 r"SNS \S!\#S\$4S" jjr%S	S	S	0 4S#\&S\S\S\	\$   4S$ jjr'S%\&4S& jr(SNS'\S\
S\)4S( jjr*S	0 4S\S)\+S*\,S+\-S,\.4
S- jjr/S	S	0 4S.\S\S)\+S*\,S+\.S,\.4S/ jjr0S	S	S	0 4S\&S\S\4S0 jjr1S	0 4S\&4S1 jjr2S	0 4S.\S\&4S2 jjr3S	S	S	0 4S\&S\S\S\	\)   4S3 jjr4S	S	S	0 4S\&S\S\S\	\)   4S4 jjr5S	0 4S.\S\&4S5 jjr6S	S	S	0 4S.\S\&S\S\4S6 jjr70 4S#\S\84S7 jjr9SNS!\#S\84S8 jjr:0 4S#\S\84S9 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>SNS< jr?SNS=\S!\#S\<4S> jjr@S	0 4S#\S+\-S?\S@\&S\<4
SA jjrASB rBSCSD0 S	S	4SE jrCS#\DSF\SG\SH\SI\SJ\4SK jrESLrFU =rG$ )Ondax   returnc           !      h  > U R                  [        [        U ]  5       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	_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	_S/S	_S0S	_S1S	_S2S	_S3S	_S4S	_S5S	_S6S	_S7S_S8S	_S9S	_E0 S:S	_S;S	_S<S	_S=S	_S>S	_S?S	_S@S	_SAS	_SBS_SCS	_SDS	_SES	_SFS	_SGS	_SHS_SIS_SJS	_E0 SKS	_SLS	_SMS_SNS	_SOS	_SPS_SQS_SRS_SSS_STS	_SUS	_SVS	_SWS	_SXS	_SYS	_SZS	_S[S	_E0 S\S	_S]S_S^S	_S_S	_S`S_SaS	_SbS	_ScS	_SdS	_SeS_SfS	_SgS	_ShS	_SiS_SjS	_SkS	_SlS	_ES	SS	SSm.ESnSoSpSqSrSsStSuSvSwSxSySzS{.S|S}S}S~.SSS~.SS/SSS.S0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSS.	E00 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_ESSSSSSSS.E0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSSSSS.	E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	SSSS	S.S	S	S	S	S.S	S S	S	S	S.S	S S S S	S	S	S.S SS 0S.	S S S.S S S.S.SS	SU R	                  S5      U R	                  S5      S.0SSSSSS.[
        [        [        [        S.[        [        S.S.SSSSSSSSSSSSSSSS.S.S.5      $ )Nr!   NDAXCA  TCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsandboxsetLeverage	setMarginsetMarginMode)setPositionModesignIntransferwithdraw603009001800360072001440021600432008640060480024192009676800)1m5m15m30m1h2h4h6h12h1d1w1M4Mzdhttps://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpgz,https://ndaxmarginstaging.cdnhop.net:8443/AP)publicprivatezhttps://api.ndax.io:8443/APzhttps://ndax.iozhttps://apidoc.ndax.io/zhttps://ndax.io/feeszhttps://one.ndax.io/bfQiSL)logotestapiwwwdocfeesreferralgetActivate2FA   Authenticate2FAAuthenticateUserGetL2Snapshot	GetLevel1GetValidate2FARequiredEndpointsLogOutGetTickerHistory
GetProductGetProductsGetInstrumentGetInstrumentsPingtradesGetLastTradesSubscribeLevel1SubscribeLevel2)	SubscribeTickerSubscribeTradesSubscribeBlockTradesUnsubscribeBlockTradesUnsubscribeLevel1UnsubscribeLevel2UnsubscribeTickerUnsubscribeTradesAuthenticateGetUserAccountInfosGetUserAccountsGetUserAffiliateCountGetUserAffiliateTagGetUserConfig"GetAllUnredactedUserConfigsForUserGetUnredactedUserConfigByKeyGetUserDevicesGetUserReportTickets GetUserReportWriterResultRecordsGetAccountInfoGetAccountPositionsGetAllAccountConfigsGetTreasuryProductsForAccountGetAccountTradesGetAccountTransactionsGetOpenTradeReportsGetAllOpenTradeReportsGetTradesHistoryGetOpenOrdersGetOpenQuotesGetOrderFeeGetOrderHistoryGetOrdersHistoryGetOrderStatusGetOmsFeeTiersGetAccountDepositTransactionsGetAccountWithdrawTransactions!GetAllDepositRequestInfoTemplatesGetDepositInfoGetDepositRequestInfoTemplateGetDepositsGetDepositTicketGetDepositTickets)GetOMSWithdrawFeesGetWithdrawFeeGetWithdrawsGetWithdrawTemplateGetWithdrawTemplateTypesGetWithdrawTicketGetWithdrawTicketsAddUserAffiliateTagCancelUserReportRegisterNewDeviceSubscribeAccountEventsUpdateUserAffiliateTagGenerateTradeActivityReport!GenerateTransactionActivityReportGenerateTreasuryActivityReportScheduleTradeActivityReport!ScheduleTransactionActivityReportScheduleTreasuryActivityReportCancelAllOrdersCancelOrderCancelQuoteCancelReplaceOrderCreateQuoteModifyOrder)		SendOrderSubmitBlockTradeUpdateQuoteCancelWithdrawCreateDepositTicketCreateWithdrawTicketSubmitDepositTicketCommentSubmitWithdrawTicketCommentGetOrderHistoryByOrderId)r   post)lastmarkindex)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergd   i )r  limitdaysBack	untilDayssymbolRequired)r  triggerr%  r/  )r  r,  r0  r%  r/  )r  r,  r-  r.  r0  r%  r/  r,  )	r   r7   createOrdersri   rq   rn   rs   fetchClosedOrdersrj   )linearinverse)r)   r+   r,   tradingz0.002z0.0025)	tierBased
percentagemakertaker)apiKeysecretuidloginpassword)Not_Enough_FundszServer ErrorzResource Not Found)zInvalid InstrumentIdz5This endpoint requires 2FACode along with the payload)exactbroad                  )r   Limit
StopMarket	StopLimitTrailingStopMarketTrailingStopLimit
BlockTrade1234567)omsId
orderTypes)idname	countries	rateLimitprohas
timeframesurlsr   featuresr   requiredCredentialsprecisionMode
exceptionsoptions)deep_extendsuperr!   describeparse_numberr   r   r   r   r   r   )self	__class__s    C/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/ndax.pyrf  ndax.describe   s   dD : <kkk %k 	k
 %k %k Uk $Uk 'k k "4k tk $Uk  k 'k  t!k" (#k$ '%k& ('k( "4)k* T+k,  -k. !%/k0 1k2 &u3k4 "55k6 +E7k8 )%9k: #E;k< ,U=k> '?k@ (AkB "4CkD &tEkF (GkH 1%IkJ  KkL &uMkN 'OkP (QkR #ESkT *5UkV $UWkX uYkZ "5[k\ *5]k^ +E_k` )%akb tckd  ekf !%gkh %eikj $Ukkl &umkn -eokp /qkr "5skt #Eukv +Ewkx ykz !%{k| !%}k~ "5k@ &uAkB +ECkD  EkF dGkH $UIkJ +EKkL %eMkN "4OkP uQkR #ESkT dUkV !$WkX tYkZ #D[k\  ]k^ '_k` $Uakb !%ckd *5ekf (gkh %eikj )%kkl )%mkn tokp qkr Uskt tukv "5wkx #Eykz ({k| )%}k~ #Dk@ AkB #ECkD &uEkF 4GkH uIkJ UKkL  MkN $)! UkZ   LM
 << )- /8&  %q)1 +A (	
 $Q :1 !! +A %a &q ( )!  !! (  *1!" *1#$ ,-+,0123-.-.-.-.()5>*-q*)1* 0* .q	*
 (* =a* 7* )!* /* ;A* )!* .q* /* 8* +A*  1!!*" .q#*$ 1!%*& +A'*( ()** (+*, &q-*. *1/*0 +A1*2 )!3*4 )!5*6 87*8 9!9*: <Q;*< )!=*> 8?*@ &qA*B +AC*D ,QE*F /0*+()/045-../S*V-q*A ,Q 1!	
 1! 6q <Q 9! 6q <Q 9! *1 &q &q -a  &q!" &q#$ &',-'(*+/0016778455YH?hV  $&+(,,1$($)%*- */+06: $(#'"&#(	( #($)$)+027/4#'5$8 %)&+!$$*%+*/& ',#($)*/	# ',!%#($)*/( ',!%$(%)#($)*/$ *.#{@D ##
 ##MJX !&"&!..w7!..x8	  $ ' ):$1*7 -6M`
 "#!"*+)*"#Gv?
 v v	    c                 j   U R                  5         U R                  b  U R                  c  [        U R                  S-   5      eSS0nU R                  U R                  X!5      5      nU R                  US5      nUb  X@R                  S'   U$ U R                  US5      nUb  U R                  c  [        U R                  S-   5      eXPR                  S'   S	U R                  U R                  5      0nU R                  U R                  X!5      5      nU R                  US5      nX@R                  S'   U$ U$ )
z
sign in, must be called prior to using other authenticated methods

https://apidoc.ndax.io/#authenticate2fa

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns: response from exchange
z4 signIn() requires exchange.login, exchange.password
grant_typeclient_credentialsSessionTokensessionTokenPending2FaTokenz- signIn() requires exchange.twofa credentialspending2faTokenCode)check_required_credentialsr=  r>  r   rW  publicGetAuthenticateextendsafe_stringrc  twofatotppublicGetAuthenticate2FA)rh  paramsrequestresponserq  rs  responseInners          rj  sign_inndax.sign_in  s/    	'')::!6%dgg0f&fgg.
 --dkk'.JK ''.A#+7LL(O**85FG&zz!)$''4c*cdd.=LL*+		$**-G !99$++g:VWM  ++M>JL+7LL(  rl  c                    U R                  U R                  SS5      nSU0nU R                  U R                  X15      5      n0 n[	        S[        U5      5       H  nXF   nU R                  US5      nU R                  U R                  US5      5      n	U R                  US5      n
U
S:X  a  SOS	nU
S
:X  a  SnU R                  UU R                  US5      U	UU R                  US5      UU R                  US5      (       + U R                  US5      U R                  US5      SSSS.SSS.S.0 U R                  US5      S.5      XY'   M     U$ )z
fetches all available currencies on an exchange

https://apidoc.ndax.io/#getproduct

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
rU  r   r   	ProductIdProductProductTypeNationalCurrencyfiatcryptoUnknownotherProductFullNameTickSize
IsDisabledDepositEnabledWithdrawEnabledNminmax)amountr   MarginEnabled)rW  rX  codetype	precisioninfoactivedepositr   feelimitsnetworksr*   )safe_integerrc  publicGetGetProductsrw  rangelenrx  safe_currency_codesafe_currency_structuresafe_number	safe_bool)rh  r|  rU  r}  r~  resulticurrencyrW  r  r  r  s               rj  fetch_currenciesndax.fetch_currencies  ss    !!$,,;U
 ,,T[[-IJ( q#h-(A{H!!(K8B**4+;+;Hi+PQD**8]CK)-??6hDi'77((3DE!--h
C "nnX|DD>>(4DE NN85FG  $#
  $#!	 ..?C-9 FL )B rl  c                     U R                  U R                  SS5      nSU0nU R                  U R                  X15      5      nU R	                  U5      $ )z
retrieves data on all markets for ndax

https://apidoc.ndax.io/#getinstruments

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
rU  r   )r  rc  publicGetGetInstrumentsrw  parse_markets)rh  r|  rU  r}  r~  s        rj  fetch_marketsndax.fetch_markets  sW     !!$,,;U
 //G0LM^ !!(++rl  marketc                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U R                  US5      5      nU R                  U R                  US5      5      nU R                  US5      nU R                  US5      nUS:H  n	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    U(       + _SS_SS _S S S S S S U R                  US5      U R                  US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$ )%NInstrumentIdProduct1Product2Product1SymbolProduct2SymbolSessionStatus	IsDisableRunningrW  symbol/basequotesettlebaseIdquoteIdsettleIdr  r)   Tr*   Fr+   r,   r-   r  contractr3  QuantityIncrementPriceIncrement)r  pricer  MinimumQuantityMinimumPrice)r&  r  r  cost)
r4  contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr  )rx  r  
safe_valuer  )
rh  r  rW  r  r  r  r  sessionStatus	isDisablesessionRunnings
             rj  parse_marketndax.parse_marketE  s   fn5!!&*5""6:6&&t'7'7@P'QR''(8(8AQ(RS((AOOFK8	'940
"0
dSj5(0
 D0
 U	0

 d0
 f0
 w0
 0
 F0
 D0
 e0
 E0
 e0
 e0
 ~7i-0
  !0
" d#0
$  "**63FG))&2BC  
  ++F4EF
  ++FNC
  $ _0
 0	
rl  NpriceKey	amountKeycountOrIdKeyc	                 L   S n	U/ / S S S S.n
[        S[        U5      5       H  nX   nUc  U R                  US5      nOU R                  US5      n[        X=5      nU	c  U R                  US5      n	OU R                  US5      n[        X5      n	U R	                  XU5      nU R                  US5      nU(       a  UOUnU
U   nUR                  U5        M     U R                  U
S   SS5      U
S'   U R                  U
S   S5      U
S'   X:S'   U R                  U5      U
S	'   XS
'   U
$ )N)r  bidsasks	timestampdatetimenoncer   rB  	   r  Tr  r  r  r  )r  r  r  r  parse_bid_askappendsort_byiso8601)rh  	orderbookr  r  bidsKeyasksKeyr  r  r  r  r  r  levelnewTimestampnewNoncebidask	levelSideside
resultSides                      rj  parse_order_bookndax.parse_order_book  sD   
 q#i.)ALE  --eQ7	#00:	8	}))%3,,UA6E,''CF))%3I'7WDJf%! *" fVna>vfVna8v'{!\\)4zwrl  r  r,  c                     U R                  U R                  SS5      nU R                  5         U R                  U5      nUc  SOUnUUS   US.nU R	                  U R                  Xc5      5      nU R                  Xq5      $ )a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://apidoc.ndax.io/#getl2snapshot

: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
rU  r   r+  rW  )rU  r  Depth)r  rc  load_marketsr  publicGetGetL2Snapshotrw  r  )rh  r  r,  r|  rU  r  r}  r~  s           rj  fetch_order_bookndax.fetch_order_book  s     !!$,,;V$E"4L

 ..t{{7/KL. $$X66rl  tickerc                    U R                  US5      nU R                  US5      nU R                  XB5      nU R                  XB5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  US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U	_SU_SU_SS _SU_SU_SS _U
UUS.EU5      $ )N	TimeStampr  LastTradedPxRolling24HrPxChangePercentRolling24HrPxChangeSessionOpenRolling24HrVolumeRolling24HrNotionalr  r  r  highSessionHighlow
SessionLowbidBestBid	bidVolumeask	BestOffer	askVolumevwapopencloser  previousClosechanger7  average)
baseVolumequoteVolumer  )r  rx  safe_marketsafe_symbolsafe_tickerr  )rh  r  r  r  marketIdr  r  r7  r  r	  r  r  s               rj  parse_tickerndax.parse_ticker  s   B %%fk:	##FN;!!(3!!(37%%f.JK
!!&*?@6%%f.AB
&&v/DE !
f!
!
 Y/!
 D$$V];	!

 4##FL9!
 4##FI6!
 !
 4##FK8!
 !
 D!
 D!
 T!
 D!
 T!
 f!
  *!!
" t#!
$ %&)!
* + 	rl  c                     U R                  U R                  SS5      nU R                  5         U R                  U5      nUUS   S.nU R	                  U R                  XR5      5      nU R                  Xd5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://apidoc.ndax.io/#getlevel1

: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>`
rU  r   rW  rU  r  )r  rc  r  r  publicGetGetLevel1rw  r  )rh  r  r|  rU  r  r}  r~  s          rj  fetch_tickerndax.fetch_ticker  su     !!$,,;V$"4L
 **4;;w+GH>   22rl  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      /$ )Nr   rC  r   rB  rD  rE  )r  r  )rh  ohlcvr  s      rj  parse_ohlcvndax.parse_ohlcvD  sn     eQ'UA&UA&UA&UA&UA&
 	
rl  r   	timeframesincec                    U R                  U R                  SS5      nU R                  5         U R                  U5      nUUS   U R	                  U R
                  X"5      S.nU R                  U5      n	U R                  5       n
Uc4  Ub0  U R                  XU-  S-  -
  5      US'   U R                  U
5      US'   OUU R                  U5      US'   Uc  U R                  U
5      US'   O)U R                  U R                  X9U-  S-  5      5      US'   U R                  U R                  X5      5      nU R                  XX#U5      $ )a<  
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

https://apidoc.ndax.io/#gettickerhistory

: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
:returns int[][]: A list of candles ordered, open, high, low, close, volume
rU  r   rW  )rU  r  Intervalr'   FromDateToDate)r  rc  r  r  rx  r]  parse_timeframemillisecondsymdhmssumpublicGetGetTickerHistoryrw  parse_ohlcvs)rh  r  r  r   r,  r|  rU  r  r}  durationnowr~  s               rj  fetch_ohlcvndax.fetch_ohlcv[  s<    !!$,,;V$"4L(()O

 ''	2!= &*kk#58H48O2O&P
#$(KK$4!"&++e"4GJ}$(KK$4!$(KK5@PSW@W0X$Y!11$++g2NO   9UKKrl  tradec                    S nS nS nS nS nS nS n	S n
S nS nS n[        U[        5      (       a  U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R	                  US5      nU(       a  SOSn	U R                  US	5      n
OU R                  US
S5      nU R                  US5      nU R                  USS5      n
U R                  USS5      nU R                  US5      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	U R                  US5      nU R                  US5      nUb(  U R                  US5      nU R                  U5      nUUS.nU R                  X5      nU R                  UUUUU R                  U5      U
UU	UUUUUS.U5      $ )NrC  rB  rF  r   r      sellbuyrD  TradeTimeMSReceiveTimeTradeIdOrderIdOrigOrderIdr  
InstrumentPriceQuantityValueGrossValueExecuted
MakerTakerSider   FeeFeeProductId)r  r  )r  rW  r  r  r  orderr  r  takerOrMakerr  r  r  r  )
isinstancelistrx  r  r  safe_integer_2safe_string_2safe_string_lowerr  r  
safe_trader  )rh  r/  r  priceStringamountString
costStringr  rW  r  r  orderIdrC  r  r  	takerSidefeeCostStringfeeCurrencyIdfeeCurrencyCoder  s                      rj  parse_tradendax.parse_trade  s/   Z 
	eT""**5!4K++E15L))%3I!!%+B''q1Hq1I&6ED&&ua0G++E=-PI!!%3B((	=IG))%NH**5':K++E:>L++E7<PQJ11%FL))%8D))%=D ,,UE:M( $ 0 0 G"&"9"9-"H) / !!(3"Y/( " 
  	rl  c                     U R                  U R                  SS5      nU R                  5         U R                  U5      nUUS   S.nUb  X7S'   U R	                  U R                  Xt5      5      nU R                  XX#5      $ )a  
get the list of most recent trades for a particular symbol
: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>`
rU  r   rW  r  Count)r  rc  r  r  publicGetGetLastTradesrw  parse_trades)	rh  r  r   r,  r|  rU  r  r}  r~  s	            rj  fetch_tradesndax.fetch_trades+  s     !!$,,;V$"4L
 $G..t{{7/KL   5@@rl  c                    U R                   (       d  [        U R                  S-   5      eU R                  U R                  SS5      nU R                  5         UU R                  U R                   S.nU R                  U R                  X15      5      n/ n[        S[        U5      5       H*  nU R                  XF5      nUR                  USSUS.5        M,     U$ )a)  
fetch all the accounts associated with a profile

https://apidoc.ndax.io/#getuseraccounts

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
z9 fetchAccounts() requires exchange.login email credentialrU  r   )rU  UserIdUserNamer   N)rW  r  r  r  )r=  r   rW  r  rc  ru  r<  privateGetGetUserAccountsrw  r  r  rx  r  )rh  r|  rU  r}  r~  r  r  	accountIds           rj  fetch_accountsndax.fetch_accountsG  s     zz%dgg0k&kll!!$,,;'')hh



 11$++g2NO q#h-(A((5IMM !	  ) rl  c                 T   US S S.n[        S[        U5      5       Hy  nX   nU R                  US5      nXPR                  ;   d  M*  U R	                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      US'   XrU'   M{     U R                  U5      $ )N)r  r  r  r   r  AmounttotalHoldused)r  r  rx  currencies_by_idr  accountsafe_balance)rh  r~  r  r  balance
currencyIdr  rg  s           rj  parse_balancendax.parse_balanceh  s    

 q#h-(AkG))';?J222..z:,,.#'#3#3GX#F "&"2"27F"C&t )   ((rl  c                    U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS5      nU R	                  USSU5      nUc  [        U R                  S   S   5      nU R                  USS/5      nUUS.nU R                  U R                  XQ5      5      nU R                  U5      $ )a/  
query for balance and get the amount of funds available for trading or funds locked in orders

https://apidoc.ndax.io/#getaccountpositions

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
rU  r   r^  	AccountIdr   rW  rU  rn  )r  rc  r  load_accountsrF  intaccountsomitprivateGetGetAccountPositionsrw  rk  )rh  r|  rU  defaultAccountIdr^  r}  r~  s          rj  fetch_balancendax.fetch_balancey  s     !!$,,;..t||[+V''[JZ[	DMM!,T23I6K#=>"
 55dkk'6RS@ !!(++rl  c                 F    SSSSSSSSSSSSSS.nU R                  X!U5      $ )Nr/  transactionr   )r   DepositWithdrawTransfer	OrderHoldWithdrawHoldDepositHold
MarginHold
ManualHoldManualEntryMarginAcquisitionMarginRelinquishMarginQuoteHoldrx  )rh  r  typess      rj  parse_ledger_entry_typendax.parse_ledger_entry_type  sE    $%" )(!!"!( '&
 T22rl  itemr  c                    U R                  US5      nU R                  X25      nU R                  US5      nU R                  US5      nS nS n[        R                  " US5      (       a  UnSnO [        R                  " US5      (       a  UnSnS nU R                  US5      n	US:X  a  [        R                  " X5      nO1US:X  a+  [        R
                  " S[        R                  " X5      5      nU R                  US5      n
U R                  UU R                  US	5      UU R                  US
5      U R                  US5      U R                  US5      U R                  U R                  US5      5      U R                  X25      U R                  U5      U R                  U5      U R                  U	5      SU
U R                  U
5      S S.U5      $ )Nr  CRDR0inoutBalancer  TransactionIdrn  ReferenceIdCounterpartyReferenceTypeok)r  rW  	directionrg  referenceIdreferenceAccountr  r  r  beforeafterstatusr  r  r  )rx  safe_currencyr   	string_lt
string_add
string_max
string_subr  safe_ledger_entryr  r  rg  r  )rh  r  r  rj  creditdebitr  r  r  r  r  s              rj  parse_ledger_entryndax.parse_ledger_entry  s   " %%dK8
%%j;!!$-  t,	VS))FIuc**FI  y1''6F$''W-?-?-NOF%%dK8	%%""49"''k:++D-@ $ 0 0~ F001A1A$1XY//
E''/''/&&u-"Y/'
  ! 	rl  r  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nUUS.nUb  X8S	'   U R                  U R                  X5      5      n	Sn
Ub  U R                  U5      n
U R                  XX#5      $ )
a
  
fetch the history of changes, actions done by the user or operations that altered the balance of the user

https://apidoc.ndax.io/#getaccounttransactions

:param str [code]: unified currency code, default is None
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
:param int [limit]: max number of ledger entries to return, default is None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
rU  r   r^  rn  r   rW  ro  Nr  )r  rc  r  rp  rF  rq  rr  rs   privateGetGetAccountTransactionsrw  r  parse_ledger)rh  r  r   r,  r|  rU  ru  r^  r}  r~  r  s              rj  fetch_ledgerndax.fetch_ledger  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>"
 $G88W9UV& }}T*H  UBBrl  r  c                 8    SSSSSSS.nU R                  X!U5      $ )Nr	  rejectedcanceledexpiredclosed)AcceptedRejectedWorkingCanceledExpiredFullyExecutedr  )rh  r  statusess      rj  parse_order_statusndax.parse_order_status(  s0    "" %
 &99rl  rB  c                    U R                  US5      nU R                  US5      nU R                  0 SU R                  USS5      _SU R                  USS5      _S	U_S
U_SU R	                  U5      _SU R                  US5      _SU R                  U R                  US5      5      _SU R                  XB5      _SU R                  US5      _SS _SS _SU R                  US5      _SU R                  US5      _SU R                  U R                  U R                  US5      5      5      _SU R                  US5      _SU R                  US5      _SU R                  US 5      _U R                  US!5      S S S S".EU5      $ )#Nr5  r9  rW  ReplacementOrderIdr7  clientOrderIdReplacementClOrdIdClientOrderIdr  r  r  lastTradeTimestampLastUpdatedTimer  
OrderStater  r  r   r#  postOnlyr  r?  r  r:  r  	StopPricer  r=  r  OrigQuantityfilledQuantityExecutedAvgPrice)r  	remainingr  r   )
r  rx  
safe_orderrG  r  r  r  rH  rg  	omit_zero)rh  rB  r  r  r  s        rj  parse_orderndax.parse_order3  s   H %%e];	##E<8  
$$$U,@)L 
T//7K_] 
 E 
 	 

 Y/ 
 !$"3"3E;L"M 
 d--d.>.>ul.ST 
 d&&x8 
 D**5+> 
 4 
  
 D**5&9 
 T%%eW5 
 D--dnnT=M=MeU`=a.bc 
 D$$U,@A 
  d&&un=! 
" d&&u.@A# 
$ ''z:+ 
, - 	rl  r  r  r  r  c                 Z   U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      n	U R	                  USS5      n
U R                  U R                  S	   U R                  U5      5      nU R                  US
5      nUb  US:X  a  SnOUS:X  a  SnU R                  U/ SQ5      nU R                  U5      nUS:X  a  SOSn[        US   5      UU	SU[        U R                  X5      5      US.nUb  [        U R                  X5      5      US'   U
b  XS'   Ub  XS'   U R                  U R                  X5      5      nU R!                  UU5      $ )a  
create a trade order

https://apidoc.ndax.io/#sendorder

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:param float [params.triggerPrice]: the price at which a trigger order would be triggered
:param str [params.clientOrderId]: a unique id for the order
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rU  r   r^  rn  r   rW  r  r  rV  r  r  rC  r,  rD  )r^  rn  r  r  r  r3  )r  rU  rn  TimeInForcer?  r;  r   
LimitPricer  )r  rc  r  rp  rF  rq  rr  
capitalizerx  rs  r  floatamount_to_precisionprice_to_precisionprivatePostSendOrderrw  r  )rh  r  r  r  r  r  r|  rU  ru  r^  r  	orderTyper  r  	orderSider}  r~  s                    rj  create_orderndax.create_order  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	++FO_U%%dll<&@$//RVBWX	''?#x		6#opV$%-Aa	t-" d66vFG"
& $)$*A*A&*P$QGL!$'4O$##/K ,,T[[-IJ &11rl  rW  c                    U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      n	U R	                  USSU	5      n
U R	                  USS5      nU R                  U/ S	Q5      nU R                  U5      nUS
:X  a  SOSn[        U5      [        US   5      UU
SU[        U R                  X%5      5      U R                  U R                  S   U R                  U5      5      S.nUb  [        U R                  X&5      5      US'   Ub  XS'   U R                  U R                  X5      5      nU R                  X5      $ )NrU  r   r^  rn  r   rW  r  r  )r^  rn  r  r  r3  rV  )OrderIdToReplacer  rU  rn  r  r?  r;  r   r  )r  rc  r  rp  rF  rq  rr  rs  r  r  r  r  r  privatePostCancelReplaceOrderrw  r  )rh  rW  r  r  r  r  r  r|  rU  ru  r^  r  r  r  r}  r~  s                   rj  
edit_orderndax.edit_order  sw   !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	++FO_U6#_`V$%-Aa	 #Bt-" d66vFG**4<<+EtW[G\]
( $)$*A*A&*P$QGL!$'4O$55dkk'6RS 11rl  c           	      &   U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nUUS.nSn	Ub  U R                  U5      n	U	S   US	'   Ub  U R                  US
-  5      US'   Ub  X8S'   U R                  U R                  X5      5      n
U R                  XX#5      $ )a  
fetch all trades made by the user

https://apidoc.ndax.io/#gettradeshistory

:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
rU  r   r^  rn  r   rW  ro  Nr  r'   StartTimeStampr  )r  rc  r  rp  rF  rq  rr  rs  r  parse_to_intprivateGetGetTradesHistoryrw  rW  rh  r  r   r,  r|  rU  ru  r^  r}  r  r~  s              rj  fetch_my_tradesndax.fetch_my_trades  s'    !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>"
 [[(F&,TlGN#(,(9(9%$,(GG$%$G224;;w3OPX   5@@rl  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nUUS.nUb  U R                  U5      nUS   US'   U R                  U R                  Xb5      5      nU R                  S	U05      /$ )
ad  
cancel all open orders

https://apidoc.ndax.io/#cancelallorders

:param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
rU  r   r^  rn  r   rW  ro  IntrumentIdr  )r  rc  r  rp  rF  rq  rr  rs  r  privatePostCancelAllOrdersrw  r  )	rh  r  r|  rU  ru  r^  r}  r  r~  s	            rj  cancel_all_ordersndax.cancel_all_ordersV  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>"
 [[(F%+D\GM"224;;w3OP OO 
 	
rl  c                    U R                  U R                  SS5      nU R                  5         U R                  5         SnUb  U R	                  U5      nSU0nU R                  USS5      nUb  XvS'   O[        U5      US'   U R                  USS/5      nU R                  U R                  Xc5      5      nU R                  X5      n	U R                  U	UUS.5      $ )aw  
cancels an open order

https://apidoc.ndax.io/#cancelorder

: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
:param str [params.clientOrderId]: a unique id for the order
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rU  r   Nr  	ClOrderIdr7  )rW  r  )r  rc  r  rp  r  rF  rq  rs  privatePostCancelOrderrw  r  )
rh  rW  r  r|  rU  r  r}  r  r~  rB  s
             rj  cancel_orderndax.cancel_order|  s     !!$,,; [[(FU
 ++FO[Q$#0K !$RGI6O[#AB..t{{7/KL  2{{5*#
  	rl  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nSnUb  U R                  U5      nUUS.n	U R                  U R                  X5      5      n
U R                  XX#5      $ )	a  
fetch all unfilled currently open orders

https://apidoc.ndax.io/#getopenorders

: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>`
rU  r   r^  rn  r   rW  Nro  )r  rc  r  rp  rF  rq  rr  rs  r  privateGetGetOpenOrdersrw  parse_orders)rh  r  r   r,  r|  rU  ru  r^  r  r}  r~  s              rj  fetch_open_ordersndax.fetch_open_orders  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>[[(F"
 //G0LMf   5@@rl  c           	      &   U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nUUS.nSn	Ub  U R                  U5      n	U	S   US	'   Ub  U R                  US
-  5      US'   Ub  X8S'   U R                  U R                  X5      5      n
U R                  XX#5      $ )a  
fetches information on multiple orders made by the user

https://apidoc.ndax.io/#getorderhistory

: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>`
rU  r   r^  rn  r   rW  ro  Nr  r'   r  r  )r  rc  r  rp  rF  rq  rr  rs  r  r  privateGetGetOrdersHistoryrw  r  r  s              rj  fetch_ordersndax.fetch_orders  s'    !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>"
 [[(F&,TlGN#(,(9(9%$,(GG$%$G224;;w3OPf   5@@rl  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nSnUb  U R                  U5      nUU[        U5      S.nU R                  U R                  X5      5      n	U R                  X5      $ )	aX  
fetches information on an order made by the user

https://apidoc.ndax.io/#getorderstatus

: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>`
rU  r   r^  rn  r   rW  N)rU  rn  r7  )r  rc  r  rp  rF  rq  rr  rs  r  privateGetGetOrderStatusrw  r  )
rh  rW  r  r|  rU  ru  r^  r  r}  r~  s
             rj  fetch_orderndax.fetch_orderL  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>[[(F"2w

 00W1MNb 11rl  c                    U R                  U R                  SS5      nU R                  5         U R                  5         SnUb  U R	                  U5      nU R                  U5      [        U5      S.nU R                  U R                  X5      5      n	U R                  U	S5      n
U R                  U
S/ 5      nU R                  XX45      $ )a  
fetch all the trades made from a single order

https://apidoc.ndax.io/#getorderhistorybyorderid

:param str id: order id
:param str symbol: unified market symbol
:param int [since]: the earliest time in ms to fetch trades for
:param int [limit]: the maximum number of trades to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
rU  r   N)OMSIdr7  ChangeReasonr   )r  rc  r  rp  r  r  rq  #privatePostGetOrderHistoryByOrderIdrw  group_by	safe_listrW  )rh  rW  r  r   r,  r|  rU  r  r}  r~  groupedr   s               rj  fetch_order_tradesndax.fetch_order_trades  s     !!$,,; [[(F&&u-2w

 ;;DKK<XYf --.9"5  >>rl  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nU R                  U5      nUUUS   SS.nU R                  U R                  Xr5      5      nU R                  X5      $ )	a  
fetch the deposit address for a currency associated with self account
:param str code: unified currency code
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
rU  r   r^  rn  r   rW  F)rU  rn  r  GenerateNewKey)r  rc  r  rp  rF  rq  rr  rs  r  privateGetGetDepositInforw  parse_deposit_address)	rh  r  r|  rU  ru  r^  r  r}  r~  s	            rj  fetch_deposit_addressndax.fetch_deposit_address  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>==&"!$#	
 00W1MN ))(==rl  c                 @   U R                  US5      n[        R                  " U5      n[        U5      nU R                  XES-
  5      nUR	                  S5      nU R                  US5      nU R                  US5      n	S n
Ub  US   n
U R                  U5        UU
S UU	S.$ )NDepositInfor   z?memo=r   r  )r  r  networkaddresstag)rx  jsonloadsr  splitcheck_address)rh  depositAddressr  depositInfoStringdepositInfodepositInfoLength
lastStringpartsr  r  r  s              rj  r  ndax.parse_deposit_address  s     !,,^]Kjj!23,%%kq3HI
  *""5!,ua(F#D7#"
 	
rl  c                 J    SS0nU R                  XR                  X25      5      $ )a  
create a currency deposit address
:param str code: unified currency code of the currency for the deposit address
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
r  T)r	  rw  )rh  r  r|  r}  s       rj  create_deposit_addressndax.create_deposit_address/  s,     d
 ))$G0LMMrl  c           	      L   U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nSnUb  U R                  U5      nUUS.n	U R                  U R                  X5      5      n
[        U
[        5      (       a'  U R                  [        R                  " U
5      XU5      $ U R                  XX#5      $ )	a  
fetch all deposits made to an account

https://apidoc.ndax.io/#getdeposits

:param str code: unified currency code
:param int [since]: not used by ndax fetchDeposits
:param int [limit]: the maximum number of deposits structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
rU  r   r^  rn  r   rW  Nro  )r  rc  r  rp  rF  rq  rr  rs  r  privateGetGetDepositsrw  rD  strparse_transactionsr  r  rh  r  r   r,  r|  rU  ru  r^  r  r}  r~  s              rj  fetch_depositsndax.fetch_deposits;  s    !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>}}T*H"
 --dkk'.JK: h$$**4::h+?RWXX&&x5HHrl  c           	         U R                  U R                  SS5      nU R                  5         U R                  5         U R	                  U R                  SS[        U R                  S   S   5      5      nU R	                  USSU5      nU R                  USS/5      nSnUb  U R                  U5      nUUS.n	U R                  U R                  X5      5      n
U R                  XX#5      $ )	a  
fetch all withdrawals made from an account

https://apidoc.ndax.io/#getwithdraws

:param str code: unified currency code
:param int [since]: the earliest time in ms to fetch withdrawals for
:param int [limit]: the maximum number of withdrawals structures to retrieve
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
rU  r   r^  rn  r   rW  Nro  )r  rc  r  rp  rF  rq  rr  rs  r  privateGetGetWithdrawsrw  r!  r"  s              rj  fetch_withdrawalsndax.fetch_withdrawalsu  s     !!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>}}T*H"
 ..t{{7/KL2 &&x5HHrl  c                     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_SSSSSSS.ES.nU R                  X20 5      nU R                  XAU5      $ )Npendingr  r  failed)NewAdminProcessingr  r  SystemProcessingFullyProcessedFailedPending	ConfirmedAmlProcessingAmlAcceptedAmlRejected	AmlFailedLimitsAcceptedLimitsRejectedr,  r-  r  r  r.  r/  r0  r1  
Pending2FaAutoAcceptedDelayedUserCanceledr  AdminCanceledr3  r4  r5  r6  )r7  r8  	Submittedr2  ManuallyConfirmedConfirmed2Fa)r  
withdrawal)r  rx  )rh  r  r  statusesByTyper  s        rj   parse_transaction_status_by_type%ndax.parse_transaction_status_by_type  sI    !#,%&$-"&"$&!*()%"+","y!9 I J	
 #I !$ ( 9 i 	 9 
     y  z!" X#$ #,",&&%. )/%+ 
X ??><&99rl  ry  c                    S nU R                  US5      nU R                  XB5      nS nSU;   a  U R                  US5      nSnOSU;   a  U R                  US5      nSnU R                  U R                  USS5      5      nU R	                  US5      nUb  U R	                  US	U5      nU R                  US
S5      n	U R	                  US5      n
U R                  US5      nU R                  US5      nS nUb  X[S.n0 SU_SU_SU R                  USS5      _SU
_SU R                  U
5      _SU	_SU	_SU R                  US5      _SS _SS _SS _SU_SU R                  US 5      _S!U_S"U R                  X5      _S#U_S$U_S S S S%.E$ )&Nr  	DepositIdr  
WithdrawIdrA  TemplateFormr  LastUpdateTimeStampLastUpdatedExternalAddress	ToAddressTimeSubmitted	FeeAmountTicketStatus)r  r  r  rW  txidTxIdTXIdr  r  r  	addressToaddressFromFromAddressr  tagTotagFromr  r  rb  r  r  updatedr  )internalcommentr  )	rx  r  
parse_jsonsafe_value_2r  rG  r  r  rC  )rh  ry  r  rW  rj  r  r  templateFormrX  r  r  feeCosttransactionStatusr  s                 rj  parse_transactionndax.parse_transaction  s9   f %%k;?
&&z<+%!!+{;BD[(!!+|<BDt'8'8nVc'de##K1FG#''mWMG$$\3DkR%%lOD	"";< ,,[.I#5C
K
"
 D&&|VVD
 	

 Y/
 w
 
 4++L-H
 4
 T
 t
 D
 d&&{H=
 
 d;;<MT
  w!
" 3#
$ )
 	
rl  r  r  c           	      ,   U R                  XE5      u  pEU R                  U R                  S5      nUc  [        U R                  S-   5      eU R
                  c  [        U R                  S-   5      eU R                  U5        U R                  U R                  SS5      nU R                  5         U R                  5         U R                  U R                  SS[        U R                  S   S	   5      5      nU R                  USSU5      n	U R                  USS/5      nU R                  U5      n
UU	U
S	   S
.nU R                  U5      nU R!                  US/ 5      nU R!                  US5      nUc  [#        U R                  S-   U
S   -   5      eU R                  US5      nUU	U
S	   UUS   S.nU R%                  U5      nU R                  US5      nUc  [#        U R                  S-   U
S   -   5      e[&        R(                  " U5      nUUS'   Ub  SU;   a  UUS'   UU	U
S	   U R'                  U5      US.nSU R+                  U R
                  5      U R'                  U5      S.nU R-                  U R/                  UU5      5      nU R1                  UU
5      $ )aO  
make a withdrawal
:param str code: unified currency code
:param float amount: the amount to withdraw
:param str address: the address to withdraw to
:param str tag:
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
rq  z/ call signIn() method to obtain a session tokenz/ withdraw() requires exchange.twofa credentialsrU  r   r^  rn  r   rW  )rU  rn  r  TemplateTypesz8 withdraw() could not find a withdraw template type for r  TemplateNameAccountProviderId)rU  rn  r  TemplateTypere  Templatez3 withdraw() could not find a withdraw template for rK  Memo)rU  rn  r  rH  rf  Google)TfaTypeTFaCodePayload)handle_withdraw_tag_and_paramsrx  rc  r   rW  ry  r  r  r  rp  rF  rq  rr  rs  r  "privateGetGetWithdrawTemplateTypesr  r   privateGetGetWithdrawTemplater  r  rz  privatePostCreateWithdrawTicketrd  r`  )rh  r  r  r  r  r|  rq  rU  ru  r^  r  withdrawTemplateTypesRequestwithdrawTemplateTypesResponsetemplateTypesfirstTemplateTypetemplateNamewithdrawTemplateRequestwithdrawTemplateResponsetemplatewithdrawTemplatewithdrawPayloadwithdrawRequestr~  s                          rj  r   ndax.withdraw8	  s    99#F''nE%dgg0a&abb::%dgg0a&abb7#!!$,,;..t||[+WZ[_[h[hij[klp[qWrs''[JZ[	6K#=>==&"!$.
$
 )-(O(OPl(m% (EXZ[ OOM1=$*d dgopvgw wxx''(9>J"!$(!23F!G)
 $(#E#EF]#^  ##$<jI*_ _bjkqbr rss::h/.5*+?))+. ("!$ II&67(!
  yy,yy1!

 778H8HZ`8ab%%h99rl  c                 "    U R                  5       $ N)r&  )rh  s    rj  r  
ndax.nonce	  s      ""rl  r   GETc                    U R                   S   U   S-   U R                  X5      -   nU R                  X@R                  U5      5      nUS:X  a  US:X  a5  U R                  S-   U R
                  -   n	U R                  U	5      n
SSU
-   0nO;US:X  a5  U R                  U R                  S	5      nUb  S
U0nU R                  US	5      nU(       a  USU R                  U5      -   -  nGOUS:X  Ga  U R                  5         U R                  U R                  S5      nUc  [        U R                  5       5      nXR                  -   U R                  -   n	U R                  U R!                  U	5      U R!                  U R"                  5      [$        R&                  5      nUU R                  UU R                  S.nOSU0nUS:X  a  SUS'   U R)                  U5      nOU(       a  USU R                  U5      -   -  nXsXeS.$ )Nr   r  r   r   :AuthorizationzBasic r   rs  rr  ?r   rq  )NonceAPIKey	Signaturer[  APTokenPOSTzapplication/jsonzContent-Type)urlmethodbodyheaders)r^  implode_paramsrs  extract_paramsr=  r>  string_to_base64rx  rc  	urlencoderu  r   r  r<  r:  hmacencoder;  hashlibsha256r  )rh  pathr   r  r|  r  r  r  queryauthauth64rs  rq  r  	signatures                  rj  sign	ndax.sign	  s   iis#c)D,?,?,MM		&"5"5d";<(?~%zzC'$--7..t4#X%6 **"&"2"24<<AR"S".)?G !IIe->?EsT^^E222I++-++DLL.IL#DJJL)xx'$++5 IIdkk$&7T[[9QSZSaSab	""kk!*"hh	 | *<'yy'3!666CdOOrl  reasonr  r  r  r  c
                 :   US:X  a  [        U R                  S-   U-   5      eUc  g U R                  US5      n
U
ba  U
S:w  a[  U R                  S-   U-   nU R                  U R                  S   X5        U R                  U R                  S   Xk5        [        U5      eg )Ni   errormsg r@  rA  )r   rW  rx  throw_exactly_matched_exceptionrb  throw_broadly_matched_exceptionr   )rh  r  r  r  r  r  r  r~  requestHeadersrequestBodymessagefeedbacks               rj  handle_errorsndax.handle_errors	  s    3;%dggmd&:;;
 ""8Z8gmww}t+H001I7]001I4Z))rl   )Nr  r  rF  r1  rB  r~  )H__name__
__module____qualname____firstlineno__r   rf  r  r   r  r   r   r  dictr  r   r  r   r   r   r  r   r  r  rE  r  r-  r   rR  rX  r   r_  r   rk  rv  r  r	   r   r  r   r  r  r   r  r   r   r  r   r  r  r  r  r  r  r  r  r  r
   r	  r  r  r   r#  r'  rC  r`  r   r  r  rq  r  __static_attributes____classcell__)ri  s   @rj  r!   r!      s^   w# wr   0d ') CZ CJ $& <,$v, <,|:
4 :
F :
x lu    GP    dm  D :>b +7s +73 +7Y +7Z@4 @ @6 @D 02 033 03f 03d
 
4 
. 9=4^bkm )L# )L# )LS )LX[ )Lrvw{r| )LVc cv c cJ 6:UW A3 As A# A\`af\g A8 %' 4= B) )" $& 5,( 5,n3$4t 4x 4; 4l (,$TZ\ .C .CC .Cs .Caefqar .C`	: 	:\ \v \ \| gksu A23 A2i A2y A2RW A2`c A2F `drv  @B +2S +2# +2Y +2i +2Y\ +2lo +2Z -1tRV_a SAc SA SAC SAj /32 $
 $
L 37r $s $C $L /3TXac LA LA3 LAc LAhlmrhs LA\ *.Dt\^ ZA3 ZAc ZA ZAcghmcn ZAx 26b J2c J23 J2X 9=4^bkm P?S P?# P?S P?X[ P?d 79 !># !>^ !>F 
h  
R`  
D 8: 
N3 
Nn 
N *.Dt\^ 8I3 8Ic 8I 8Icghsct 8It -1tRV_a 2Ic 2I 2IC 2Ifjkvfw 2Ih.:`]
T ]
X ]
Q\ ]
~ KOWY U:S U:% U:# U:C U:^i U:n# &eBSW ,P\# s  c TX `c  rl  r!   )'ccxt.base.exchanger   ccxt.abstract.ndaxr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!   r  rl  rj  <module>r     s_    ( *   L  L  L  L  L  L  * 0 & . * 4 %z&8[ z&rl  