
    E#ik                         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  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)AnyBalancesIntMarketNum	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTrade)List)ExchangeError)ArgumentsRequired)	TICK_SIZE)Precisec                   v  ^  \ rS rSrS\4U 4S jjrS\4S jr0 4S\4S jjrS0 4S\	S\
S\4S	 jjrS S
\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S0 4S\	S\
S\
S\\   4S jjrSSS0 4S\S\
S\
4S jjrS S\S\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S0 SS4S jr!Sr"U =r#$ )!coinspot   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_S/S_S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_E0 S:S_S;S_S<S_S=S_S>S_S?S_S@S_SAS_SBS_SCS_SDS_SES_SFS_SGS_SHS_SIS_SJS_E0 SKS_SLS_SMS_SNS_SOS_SPS_SQS_SRS_SSS_STS_SUS_SVS_SWS_SXS_SYS_SZS_S[S_ESSS\.ES]S^S_S`.SaS_SbSc.SdSe/0Sf/ SgQ0S`.U R	                  ShSiSjSkShSlSSSm.5      U R	                  SnSoSpSkSnSlSSSm.5      U R	                  SqSrSsSkSqSlSSSm.5      U R	                  StSuSvSkStSlSSSm.5      U R	                  SwSxSySkSwSlSSSm.5      U R	                  SzS{S|SkSzSlSSSm.5      U R	                  S}S~SSkS}SlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      U R	                  SSSSkSSlSSSm.5      S.SS0SS0SSSS SSSS SSSSS.SSSSSSSS.S SS SSSS.S S S S S S.	S S S.S S S.S.[
        S.5      $ )Nr   CoinSpotAUi  FCORSspotTmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTradesfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOptionfetchOptionChainfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMarginsetMarginMode)setPositionModewszchttps://user-images.githubusercontent.com/1294454/28208429-3cacdf9a-6896-11e7-854e-4c79a772a30f.jpgz"https://www.coinspot.com.au/pubapizhttps://www.coinspot.com.au/api)publicprivatezhttps://www.coinspot.com.auz0https://www.coinspot.com.au/register?code=PJURCU)logoapiwwwdocreferralgetlatestpost)orderszorders/historyzmy/coin/depositzmy/coin/sendz	quote/buyz
quote/sellzmy/balancesz	my/orderszmy/buyzmy/sellzmy/buy/cancelzmy/sell/cancelzro/my/balanceszro/my/balances/{cointype}zro/my/depositszro/my/withdrawalszro/my/transactionszro/my/transactions/{cointype}zro/my/transactions/openz"ro/my/transactions/{cointype}/openzro/my/sendreceivezro/my/affiliatepaymentszro/my/referralpaymentsadaADA/AUDADAAUDaud)idsymbolbasequotebaseIdquoteIdtyper   btcBTC/AUDBTCethETH/AUDETHxrpXRP/AUDXRPltcLTC/AUDLTCdogeDOGE/AUDDOGErfoxRFOX/AUDRFOXpowrPOWR/AUDPOWRneoNEO/AUDNEOtrxTRX/AUDTRXeosEOS/AUDEOSxlmXLM/AUDXLMrhocRHOC/AUDRHOCgasGAS/AUDGAS)r   r   r   r   r   r   r   r   r   r   r   r   r   r   DRKDASHprivate_post_my_balances)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergi )r   limitdaysBack	untilDayssymbolRequired)	sandboxr,   createOrdersrV   
fetchOrderfetchOpenOrdersfetchOrdersfetchClosedOrders
fetchOHLCV)linearinverse)r   r!   r"   )r   name	countries	rateLimitprohasurlsrx   marketscommonCurrenciesoptionsfeaturesprecisionMode)deep_extendsuperr   describesafe_market_structurer   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/coinspot.pyr   coinspot.describe   sQ	   h > @XXX %X 	X
 %X %X UX $UX 'X X tX $UX  X $UX tX  7!X" 9%#X$ &u%X& ('X( ')X* (+X, "5-X. /X0 &u1X2 "53X4 +E5X6 )%7X8 #E9X: ,U;X< '=X> (?X@ &uAXB 'CXD (EXF #EGXH *5IXJ $UKXL uMXN "5OXP *5QXR +ESXT )%UXV  WXX !%YXZ %e[X\ $U]X^ &u_X` -eaXb /cXd "5eXf #EgXh +EiXj !%kXl "5mXn &uoXp +EqXr  sXt $UuXv +EwXx %eyXz u{X| #E}X~ !$X@  AXB 'CXD $UEXF !%GXH *5IXJ (KXL %eMXN )%OXP )%QXR tSXT UXV tWXX "5YXZ #E[X\ )%]X^ _X` #EaXb &ucXd ueXf ugXh UiXj  kXl $)oXt ~B@ 58N	    !F  55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z 66fPZdjuz  GM  Z_  io  y}  8~   66fPZdjuz  GM  Z_  io  y}  8~   66fPZdjuz  GM  Z_  io  y}  8~  55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z55Uiafqv  CH  UZ  dj  tx  7y  z 66fPZdjuz  GM  Z_  io  y}  8~  55Uiafqv  CH  UZ  dj  tx  7y  z" v!  :
  %&+(-,0,1).+06:#(#("'#(	( #($)$)+027/4#()$, %)&+!%$*%+*/& #''+#')-"&I%N ##
 ##W/` 'cRC
 R R	    c                    SU0nU R                  USS5      n[        U[        5      (       a  [        S[	        U5      5       H~  nX4   n[        UR                  5       5      n[        S[	        U5      5       HE  nXg   nXX   n	U R                  U5      n
U R                  5       nU R                  U	S5      US'   XU
'   MG     M     Or[        UR                  5       5      n[        S[	        U5      5       H@  nXd   nU R                  U5      n
U R                  5       nU R                  X85      US'   XU
'   MB     U R                  U5      $ )Ninfobalancebalancesr   total)
safe_value_2
isinstancelistrangelenkeyssafe_currency_codeaccountsafe_stringsafe_balance)r   responseresultr   i
currenciescurrencyIdsj
currencyIdr   coder   s               r   parse_balancecoinspot.parse_balance   s1   )$$Xy*Eh%%1c(m,%[
":??#45q#k"23A!,J(4G22:>D"llnG'+'7'7'KGG$#*4L 4 - x}}/K1c+./(^
..z:,,.#'#3#3H#I &t 0   ((r   c                     U R                  5         U R                  U R                  SS5      n[        X5      " U5      nU R	                  U5      $ )a1  
query for balance and get the amount of funds available for trading or funds locked in orders

https://www.coinspot.com.au/api#listmybalance

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
r4   r   )load_marketsr   r   getattrr  )r   paramsmethodr   s       r   fetch_balancecoinspot.fetch_balance   sK     	!!$,,@Z[4(0" !!(++r   Nr   r   c           	          U R                  5         U R                  U5      nSUS   0nU R                  U R                  XS5      5      nU R	                  XdS   SSSSS5      $ )	a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://www.coinspot.com.au/api#listopenorders

: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
cointyper   r   N	buyorders
sellordersrateamount)r  marketprivatePostOrdersextendparse_order_book)r   r   r   r  r  request	orderbooks          r   fetch_order_bookcoinspot.fetch_order_book  sl     	V$t
 **4;;w+GH	$$Yx0@$Uaciksttr   tickerr  c                     U R                  S U5      nU R                  US5      nU R                  0 SU_SS _SS _SS _SS _SU R                  US5      _SS _S	U R                  US	5      _S
S _SS _SS _SU_SU_SS _SS _SS _SS _S S US.EU5      $ )Nlastr   	timestampdatetimehighlowbid	bidVolumeask	askVolumevwapopenclosepreviousClosechange
percentageaverage)
baseVolumequoteVolumer   )safe_symbolr   safe_ticker)r   r  r  r   r  s        r   parse_tickercoinspot.parse_ticker1  s7    !!$// !
f!
!
 !
 D	!

 4!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ )!
* + 	r   c                     U R                  5         U R                  U5      nU R                  U5      nUS   nUR                  5       nU R	                  US0 5      nU R	                  Xe5      nU R                  Xs5      $ )a  
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

https://www.coinspot.com.au/api#latestprices

: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   prices)r  r  publicGetLatestlower	safe_dictr.  )r   r   r  r  r   r   r1  r  s           r   fetch_tickercoinspot.fetch_tickerT  su     	V$''/D\XXZ(B7 +  00r   symbolsc                 x   U R                  5         U R                  U5      n0 nU R                  US0 5      n[        UR	                  5       5      n[        S[        U5      5       H@  nXg   nU R                  U5      n	U	S   (       d  M$  U	S   n
XX   nU R                  X5      XJ'   MB     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://www.coinspot.com.au/api#latestprices

: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>`
r1  r   r   r   )
r  r2  r4  r   r   r   r   safe_marketr.  filter_by_array_tickers)r   r7  r  r   r   r1  idsr   r   r  r   r  s               r   fetch_tickerscoinspot.fetch_tickerss  s     	''/$ (B76;;=!q#c(#AB%%b)Ff~~)!%!2!26!B $ ++FHgFFr   sincec                     U R                  5         U R                  U5      nSUS   0n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://www.coinspot.com.au/api#orderhistory

: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  r  privatePostOrdersHistoryr  	safe_listparse_trades)	r   r   r>  r   r  r  r  r   tradess	            r   fetch_tradescoinspot.fetch_trades  sp     	V$t
 00W1MN (B7  >>r   c                    U R                  5         0 nSnUb  U R                  U5      nUb  U R                  U5      US'   U R                  U R	                  XT5      5      nU R                  US/ 5      n[        S[        U5      5       H
  n	SX   S'   M     U R                  US/ 5      n
[        S[        U
5      5       H
  n	SX   S'   M     U R                  X5      nU R                  XX#5      $ )	a  
fetch all trades made by the user

https://www.coinspot.com.au/api#rotransaction

: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>`
N	startdater  r   buysider  sell)
r  r  yyyymmddprivatePostRoMyTransactionsr  rA  r   r   array_concatrB  )r   r   r>  r   r  r  r  r   	buyTradesr   
sellTradesrC  s               r   fetch_my_tradescoinspot.fetch_my_trades  s     	[[(F#'==#7GK 33DKK4PQ6 NN8["=	q#i.)A#(IL  *^^HlB?
q#j/*A$*JM&! +""99  >>r   tradec                 $   S nS nS nU R                  US5      nU R                  USU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b  U R                  US5      nUnO[        R                  " Xy5      nU R                  US	5      nU R                  U5      nU R                  US
5      nU R                  US5      n[        R                  " X5      nSnU R                  U5      U R                  U5      S.nU R                  US UUU R                  U5      S S US U R                  U5      U R                  U	5      U R                  U5      US.U5      $ )Naudtotalr   rI  r  r  /solddater  createdaudfeeExGstaudGstr   )costcurrency)r   r   r   r  r  orderr   rI  takerOrMakerpricer  rZ  fee)r   r,  safe_integerr   
string_div	parse8601
string_addparse_numberr   
safe_tradeiso8601)r   rR  r  r  priceStringr_  audTotal
costStringrI  amountStringmarketIdr   rV  createdStringrX  rY  feeCostfeeCurrencyIds                     r   parse_tradecoinspot.parse_trade  s   4 	##E:6%%eWh?
v.''x8##E84!!(C8$$UJ7**5&9K I!,,ZFK ,,UI>M}5I**5-@K%%eX6F((=G!M))'2 33MBC "Y/ &&{3''5%%j1 
  	r   r   rI  r  r^  c                    U R                  5         SU R                  U5      -   nUS:X  a  [        U R                  S-   5      eU R	                  U5      nUS   UUS.n	[        X5      " U R                  X5      5      n
U R                  U
5      $ )aC  
create a trade order

https://www.coinspot.com.au/api#placebuyorder

:param str symbol: unified symbol of the market to create an order in
:param str type: must be 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
privatePostMyr  z' createOrder() allows limit orders onlyr   )r  r  r  )r  
capitalizer   r   r  r  r  parse_order)r   r   r   rI  r  r^  r  r  r  r  r   s              r   create_ordercoinspot.create_order4  s     	 4??4#888*S STTV$t

 4(W)EF))r   r   c                 R   U R                  US5      nUS:w  a  US:w  a  [        U R                  S-   5      eU R                  US5      nSU0nSnUS:X  a!  U R	                  U R                  XS5      5      nO U R                  U R                  XS5      5      nU R                  SU05      $ )ae  
cancels an open order

https://www.coinspot.com.au/api#cancelbuyorder
https://www.coinspot.com.au/api#cancelsellorder

:param str id: order id
:param str symbol: not used by coinspot cancelOrder()
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
rI  rH  rJ  z9 cancelOrder() requires a side parameter, "buy" or "sell"r   Nr   )r   r   r   omitprivatePostMyBuyCancelr  privatePostMySellCancel
safe_order)r   r   r   r  rI  r  r   s          r   cancel_ordercoinspot.cancel_orderO  s     /5=TV^#DGG.i$ijj66*"
 5=224;;w3OPH33DKK4PQH H 
  	r   ru   GETc                 |   U R                   S   U   S-   U-   nUS:X  a  U R                  5         U R                  5       nU R                  U R	                  SU0U5      5      nSU R
                  U R                  U R                  U5      U R                  U R                  5      [        R                  5      S.nXsXeS.$ )Nrx   rU  rv   noncezapplication/json)zContent-Typekeysign)urlr  bodyheaders)r   check_required_credentialsr  jsonr  apiKeyhmacencodesecrethashlibsha512)	r   pathrx   r  r  r  r  r  r  s	            r   r  coinspot.signn  s    iis#c)D0)++-JJLE99T[['5)96BCD 2{{		$++d"3T[[5Mw~~^G
 dOOr    )N)$__name__
__module____qualname____firstlineno__r   r   r   r  r  strr   r
   r  dictr   r   r.  r5  r   r   r<  r   r   rD  r   rP  ro  r   r   floatr	   ru  r|  r  __static_attributes____classcell__)r   s   @r   r   r      s   S# Sj) )0 $& ,( ,< :>b us u3 uY u&!4 ! !6 !F 02 13 1f 1> 04B 'GW 'G7 'GR 6:UW ?3 ?s ?# ?\`af\g ?: -1tRV_a 5?c 5? 5?C 5?nB Bv B BH gksu *3 *i *y *RW *`c *6 37r s C > &eBSW P Pr   r   )ccxt.base.exchanger   ccxt.abstract.coinspotr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r   r  r   r   <module>r     sI    ( .  C  C  C  C  * . 4 %h	Px h	Pr   