
    E#i3                    X   S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJ r   S SKJ!r!  S SKJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S SKJ'r'  S SKJ(r(  S SK)J*r*  S SK+J,r,   " S S\\5      r-g)    )Exchange)ImplicitAPIN)AccountAnyBalances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                   F  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
S\S\	4S jrSHS	\S\	S\4S
 jjr0 4S\S\4S jjrS0 4S\S\4S jjrS0 4S\S\S\4S jjrSHS\S\	S\4S jjrSS0 4S\S\S\S\\   4S jjrSSS0 4S\S\S\S\S\\   4
S jjrSHS\	S\4S jjrS\4S jr0 4S\4S jjrS0 4S\S\S\ S\!S\"4
S jjr#S0 4S \S\$4S! jjr%S0 4S \S\$4S" jjr&SSS0 4S\$S\S\S\\'   4S# jjr(SSS0 4S\$S\S\S\\'   4S$ jjr)SSS0 4S\$S\S\S\\'   4S% jjr*SSS0 4S \S\$S\S\4S& jjr+S'\$4S( jr,SHS)\S\	S\'4S* jjr-0 4S+\S\!S,\S-\S\.4
S. jjr/SHS/\S0\0S\.4S1 jjr1S'\$S\$4S2 jr2S0 4S+\S\!S3\S4\$S\34
S5 jjr40 4S\\5   4S6 jjr6SSS0 4S+\$S\S\S\\3   4S7 jjr7SSS0 4S+\$S\S\S\\3   4S8 jjr8SSS0 4S+\$S\S\S\\3   4S9 jjr9S'\$4S: jr:SHS;\S0\0S\34S< jjr;SSS0 4S\$S\S\4S= jjr<S>S?0 SS4S@ jr=S+\>SA\SB\SC\SD\SE\4SF jr?SGr@U =rA$ )Inovadax   returnc           "        > U R                  [        [        U ]  5       SSS/SS0 SS _SS_S	S
_SS
_SS
_SS
_SS
_SS
_SS
_SS
_SS_SS
_SS
_SS_SS
_SS
_SS_0 SS
_SS_SS_SS_SS_SS
_SS_S S
_S!S
_S"S
_S#S
_S$S
_S%S
_S&S_S'S
_S(S
_S)S
_E0 S*S
_S+S
_S,S
_S-S_S.S_S/S
_S0S
_S1S
_S2S
_S3S
_S4S
_S5S
_S6S
_S7S
_S8S
_S9S
_S:S
_E0 S;S
_S<S
_S=S
_S>S
_S?S
_S@S
_SAS
_SBS
_SCS
_SDS_SES
_SFS
_SGS
_SHS
_SIS
_SJS_SKS_E0 SLS
_SMS
_SNS
_SOS_SPS
_SQS
_SRS_SSS_STS_SUS_SVS
_SWS
_SXS
_SYS
_SZS
_S[S
_S\S
_E0 S]S
_S^S
_S_S_S`S_SaS_SbS_ScS
_SdS
_SeSf_SgS
_ShS
_SiS_SjS
_SkS
_SlS
_SmS
_SnS
_ES
S
SSSo.ESpSqSrSsStSuSvSwSx.SySzSzS{.S|S}/S~SS.SSSSSSSSSS.0SSSSSSSSSS.	SSSSSSSSS.S.S{.SS
SU R	                  S5      U R	                  S5      S.0SSS.[
        0 S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[        _S[         _S[         _S[         _S[         _S[         _["        [         [         [$        [         [         ["        S.E0 S.SS0SS0S.S
S
SSS S
S
S S
S
S
S
S.S
S
S
SS
S
SS.S S
SSSS
S.S
S
S
S
S.S
S S
S
S
S.S
SSSS
S
S
S.S
SSSSS
S
S
S.SS 0S.	S S S.S S S.S.S.5      $ )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)rt   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   )	sandboxrA   createOrdersrs   r{   rx   r}   rO   rt   )linearinverse)r2   r4   r5   )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    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/novadax.pyr  novadax.describe   s(	   gt = ? 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* "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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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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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N "'#(  UkZ   $!	 ~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KtB
 t t	    c                 H    U R                  U5      nU R                  US5      $ )a+  
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_timenovadax.fetch_timeV  s)     008   622r  c                 l    U R                  U5      nU R                  US/ 5      nU R                  U5      $ )z
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_marketsnovadax.fetch_marketsi  s9     ..v6( x4!!$''r  marketc                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  U5      nU R                  U5      nU R                  US5      n0 SU_SUS-   U-   _SU_SU_S	S _S
U_SU_SS _SS_SS_SS_SS_SS_SS_SUS:H  _SS_SS _S S S S S S U R                  U R                  U R                  US5      5      5      U R                  U R                  U R                  US5      5      5      S.S S S.U R	                  US5      S S.S S S.U R	                  US5      S S.S.S US .
E$ )!NbaseCurrencyquoteCurrencysymbolstatusr   /basequotesettlebaseIdquoteIdsettleIdtyper2   Tr3   Fr4   r5   r6   activeONLINEcontractr   amountPrecisionpricePrecision)r   price)minmaxminOrderAmountminOrderValue)r   r   r4  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_marketnovadax.parse_market  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                 2   U R                  US5      nU R                  US5      nU R                  XBS5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  0 SU_SU_SU R	                  U5      _S	U R                  US
5      _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SS _SS _SU_SU_SU_SS _SS _SS _SS _UU	US.EU5      $ )N	timestampr%  _open24h	lastPricebaseVolume24hquoteVolume24hdatetimehighhigh24hlowlow24hbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechanger   average)
baseVolumequoteVolumerB  )r  rC  safe_symbolsafe_tickeriso8601)
r  rI  r!  rK  marketIdr%  r[  r]  ra  rb  s
             r  parse_tickernovadax.parse_ticker  s   " %%fk:	##FH5!!(C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                     U R                  5         U R                  U5      nSUS   0nU R                  U R                  XB5      5      nU R	                  US0 5      nU R                  Xc5      $ )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_dictrg  )r  r%  r  r!  requestr  r  s          r  fetch_tickernovadax.fetch_ticker  sn     	V$fTl
 --dkk'.JK& ~~h3  ..r  symbolsc                 &   U R                  5         U R                  U5      nU R                  U5      nU R                  US/ 5      n0 n[	        S[        U5      5       H  nU R                  XF   5      nUS   nXuU'   M!     U R                  USU5      $ )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%  )rj  market_symbolspublicGetMarketTickersr  rangelenrg  filter_by_array_tickers)	r  rq  r  r  r  resultirI  r%  s	            r  fetch_tickersnovadax.fetch_tickers  s     	%%g...v6* x4q#d)$A&&tw/FH%F#6N % ++FHgFFr  r   c                    U R                  5         U R                  U5      nSUS   0nUb  X%S'   U R                  U R                  XS5      5      nU R	                  US0 5      nU R                  US5      nU R                  XtS   USS5      $ )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   r   r  rK  bidsasks)rj  r!  publicGetMarketDepthrl  r  r  parse_order_book)	r  r%  r   r  r!  rn  r  r  rK  s	            r  fetch_order_booknovadax.fetch_order_book@  s     	V$fTl
 $G,,T[[-IJ( x4%%dK8	$$T(+;YPVWWr  tradec                 B   U R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	U R                  XS5      n
U R                  US	5      nU R                  US
5      nS nUb8  U R                  US5      nU R	                  U5      nU R                  US5      US.nU R                  UUUU R                  U5      U
S UUUS UUUS.U5      $ )Nr   orderIdrK  sider4  r   r%  rL  rolefeefeeCurrency	feeAmountr9  currency)r   orderrK  rQ  r%  r.  r  r4  r   r9  takerOrMakerr  rB  )rC  r  safe_string_lowerrc  rD  
safe_tradere  )r  r  r!  r   r  rK  r  priceStringamountStringrf  r%  r  	feeStringr  feeCurrencyIdfeeCurrencyCodes                   r  parse_tradenovadax.parse_tradej  sM   V eT*""5)4%%e[9	%%eV4&&ug6''x8##E84!!(C8--eV<$$UE2	  ,,UMBM"55mDO((<+C "Y/ "( 
  	r  sincec                     U R                  5         U R                  U5      nSUS   0nUb  X6S'   U R                  U R                  Xd5      5      nU R	                  US/ 5      nU R                  XX#5      $ )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   r   r  )rj  r!  publicGetMarketTradesrl  	safe_listparse_trades)	r  r%  r  r   r  r!  rn  r  r  s	            r  fetch_tradesnovadax.fetch_trades  s~     	V$fTl
 $G--dkk'.JK ~~h3  u<<r  r   	timeframec                    U R                  5         U R                  U5      nUS   U R                  U R                  X"5      S.nU R	                  U5      nU R                  5       n	Uc  SnUc  XU-  -
  US'   XS'   O/U R                  US-  5      n
XS'   U R                  XU-  5      US'   U R                  U R                  Xu5      5      nU R                  US/ 5      nU R                  XX#U5      $ )aA  
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%  uniti  fromtoi  r  )rj  r!  rC  r  parse_timeframesecondsparse_to_intsumpublicGetMarketKlineHistoryrl  r  parse_ohlcvs)r  r%  r  r  r   r  r!  rn  durationnow	startFromr  r  s                r  fetch_ohlcvnovadax.fetch_ohlcv  s     	V$Tl$$T__iK
 ''	2lln=E=!H$44GFODM))%$,7I'FO HHY0@AGDM33DKK4PQ( ~~h3  yGGr  c           	      0   U R                  U R                  S0 5      nU R                  USS5      nU R                  US5      U R	                  US5      U R	                  US5      U R	                  US5      U R	                  US5      U R	                  X5      /$ )	Nrt   r   r   score	openPrice	highPricelowPrice
closePrice)r  r  rC  safe_timestamprF  )r  ohlcvr!  r  volumeFields        r  parse_ohlcvnovadax.parse_ohlcv  s     //$,,bA&&w(Cw/UK0UK0UJ/UL1U0
 	
r  c                    U R                  US/ 5      nUS S S.n[        S[        U5      5       H}  nX$   nU R                  US5      nU R	                  U5      nU R                  5       nU R                  US5      US'   U R                  US5      US'   U R                  US	5      US
'   XU'   M     U R                  U5      $ )Nr  )rB  rK  rQ  r   r  balancetotal	availablefreeholdused)r  ru  rv  rC  rD  accountsafe_balance)	r  r  r  rx  ry  r  
currencyIdcoder  s	            r  parse_balancenovadax.parse_balance'  s    x4

 q#d)$AgG))':>J**:6DllnG#//CGG"..wDGFO"..w?GFO"4L %   ((r  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )a6  
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>`
)rj  privateGetAccountGetBalancer  r  s      r  fetch_balancenovadax.fetch_balance9  s3     	33F; !!(++r  r.  r  r   r4  c                    U R                  5         U R                  U5      nUR                  5       nUR                  5       n	US   U	S.n
U R                  USS5      nUc+  US:X  d  US:X  a  [	        U R
                  S-   U-   S	-   5      eOYUS
:X  a  SnOUS:X  a  SnU	S:X  a  SOSnU R                  USU5      U
S'   U R                  X5      U
S'   U R                  USS/5      nUS
:X  d  US:X  a*  U R                  X5      U
S'   U R                  X5      U
S'   GOUS:X  d  US:X  a  U	S:X  a  U R                  X5      U
S'   OU	S:X  a  SnSnU R                  USSS5      u  pU R                  USS5      nU R                  US5      nUb  U R                  X5      nOU(       ag  Uc  [        U R
                  S-   5      eU R                  U5      nU R                  U5      n[        R                   " UU5      nU R                  UU5      nOU R                  X5      nXS'   XS'   U R#                  U R%                  X5      5      nU R'                  US0 5      nU R)                  UU5      $ )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operatorr4  r   SELLTrA   !createMarketBuyOrderRequiresPricer9  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  )rj  r!  uppersafe_value_2r   r   rC  price_to_precisionomitamount_to_precisionhandle_option_and_paramssafe_number_2cost_to_precisionr!   number_to_stringr'   
string_mulprivatePostOrdersCreaterl  rm  parse_order)r  r%  r.  r  r   r4  r  r!  uppercaseTypeuppercaseSidern  r   defaultOperatorquoteAmountr  r9  r  r  costRequestr  r  s                        r  create_ordernovadax.create_orderT  s    	V$



Tl!
 ((M-=M3Q'2f(fiv(v  zC  )C  D  D 4R ' ,(* -(5(>eUO"&"2"26:"WGJ#'#:#:6#PGK YYv'DEFW$-<*G#66vEGG $ 8 8 HGHx']m-K&$($<$<V$L!%'"481<@<Y<YZ`bo  rU  W[  =\91))&&'B662#"&"8"8"FK6}*477  6A  ,A  B  B'+'<'<V'D&*&;&;E&B&-&8&8{&S&*&<&<V[&Q"&"8"8"HK#. '//G0LM0 ~~h3f--r  r   c                     U R                  5         SU0nU R                  U R                  XC5      5      nU R                  US0 5      nU R	                  U5      $ )a4  
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  )rj  privatePostOrdersCancelrl  rm  r  r  r   r%  r  rn  r  r  s          r  cancel_ordernovadax.cancel_order  s\     	"
 //G0LM ~~h3%%r  c                     U R                  5         SU0nU R                  U R                  XC5      5      nU R                  US0 5      nU R	                  U5      $ )aN  
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  )rj  privateGetOrdersGetrl  rm  r  r  s          r  fetch_ordernovadax.fetch_order  s\     	"
 ++DKK,HI, ~~h3%%r  c                    U R                  5         0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   Ub  X%S'   U R                  U R                  XT5      5      nU R	                  US/ 5      nU R                  XX#5      $ )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  )rj  r!  privateGetOrdersListrl  r  parse_orders	r  r%  r  r   r  rn  r!  r  r  s	            r  fetch_ordersnovadax.fetch_orders  s     	
 [[(F &tGH$G',O$,,T[[-IJ0 ~~h3  u<<r  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )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  rl  r  r%  r  r   r  rn  s         r  fetch_open_ordersnovadax.fetch_open_orders/  s/     E
   {{77STTr  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )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_ordersnovadax.fetch_closed_orders@  s/     0
   {{77STTr  c                     U R                  5         SU0nU R                  U R                  Xe5      5      nSnUb  U R                  U5      nU R	                  US/ 5      n	U R                  XX45      $ )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  )rj  privateGetOrdersFillrl  r!  r  r  )
r  r   r%  r  r   r  rn  r  r!  r  s
             r  fetch_order_tradesnovadax.fetch_order_tradesQ  sw     	"
 ,,T[[-IJ[[(Fx4,   u<<r  r&  c                 :    SSSSSSSS.nU R                  X!U5      $ )Nr[  closedcanceledrejected)	SUBMITTED
PROCESSINGPARTIAL_FILLED	CANCELINGFILLEDCANCELEDREJECTEDrC  r  r&  statusess      r  parse_order_statusnovadax.parse_order_status~  s3     $""
 &99r  r  c                    U R                  US5      nU R                  US5      nU R                  US5      nU R                  USS5      nU R                  US5      nU R                  US5      nU R                  U R                  US5      5      n	U R	                  US	5      n
U R                  US
5      nU R                  US5      nS nU R                  US5      nUb  US S.nU R                  US5      nU R                  XS5      nU R                  0 SU_SS _SU_S	U
_SU R                  U
5      _SS _SU_SU_SS _SS _SU_SU_SU R                  US5      _SU_SU_SU_SU_S U	US S.EU5      $ )Nr   r   r4  filledValuer  r.  r  r&  rK  averagePricefilledAmount	filledFeer  r%  rL  clientOrderIdrB  rQ  lastTradeTimestampr   postOnlyr   r  r9  r`  filled)	remainingr&  r  trades)	rC  safe_string_2r  r  r  rF  rc  
safe_orderre  )r  r  r!  r   r   r4  r9  r.  r  r&  rK  r`  r  r  feeCostrf  r%  s                    r  r  novadax.parse_order  s!   8 eT*!!%2  0!!%@%%eV4%%eV4(()9)9%)JK%%e[9	""5.9!!%8""5+6 C ##E84!!(C8  
" 
T 
 E 
 	 

 Y/ 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D,,UK@ 
 f 
 D 
  w! 
" f# 
$ + 
, - 	r  r  fromAccount	toAccountc                    U R                  5         U R                  U5      nUS:w  a  US:w  a  [        U R                  S-   5      eUS:X  a  SOSnU R	                  X5      US   US:X  a  UOUUS.nU R                  U R                  X5      5      n	U R                  X5      n
U R                  U R                  S0 5      nU R                  USS	5      nU(       a  X:S
'   XJS'   X*S'   U
$ )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   )rj  r  r   r   currency_to_precisionprivatePostAccountSubsTransferrl  parse_transferr  r  	safe_bool)r  r  r   r&  r'  r  r  r.  rn  r  r   transferOptionsr   s                r  r   novadax.transfer  s     	==&& Y&%8*t tuu )4v(=#DY"88F #'+?#?Yk 	
 66t{{77ST &&x://$,,
BG"&..B[]a"b"&1]#$-[!!'Xr  r   r  c           
          U R                  US5      nU R                  US5      nU R                  S U5      nUUS US S S S US.	$ )Nr  message)	rB  r   r   r  r&  r'  rK  rQ  r&  )rC  rD  )r  r   r  r   r&  currencyCodes         r  r/  novadax.parse_transfer  s_     h/!!(I6..tX>$

 
	
r  c                 .    SS0nU R                  X!S5      $ )NSUCCESSpendingfailedr  r  s      r  parse_transfer_statusnovadax.parse_transfer_status  s#    y
 (;;r  addresstagc                 
   U R                  XE5      u  pEU R                  5         U R                  U5      nUS   U R                  X5      US.nUb  XGS'   U R	                  U R                  Xu5      5      nU R                  X5      $ )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   walletr>  )handle_withdraw_tag_and_paramsrj  r  r-  privatePostAccountWithdrawCoinrl  parse_transaction)	r  r  r   r=  r>  r  r  rn  r  s	            r  r   novadax.withdraw  s     99#F==&TN00>

 ? EN66t{{77ST %%h99r  c                    U R                  U5      nU R                  US/ 5      n/ n[        S[        U5      5       HA  nX5   nU R	                  US5      nU R	                  US5      nUR                  UUSUS.5        MC     U$ )a5  
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  rB  )privateGetAccountSubsr  ru  rv  rC  append)	r  r  r  r  rx  ry  r  	accountIdr.  s	            r  fetch_accountsnovadax.fetch_accounts:  s     --f5 x4q#d)$AgG((':I##G\:DMM 	 	 % r  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )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_withdrawalsrl  r  r  r  r   r  rn  s         r  fetch_depositsnovadax.fetch_deposits`  s.     I
 ..tE;;wC_``r  c           	      L    SS0nU R                  XX0R                  XT5      5      $ )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_outrN  rP  s         r  fetch_withdrawalsnovadax.fetch_withdrawalsq  s.     J
 ..tE;;wC_``r  c                     U R                  5         0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   U R                  U R                  XT5      5      nU R	                  US/ 5      nU R                  XX#5      $ )a6  
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  )rj  r  $privateGetWalletQueryDepositWithdrawrl  r  parse_transactions)	r  r  r  r   r  rn  r  r  r  s	            r  rO  "novadax.fetch_deposits_withdrawals  s     	
 }}T*H"*4.GJ#FO<<T[[=YZ, ~~h3&&tuDDr  c                 |    UR                  S5      nU R                  USU5      nSSSSS.nU R                  X1U5      $ )N r   r9  okr:  )Pending
confirmingr8  FAIL)splitrC  )r  r&  partsr  s       r  parse_transaction_status novadax.parse_transaction_status  sN    
 S!!!%F3 #	
 &99r  transactionc                    U R                  USS5      nU R                  US5      nUS:X  a  SnOUS:X  a  SnU R                  US5      nU R                  US	5      nU R                  US
5      nU R                  US5      nU R                  US5      n	U R                  US5      n
U R                  US5      nU R	                  X5      nU R                  U R                  US5      5      nU R                  US5      n0 SU_SU_SU_SU_SU_S	U_SU_SS _SU_SU_SS _SU_SU_SU
_SU_SU	_SU R                  U	5      _S S S S S S.S.E$ )Nr   r  r.  COIN_INdepositCOIN_OUTr   r   r=  
addressTagtxHash	createdAt	updatedAtr  statechainrB  network	addressToaddressFromr>  tagTotagFromr&  updatedtxidrK  rQ  )r  r9  rate)commentinternalr  )r"  rC  rF  r  rD  rd  re  )r  rf  r  r   r.  r   r=  r>  rw  rK  rv  r  r  r&  rq  s                  r  rC  novadax.parse_transaction  s   4 T6:V49DZD!!+x8"";	:{L9X6%%k;?	##K=%%k:>
&&z<..t/?/?W/UV"";8
K
"
 
 f	

 w
 w
 
 4
 3
 S
 t
 f
 D
 w
 D
  !
" Y/#
$  )
 	
r  c                    U R                  5         0 nSnUb  U R                  U5      nUS   US'   Ub  X5S'   Ub  X%S'   U R                  U R                  XT5      5      nU R	                  US/ 5      nU R                  XX#5      $ )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  )rj  r!  privateGetOrdersFillsrl  r  r  r  s	            r  fetch_my_tradesnovadax.fetch_my_trades	  s     		
 [[(F &tGH$G',O$--dkk'.JK, ~~h3  u<<r  r   GETc                 D   SU R                   -   S-   U R                  X5      -   nU R                  S   U   U-   nU R                  X@R	                  U5      5      n	US:X  a   U	(       a  USU R                  U	5      -   -  nGOUS:X  Ga  U R                  5         [        U R                  5       5      n
U R                  U
S.nS nUS:X  a8  U R                  U	5      nU R                  U R                  U5      S5      nS	US
'   O>U	(       a  USU R                  U	5      -   -  nU R                  U R                  U	5      5      nUS-   U-   S-   U-   S-   U
-   nU R                  U R                  U5      U R                  U R                  5      [         R"                  5      US'   XXeS.$ )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   r  r  r  r  rn  r  queryrK  queryStringauths                r  signnovadax.signA  s   $s*T-@-@-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&'dOOr  reasonr  r  r  r  c
                    Uc  g U R                  US5      n
U
S:w  am  U R                  US5      nU R                  S-   U-   nU R                  U R                  S   X5        U R	                  U R                  S   X5        [        U5      eg )Nr  A10000r4  r]  r   r   )rC  r   throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr   )r  r  r  r  r  r  r  r  requestHeadersrequestBody	errorCoder4  feedbacks                r  handle_errorsnovadax.handle_errors\  s     $$Xv6	 &&x;Gww}t+H001I9_001I7]))r   )N)B__name__
__module____qualname____firstlineno__r   r  r	   r  r   r
   r  dictrG  r   rg  r  ro  r   r   rz  r   r  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   rJ  rQ  rU  rO  rd  rC  r~  r  intr  __static_attributes____classcell__)r  s   @r  r)   r)      s   u# un	 !# 3s 3& $& ($v, (@8
4 8
F 8
t-4 - -6 -^ 02 #/3 #/f #/J 04B 'GW 'G7 'GR :>b (Xs (X3 (XY (XTK Kv K KZ 6:UW  =3  =s  =#  =\`af\g  =D 9=4^bkm 3H# 3H# 3HS 3HX[ 3Hrvw{r| 3Hj
 
4 
2) )$ $& ,( ,6 gksu \.3 \.i \.y \.RW \.`c \.| 37r &s &C &8 26b &&c &&3 &&P *.Dt\^ 7=3 7=c 7= 7=cghmcn 7=r /3TXac U U3 Uc Uhlmrhs U" 154VZce U# US UPS Ujnotju U" 9=4^bkm +=S +=# +=S +=X[ +=Z
: 
:E Ev E EN [] )S )% )c )c )an )V
t 
x 
= 
.<C <C < KOWY :S :% :# :C :^i :B %' $4= $L *.Dt\^ a3 ac a acghsct a" -1tRV_a ac a aC afjkvfw a" 6:[_hj 1Es 1E# 1EUX 1Eost  pA 1Ef:s :C
T C
X C
Q\ C
J -1tRV_a 6=c 6= 6=C 6=p &eBSW P6# s  c TX `c  r  r)   ).ccxt.base.exchanger   ccxt.abstract.novadaxr   r  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  r  <module>r     sq    ( -  y  y  y  y  y  * 0 - . - . ' & . ) * . * * 4 %Lh Lr  