
    ei                        d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lm Z  d d
lm!Z! d dl"m#Z# d dl$m%Z%  G d dee          Z&dS )    )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                        e Zd Zdef fdZi fdZi fdefdZi fdee	         fdZ
dede	fdZdPdededefdZdi fdededefdZdQdede	defdZi fdedefdZdQde	defdZdddi fdededededee         f
dZdQdede	defdZddi fdedededee         fdZi fdee         fd Zdefd!Zi fdefd"Z d# Z!dQd$ed%e"de#fd&Z$dddi fd'e%dededee#         fd(Z&d)e%fd*Z'dQd+ede	de(fd,Z)di fded-e*d.e+d/e,d0e-f
d1Z.ddi fd2eded-e*d.e+d/e-d0e-fd3Z/dddi fde%dedefd4Z0di fde%fd5Z1di fd2ede%fd6Z2dddi fde%dededee(         fd7Z3dddi fde%dededee(         fd8Z4di fd2ede%fd9Z5dddi fd2ede%dedefd:Z6i fd'ede7fd;Z8dQd%e"de7fd<Z9i fd'ede7fd=Z:dddi fd'e%dededee;         fd>Z<dddi fd'e%dededee;         fd?Z=dQd@Z>dQdAed%e"de;fdBZ?di fd'ed/e,dCedDe%de;f
dEZ@dF ZAdGdHi ddfdIZBd'eCdJedKedLedMedNefdOZD xZES )Rndaxreturnc           !         |                      t          t          |                                           dddgddi dd dddd	d
d	dd	dd	dd	dd	dd	dd	dddddd	dd	dddddd	i dddddddddddd	dddd	d d	d!d	d"d	d#d	d$d	d%d	d&d	d'dd(di d)d	d*d	d+dd,d	d-d	d.d	d/d	d0d	d1d	d2d	d3d	d4d	d5d	d6d	d7dd8d	d9d	i d:d	d;d	d<d	d=d	d>d	d?d	d@d	dAd	dBddCd	dDd	dEd	dFd	dGd	dHddIddJd	i dKd	dLd	dMddNd	dOd	dPddQddRddSddTd	dUd	dVd	dWd	dXd	dYd	dZd	d[d	i d\d	d]dd^d	d_d	d`ddad	dbd	dcd	ddd	deddfd	dgd	dhd	diddjd	dkd	dld	d	dd	ddmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d}d~ddd~ddgddddi dddddddddddddddddddddddddddddddddddddddddddd	ii ddddddddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddddddddddi dddddddddddddddddddddddddddddddddddddddddddd͜	dΜd~dd	dd	dd	d	dϜd	d	d dddd	dМd	d	d	d	d	d	ddќd d	dddd	dԜd	d	d	d	d՜d	d d	d	d	d֜d	d d d d	d	d	dלd dd idٜ	d d dڜd d dڜdۜdd	d|                     dݦ          |                     dަ          dߜiddddddt
          t          t          t          dt          t          dddddddddddddddddddd          S )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+  r/  r$  r.  )r  r+  r,  r-  r/  r$  r.  r+  )	r   r6   createOrdersrh   rp   rm   rr   fetchClosedOrdersri   )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    G/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/ndax.pyre  zndax.describe   s   dD 1 1 : : < <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& ('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 k 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 k 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 k 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 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 kN $)! Uk k 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?h hV  $&+(,,1$($)%*- - */+06: $(#'"&#(	( ( #($)$)+027/4#'5$ $8 %)&+!$$*%+*/& & ',#($)*/	# # ',!%#($)*/( ( ',!%$(%)#($)*/$ $ *.#{@ @D ## 
 ## MJ JX !&"&!..w77!..x88	   $ $ ' ):$1*7  -6M` 
 
 "#!"*+)*"#  Gv?
 v?
 v v v	    c                 h   |                                   | j        | j        t          | j        dz             ddi}|                     |                     ||                    }|                     |d          }||| j        d<   |S |                     |d          }|| j	        t          | j        dz             || j        d	<   d
| 
                    | j	                  i}|                     |                     ||                    }|                     |d          }|| j        d<   |S |S )a  
        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
        Nz4 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   rV  publicGetAuthenticateextendsafe_stringrb  twofatotppublicGetAuthenticate2FA)rg  paramsrequestresponsero  rq  responseInners          ri  sign_inzndax.sign_in  sK    	''))):!6%dg0f&fggg.
 --dkk'6.J.JKK ''.AA#+7DL(O**85FGG&z!)$'4c*cddd.=DL*+		$*--G !99$++gv:V:VWWM  ++M>JJL+7DL(  rj  c                    |                      | j        dd          }d|i}|                     |                     ||                    }i }t	          dt          |                    D ]}||         }|                     |d          }|                     |                     |d                    }	|                     |d          }
|
dk    rdnd	}|
d
k    rd}|                     ||                     |d          |	|| 	                    |d          || 
                    |d           | 
                    |d          | 
                    |d          ddddddddi | 
                    |d          d          ||	<   |S )a  
        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
        rT  r   r   	ProductIdProductProductTypeNationalCurrencyfiatcryptoUnknownotherProductFullNameTickSize
IsDisabledDepositEnabledWithdrawEnabledNminmax)amountr   MarginEnabled)rV  rW  codetype	precisioninfoactivedepositr   feelimitsnetworksr)   )safe_integerrb  publicGetGetProductsru  rangelenrv  safe_currency_codesafe_currency_structuresafe_number	safe_bool)rg  rz  rT  r{  r|  resulticurrencyrV  r  r  r  s               ri  fetch_currencieszndax.fetch_currencies  s    !!$,;;U
 ,,T[[&-I-IJJ( q#h--((  	  	A{H!!(K88B**4+;+;Hi+P+PQQD**8]CCK)-???66hDi''77((3DEE!--h
CC "nnX|DDD>>(4DEE NN85FGG  $# 
  $#! !	 	 ..?CC-9 9  F4LL0 rj  c                     |                      | j        dd          }d|i}|                     |                     ||                    }|                     |          S )a  
        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
        rT  r   )r  rb  publicGetGetInstrumentsru  parse_markets)rg  rz  rT  r{  r|  s        ri  fetch_marketszndax.fetch_markets  sc     !!$,;;U
 //GV0L0LMM^ !!(+++rj  marketc                    |                      |d          }|                      |d          }|                      |d          }|                     |                      |d                    }|                     |                      |d                    }|                      |d          }|                     |d          }|dk    }	i d	|d
|dz   |z   d|d|dd d|d|dd ddddddddddddd|	o| dddd d d d d d d |                     |d          |                     |d          dd d d |                     |d!          d d |                     |d"          d d d d d d#d |d$
S )%NInstrumentIdProduct1Product2Product1SymbolProduct2SymbolSessionStatus	IsDisableRunningrV  symbol/basequotesettlebaseIdquoteIdsettleIdr  r(   Tr)   Fr*   r+   r,   r  contractr2  QuantityIncrementPriceIncrement)r  pricer  MinimumQuantityMinimumPrice)r%  r  r  cost)
r3  contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr  )rv  r  
safe_valuer  )
rg  r  rV  r  r  r  r  sessionStatus	isDisablesessionRunnings
             ri  parse_marketzndax.parse_marketE  sn   fn55!!&*55""6:66&&t'7'7@P'Q'QRR''(8(8AQ(R(RSS((AAOOFK8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G))&2BCC    
  ++F4EFF 
  ++FNCC 
    $ _0
 0
 0
 0	
rj  NbidsasksrE     rA  priceKey	amountKeycountOrIdKeyc	                    d }	|g g d d d d}
t          dt          |                    D ]}||         }||                     |d          }n&|                     |d          }t          ||          }|	|                     |d          }	n&|                     |d          }t          |	|          }	|                     |||          }|                     |d          }|r|n|}|
|         }|                    |           |                     |
d         dd          |
d<   |                     |
d         d          |
d<   ||
d<   |                     |          |
d	<   |	|
d
<   |
S )N)r  r  r  	timestampdatetimenoncer   rA  	   r  Tr  r  r  r  )r  r  r  r  parse_bid_askappendsort_byiso8601)rg  	orderbookr  r  bidsKeyasksKeyr  r  r  r  r  r  levelnewTimestampnewNoncebidask	levelSideside
resultSides                      ri  parse_order_bookzndax.parse_order_book  s   
 
 q#i..)) 	& 	&AaLE  --eQ77		#00::	<88	}))%33,,UA66E8,,''xCCF))%33I'477WDJf%%%%fVna>>vfVna88v'{!\\)44zwrj  r  r+  c                 .   |                      | j        dd          }|                                  |                     |          }|dn|}||d         |d}|                     |                     ||                    }|                     ||          S )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
        rT  r   Nr*  rV  )rT  r  Depth)r  rb  load_marketsr  publicGetGetL2Snapshotru  r  )rg  r  r+  rz  rT  r  r{  r|  s           ri  fetch_order_bookzndax.fetch_order_book  s     !!$,;;V$$E"4L
 

 ..t{{7F/K/KLL. $$Xv666rj  tickerc                    |                      |d          }|                     |d          }|                     ||          }|                     ||          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }	|                     |d          }
|                     |d          }|                     i d	|d
|d|                     |          d|                     |d          d|                     |d          d|                     |d          dd d|                     |d          dd dd d|	d|d|dd d|d|dd |
||d|          S )N	TimeStampr  LastTradedPxRolling24HrPxChangePercentRolling24HrPxChangeSessionOpenRolling24HrVolumeRolling24HrNotionalr  r  r  highSessionHighlow
SessionLowbidBestBid	bidVolumeask	BestOffer	askVolumevwapopencloser  previousClosechanger6  average)
baseVolumequoteVolumer  )r  rv  safe_marketsafe_symbolsafe_tickerr  )rg  r  r  r  marketIdr  r  r6  r  r  r  r  s               ri  parse_tickerzndax.parse_ticker  s+   B %%fk::	##FN;;!!(F33!!(F3377%%f.JKK
!!&*?@@66%%f.ABB
&&v/DEE !
f!
!
 Y//!
 D$$V];;	!

 4##FL99!
 4##FI66!
 !
 4##FK88!
 !
 D!
 D!
 T!
 D!
 T!
 f!
  *!!
" t#!
$ %&)!
 !
 !
* +  	rj  c                     |                      | j        dd          }|                                  |                     |          }||d         d}|                     |                     ||                    }|                     ||          S )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>`
        rT  r   rV  rT  r  )r  rb  r  r  publicGetGetLevel1ru  r  )rg  r  rz  rT  r  r{  r|  s          ri  fetch_tickerzndax.fetch_ticker  s     !!$,;;V$$"4L
 
 **4;;w+G+GHH>   6222rj  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr   rB  r   rA  rC  rD  )r  r  )rg  ohlcvr  s      ri  parse_ohlcvzndax.parse_ohlcvD  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
rj  r   	timeframesincec                    |                      | j        dd          }|                                  |                     |          }||d         |                     | j        ||          d}|                     |          }	|                                 }
|<|9|                     |
|	|z  dz  z
            |d<   |                     |
          |d<   ne|                     |          |d<   ||                     |
          |d<   n2|                     | 	                    ||	|z  dz                      |d<   | 
                    |                     ||                    }|                     |||||          S )	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
        rT  r   rV  )rT  r  IntervalNr&   FromDateToDate)r  rb  r  r  rv  r\  parse_timeframemillisecondsymdhmssumpublicGetGetTickerHistoryru  parse_ohlcvs)rg  r  r  r  r+  rz  rT  r  r{  durationnowr|  s               ri  fetch_ohlcvzndax.fetch_ohlcv[  s|    !!$,;;V$$"4L(()YOO
 

 ''	22!!= &*kk#58H48O2O&P&P
#$(KK$4$4!"&++e"4"4GJ}$(KK$4$4!!$(KK5@PSW@W0X0X$Y$Y!11$++gv2N2NOO   69eUKKKrj  tradec                    d }d }d }d }d }d }d }	d }
d }d }d }t          |t                    r|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|rdnd}	|                     |d	          }
n(|                     |d
d          }|                     |d          }|                     |dd          }
|                     |dd          }|                     |d          }|                     |d          }|                     |dd          }|                     |d          }|                     |d          }	|                     |d          }|                     |d          }|0|                     |d          }|                     |          }||d}| 	                    ||          }| 
                    |||||                     |          |
||	|||||d|          S )NrB  rA  rE  r   r   r  sellbuyrC  TradeTimeMSReceiveTimeTradeIdOrderIdOrigOrderIdr  
InstrumentPriceQuantityValueGrossValueExecuted
MakerTakerSider   FeeFeeProductId)r  r  )r  rV  r  r  r  orderr  r  takerOrMakerr  r  r  r  )
isinstancelistrv  r  r  safe_integer_2safe_string_2safe_string_lowerr  r
  
safe_trader  )rg  r$  r  priceStringamountString
costStringr  rV  r  r  orderIdr7  r  r  	takerSidefeeCostStringfeeCurrencyIdfeeCurrencyCoder  s                      ri  parse_tradezndax.parse_trade  s   Z 
	eT"" 	**5!44K++E155L))%33I!!%++B''q11Hq11I&166ED&&ua00GG++E=-PPI!!%33B((	=IIG))%NNH**5'::K++E:>>L++E7<PQQJ11%FFL))%88D))%==D ,,UE::M( $ 0 0 G G"&"9"9-"H"H) /  !!(F33"Y//( " 
  
   	rj  c                 2   |                      | j        dd          }|                                  |                     |          }||d         d}|||d<   |                     |                     ||                    }|                     ||||          S )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>`
        rT  r   rV  r  NCount)r  rb  r  r  publicGetGetLastTradesru  parse_trades)	rg  r  r  r+  rz  rT  r  r{  r|  s	            ri  fetch_tradeszndax.fetch_trades+  s     !!$,;;V$$"4L
 
 $GG..t{{7F/K/KLL   65%@@@rj  c                    | j         st          | j        dz             |                     | j        dd          }|                                  || j        | j         d}|                     |                     ||                    }g }t          dt          |                    D ]2}|                     ||          }|                    |dd|d           3|S )aO  
        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 credentialrT  r   )rT  UserIdUserNamer   N)rV  r  r  r  )r<  r   rV  r  rb  rs  r;  privateGetGetUserAccountsru  r  r  rv  r  )rg  rz  rT  r{  r|  r  r  	accountIds           ri  fetch_accountszndax.fetch_accountsG  s     z 	m%dg0k&klll!!$,;;'')))h

 

 11$++gv2N2NOO q#h--(( 	 	A((155IMM !	      rj  c                    |d d d}t          dt          |                    D ]}||         }|                     |d          }|| j        v r`|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |||<   |                     |          S )N)r  r  r  r   r  AmounttotalHoldused)r  r  rv  currencies_by_idr  accountsafe_balance)rg  r|  r  r  balance
currencyIdr  rX  s           ri  parse_balancezndax.parse_balanceh  s    
 

 q#h--(( 	' 	'AqkG))';??JT222..z::,,..#'#3#3GX#F#F "&"2"27F"C"C&t  (((rj  c                    |                      | j        dd          }|                                  |                                  |                     | j        dd          }|                     |dd|          }| t          | j        d         d                   }|                     |ddg          }||d}|                     | 	                    ||                    }| 
                    |          S )	aU  
        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>`
        rT  r   rP  	AccountIdNr   rV  rT  r^  )r  rb  r  load_accountsr:  intaccountsomitprivateGetGetAccountPositionsru  r\  )rg  rz  rT  defaultAccountIdrP  r{  r|  s          ri  fetch_balancezndax.fetch_balancey  s     !!$,;;..t|[+VV''[JZ[[	DM!,T233I6K#=>>"
 
 55dkk'66R6RSS@ !!(+++rj  c                 P    dddddddddddddd}|                      |||          S )Nr$  transactionr   )r   DepositWithdrawTransfer	OrderHoldWithdrawHoldDepositHold
MarginHold
ManualHoldManualEntryMarginAcquisitionMarginRelinquishMarginQuoteHoldrv  )rg  r  typess      ri  parse_ledger_entry_typezndax.parse_ledger_entry_type  sO    $%" )(!!"!( '&
 
 tT222rj  itemr  c                 
   |                      |d          }|                     ||          }|                      |d          }|                      |d          }d }d }t          j        |d          r|}d}nt          j        |d          r|}d}d }|                      |d          }	|dk    rt          j        |	|          }n.|dk    r(t          j        dt          j        |	|                    }|                     |d          }
|                     ||                      |d	          ||                      |d
          |                      |d          |                      |d          | 	                    |                      |d                    | 
                    ||          |                     |          |                     |          |                     |	          d|
|                     |
          d d|          S )Nr  CRDR0inoutBalancer  TransactionIdr^  ReferenceIdCounterpartyReferenceTypeok)r  rV  	directionrX  referenceIdreferenceAccountr  r  r  beforeafterstatusr  r  r  )rv  safe_currencyr   	string_lt
string_add
string_max
string_subr  safe_ledger_entryrw  r  rf  r  )rg  rx  r  r[  creditdebitr  r  r  r  r  s              ri  parse_ledger_entryzndax.parse_ledger_entry  s   " %%dK88
%%j(;;!!$--  t,,	VS)) 	FIIuc** 	FI  y11'v66FF$'W-?v-N-NOOF%%dK88	%%""499"''k::++D-@@ $ 0 0~ F F001A1A$1X1XYY//
HEE''//''//&&u--"Y//'
 '
  !  	rj  r  c           	      ,   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }||d}|||d	<   |                     | 	                    ||                    }	d}
|| 
                    |          }
|                     |	|
||          S )
aX  
        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-entry-structure>`
        rT  r   rP  r^  r   rV  r_  Nr  )r  rb  r  r`  r:  ra  rb  rc   privateGetGetAccountTransactionsru  r  parse_ledger)rg  r  r  r+  rz  rT  re  rP  r{  r|  r  s              ri  fetch_ledgerzndax.fetch_ledger  s%    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>"
 
 $GG88Wf9U9UVV& }}T**H  8UEBBBrj  r  c                 B    ddddddd}|                      |||          S )Nr  rejectedcanceledexpiredclosed)AcceptedRejectedWorkingCanceledExpiredFullyExecutedru  )rg  r  statusess      ri  parse_order_statuszndax.parse_order_status(  s:    "" %
 
 &&999rj  r6  c                    |                      |d          }|                     |d          }|                     i d|                     |dd          d|                     |dd          d	|d
|d|                     |          d|                      |d          d|                     |                     |d                    d|                     ||          d|                     |d          dd dd d|                     |d          d|                     |d          d|                     | 	                    |                     |d                              d|                     |d          d|                     |d          d|                     |d           |                     |d!          d d d d"|          S )#Nr)  r-  rV  ReplacementOrderIdr+  clientOrderIdReplacementClOrdIdClientOrderIdr  r  r  lastTradeTimestampLastUpdatedTimer  
OrderStater  r  r   r"  postOnlyr  r3  r  r.  r  	StopPricer  r1  r  OrigQuantityfilledQuantityExecutedAvgPrice)r  	remainingr  r   )
r  rv  
safe_orderr;  r  r  r
  r<  rf  	omit_zero)rg  r6  r  r  r  s        ri  parse_orderzndax.parse_order3  sB   H %%e];;	##E<88  
$$$U,@)LL 
T//7K_]] 
 E 
 	 

 Y// 
 !$"3"3E;L"M"M 
 d--d.>.>ul.S.STT 
 d&&x88 
 D**5+>> 
 4 
  
 D**5&99 
 T%%eW55 
 D--dnnT=M=MeU`=a=a.b.bcc 
 D$$U,@AA 
  d&&un==! 
" d&&u.@AA# 
$ ''z::+ 
  
  
, -  	rj  r  r  r  r  c                    |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }	|                     |dd          }
|                      | j        d	         |                     |                    }|                     |d
          }||dk    rd}n|dk    rd}| 	                    |g d          }| 
                    |          }|dk    rdnd}t          |d                   ||	d|t          |                     ||                    |d}|&t          |                     ||                    |d<   |
|
|d<   |||d<   |                     |                     ||                    }|                     ||          S )a0  
        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>`
        rT  r   rP  r^  r   rV  r  r  rU  r  Nr  rB  r+  rC  )rP  r^  r  r  r  r'  )r  rT  r^  TimeInForcer3  r/  r   
LimitPricer  )r  rb  r  r`  r:  ra  rb  
capitalizerv  rc  r  floatamount_to_precisionprice_to_precisionprivatePostSendOrderru  r  )rg  r  r  r  r  r  rz  rT  re  rP  r  	orderTyper  r  	orderSider{  r|  s                    ri  create_orderzndax.create_order  s     !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	++FO_UU%%dl<&@$//RVBWBWXX	''??#x			6#o#o#oppV$$%--AAa	t--" d66vvFFGG"
 
& $)$*A*A&%*P*P$Q$QGL!$'4GO$##/GK ,,T[[&-I-IJJ &111rj  rV  c                    |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }	|                     |dd|	          }
|                     |dd          }|                     |g d	          }|                     |          }|d
k    rdnd}t          |          t          |d                   ||
d|t          | 
                    ||                    |                      | j        d         |                     |                    d}|&t          |                     ||                    |d<   |||d<   |                     |                     ||                    }|                     ||          S )NrT  r   rP  r^  r   rV  r  r  )rP  r^  r  r  r'  rU  )OrderIdToReplacer  rT  r^  r  r3  r/  r   r  )r  rb  r  r`  r:  ra  rb  rc  r  r  r  r  r  privatePostCancelReplaceOrderru  r  )rg  rV  r  r  r  r  r  rz  rT  re  rP  r  r  r  r{  r|  s                   ri  
edit_orderzndax.edit_order  s   !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	++FO_UU6#_#_#_``V$$%--AAa	 #Bt--" d66vvFFGG**4<+EtW[G\G\]]
 
( $)$*A*A&%*P*P$Q$QGL!$'4GO$55dkk'66R6RSS &111rj  c           	      |   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }||d}d}	| |                     |          }	|	d         |d	<   || 	                    |d
z            |d<   |||d<   | 
                    |                     ||                    }
|                     |
|	||          S )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>`
        rT  r   rP  r^  r   rV  r_  Nr  r&   StartTimeStampr  )r  rb  r  r`  r:  ra  rb  rc  r  parse_to_intprivateGetGetTradesHistoryru  rJ  rg  r  r  r+  rz  rT  re  rP  r{  r  r|  s              ri  fetch_my_tradeszndax.fetch_my_trades  sW    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>"
 
 [[((F&,TlGN#(,(9(9%$,(G(GG$%$GG224;;w3O3OPPX   65%@@@rj  c           	      0   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }||d}| |                     |          }|d         |d	<   | 	                    | 
                    ||                    }|                     d
|i          gS )a  
        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>`
        rT  r   rP  r^  r   rV  r_  NIntrumentIdr  )r  rb  r  r`  r:  ra  rb  rc  r  privatePostCancelAllOrdersru  r  )	rg  r  rz  rT  re  rP  r{  r  r|  s	            ri  cancel_all_orderszndax.cancel_all_ordersV  s)    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>"
 
 [[((F%+D\GM"224;;w3O3OPP OO  
 	
rj  c                    |                      | j        dd          }|                                  |                                  d}||                     |          }d|i}|                     |dd          }|||d<   nt          |          |d<   |                     |ddg          }|                     | 	                    ||                    }| 
                    ||          }	| 	                    |	||d          S )a  
        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>`
        rT  r   Nr  	ClOrderIdr+  )rV  r  )r  rb  r  r`  r  r:  ra  rc  privatePostCancelOrderru  r  )
rg  rV  r  rz  rT  r  r{  r  r|  r6  s
             ri  cancel_orderzndax.cancel_order|  s    !!$,;; [[((FU
 ++FO[QQ$#0GK  !$RGI6O[#ABB..t{{7F/K/KLL  622{{5*#
 #
   	rj  c           	         |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }d}||                     |          }||d}	| 	                    | 
                    |	|                    }
|                     |
|||          S )	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>`
        rT  r   rP  r^  r   rV  Nr_  )r  rb  r  r`  r:  ra  rb  rc  r  privateGetGetOpenOrdersru  parse_orders)rg  r  r  r+  rz  rT  re  rP  r  r{  r|  s              ri  fetch_open_orderszndax.fetch_open_orders  s    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>[[((F"
 
 //GV0L0LMMf   65%@@@rj  c           	      |   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }||d}d}	| |                     |          }	|	d         |d	<   || 	                    |d
z            |d<   |||d<   | 
                    |                     ||                    }
|                     |
|	||          S )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>`
        rT  r   rP  r^  r   rV  r_  Nr  r&   r  r  )r  rb  r  r`  r:  ra  rb  rc  r  r  privateGetGetOrdersHistoryru  r  r  s              ri  fetch_orderszndax.fetch_orders  sW    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>"
 
 [[((F&,TlGN#(,(9(9%$,(G(GG$%$GG224;;w3O3OPPf   65%@@@rj  c           	      6   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }d}||                     |          }||t          |          d}| 	                    | 
                    ||                    }	|                     |	|          S )	a  
        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>`
        rT  r   rP  r^  r   rV  N)rT  r^  r+  )r  rb  r  r`  r:  ra  rb  rc  r  privateGetGetOrderStatusru  r  )
rg  rV  r  rz  rT  re  rP  r  r{  r|  s
             ri  fetch_orderzndax.fetch_orderL  s    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>[[((F"2ww
 

 00Wf1M1MNNb &111rj  c                    |                      | j        dd          }|                                  |                                  d}||                     |          }|                     |          t          |          d}|                     |                     ||                    }	| 	                    |	d          }
| 
                    |
dg           }|                     ||||          S )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>`
        rT  r   N)OMSIdr+  ChangeReasonr   )r  rb  r  r`  r  r  ra  #privatePostGetOrderHistoryByOrderIdru  group_by	safe_listrJ  )rg  rV  r  r  r+  rz  rT  r  r{  r|  groupedr   s               ri  fetch_order_tradeszndax.fetch_order_trades  s     !!$,;; [[((F&&u--2ww
 

 ;;DKKQW<X<XYYf --.99"55  >>>rj  c           	      "   |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }|                     |          }|||d         dd}| 	                    | 
                    ||                    }|                     ||          S )	a7  
        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>`
        rT  r   rP  r^  r   rV  F)rT  r^  r  GenerateNewKey)r  rb  r  r`  r:  ra  rb  rc  r  privateGetGetDepositInforu  parse_deposit_address)	rg  r  rz  rT  re  rP  r  r{  r|  s	            ri  fetch_deposit_addresszndax.fetch_deposit_address  s    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>==&&"!$#	
 
 00Wf1M1MNN ))(H===rj  c                 z   |                      |d          }t          j        |          }t          |          }|                      ||dz
            }|                    d          }|                      |d          }|                      |d          }	d }
||d         }
|                     |           ||
d ||	dS )NDepositInfor   z?memo=r   r  )r  r  networkaddresstag)rv  jsonloadsr  splitcheck_address)rg  depositAddressr  depositInfoStringdepositInfodepositInfoLength
lastStringpartsr  r  r  s              ri  r  zndax.parse_deposit_address  s     !,,^]KKj!233,,%%k3Dq3HII
  **""5!,,ua((F#D7###"
 
 	
rj  c                 ^    ddi}|                      ||                     ||                    S )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  ru  )rg  r  rz  r{  s       ri  create_deposit_addresszndax.create_deposit_address/  s6     d
 ))$GV0L0LMMMrj  c           	         |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }d}||                     |          }||d}	| 	                    | 
                    |	|                    }
t          |
t                    r*|                     t          j        |
          |||          S |                     |
|||          S )	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>`
        rT  r   rP  r^  r   rV  Nr_  )r  rb  r  r`  r:  ra  rb  rc  r  privateGetGetDepositsru  r8  strparse_transactionsr  r  rg  r  r  r+  rz  rT  re  rP  r  r{  r|  s              ri  fetch_depositszndax.fetch_deposits;  sM    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>}}T**H"
 
 --dkk'6.J.JKK: h$$ 	Y**4:h+?+?5RWXXX&&x5%HHHrj  c           	         |                      | j        dd          }|                                  |                                  |                     | j        ddt          | j        d         d                             }|                     |dd|          }|                     |ddg          }d}||                     |          }||d}	| 	                    | 
                    |	|                    }
|                     |
|||          S )	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>`
        rT  r   rP  r^  r   rV  Nr_  )r  rb  r  r`  r:  ra  rb  rc  r  privateGetGetWithdrawsru  r  r   s              ri  fetch_withdrawalszndax.fetch_withdrawalsu  s    !!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>}}T**H"
 
 ..t{{7F/K/KLL2 &&x5%HHHrj  c                     ddddddddddddddddi ddddddd	dd
ddddddddddddddddddddddddddddddddd}|                      ||i           }|                     |||          S )Npendingr  r  failed)NewAdminProcessingr  r  SystemProcessingFullyProcessedFailedPending	ConfirmedAmlProcessingAmlAcceptedAmlRejected	AmlFailedLimitsAcceptedLimitsRejectedr  r	  r  r  r
  r  r  r  
Pending2FaAutoAcceptedDelayedUserCanceledr  AdminCanceledr  r  r  r  )r  r  	Submittedr  ManuallyConfirmedConfirmed2Fa)r  
withdrawal)r  rv  )rg  r  r  statusesByTyper  s        ri   parse_transaction_status_by_typez%ndax.parse_transaction_status_by_type  sg    !#,%&$-"&"$&!*()%"+", "y!9 I J	
 #I !$ ( 9 i 	 9 
     y  z!" X#$ #,",&&%. )/  %+ 
 + 
X ??>4<<&&999rj  rh  c                    d }|                      |d          }|                     ||          }d }d|v r|                      |d          }d}nd|v r|                      |d          }d}|                     |                     |dd                    }|                     |d          }||                     |d	|          }|                     |d
d          }	|                     |d          }
|                     |d          }|                      |d          }d }|||d}i d|d|d|                     |dd          d|
d|                     |
          d|	d|	d|                      |d          dd dd dd d|d|                     |d           d!|d"|                     ||          d#|d$|d d d d%S )&Nr  	DepositIdr  
WithdrawIdr  TemplateFormr  LastUpdateTimeStampLastUpdatedExternalAddress	ToAddressTimeSubmitted	FeeAmountTicketStatus)r  r  r  rV  txidTxIdTXIdr  r  r  	addressToaddressFromFromAddressr  tagTotagFromr  r  rS  r  r  updatedr  )internalcommentr  )	rv  r  
parse_jsonsafe_value_2r  r;  r  r  r  )rg  rh  r  rV  r[  r  r  templateFormr3  r  r  feeCosttransactionStatusr  s                 ri  parse_transactionzndax.parse_transaction  s   f %%k;??
&&z8<<+%%!!+{;;BDD[((!!+|<<BDt'8'8nVc'd'dee##K1FGG#''mWMMG$$\3DkRR%%lODD	"";<< ,,[.II#W55C
K
"
 D&&|VVDD
 	

 Y//
 w
 
 4++L-HH
 4
 T
 t
 D
 d&&{H==
 
 d;;<MtTT
  w!
" 3#
$ )
 
 
 	
rj  r  r  c           	         |                      ||          \  }}|                     | j        d          }|t          | j        dz             | j        t          | j        dz             |                     |           |                     | j        dd          }|                                  | 	                                 | 
                    | j        ddt          | j        d	         d
                             }| 
                    |dd|          }	|                     |ddg          }|                     |          }
||	|
d
         d}|                     |          }|                     |dg           }|                     |d	          }| t#          | j        dz   |
d         z             |                     |d          }||	|
d
         ||d         d}|                     |          }|                     |d          }| t#          | j        dz   |
d         z             t'          j        |          }||d<   |	d|v r||d<   ||	|
d
         |                     |          |d}d|                     | j                  |                     |          d}|                     |                     ||                    }|                     ||
          S )a  
        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>`
        ro  Nz/ call signIn() method to obtain a session tokenz/ withdraw() requires exchange.twofa credentialsrT  r   rP  r^  r   rV  )rT  r^  r  TemplateTypesz8 withdraw() could not find a withdraw template type for r  TemplateNameAccountProviderId)rT  r^  r  TemplateTyper?  Templatez3 withdraw() could not find a withdraw template for r&  Memo)rT  r^  r  r#  r@  Google)TfaTypeTFaCodePayload)handle_withdraw_tag_and_paramsrv  rb  r   rV  rw  r  r  r  r`  r:  ra  rb  rc  r  "privateGetGetWithdrawTemplateTypesr  r   privateGetGetWithdrawTemplater  r  rx  privatePostCreateWithdrawTicketrc  r;  )rg  r  r  r  r  rz  ro  rT  re  rP  r  withdrawTemplateTypesRequestwithdrawTemplateTypesResponsetemplateTypesfirstTemplateTypetemplateNamewithdrawTemplateRequestwithdrawTemplateResponsetemplatewithdrawTemplatewithdrawPayloadwithdrawRequestr|  s                          ri  r   zndax.withdraw8	  s!    99#vFFV''nEE%dg0a&abbb:%dg0a&abbb7###!!$,;;..t|[+WZ[_[hij[klp[qWrWrss''[JZ[[	6K#=>>==&&"!$.
 .
$
 )-(O(OPl(m(m% (EXZ[[ OOM1==$*d dgopvgw wxxx''(9>JJ"!$(!23F!G)
 )
 $(#E#EF]#^#^  ##$<jII*_ _bjkqbr rsss:h//.5*+?)))+. ("!$ II&677(!
 !
  yy,,yy11!
 !

 778H8HZ`8a8abb%%h999rj  c                 *    |                                  S N)r  )rg  s    ri  r  z
ndax.nonce	  s      """rj  r   GETc                     | j         d         |         dz   |                     ||          z   }|                     ||                     |                    }|dk    r|dk    r/| j        dz   | j        z   }	|                     |	          }
dd|
z   i}n=|dk    r7|                     | j        d	          }|d
|i}|                     |d	          }|r|d| 	                    |          z   z  }n|dk    r| 
                                 |                     | j        d          }|t          |                                           }|| j        z   | j        z   }	|                     |                     |	          |                     | j                  t$          j                  }|| j        || j        d}nd|i}|dk    rd|d<   |                     |          }n|r|d| 	                    |          z   z  }||||dS )Nr   r  r   r   :AuthorizationzBasic r   rq  rp  ?r   ro  )NonceAPIKey	SignaturerM  APTokenPOSTzapplication/jsonzContent-Type)urlmethodbodyheaders)r]  implode_paramsrc  extract_paramsr<  r=  string_to_base64rv  rb  	urlencoders  r  r  r;  r9  hmacencoder:  hashlibsha256r  )rg  pathr   rc  rz  re  rd  rb  queryauthauth64rq  ro  r  	signatures                  ri  signz	ndax.sign	  s-   is#c)D,?,?f,M,MM		&$"5"5d";";<<(??~%%zC'$-7..t44#X%6 ***"&"2"24<AR"S"S".)?G !IIe->??E 3sT^^E2222I++---++DL.IIL#DJJLL))tx'$+5 IIdkk$&7&7T[9Q9QSZSabb	""k!*"h	  | *<'yy'' 73!6!666CfdwOOOrj  reasonrb  rc  re  rd  c
                 J   |dk    rt          | j        dz   |z             |d S |                     |d          }
|
f|
dk    r`| j        dz   |z   }|                     | j        d         |
|           |                     | j        d         ||           t          |          d S )Ni   errormsg r?  r@  )r   rV  rv  throw_exactly_matched_exceptionra  throw_broadly_matched_exceptionr   )rg  r  rt  rb  rc  re  rd  r|  requestHeadersrequestBodymessagefeedbacks               ri  handle_errorszndax.handle_errors	  s    3;;%dgmd&:;;;4
 ""8Z88gmmw}t+H001I7T\]]]001I4QYZZZ)))trj  )Nr  r  rE  r  rA  rW  )F__name__
__module____qualname__r   re  r~  r   r  r   r   r  dictr  r   r  r  r   r   r  r   r  r  r9  r  r#  r   rF  rK  r   rQ  r   r\  rf  rw  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  r;  r   r  rs  ra  r  __classcell__)rh  s   @ri  r!   r!      s       w# w w w w w wr   0 0 0 0d ') C CZ C C C CJ $& <, <,$v, <, <, <, <,|:
4 :
F :
 :
 :
 :
x   lu    GP    dm        D :>b +7 +7s +73 +7Y +7 +7 +7 +7Z@ @4 @ @6 @ @ @ @D 02 03 033 03f 03 03 03 03d
 
 
4 
 
 
 
. 9=4^bkm )L )L# )L# )LS )LX[ )Lrvw{r| )L )L )L )LVc c cv c c c c cJ 6:UW A A3 As A# A\`af\g A A A A8 %'  4=    B) ) ) ) )" $& 5, 5,( 5, 5, 5, 5,n3 3 3$4 4t 4x 4; 4 4 4 4l (,$TZ\ .C .C .CC .Cs .Caefqar .C .C .C .C`	: 	: 	: 	: 	:\ \ \v \ \ \ \ \| gksu A2 A23 A2i A2y A2RW A2`c A2 A2 A2 A2F `drv  @B +2 +2S +2# +2Y +2i +2Y\ +2lo +2 +2 +2 +2Z -1tRV_a SA SAc SA SAC SA SA SA SAj /32 $
 $
 $
 $
 $
 $
L 37r $ $s $C $ $ $ $L /3TXac LA LA LA3 LAc LAhlmrhs LA LA LA LA\ *.Dt\^ ZA ZA3 ZAc ZA ZAcghmcn ZA ZA ZA ZAx 26b J2 J2c J23 J2 J2 J2 J2X 9=4^bkm P? P?S P?# P?S P?X[ P? P? P? P?d 79 !> !># !>^ !> !> !> !>F 
  
h  
R`  
  
  
  
D 8: 
N 
N3 
Nn 
N 
N 
N 
N *.Dt\^ 8I 8I3 8Ic 8I 8Icghsct 8I 8I 8I 8It -1tRV_a 2I 2Ic 2I 2IC 2Ifjkvfw 2I 2I 2I 2Ih.: .: .: .:`]
 ]
T ]
X ]
Q\ ]
 ]
 ]
 ]
~ KOWY U: U:S U:% U:# U:C U:^i U: U: U: U:n# # # &eBSW ,P ,P ,P ,P\# s  c TX `c        rj  r!   )'ccxt.base.exchanger   ccxt.abstract.ndaxr   rl  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!    rj  ri  <module>r     s	   ( ' ' ' ' ' * * * * * *   L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L  L       * * * * * * 0 0 0 0 0 0 & & & & & & . . . . . . * * * * * * 4 4 4 4 4 4 % % % % % %z& z& z& z& z&8[ z& z& z& z& z&rj  