
    ei                    `   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-dS )    )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dFd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dFd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dee         f
dZdFd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+dFd(e
dede&fd)Z,i fd*ede d+ed,ede-f
d-Z.dFd.e
d/e/de-fd0Z0d&e#de#fd1Z1di fd*ede d2ed3e#de2f
d4Z3i fdee4         fd5Z5dddi fd*e#dededee2         fd6Z6dddi fd*e#dededee2         fd7Z7dddi fd*e#dededee2         fd8Z8d&e#fd9Z9dFd:e
d/e/de2fd;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dAedBedCe
dDefdEZ> xZ?S )Gnovadax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
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
dGd
dHd
dId
dJddKdi dLd
dMd
dNd
dOddPd
dQd
dRddSddTddUddVd
dWd
dXd
dYd
dZd
d[d
d\d
i d]d
d^d
d_dd`ddaddbddcd
ddd
dedfdgd
dhd
diddjd
dkd
dld
dmd
dnd
d
d
dddodpdqdrdsdtdudvdwdxdydzdzd{d|d}gd~ddddddddddddidddddddddd	ddddddddddd{dd
d|                     d          |                     d          didddt
          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt           dt           dt           dt           dt           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
ddddd
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borrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchAllGreeksfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricefetchMarkPricesfetchMyLiquidationsfetchMySettlementHistory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fetchTransactionsemulatedfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMargin)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)rs   r   )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@   createOrdersrr   rz   rw   r|   rN   rs   )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    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/novadax.pyr
  znovadax.describe   s
   gt 4 4 = = ? ? kkk %k 	k
 %k %k Uk $Uk 'k k tk $Uk  k /k ,Uk  0!k" t#k k$ (%k& ''k( ()k* "4+k,  -k. !%/k0 1k2 &u3k4 "55k6 +E7k8 )%9k: #E;k< ,U=k> $T?k@ 'AkB (CkD "5Ek k kF &uGkH (IkJ 1%KkL  MkN +DOkP &uQkR 'SkT (UkV #EWkX *5YkZ $U[k\ u]k^ "5_k` *5akb +Eckd )%ekf  gk k kh !%ikj %ekkl $Umkn &uokp -eqkr /skt "5ukv #Ewkx +Eykz {k| !%}k~ !%k@ "5AkB &uCkD +EEkF  GkH dIk k kJ $UKkL +EMkN %eOkP "4QkR uSkT #EUkV dWkX !$YkZ t[k\ #D]k^  _k` 'akb $Uckd !%ekf *5gkh (ikj %ekk k kl )%mkn )%okp tqkr skt Tukv twkx "5ykz #E{k| $Z}k~ (k@ )%AkB #DCkD EkF #EGkH &uIkJ uKkL UMk kN "'#(  Uk k kZ   $!	 	 ~78  44 E@  )**+,-*+)*())*01	 	 '(')'((*./()018:9:
 
 *+/1)*/135120112	 	 $ $L !&"&!..w77!..x8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 DL ## 
 ## UN NKtB
 tB
 t t t	    c                 X    |                      |          }|                     |d          S )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
        data)publicGetCommonTimestampsafe_integerr  paramsresponses      r  
fetch_timeznovadax.fetch_timeV  s/     0088   6222r  c                     |                      |          }|                     |dg           }|                     |          S )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
        r  )publicGetCommonSymbols
safe_valueparse_markets)r  r  r  r  s       r  fetch_marketsznovadax.fetch_marketsi  sB     ..v66( x44!!$'''r  marketc                    |                      |d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                      |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 |                     |                     |                      |d                              |                     |                     |                      |d                              dd d d|                     |d          d dd d d|                     |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   r0  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_market  sg   !!&.99""6?;;fh//&&v..''00!!&(3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,@,@AQAQRXZkAlAl,m,mnn**4+?+?@P@PQWYi@j@j+k+kll    
  ++F4DEE 
   
  ++FODD  $ a1
 1
 1
 1	
r  Ntickerc                    |                      |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|          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  rD  r  rF  marketIdr!  rV  rX  r\  r]  s
             r  parse_tickerznovadax.parse_ticker  s   " %%fk::	##FH55!!(FC88	2244%%fo>>
&&v/?@@ !
f!
!
 Y//!
 D$$VY77	!

 4##FH55!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r  r!  c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     ||          S )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>`
        r!  r   r  )load_marketsr  publicGetMarketTickerextend	safe_dictrb  )r  r!  r  r  requestr  r  s          r  fetch_tickerznovadax.fetch_ticker  s     	V$$fTl
 --dkk'6.J.JKK& ~~h33  v...r  symbolsc                 n   |                                   |                     |          }|                     |          }|                     |dg           }i }t	          dt          |                    D ]*}|                     ||                   }|d         }|||<   +|                     |d|          S )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>`
        r  r   r!  )rd  market_symbolspublicGetMarketTickersr  rangelenrb  filter_by_array_tickers)	r  rj  r  r  r  resultirD  r!  s	            r  fetch_tickersznovadax.fetch_tickers  s     	%%g....v66* x44q#d))$$ 	$ 	$A&&tAw//FH%F#F6NN++FHgFFFr  r   c                 `   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |di           }|                     |d          }|                     ||d         |dd          S )	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
        r!  r   Nr   r  rF  bidsasks)rd  r  publicGetMarketDepthrf  r  r  parse_order_book)	r  r!  r   r  r  rh  r  r  rF  s	            r  fetch_order_bookznovadax.fetch_order_book@  s     	V$$fTl
 $GG,,T[[&-I-IJJ( x44%%dK88	$$T6(+;YPVWWWr  tradec                    |                      |d          }|                      |d          }|                     |d          }|                     |d          }|                      |d          }|                      |d          }|                      |d          }	|                     |	|d          }
|                     |d	          }|                      |d
          }d }|D|                      |d          }|                     |          }|                      |d          |d}|                     ||||                     |          |
d |||d |||d|          S )Nr   orderIdrF  sider0  r   r!  rG  rolefeefeeCurrency	feeAmountr5  currency)r   orderrF  rL  r!  r*  r}  r0  r   r5  takerOrMakerr  r>  )r?  r  safe_string_lowerr^  r@  
safe_trader`  )r  rz  r  r   r|  rF  r}  priceStringamountStringra  r!  r  	feeStringr  feeCurrencyIdfeeCurrencyCodes                   r  parse_tradeznovadax.parse_tradej  s   V eT**""5)44%%e[99	%%eV44&&ug66''x88##E844!!(FC88--eV<<$$UE22	  ,,UMBBM"55mDDO((<<+ C "Y// "( 
  
   	r  sincec                 &   |                                   |                     |          }d|d         i}|||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )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>`
        r!  r   Nr   r  )rd  r  publicGetMarketTradesrf  	safe_listparse_trades)	r  r!  r  r   r  r  rh  r  r  s	            r  fetch_tradesznovadax.fetch_trades  s     	V$$fTl
 $GG--dkk'6.J.JKK ~~h33  vue<<<r  r   	timeframec                 B   |                                   |                     |          }|d         |                     | j        ||          d}|                     |          }|                                 }	|d}||	||z  z
  |d<   |	|d<   n9|                     |dz            }
|
|d<   |                     |
||z            |d<   |                     | 	                    ||                    }| 
                    |dg           }|                     |||||          S )	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
        r   )r!  unitNi  fromtoi  r  )rd  r  r?  r  parse_timeframesecondsparse_to_intsumpublicGetMarketKlineHistoryrf  r  parse_ohlcvs)r  r!  r  r  r   r  r  rh  durationnow	startFromr  r  s                r  fetch_ohlcvznovadax.fetch_ohlcv  s0    	V$$Tl$$T_iKK
 
 ''	22llnn=E=!EH$44GFOGDMM))%$,77I'GFO HHY0@AAGDM33DKK4P4PQQ( ~~h33  vy%GGGr  c           	      h   |                      | j        di           }|                     |dd          }|                     |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     ||          gS )	Nrs   r   r   score	openPrice	highPricelowPrice
closePrice)r  r  r?  safe_timestamprB  )r  ohlcvr  r  volumeFields        r  parse_ohlcvznovadax.parse_ohlcv  s     //$,bAA&&w(CCw//UK00UK00UJ//UL11UK00
 	
r  c                    |                      |dg           }|d d d}t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                                 }|                     |d          |d<   |                     |d          |d<   |                     |d	          |d
<   |||<   |                     |          S )Nr  )r>  rF  rL  r   r  balancetotal	availablefreeholdused)r  rn  ro  r?  r@  accountsafe_balance)	r  r  r  rq  rr  r  
currencyIdcoder  s	            r  parse_balanceznovadax.parse_balance'  s    x44
 

 q#d))$$ 	# 	#A1gG))':>>J**:66DllnnG#//CCGG"..wDDGFO"..w??GFO"F4LL  (((r  c                 ~    |                                   |                     |          }|                     |          S )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>`
        )rd  privateGetAccountGetBalancer  r  s      r  fetch_balanceznovadax.fetch_balance9  s?     	33F;; !!(+++r  r*  r}  r   r0  c                    |                                   |                     |          }|                                }|                                }	|d         |	d}
|                     |dd          }|*|dk    s|dk    rt	          | j        dz   |z   d	z             nf|d
k    rd}n|dk    rd}|	dk    rdnd}|                     |d|          |
d<   |                     ||          |
d<   |                     |ddg          }|d
k    s|dk    r4|                     ||          |
d<   | 	                    ||          |
d<   n$|dk    s|dk    r|	dk    r| 	                    ||          |
d<   n|	dk    rd}d}| 
                    |ddd          \  }}|                     |dd          }|                     |d          }||                     ||          }n|ro|t          | j        dz             |                     |          }|                     |          }t          j        ||          }|                     ||          }n|                     ||          }||
d<   ||
d<   |                     |                     |
|                    }|                     |di           }|                     ||          S )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>`
        r   )r!  r}  r   	stopPriceN
STOP_LIMITSTOP_MARKETz2 createOrder() requires a stopPrice parameter for z ordersLIMITMARKETBUYLTEGTEoperatorr0  r   SELLTr@   !createMarketBuyOrderRequiresPricer5  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  )rd  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privatePostOrdersCreaterf  rg  parse_order)r  r!  r*  r}  r   r0  r  r  uppercaseTypeuppercaseSiderh  r   defaultOperatorquoteAmountr  r5  r  r  costRequestr  r  s                        r  create_orderznovadax.create_orderT  sW    	V$$



Tl!
 
 ((MM--=M3Q3Q'2f(fiv(v  zC  )C  D  D  D 4R '' ,(** -(5(>(>eeUO"&"2"26:"W"WGJ#'#:#:6<#P#PGK YYv'DEEFW$$-<*G*G#66vuEEGG $ 8 8 H HGHx'']m-K-K&&$($<$<VV$L$L!!%''"481<@<Y<YZ`bo  rU  W[  =\  =\916))&&'BB6622#"&"8"8"F"FKK6 	I}*47  6A  ,A  B  B  B'+'<'<V'D'D&*&;&;E&B&B&-&8{&S&S&*&<&<V[&Q&Q"&"8"8"H"HK#. '//GV0L0LMM0 ~~h33f---r  r   c                     |                                   d|i}|                     |                     ||                    }|                     |di           }|                     |          S )aj  
        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>`
        r   r  )rd  privatePostOrdersCancelrf  rg  r  r  r   r!  r  rh  r  r  s          r  cancel_orderznovadax.cancel_order  sp     	"
 //GV0L0LMM ~~h33%%%r  c                     |                                   d|i}|                     |                     ||                    }|                     |di           }|                     |          S )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>`
        r   r  )rd  privateGetOrdersGetrf  rg  r  r  s          r  fetch_orderznovadax.fetch_order  sp     	"
 ++DKK,H,HII, ~~h33%%%r  c                 B   |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )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  )rd  r  privateGetOrdersListrf  r  parse_orders	r  r!  r  r   r  rh  r  r  r  s	            r  fetch_ordersznovadax.fetch_orders  s     	
 [[((F &tGH$GG',GO$,,T[[&-I-IJJ0 ~~h33  vue<<<r  c           	      b    ddi}|                      ||||                     ||                    S )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,CANCELINGr  rf  r  r!  r  r   r  rh  s         r  fetch_open_ordersznovadax.fetch_open_orders/  s;     E
   t{{7F7S7STTTr  c           	      b    ddi}|                      ||||                     ||                    S )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,REJECTEDr  r  s         r  fetch_closed_ordersznovadax.fetch_closed_orders@  s;     0
   t{{7F7S7STTTr  c                    |                                   d|i}|                     |                     ||                    }d}||                     |          }|                     |dg           }	|                     |	|||          S )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>`
        r   Nr  )rd  privateGetOrdersFillrf  r  r  r  )
r  r   r!  r  r   r  rh  r  r  r  s
             r  fetch_order_tradesznovadax.fetch_order_tradesQ  s     	"
 ,,T[[&-I-IJJ[[((Fx44,   vue<<<r  r"  c                 D    dddddddd}|                      |||          S )NrV  closedcanceledrejected)	SUBMITTED
PROCESSINGPARTIAL_FILLED	CANCELINGFILLEDCANCELEDREJECTEDr?  r  r"  statusess      r  parse_order_statusznovadax.parse_order_status~  s=     $""
 
 &&999r  r  c                 h   |                      |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|          S )Nr   r   r0  filledValuer  r*  r}  r"  rF  averagePricefilledAmount	filledFeer  r!  rG  clientOrderIdr>  rL  lastTradeTimestampr   postOnlyr   r  r5  r[  filled)	remainingr"  r  trades)	r?  safe_string_2r  r  r  rB  r^  
safe_orderr`  )r  r  r  r   r   r0  r5  r*  r}  r"  rF  r[  r  r  feeCostra  r!  s                    r  r  znovadax.parse_order  sg   8 eT**!!%22  00!!%@@%%eV44%%eV44(()9)9%)J)JKK%%e[99	""5.99!!%88""5+66  C ##E844!!(FC88  
" 
T 
 E 
 	 

 Y// 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D,,UK@@ 
 f 
 D 
  w! 
" f# 
$ + 
  
  
, -  	r  r  fromAccount	toAccountc                 
   |                                   |                     |          }|dk    r|dk    rt          | j        dz             |dk    rdnd}|                     ||          |d         |dk    r|n||d}|                     |                     ||                    }	|                     |	|          }
|                     | j	        di           }| 
                    |dd	          }|r||
d
<   ||
d<   ||
d<   |
S )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>`
        mainzH transfer() supports transfers between main account and subaccounts onlyzmaster-transfer-inzmaster-transfer-outr   )transferAmountr  subIdtransferTyper   r   Tr  r  r   )rd  r  r   r   currency_to_precisionprivatePostAccountSubsTransferrf  parse_transferr  r  	safe_bool)r  r  r   r  r  r  r  r*  rh  r  r   transferOptionsr   s                r  r   znovadax.transfer  s9    	==&&&  Y&%8%8*t tuuu )4v(=(=##DY"88vFF #'+?#?#?YYk 	
 
 66t{{7F7S7STT &&x:://$,
BGG"&..B[]a"b"b" 	(&1H]#$-H[!!'HXr  r   r  c           
          |                      |d          }|                      |d          }|                     d |          }||d |d d d d |d	S )Nr  message)	r>  r   r   r  r  r  rF  rL  r"  )r?  r@  )r  r   r  r   r"  currencyCodes         r  r  znovadax.parse_transfer  sm     h//!!(I66..tX>>$

 

 
	
r  c                 8    ddi}|                      ||d          S )NSUCCESSpendingfailedr  r  s      r  parse_transfer_statusznovadax.parse_transfer_status  s(    y
 &(;;;r  addresstagc                 R   |                      ||          \  }}|                                  |                     |          }|d         |                     ||          |d}|||d<   |                     |                     ||                    }|                     ||          S )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>`
        r   )r  r   walletNr#  )handle_withdraw_tag_and_paramsrd  r  r  privatePostAccountWithdrawCoinrf  parse_transaction)	r  r  r   r"  r#  r  r  rh  r  s	            r  r   znovadax.withdraw  s     99#vFFV==&&TN00v>>
 

 ? GEN66t{{7F7S7STT %%h999r  c                 >   |                      |          }|                     |dg           }g }t          dt          |                    D ]P}||         }|                     |d          }|                     |d          }|                    ||d|d           Q|S )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
        r  r   r  
subAccountN)r   r*  r  r>  )privateGetAccountSubsr  rn  ro  r?  append)	r  r  r  r  rq  rr  r  	accountIdr*  s	            r  fetch_accountsznovadax.fetch_accounts:  s     --f55 x44q#d))$$ 		 		A1gG(('::I##G\::DMM 	      r  c           	      b    ddi}|                      ||||                     ||                    S )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_infetch_deposits_withdrawalsrf  r  r  r  r   r  rh  s         r  fetch_depositsznovadax.fetch_deposits`  s;     I
 ..tUE4;;wX^C_C_```r  c           	      b    ddi}|                      ||||                     ||                    S )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_outr1  r3  s         r  fetch_withdrawalsznovadax.fetch_withdrawalsq  s;     J
 ..tUE4;;wX^C_C_```r  c                 4   |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )at  
        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  )rd  r  $privateGetWalletQueryDepositWithdrawrf  r  parse_transactions)	r  r  r  r   r  rh  r  r  r  s	            r  r2  z"novadax.fetch_deposits_withdrawals  s     	
 }}T**H"*4.GJ#GFO<<T[[RX=Y=YZZ, ~~h33&&tXueDDDr  c                     |                     d          }|                     |d|          }ddddd}|                     |||          S )N r   r  okr   )Pending
confirmingr  FAIL)splitr?  )r  r"  partsr  s       r  parse_transaction_statusz novadax.parse_transaction_status  s^    
 S!!!!%F33 #	
 
 &&999r  transactionc                     |                      |dd          }|                     |d          }|dk    rd}n|dk    r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S )Nr   r  r*  COIN_INdepositCOIN_OUTr   r   r"  
addressTagtxHash	createdAt	updatedAtr  statechainr>  network	addressToaddressFromr#  tagTotagFromr"  updatedtxidrF  rL  )r  r5  rate)commentinternalr  )r  r?  rB  r  r@  rD  r`  )r  rE  r  r   r*  r   r"  r#  rV  rF  rU  r  r  r"  rP  s                  r  r(  znovadax.parse_transaction  s:   4 T6::V449DDZD!!+x88"";	::{L99X66%%k;??	##K==%%k:>>
&&z8<<..t/?/?W/U/UVV"";88
K
"
 
 f	

 w
 w
 
 4
 3
 S
 t
 f
 D
 w
 D
  !
" Y//#
$   )
 
 
 	
r  c                 B   |                                   i }d}| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )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  )rd  r  privateGetOrdersFillsrf  r  r  r  s	            r  fetch_my_tradesznovadax.fetch_my_trades	  s     		
 [[((F &tGH$GG',GO$--dkk'6.J.JKK, ~~h33  vue<<<r  r   GETc                    d| j         z   dz   |                     ||          z   }| j        d         |         |z   }|                     ||                     |                    }	|dk    r|	r|d|                     |	          z   z  }n:|dk    r3|                                  t          |                                           }
| j	        |
d}d }|dk    rD| 
                    |	          }|                     |                     |          d          }d	|d
<   nE|	r|d|                     |	          z   z  }|                     |                     |	                    }|dz   |z   dz   |z   dz   |
z   }|                     |                     |          |                     | 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  rh  rc  queryrF  queryStringauths                r  signznovadax.signA  s   $s*T-@-@v-N-NNis#g-		&$"5"5d";";<<(?? 3sT^^E2222I++---D--//00I%)[$- G Kyy''"iiD(9(95AA*<'' 73!6!666C"nnT\\%-@-@AAD=7*T1K?$FRD*.))DKK4E4Et{{SWS^G_G_ahao*p*pG&'fdwOOOr  reasonrc  rd  rf  re  c
                 2   |d S |                      |d          }
|
dk    rv|                      |d          }| j        dz   |z   }|                     | j        d         |
|           |                     | j        d         ||           t          |          d S )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_errors\  s    4 $$Xv66	  &&x;;Gw}t+H001I9V^___001I7T\]]])))tr  )N)@__name__
__module____qualname__r   r
  r	   r  r   r
   r  dictrC  r   rb  rk  ri  r   r   rs  r   ry  r   r  r  listr  r  r   r  r  r   r   floatr   r  r   r  r  r   r  r  r  r  r  r  r   r   r   r  r!  r   r   r   r.  r4  r7  r2  rD  r(  r\  rx  intr  __classcell__)r  s   @r  r)   r)      s       u# u u u u u un	 !# 3 3s 3 3 3 3& $& ( ($v, ( ( ( (@8
4 8
F 8
 8
 8
 8
t- -4 - -6 - - - -^ 02 #/ #/3 #/f #/ #/ #/ #/J 04B 'G 'GW 'G7 'G 'G 'G 'GR :>b (X (Xs (X3 (XY (X (X (X (XTK K Kv K K K K KZ 6:UW  =  =3  =s  =#  =\`af\g  =  =  =  =D 9=4^bkm 3H 3H# 3H# 3HS 3HX[ 3Hrvw{r| 3H 3H 3H 3Hj
 
 
4 
 
 
 
2) ) ) ) )$ $& , ,( , , , ,6 gksu \. \.3 \.i \.y \.RW \.`c \. \. \. \.| 37r & &s &C & & & &8 26b && &&c &&3 && && && &&P *.Dt\^ 7= 7=3 7=c 7= 7=cghmcn 7= 7= 7= 7=r /3TXac U U U3 Uc Uhlmrhs U U U U" 154VZce U U# US UPS Ujnotju U U U U" 9=4^bkm += +=S +=# +=S +=X[ += += += +=Z
: 
: 
: 
: 
:E E Ev E E E E EN [] ) )S )% )c )c )an ) ) ) )V
 
t 
x 
= 
 
 
 
.<C <C < < < < KOWY : :S :% :# :C :^i : : : :B %' $ $4= $ $ $ $L *.Dt\^ a a3 ac a acghsct a a a a" -1tRV_a a ac a aC afjkvfw a a a a" 6:[_hj 1E 1Es 1E# 1EUX 1Eost  pA 1E 1E 1E 1Ef:s : : : :C
 C
T C
X C
Q\ C
 C
 C
 C
J -1tRV_a 6= 6=c 6= 6=C 6= 6= 6= 6=p &eBSW P P P P6# s  c TX `c        r  r)   ).ccxt.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>r     s   ( ' ' ' ' ' - - - - - -  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y  y       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * . . . . . . * * * * * * * * * * * * 4 4 4 4 4 4 % % % % % %L L L L Lh L L L L Lr  