
    !:ho	                    X   d dl mZ d dlm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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dlm"Z" 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-y)    )Exchange)ImplicitAPIN)AccountAnyBalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionTransferEntry)List)ExchangeError)AuthenticationError)PermissionDenied)AccountNotEnabled)AccountSuspended)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)RateLimitExceeded)OnMaintenance)CancelPending)	TICK_SIZE)Precisec                       e Zd Zdef 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dDde
dedefd	Zi fd
edefdZdi fdedefdZdi fd
ededefdZdDde
dedefdZ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dDdedefdZdefdZi fdefdZdi fd
ededede de!f
dZ"di fded
e#fdZ$di fded
e#fd Z%dddi fd
e#dededee&   fd!Z'dddi fd
e#dededee&   fd"Z(d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fd$Z*d%e#fd&Z+dDd'e
dede&fd(Z,i fd)ede d*ed+ede-f
d,Z.dDd-e
d.e/de-fd/Z0d%e#de#fd0Z1di fd)ede d1ede2fd2Z3i fdee4   fd3Z5dddi fd)e#dededee2   fd4Z6dddi fd)e#dededee2   fd5Z7dddi fd)e#dededee2   fd6Z8d%e#fd7Z9dDd8e
d.e/de2fd9Z:dddi fd
e#dedefd:Z;d;d<i ddfd=Z<d)e=d>ed?ed@edAe
dBefdCZ> xZ?S )Enovadaxreturnc           "         | j                  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d0d
d1dd2dd3d
d4dd5dd6dd7dd8dd9d
d:d
i d;d
d<d
d=d
d>d
d?d
d@d
dAddBddCddDddEd
dFd
dGdHdIddJd
dKd
dLd
d
dddMdNdOdPdQdRdSdTdUdVdWdXdXdYdZd[gd\d]d^d_d`d`d`dad`d`dadadbid`ddcdd`d`d`ddcdd	daded`dddadcdcdfdgdYdhd
d| j	                  di      | j	                  dj      dkidddlt
        i dmt        dnt        dot        dpt        dqt        drt        dst        dtt        dut        dvt        dwt        dxt        dyt         dzt         d{t         d|t         d}t         t"        t         t         t$        t         t         t"        d~i dddidd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
dddd
dd
d
d
d
dd
d d
d
d
dd
dddd
d
d
dd
ddd`dd
d
d
ddd id	d d dd d ddd      S )Nr)   NovaDAXBR
   v1CORSspotTmarginFswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchWithdrawalsreduceMarginsetLeveragesetMarginMode)setPositionModetransferwithdrawONE_MINFIVE_MINFIFTEEN_MINHALF_HOUONE_HOUONE_DAYONE_WEEONE_MON)1m5m15m30m1h1d1w1Mzchttps://user-images.githubusercontent.com/1294454/92337550-2b085500-f0b3-11ea-98e7-5794fb07dd3b.jpgzhttps://api.novadax.com)publicprivatezhttps://www.novadax.com.brzhttps://doc.novadax.com/pt-BR/z*https://www.novadax.com.br/fees-and-limitsz"https://www.novadax.com.br/?s=ccxt)logoapiwwwdocfeesreferralget      )zcommon/symbolzcommon/symbolszcommon/timestampzmarket/tickerszmarket/tickerzmarket/depthzmarket/tradeszmarket/kline/history   )	z
orders/getzorders/listzorders/fillzorders/fillszaccount/getBalancezaccount/subszaccount/subs/balancezaccount/subs/transfer/recordzwallet/query/deposit-withdraw2   )zorders/createzorders/batch-createzorders/cancelzorders/batch-cancelzorders/cancel-by-symbolzaccount/subs/transferzwallet/withdraw/coinzaccount/withdraw/coin)r   posttradingz0.005z0.0025)	tierBased
percentagetakermaker)apiKeysecretA99999A10001A10002A10003A10004A10005A10006A10007A10011A10012A10013A30001A30002A30003A30004A30005A30006)A30007A30008A30009A30010A30011A30012A40004)exactbroadvolumeamountfillResponseFromRequest)rZ   rv   )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   r   daysBackCanceledr   r   r   r   r   )	sandboxr=   createOrdersrY   r]   r\   r_   rF   rZ   )linearinverse)r1   r3   r4   )idname	countries	rateLimitversionhas
timeframesurlsr   r   requiredCredentialsprecisionMode
exceptionsoptionsfeatures)deep_extendsuperr)   describeparse_numberr&   r   r   r   r#   r   r   r   r   r$   r"   r!   r    r%   )self	__class__s    T/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/novadax.pyr   znovadax.describe   s'   gt = ? HHH %H 	H
 %H %H UH tH $UH  H /H ,UH 0H tH (H  '!H" (#H$ "4%H&  'H( )H* +E+H, )%-H. $T/H0 '1H2 (3H4 &u5H6 (7H8 1%9H:  ;H< +D=H> &u?H@ #EAHB *5CHD $UEHF "5GHH *5IHJ +EKHL  MHN %eOHP QHR !%SHT  UHV dWHX +EYHZ "4[H\ d]H^ !$_H` taHb #DcHd  eHf 'gHh $UiHj !%kHl *5mHn (oHp %eqHr )%sHt tuHv wHx TyHz t{H| "5}H~ #EH@ $ZAHB #DCHD EHF uGHH  IHJ $)  OHT   $!	 ~78 44 E@ )**+,-*+)*())*01	 '(')'((*./()018:9:
 *+/1)*/135120112	$L !&"&!..w7!..x8	 $ 'm j m	
 1 / . . / i i m m l l  l!" l#$ l%& 0**+**/369B h .t	  %&+(,,0,0).+06: $)#("'#(	( #($)$)+/27/4#'+$. %)&+!$$*%+*/& ',#($)*/	# ',!%#($)*/( ',!$$*%+#($)*/$ ',!$$*,-%+#($)*/	*  #CDL ##
 ##UNEQB
 Q Q	    c                 d   K   | j                  |       d{   }| j                  |d      S 7 w)aS  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://doc.novadax.com/en-US/#get-current-system-time

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        Ndata)publicGetCommonTimestampsafe_integerr   paramsresponses      r   
fetch_timeznovadax.fetch_time3  s5      66v>>   622 ?s   0.0c                    K   | j                  |       d{   }| j                  |dg       }| j                  |      S 7 (w)a   
        retrieves data on all markets for novadax

        https://doc.novadax.com/en-US/#get-all-supported-trading-symbol

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Nr   )publicGetCommonSymbols
safe_valueparse_markets)r   r   r   r   s       r   fetch_marketsznovadax.fetch_marketsF  sE      44V<<( x4!!$''+ =s   AA )Amarketc                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j                  |d      }i d|d|dz   |z   d|d|d	d d
|d|dd ddddddddddddd|dk(  dddd d d d d d d | j                  | j                  | j                  |d                  | j                  | j                  | j                  |d                  dd d d| j	                  |d      d dd d d| j	                  |d      d ddd |d 
S )!NbaseCurrencyquoteCurrencysymbolstatusr   /basequotesettlebaseIdquoteIdsettleIdtyper1   Tr2   Fr3   r4   r5   activeONLINEcontractr   amountPrecisionpricePrecision)r   price)minmaxminOrderAmountminOrderValue)r   r   r  cost)
r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_coder   parse_precisionsafe_number)r   r   r  r  r   r  r  r   s           r   parse_marketznovadax.parse_marketf  s   !!&.9""6?;fh/&&v.''0!!&(31
"1
dSj5(1
 D1
 U	1

 d1
 f1
 w1
 1
 F1
 D1
 e1
 E1
 e1
 e1
 v)1
  !1
" d#1
$  "++D,@,@AQAQRXZkAl,mn**4+?+?@P@PQWYi@j+kl  
  ++F4DE
  
  ++FOD$ a1
 1	
r   Ntickerc                 4   | j                  |d      }| j                  |d      }| j                  ||d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  i d|d|d| j	                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      dd d| j                  |d      dd dd d|d|d|dd dd dd dd ||	|d|      S )N	timestampr   _open24h	lastPricebaseVolume24hquoteVolume24hdatetimehighhigh24hlowlow24hbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechanger   average)
baseVolumequoteVolumer  )r   r  safe_symbolsafe_tickeriso8601)
r   r!  r   r#  marketIdr   r3  r5  r9  r:  s
             r   parse_tickerznovadax.parse_ticker  s   " %%fk:	##FH5!!(FC8	24%%fo>
&&v/?@ !
f!
!
 Y/!
 D$$VY7	!

 4##FH5!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r   r   c                   K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  |di       }| j                  ||      S 7 j7 +w)a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://doc.novadax.com/en-US/#get-latest-ticker-for-specific-pair

        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   r   )load_marketsr   publicGetMarketTickerextend	safe_dictr?  )r   r   r   r   requestr   r   s          r   fetch_tickerznovadax.fetch_ticker  s      !!!V$fTl
 33DKK4PQQ& ~~h3  v..3 	"
 Rs"   BBA BB*BBsymbolsc                 V  K   | j                          d{    | j                  |      }| j                  |       d{   }| j                  |dg       }i }t	        dt        |            D ]   }| j                  ||         }|d   }|||<   " | j                  |d|      S 7 7 fw)a#  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://doc.novadax.com/en-US/#get-latest-tickers-for-all-trading-pairs

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        Nr   r   r   )rA  market_symbolspublicGetMarketTickersr   rangelenr?  filter_by_array_tickers)	r   rG  r   r   r   resultir!  r   s	            r   fetch_tickersznovadax.fetch_tickers  s      !!!%%g.44V<<* x4q#d)$ 	$A&&tAw/FH%F#F6N	$ ++FHgFF; 	"<s"   B)B%)B) B'A%B)'B)r   c                 L  K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }| j	                  |di       }| j                  |d      }| j                  ||d   |dd      S 7 7 Cw)	a-  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://doc.novadax.com/en-US/#get-market-depth

        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        Nr   r   r   r   r#  bidsasks)rA  r   publicGetMarketDepthrC  r   r   parse_order_book)	r   r   r   r   r   rE  r   r   r#  s	            r   fetch_order_bookznovadax.fetch_order_book  s      !!!V$fTl
 $GG224;;w3OPP( x4%%dK8	$$T6(+;YPVWW; 	" Qs#   B$B AB$B"AB$"B$tradec                 B   | j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |	|d      }
| j                  |d	      }| j                  |d
      }d }|8| j                  |d      }| j	                  |      }| j                  |d      |d}| j                  |||| j                  |      |
d |||d |||d|      S )Nr   orderIdr#  sider  r   r   r$  rolefeefeeCurrency	feeAmountr  currency)r   orderr#  r)  r   r  rZ  r  r   r  takerOrMakerr\  r  )r  r   safe_string_lowerr;  r  
safe_trader=  )r   rW  r   r   rY  r#  rZ  priceStringamountStringr>  r   rb  	feeStringr\  feeCurrencyIdfeeCurrencyCodes                   r   parse_tradeznovadax.parse_tradeG  sO   V eT*""5)4%%e[9	%%eV4&&ug6''x8##E84!!(FC8--eV<$$UE2	  ,,UMBM"55mDO((<+C "Y/ "( 
  	r   sincec                    K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }| j	                  |dg       }| j                  ||||      S 7 s7 -w)a  
        get the list of most recent trades for a particular symbol

        https://doc.novadax.com/en-US/#get-recent-trades

        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        Nr   r   r   r   )rA  r   publicGetMarketTradesrC  	safe_listparse_trades)	r   r   rk  r   r   r   rE  r   r   s	            r   fetch_tradesznovadax.fetch_trades  s      !!!V$fTl
 $GG33DKK4PQQ ~~h3  vue<<) 	" Rs"   BB
ABB,BBr   c                   K   | j                          d{    | j                  |      }|d   | j                  | j                  ||      d}| j	                  |      }| j                         }	|d}||	||z  z
  |d<   |	|d<   n1| j                  |dz        }
|
|d<   | j                  |
||z        |d<   | j                  | j                  ||             d{   }| j                  |dg       }| j                  |||||      S 7 7 .w)	a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://doc.novadax.com/en-US/#get-kline-data

        :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
        Nr   )r   uniti  fromtoi  r   )rA  r   r  r   parse_timeframesecondsparse_to_intsumpublicGetMarketKlineHistoryrC  rn  parse_ohlcvs)r   r   	timeframerk  r   r   r   rE  durationnow	startFromr   r   s                r   fetch_ohlcvznovadax.fetch_ohlcv  s"     !!!V$Tl$$T__iK
 ''	2lln=E=!EH$44GFOGDM))%$,7I'GFO HHY0@AGDM99$++gv:VWW( ~~h3  vy%GGM 	"" Xs"   DD	CDD-DDc           	      2   | j                  | j                  di       }| j                  |dd      }| j                  |d      | j	                  |d      | j	                  |d      | j	                  |d      | j	                  |d      | j	                  ||      gS )	NrZ   r   r   score	openPrice	highPricelowPrice
closePrice)r   r   r  safe_timestampr  )r   ohlcvr   r   volumeFields        r   parse_ohlcvznovadax.parse_ohlcv  s     //$,,bA&&w(Cw/UK0UK0UJ/UL1UK0
 	
r   c                    | j                  |dg       }|d d d}t        dt        |            D ]~  }||   }| j                  |d      }| j	                  |      }| j                         }| j                  |d      |d<   | j                  |d      |d<   | j                  |d	      |d
<   |||<    | j                  |      S )Nr   )r  r#  r)  r   r`  balancetotal	availablefreeholdused)r   rK  rL  r  r  accountsafe_balance)	r   r   r   rN  rO  r  
currencyIdcoder  s	            r   parse_balanceznovadax.parse_balance  s    x4

 q#d)$ 	#A1gG))':>J**:6DllnG#//CGG"..wDGFO"..w?GFO"F4L	#   ((r   c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)a^  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://doc.novadax.com/en-US/#get-account-balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        N)rA  privateGetAccountGetBalancer  r   s      r   fetch_balanceznovadax.fetch_balance  sI      !!!99&AA !!(++! 	"As   A	AA	AA	A	r  rZ  r   r  c                   K   | j                          d{    | j                  |      }|j                         }|j                         }	|d   |	d}
| j                  |dd      }|(|dk(  s|dk(  rut	        | j
                  dz   |z   d	z         |d
k(  rd}n|dk(  rd}|	dk(  rdnd}| j                  |d|      |
d<   | j                  ||      |
d<   | j                  |ddg      }|d
k(  s|dk(  r+| j                  ||      |
d<   | j                  ||      |
d<   n|dk(  s|dk(  r|	dk(  r| j                  ||      |
d<   n|	dk(  rd}d}| j                  |ddd      \  }}| j                  |dd      }| j                  |d      }|| j                  ||      }ny|re|t        | j
                  dz         | j                  |      }| j                  |      }t        j                   ||      }| j                  ||      }n| j                  ||      }||
d<   ||
d<   | j#                  | j%                  |
|             d{   }| j'                  |di       }| j)                  ||      S 7 W7 ,w)a  
        create a trade order

        https://doc.novadax.com/en-US/#order-introduction

        :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 you want to trade in units of the 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.cost]: for spot market buy orders, the quote quantity that can be used alternative for the amount
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   )r   rZ  r   	stopPrice
STOP_LIMITSTOP_MARKETz2 createOrder() requires a stopPrice parameter for z ordersLIMITMARKETBUYLTEGTEoperatorr  r   SELLTr=   !createMarketBuyOrderRequiresPricer  valuea	   createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend(quote quantity) in the amount argumentr  r   )rA  r   uppersafe_value_2r   r   r  price_to_precisionomitamount_to_precisionhandle_option_and_paramssafe_number_2cost_to_precisionr!   number_to_stringr'   
string_mulprivatePostOrdersCreaterC  rD  parse_order)r   r   r  rZ  r   r  r   r   uppercaseTypeuppercaseSiderE  r   defaultOperatorquoteAmountr  r  rf  re  costRequestr   r   s                        r   create_orderznovadax.create_order1  s     !!!V$



Tl!
 ((M-=M3Q'2f(fiv(v  zC  )C  D  D' ,(* -(5(>eUO"&"2"26:"WGJ#'#:#:6<#PGK YYv'DEFW$-<*G#66vuEGG $ 8 8 HGHx']m-K&$($<$<VV$L!%'"481<@<Y<YZ`bo  rU  W[  =\916))&&'B662#"&"8"8"FK6}*477  6A  ,A  B  B'+'<'<V'D&*&;&;E&B&-&8&8{&S&*&<&<V[&Q"&"8"8"HK#. '55dkk'66RSS0 ~~h3f--[ 	"h Ts"   I2I-H,I2I0*I20I2r   c                    K   | j                          d{    d|i}| j                  | j                  ||             d{   }| j                  |di       }| j	                  |      S 7 U7 *w)al  
        cancels an open order

        https://doc.novadax.com/en-US/#cancel-an-order

        :param str id: order id
        :param str symbol: not used by novadax cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   )rA  privatePostOrdersCancelrC  rD  r  r   r   r   r   rE  r   r   s          r   cancel_orderznovadax.cancel_order  sw      !!!"
 55dkk'66RSS ~~h3%% 	" T!   A0A,,A0A.)A0.A0c                    K   | j                          d{    d|i}| j                  | j                  ||             d{   }| j                  |di       }| j	                  |      S 7 U7 *w)a  
        fetches information on an order made by the user

        https://doc.novadax.com/en-US/#get-order-details

        :param str id: order id
        :param str symbol: not used by novadax fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   )rA  privateGetOrdersGetrC  rD  r  r  s          r   fetch_orderznovadax.fetch_order  sw      !!!"
 11$++gv2NOO, ~~h3%%7 	" Pr  c                 <  K   | j                          d{    i }d}|| j                  |      }|d   |d<   |||d<   |||d<   | j                  | j                  ||             d{   }| j	                  |dg       }| j                  ||||      S 7 7 -w)a(  
        fetches information on multiple orders made by the user

        https://doc.novadax.com/en-US/#get-order-history

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr   r   r   fromTimestampr   )rA  r   privateGetOrdersListrC  rn  parse_orders	r   r   rk  r   r   rE  r   r   r   s	            r   fetch_ordersznovadax.fetch_orders  s      !!!
 [[(F &tGH$GG',GO$224;;w3OPP0 ~~h3  vue<<W 	"$ Q"   BBAB,B-,BBc           	      n   K   ddi}| j                  |||| j                  ||             d{   S 7 w)a  
        fetch all unfilled currently open orders

        https://doc.novadax.com/en-US/#get-order-history

        :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>`
        r   z-SUBMITTED,PROCESSING,PARTIAL_FILLED,CANCELINGNr  rC  r   r   rk  r   r   rE  s         r   fetch_open_ordersznovadax.fetch_open_orders  s@      E
 &&vueT[[RX=YZZZZ   ,535c           	      n   K   ddi}| j                  |||| j                  ||             d{   S 7 w)a/  
        fetches information on multiple closed orders made by the user

        https://doc.novadax.com/en-US/#get-order-history

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r   zFILLED,CANCELED,REJECTEDNr  r  s         r   fetch_closed_ordersznovadax.fetch_closed_orders  s@      0
 &&vueT[[RX=YZZZZr  c                   K   | j                          d{    d|i}| j                  | j                  ||             d{   }d}|| j                  |      }| j	                  |dg       }	| j                  |	|||      S 7 m7 Bw)a  
        fetch all the trades made from a single order

        https://doc.novadax.com/en-US/#get-order-match-details

        :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>`
        Nr   r   )rA  privateGetOrdersFillrC  r   r   ro  )
r   r   r   rk  r   r   rE  r   r   r   s
             r   fetch_order_tradesznovadax.fetch_order_trades.  s      !!!"
 224;;w3OPP[[(Fx4,   vue<<= 	" Qs"   BB,BBABBr   c                 <    dddddddd}| j                  |||      S )Nr3  closedcanceledrejected)	SUBMITTED
PROCESSINGPARTIAL_FILLED	CANCELINGFILLEDCANCELEDREJECTEDr  r   r   statusess      r   parse_order_statusznovadax.parse_order_status[  s5     $""
 &&99r   ra  c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  |d      }| j                  |d      }| j                  | j                  |d            }	| j	                  |d	      }
| j                  |d
      }| j                  |d      }d }| j                  |d      }||d d}| j                  |d      }| j                  ||d      }| j                  i d|dd d|d	|
d| j                  |
      dd d|d|dd dd d|d|d| j                  |d      d|d|d|d|d |	|d d|      S )Nr   r   r  filledValuer  r  rZ  r   r#  averagePricefilledAmount	filledFeer_  r   r$  clientOrderIdr  r)  lastTradeTimestampr   postOnlyr   r  r  r8  filled)	remainingr   r\  trades)	r  safe_string_2rc  r  r   r  r;  
safe_orderr=  )r   ra  r   r   r   r  r  r  rZ  r   r#  r8  r  r\  feeCostr>  r   s                    r   r  znovadax.parse_orderg  s#   8 eT*!!%2  0!!%@%%eV4%%eV4(()9)9%)JK%%e[9	""5.9!!%8""5+6 C ##E84!!(FC8  
" 
T 
 E 
 	 

 Y/ 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D,,UK@ 
 f 
 D 
  w! 
" f# 
$ + 
, - 	r   r  fromAccount	toAccountc                   K   | j                          d{    | j                  |      }|dk7  r|dk7  rt        | j                  dz         |dk(  rdnd}| j	                  ||      |d   |dk(  r|n||d}| j                  | j                  ||             d{   }	| j                  |	|      }
| j                  | j                  di       }| j                  |d	d
      }|r||
d<   ||
d<   ||
d<   |
S 7 7 [w)a  
        transfer currency internally between wallets on the same account

        https://doc.novadax.com/en-US/#get-sub-account-transfer

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        NmainzH transfer() supports transfers between main account and subaccounts onlyzmaster-transfer-inzmaster-transfer-outr   )transferAmountr`  subIdtransferTyperv   r   Tr  r  r   )rA  r`  r   r   currency_to_precisionprivatePostAccountSubsTransferrC  parse_transferr   r   	safe_bool)r   r  r   r  r  r   r`  r  rE  r   rv   transferOptionsr   s                r   rv   znovadax.transfer  s     !!!==&& Y&%8*t tuu )4v(=#DY"88vF #'+?#?Yk 	
 <<T[[RX=YZZ &&x://$,,
BG"&..B[]a"b"&1H]#$-H[!!'HX9 	" [s#   C:C6BC:C8AC:8C:rv   r`  c           
          | j                  |d      }| j                  |d      }| j                  d |      }||d |d d d d |d	S )Nr   message)	r  r   r   r`  r  r  r#  r)  r   )r  r  )r   rv   r`  r   r   currencyCodes         r   r  znovadax.parse_transfer  s_     h/!!(I6..tX>$

 
	
r   c                 0    ddi}| j                  ||d      S )NSUCCESSpendingfailedr  r  s      r   parse_transfer_statusznovadax.parse_transfer_status  s%    y
 &(;;r   addressc                 D  K   | j                  ||      \  }}| j                          d{    | j                  |      }|d   | j                  ||      |d}|||d<   | j	                  | j                  ||             d{   }| j                  ||      S 7 p7 w)a  
        make a withdrawal

        https://doc.novadax.com/en-US/#send-cryptocurrencies

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   )r  r   wallettag)handle_withdraw_tag_and_paramsrA  r`  r  privatePostAccountWithdrawCoinrC  parse_transaction)	r   r  r   r  r  r   r`  rE  r   s	            r   rw   znovadax.withdraw  s      99#vFV!!!==&TN00v>

 ? GEN<<T[[RX=YZZ %%h99# 	" [s"   )B BAB BB B c                    K   | j                  |       d{   }| j                  |dg       }g }t        dt        |            D ]A  }||   }| j	                  |d      }| j	                  |d      }|j                  ||d|d       C |S 7 tw)a]  
        fetch all the accounts associated with a profile

        https://doc.novadax.com/en-US/#get-sub-account-list

        :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
        Nr   r   r  
subAccount)r   r  r`  r  )privateGetAccountSubsr   rK  rL  r  append)	r   r   r   r   rN  rO  r  	accountIdr  s	            r   fetch_accountsznovadax.fetch_accounts  s      33F;; x4q#d)$ 		A1gG((':I##G\:DMM 	 			 7 <s   BBA5Bc           	      n   K   ddi}| j                  |||| j                  ||             d{   S 7 w)a  
        fetch all deposits made to an account

        https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws

        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :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>`
        r  coin_inNfetch_deposits_withdrawalsrC  r   r  rk  r   r   rE  s         r   fetch_depositsznovadax.fetch_deposits=  s@      I
 44T5%U\^dIeffffr  c           	      n   K   ddi}| j                  |||| j                  ||             d{   S 7 w)a$  
        fetch all withdrawals made from an account

        https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws

        :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>`
        r  coin_outNr  r  s         r   fetch_withdrawalsznovadax.fetch_withdrawalsN  s@      J
 44T5%U\^dIeffffr  c                 .  K   | j                          d{    i }d}|| j                  |      }|d   |d<   |||d<   | j                  | j                  ||             d{   }| j	                  |dg       }| j                  ||||      S 7 z7 -w)av  
        fetch history of deposits and withdrawals

        https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws

        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr   r`  sizer   )rA  r`  $privateGetWalletQueryDepositWithdrawrC  rn  parse_transactions)	r   r  rk  r   r   rE  r`  r   r   s	            r   r  z"novadax.fetch_deposits_withdrawals_  s      !!!
 }}T*H"*4.GJ#GFOBB4;;wX^C_``, ~~h3&&tXueDDK 	" as"   BBAB%B&,BBc                 ~    |j                  d      }| j                  |d|      }ddddd}| j                  |||      S )N r   r  okr   )Pending
confirmingr  FAIL)splitr  )r   r   partsr  s       r   parse_transaction_statusz novadax.parse_transaction_status  sP    
 S!!!%F3 #	
 &&99r   transactionc                    | j                  |dd      }| j                  |d      }|dk(  rd}n|dk(  rd}| j                  |d      }| j                  |d	      }| j                  |d
      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d      }| j	                  ||      }| j                  | j                  |d            }| j                  |d      }i d|d|d|d|d|d	|d|dd d|d|dd d|d|d|
d|d|	d| j                  |	      d d d d d ddS )Nr   r   r  COIN_INdepositCOIN_OUTrw   r   r  
addressTagtxHash	createdAt	updatedAtr`  statechainr  network	addressToaddressFromr  tagTotagFromr   updatedtxidr#  r)  )r`  r  rate)commentinternalr\  )r  r  r  r   r  r$  r=  )r   r%  r`  r   r  r   r  r  r6  r#  r5  r  r  r   r0  s                  r   r  znovadax.parse_transaction  s   4 T6:V49DZD!!+x8"";	:{L9X6%%k;?	##K=%%k:>
&&z8<..t/?/?W/UV"";8
K
"
 
 f	

 w
 w
 
 4
 3
 S
 t
 f
 D
 w
 D
  !
" Y/#
$  )
 	
r   c                 <  K   | j                          d{    i }d}|| j                  |      }|d   |d<   |||d<   |||d<   | j                  | j                  ||             d{   }| j	                  |dg       }| j                  ||||      S 7 7 -w)a  
        fetch all trades made by the user

        https://doc.novadax.com/en-US/#get-order-history

        :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>`
        Nr   r   r   r  r   )rA  r   privateGetOrdersFillsrC  rn  ro  r  s	            r   fetch_my_tradesznovadax.fetch_my_trades  s      !!!	
 [[(F &tGH$GG',GO$33DKK4PQQ, ~~h3  vue<<U 	"& Rr  r   GETc                 4   d| j                   z   dz   | j                  ||      z   }| j                  d   |   |z   }| j                  || j	                  |            }	|dk(  r|	r/|d| j                  |	      z   z  }n|dk(  r| j                          t        | j                               }
| j                  |
d}d }|dk(  r8| j                  |	      }| j                  | j                  |      d      }d	|d
<   n9|	r|d| j                  |	      z   z  }| j                  | j                  |	            }|dz   |z   dz   |z   dz   |
z   }| j                  | j                  |      | j                  | j                        t         j"                        |d<   ||||dS )Nr   r   r   ?r   )zX-Nova-Access-KeyzX-Nova-TimestampPOSTmd5zapplication/jsonzContent-Type
zX-Nova-Signature)urlmethodbodyheaders)r   implode_paramsr   r  extract_params	urlencodecheck_required_credentialsstrmillisecondsr   jsonhashencodekeysorthmacr   hashlibsha256)r   pathr   rD  r   rF  rE  rE  rC  queryr#  queryStringauths                r   signznovadax.sign  s   $s*T-@-@v-NNiis#g-		&$"5"5d";<(?sT^^E222I++-D--/0I%)[[$-G Kyy'"iiD(95A*<'3!666C"nnT\\%-@AD=7*T1K?$FRD*.))DKK4Et{{SWS^S^G_ahaoao*pG&'fdwOOr   reasonrC  rD  rF  rE  c
                    |y | j                  |d      }
|
dk7  ro| j                  |d      }| j                  dz   |z   }| j                  | j                  d   |
|       | j	                  | j                  d   ||       t        |      y )Nr  A10000r  r  r   r   )r  r   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   )r   r  rY  rC  rD  rF  rE  r   requestHeadersrequestBody	errorCoder  feedbacks                r   handle_errorsznovadax.handle_errors9  s     $$Xv6	 &&x;Gww}t+H001I9V^_001I7T\]))r   )N)@__name__
__module____qualname__r   r   r	   r   r   r
   r   dictr   r   r?  rK  rF  r   r   rP  r   rV  r   rj  rp  listr  r  r   r  r  r   r   floatr   r  r   r  r  r   r  r  r  r  r  r  r   rv   r   r  r  r   rw   r   r  r  r  r  r$  r  r<  rX  intrb  __classcell__)r   s   @r   r)   r)      s   R# Rh ') 3S 3& *, (V (@8
4 8
F 8
t-4 - -6 -^ 68 #/ #/F #/J 6:" 'G7 'G 'GR @DB (XS (X (XS\ (XTK Kv K KZ <@d[]  =  =S  =  =bfglbm  =D 8<$]ajl 3H 3HC 3HWZ 3Hquvzq{ 3Hj
 
4 
2) )$ *, , ,6 mqy{ \. \.I \.Y \.X] \.fi \.| 9=R &S &# &8 8<B &&C && &&P 04$UYbd 7= 7=C 7=s 7=imnsit 7=r 59tZ^gi [c [ [TW [nrsxny [" 7;\`ik [ [3 [VY [ptuzp{ [" ?CQUdhqs +=3 += +=3 +=^a +=Z
: 
:E Ev E EN ac )3 ) )C )TW )gt )V
t 
x 
= 
.<C <C < JNVX :3 : : :]h :B +- $g $L 04$UYbd g gC gs gimnyiz g" 37TX\eg gC gs gRU glpq|l} g" <@daenp 1ES 1E 1E[^ 1Euy  {F  vG 1Ef:s :C
T C
X C
Q\ C
J 37TX\eg 6=C 6=s 6=RU 6=p &eBSW P6# s  c TX `c r   r)   ). ccxt.async_support.base.exchanger   ccxt.abstract.novadaxr   rR  ccxt.base.typesr   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   r   r   r   r    r!   r"   r#   r$   r%   ccxt.base.decimal_to_precisionr&   ccxt.base.preciser'   r)    r   r   <module>rs     sq    6 -  y  y  y  y  y  * 0 - . - . ' & . ) * . * * 4 %ih ir   