
    E#i                         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  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)AnyBalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFeeInterfaceTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)InsufficientFunds)InvalidOrder)OrderNotFound)RateLimitExceeded)	TICK_SIZE)Precisec                     ^  \ rS rSrS\4U 4S jjr0 4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\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\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S:S\S\S\4S jjrS0 4S\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S0 4S\S\S	\S\\    4S  jjr"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\4S$ jr(S%\4S& 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0 4S,\S\4S. jjr0S/ r1S0S10 SS4S2 jr2S\3S3\S4\S5\S6\S7\4S8 jr4S9r5U =r6$ );coinmate   returnc                 &  > U R                  [        [        U ]  5       SS/ SQ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	_SUSV_SWS	_SXS	_SYS	_SZS	_S[S	_S\S	_ES	S	S	S	SS].ES^S_S`0SaSbScSd/SeSf.SSSSg.Sh/ SiQ0Sj/ SkQ0Sl.SmSSU R	                  Sn5      U R	                  So5      U R	                  Sp5      U R	                  Sn5      /U R	                  Sq5      U R	                  Sr5      /U R	                  Ss5      U R	                  St5      /U R	                  Su5      U R	                  Sv5      /U R	                  Sw5      U R	                  Sx5      /U R	                  Sy5      U R	                  Sz5      /U R	                  S{5      U R	                  S|5      /U R	                  S}5      U R	                  S~5      //U R	                  Sp5      U R	                  So5      /U R	                  Sq5      U R	                  S5      /U R	                  Ss5      U R	                  S|5      /U R	                  Su5      U R	                  S5      /U R	                  Sw5      U R	                  S5      /U R	                  Sy5      U R	                  S5      /U R	                  S{5      U R	                  S5      /U R	                  S}5      U R	                  S5      //S.S.0SSSSSSSSSSSS.	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	SSSS	S.S	S	S	S	S.S	S S	S	SS.S	SS S S	S	SS.S S S.	S S S.S S S.S.S[
        0[        [        [        [        [        [        S.S.[        S.5      $ )Nr!   CoinMate)GBCZEUiX  CORSTspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTradesfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrdersfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage)	setMarginsetMarginModesetPositionModetransferwithdrawzdhttps://user-images.githubusercontent.com/51840849/87460806-1c9f3f00-c616-11ea-8c46-a77018a8f3f4.jpgrestzhttps://coinmate.io/apizhttps://coinmate.iozhttps://coinmate.io/feeszhttps://coinmate.docs.apiary.iozhttps://coinmate.io/developerszHhttps://coinmate.io?referral=YTFkM1RsOWFObVpmY1ZjMGREQmpTRnBsWjJJNVp3PT0)logoapiwwwfeesdocreferral)apiKeysecretuidget)	orderBookticker	tickerAllproductstransactionstradingPairspost)4balancesbitcoinCashWithdrawalbitcoinCashDepositAddressesbitcoinDepositAddressesbitcoinWithdrawalbitcoinWithdrawalFees
buyInstantbuyLimitr3   cancelOrderWithInfocreateVoucherdashDepositAddressesdashWithdrawalethereumWithdrawalethereumDepositAddresseslitecoinWithdrawallitecoinDepositAddresses
openOrdersorderorderHistory	orderById
pusherAuthredeemVoucherreplaceByBuyLimitreplaceByBuyInstantreplaceBySellLimitreplaceBySellInstantrippleDepositAddressesrippleWithdrawalsellInstant	sellLimittransactionHistory
traderFeestradeHistoryr   transferHistoryunconfirmedBitcoinDepositsunconfirmedBitcoinCashDepositsunconfirmedDashDepositsunconfirmedEthereumDepositsunconfirmedLitecoinDepositsunconfirmedRippleDepositscancelAllOpenOrderswithdrawVirtualCurrencyvirtualCurrencyDepositAddresses"unconfirmedVirtualCurrencyDepositsadaWithdrawaladaDepositAddressesunconfirmedAdaDepositssolWithdrawalsolDepositAddressesunconfirmedSolDeposits)publicprivatetradingz0.006z0.004010000z0.003100000z0.0023250000z0.0021500000z0.00181000000z0.00153000000z0.001215000000z0.001z0.002z0.0009z0.0005z0.0003z0.0002z-0.0004)takermaker)	tierBased
percentager   r   tiersr   privatePostBitcoinWithdrawalprivatePostLitecoinWithdrawal privatePostBitcoinCashWithdrawalprivatePostEthereumWithdrawalprivatePostRippleWithdrawalprivatePostDashWithdrawalprivatePostDaiWithdrawalprivatePostAdaWithdrawalprivatePostSolWithdrawal)	BTCLTCBCHETHXRPDASHDAIADASOL)fillResponsefromRequestmethods)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg  i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r  )r   r   r  r   r  d   )r   r   r  r  r  r   r  )	sandboxr6   createOrdersr_   rf   rc   rh   fetchClosedOrders
fetchOHLCV)linearinverse)r*   r,   r-   zNo order with given ID)z$Not enough account balance availablezIncorrect order IDzMinimum Order Size zmax allowed precisionzTOO MANY REQUESTSzAccess denied.)exactbroad)idname	countries	rateLimithasurlsrequiredCredentialsr   r   optionsfeatures
exceptionsprecisionMode)deep_extendsuperr!   describeparse_numberr   r   r   r   r   r   )self	__class__s    G/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/coinmate.pyr  coinmate.describe   s   h > @+[[[ %[ 	[
 %[ %[ U[ $U[ '[ [ t[ $U[  [ t[ 7[  9%![" &u#[$ (%[& '[( &u)[* "5+[, +E-[. )%/[0 #E1[2 ,U3[4 '5[6 (7[8 +D9[: &u;[< '=[> (?[@ #EA[B *5C[D $UE[F uG[H "5I[J *5K[L +EM[N )%O[P  Q[R !%S[T %eU[V $UW[X &uY[Z -e[[\ /][^ "5_[` #Ea[b +Ec[d e[f !%g[h "5i[j &uk[l +Em[n  o[p $Uq[r +Es[t %eu[v "4w[x uy[z #E{[| d}[~ !$[@ tA[B  C[D 'E[F $UG[H !%I[J *5K[L (M[N %eO[P )%Q[R )%S[T tU[V W[X tY[Z "4[[\ #E][^ $Z_[` )%a[b c[d #Ee[f &ug[h ui[j uk[l #!&#(! u[z 5 -254 g $  	  57CJ !%"&!..w7!..w7 "..s3T5F5Fw5OP!..w79J9J79ST!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mg<VW	" "..s3T5F5Fw5OP!..w79J9J79ST!..x8$:K:KH:UV!..x8$:K:KH:UV!..x8$:K:KH:UV!..y94;L;LX;VW!..y94;L;LX;VW!..z:D<M<Mi<XY	"> /3=>A>< ;999
 $  %&+(,,0,1).+06:#'#("&#(	( #($($)+027/4#')$, %)&+!%$*%+*/& ',#($)*/	# ',!%#($)*.( ',!$$(%)#($)*.$ *."&o8t ##
 ##}BJ -m =N*6+7-9):&9	 'k	vC
 v v	    c                    U R                  U5      nU R                  US/ 5      n/ n[        S[        U5      5       GH9  nX5   n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
S-   U-   nUR                  0 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S_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.SSS.S .SUS!.
E5        GM<     U$ )"a  
retrieves data on all markets for coinmate

https://coinmate.docs.apiary.io/#reference/trading-pairs/get-trading-pairs/get

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
datar   r  firstCurrencysecondCurrency/r  symbolbasequotesettleNbaseIdquoteIdsettleIdtyper*   Tr+   Fr,   r-   r.   activecontractr
  lotDecimalspriceDecimals)amountprice)minmax	minAmount)r   r3  r4  cost)
r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)
publicGetTradingPairs
safe_valuerangelensafe_stringsafe_currency_codeappendr  parse_precisionsafe_number)r  paramsresponser#  resultimarketr  r+  r,  r(  r)  r'  s                r  fetch_marketscoinmate.fetch_marketsQ  sL    --f5( x4q#d)$AWF!!&&1B%%fo>F&&v/?@G**62D++G4ECZ%'FMM 0b0&0 0 	0
 $0 &0 70 D0 0 0 %0 0 %0 %0 $0  E!0" $#0$   $"&""//0D0DTEUEUV\^kEl0mn!..t/C/CDDTDTU[]lDm/no  $#!
  $//D#
  $#
  $#$  _0 0 %r r!  c                    U R                  US0 5      nSU0n[        UR                  5       5      n[        S[	        U5      5       H|  nXE   nU R                  U5      nU R                  X&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#  rA  r   	availablefreereservedusedbalancetotal)	rC  listkeysrD  rE  rG  accountrF  safe_balance)
r  rL  r   rM  currencyIdsrN  
currencyIdcoderW  r[  s
             r  parse_balancecoinmate.parse_balance  s    ??8VR8)8==?+q#k*+A$J**:6Dooh;GllnG"..wDGFO"..w
CGFO#//CGG"4L ,   ((r!  c                 f    U R                  5         U R                  U5      nU R                  U5      $ )aH  
query for balance and get the amount of funds available for trading or funds locked in orders

https://coinmate.docs.apiary.io/#reference/balance/get-balances/post

:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
)load_marketsprivatePostBalancesr`  )r  rK  rL  s      r  fetch_balancecoinmate.fetch_balance  s1     	++F3!!(++r!  Nr'  r   c           	          U R                  5         U R                  U5      nUS   SS.nU R                  U R                  XS5      5      nUS   nU R	                  US5      nU R                  XtS   USSS	S
5      $ )a  
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

https://coinmate.docs.apiary.io/#reference/order-book/get-order-book/get

: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  False)currencyPairgroupByPriceLimitr#  	timestampr'  bidsasksr4  r3  )rc  rO  publicGetOrderBookextendsafe_timestampparse_order_book)	r  r'  r   rK  rO  requestrL  	orderbookrk  s	            r  fetch_order_bookcoinmate.fetch_order_book  s     	V$"4L!(
 **4;;w+GHV$	''	;?	$$Yx0@)VU[]dfnoor!  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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://coinmate.docs.apiary.io/#reference/ticker/get-ticker/get

: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>`
ri  r  r#  )rc  rO  publicGetTickerro  	safe_dictparse_ticker)r  r'  rK  rO  rr  rL  r#  s          r  fetch_tickercoinmate.fetch_ticker  sl     	V$F4L
 ''G(DE$ ~~h/  ..r!  symbolsc                    U R                  5         U R                  U5      nU R                  U5      nU R                  US0 5      n[	        UR                  5       5      n0 n[        S[        U5      5       HA  nU R                  XW   5      nU R                  U R                  XEU   5      U5      n	XUS   '   MC     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://coinmate.docs.apiary.io/#reference/ticker/get-ticker-all/get

: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'  )rc  market_symbolspublicGetTickerAllrC  rY  rZ  rD  rE  rO  ry  filter_by_array_tickers)
r  r|  rK  rL  r#  rZ  rM  rN  rO  r   s
             r  fetch_tickerscoinmate.fetch_tickers  s     	%%g.**62( x4DIIK q#d)$A[[)F&&tt!W'EvNF'-6(#$ % ++FHgFFr!  r   rO  c                    U R                  US5      nU R                  US5      nU R                  0 SUS   _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S _SU_SU_SS _SS _SS _SS _U R                  US5      S US.EU5      $ )Nrk  lastr'  datetimehighlowbid	bidVolumeaskvwap	askVolumeopenclosepreviousClosechanger   averager3  )
baseVolumequoteVolumerA  )rp  rJ  safe_tickeriso8601)r  r   rO  rk  r  s        r  ry  coinmate.parse_ticker*  sl    ''<	/ !
fX&!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 D!
 !
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **68<)!
* + 	r!  r_  sincec                     U R                  5         SS0nUb  X5S'   Ub  X%S'   Ub  U R                  U5      nUS   US'   U R                  U R                  XT5      5      nUS   nU R	                  USX#5      $ )a=  
fetch history of deposits and withdrawals

https://coinmate.docs.apiary.io/#reference/transfers/get-transfer-history/post

: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>`
r   r   NtimestampFromr  currencyr#  )rc  r  privatePostTransferHistoryro  parse_transactions)	r  r_  r  r   rK  rr  r  rL  itemss	            r  fetch_deposits_withdrawals#coinmate.fetch_deposits_withdrawalsQ  s     	T
 $G',O$}}T*H"*4.GJ224;;w3OP &&udEAAr!  statusc                 :    SSSSSSSS.nU R                  X!U5      $ )Nokpendingcanceled)	COMPLETEDWAITINGSENTCREATEDOKNEWCANCELEDrF  r  r  statusess      r  parse_transaction_status!coinmate.parse_transaction_statusl  s3      "
 &99r!  transactionr  c                 H   U R                  US5      nU R                  US5      nU R                  XB5      n0 SU_SU R                  USS5      _SU R                  US5      _SU R	                  US5      _S	U_S
U R                  US5      _SU R                  US5      _SU R                  U R                  US5      5      _SU_SU R                  U5      _SU R                  US5      _SS _SS _SU R                  US5      _SS _SS _SS _S S U R                  US5      US S.S.E$ )Nrk  amountCurrencyrA  r  transactionIdtxidr.  transferTyper  network
walletTyper3  r  transferStatusr  addressdestinationaddressFrom	addressTotagdestinationTagtagFromtagToupdatedfee)r8  r  rate)commentinternalr  )safe_integerrF  rG  safe_string_2safe_string_lowerrJ  r  r  )r  r  r  rk  r^  r_  s         r  parse_transactioncoinmate.parse_transactionx  s   R %%k;?	%%k3CD
&&z<
K
$$$[/4H
 D$$[&9
 D**;G	

 
 t''\B
 d&&{H=
 d33D4D4D[Rb4cd
 
 Y/
 t'']C
 4
 
 4##K1AB
 t
  T!
" t#
$ ((e< )
 	
r!  r3  r  r  c                    U R                  XE5      u  pEU R                  U5        U R                  5         U R                  U5      nU R	                  U R
                  S0 5      nU R	                  US0 5      nU R                  X5      n	U	cC  [        UR                  5       5      n
[        U R                  S-   SR                  U
5      -   5      eU R                  X5      US.nUb  XKS'   [        X	5      " U R                  X5      5      nU R	                  US5      nU R                  X5      nU R!                  USS	5      nU(       a  X.S
'   XS'   X>S'   XNS'   SUS'   SUS'   U$ )a  
make a withdrawal

https://coinmate.docs.apiary.io/#reference/bitcoin-withdrawal-and-deposit/withdraw-bitcoins/post
https://coinmate.docs.apiary.io/#reference/litecoin-withdrawal-and-deposit/withdraw-litecoins/post
https://coinmate.docs.apiary.io/#reference/ethereum-withdrawal-and-deposit/withdraw-ethereum/post
https://coinmate.docs.apiary.io/#reference/ripple-withdrawal-and-deposit/withdraw-ripple/post
https://coinmate.docs.apiary.io/#reference/cardano-withdrawal-and-deposit/withdraw-cardano/post
https://coinmate.docs.apiary.io/#reference/solana-withdrawal-and-deposit/withdraw-solana/post

: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   z> withdraw() only allows withdrawing the following currencies: z, )r3  r  r  r#  fillResponseFromRequestTr3  r  r  r  
withdrawalr.  r  r  )handle_withdraw_tag_and_paramscheck_addressrc  r  rC  r  rF  rY  rZ  r   r  joincurrency_to_precisiongetattrro  r  	safe_bool)r  r_  r3  r  r  rK  r  withdrawOptionsr   methodallowedCurrenciesrr  rL  r#  r  r  s                   r  r   coinmate.withdraw  sx   $ 99#F7#==&//$,,
BG///9bA!!'0> $W\\^ 4*j jmqmvmv  xI  nJ  !J  K  K00>
 ?(+$%4(W)EF x0,,T<"&..B[]a"b"$*!&*
#%,	"!$".K$-K!r!  c                    U R                  5         Uc  SnSU0nUb  U R                  U5      nUS   US'   Ub  X%S'   U R                  U R                  XT5      5      nU R	                  US/ 5      nU R                  USX#5      $ )a  
fetch all trades made by the user

https://coinmate.docs.apiary.io/#reference/trade-history/get-trade-history/post

: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  ri  r  r#  )rc  rO  privatePostTradeHistoryro  	safe_listparse_trades)	r  r'  r  r   rK  rr  rO  rL  r#  s	            r  fetch_my_tradescoinmate.fetch_my_trades  s     	=EU
 [[(F&,TlGN#',O$//G0LM~~h3  tU::r!  tradec                 $   U R                  US5      nU R                  X2S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S	5      n	U R	                  US
S5      n
S nU R                  US5      nUb  UUS   S.nU R                  US5      nUS:X  a  SOSnU R                  U	UU
U R                  U
5      US   UUUUUUS US.U5      $ )Nri  _r4  r3  r.  	tradeType	orderTypeorderIdr  rk  createdTimestampr  r)  )r8  r  feeTypeMAKERr   r   r'  )r  rA  rk  r  r'  r.  sider   takerOrMakerr4  r3  r8  r  )rF  safe_marketsafe_string_lower_2r  safe_integer_2
safe_trader  )r  r  rO  marketIdpriceStringamountStringr  r.  r  r  rk  r  feeCostStringr  s                 r  parse_tradecoinmate.parse_trade  sK   8 ##E>:!!(C8&&ug6''x8''v{C%%e[9""5)4e_5''{<NO	((6$%"7OC ''y9#/7#:w"Y/X&( " 
  	r!  c                     U R                  5         U R                  U5      nUS   SS.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://coinmate.docs.apiary.io/#reference/transactions/transactions/get

: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  
   )ri  minutesIntoHistoryr#  )rc  rO  publicGetTransactionsro  r  r  )	r  r'  r  r   rK  rO  rr  rL  r#  s	            r  fetch_tradescoinmate.fetch_tradesP  sq     	V$"4L"$
 --dkk'.JK" ~~h3  u<<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                  US5      nU R                  US5      nU R                  [        R                  " US5      5      n	U R                  [        R                  " US5      5      n
UUS   U	U
SSS	.$ )
a7  
fetch the trading fees for a market

https://coinmate.docs.apiary.io/#reference/trader-fees/get-trading-fees/post

:param str symbol: unified market symbol
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
ri  r  r#  r   r   100r'  T)rA  r'  r   r   r   r   )	rc  rO  privatePostTraderFeesro  rC  rF  r  r   
string_div)r  r'  rK  rO  rr  rL  r#  makerStringtakerStringr   r   s              r  fetch_trading_feecoinmate.fetch_trading_feev  s     	V$F4L
 --dkk'.JK x4&&tW5&&tW5!!'"4"4[%"HI!!'"4"4[%"HIX&
 	
r!  c                 z    U R                  U R                  0 U5      5      nSS0nU R                  US   SX#U5      $ )a  
fetch all unfilled currently open orders

https://coinmate.docs.apiary.io/#reference/order/get-open-orders/post

: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  r  r#  N)privatePostOpenOrdersro  parse_orders)r  r'  r  r   rK  rL  	extensions          r  fetch_open_orderscoinmate.fetch_open_orders  sE     --dkk"f.EF#V,	  &!14yQQr!  c                    Uc  [        U R                  S-   5      e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   XRU5      $ )a  
fetches information on multiple orders made by the user

https://coinmate.docs.apiary.io/#reference/order/order-history/post

: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>`
z) fetchOrders() requires a symbol argumentri  r  r   r#  )r   r  rc  rO  privatePostOrderHistoryro  r  )r  r'  r  r   rK  rO  rr  rL  s           r  fetch_orderscoinmate.fetch_orders  s     >#DGG.Y$YZZV$F4L
 $G//G0LM  &!16%HHr!  c                 4    SSSSS.nU R                  X!U5      $ )Nclosedr  r  )FILLED	CANCELLEDPARTIALLY_FILLEDOPENr  r  s      r  parse_order_statuscoinmate.parse_order_status  s*    # &	
 &99r!  r.  c                 0    SSS.nU R                  X!U5      $ )Nr   rO  )LIMITMARKETr  )r  r.  typess      r  parse_order_typecoinmate.parse_order_type  s$    
 T22r!  r   c                    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S5      nU R	                  U R                  US5      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                  XS5      nU R                  US5      nU R                  0 SU_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S _SU_SS _SU_U	S US S.EU5      $ )Nr  rk  r.  r4  originalAmountremainingAmountr3  r  orderTradeTypeavgPriceri  r  clientOrderIdr  lastTradeTimestampr'  r   postOnlyr  r   	stopPricer8  r  filled	remaining)r  tradesrA  r  )
rF  r  r  r  r  r  safe_symbol
safe_orderr  rJ  )r  r   rO  r  rk  r  r  r  remainingStringr  r.  averageStringr  r'  r  s                  r  parse_ordercoinmate.parse_order  s   d eT*%%e[9	%%eV4&&ug6''/?@,,U4ExP(()9)9%)JK$$T%5%5e=M%NO((
;##E>:!!(C8((@  
" 
] 
  
 Y/	 

 !$ 
 f 
 D 
 4 
  
 D 
 [ 
 D,,UK@ 
 l 
 D 
 } 
  d! 
" # 
$ + 
, - 	r!  r  r4  c                    U R                  5         SU R                  U5      -   nU R                  U5      nSUS   0n	US:X  a5  US:X  a  U R                  X5      U	S'   OU R                  X5      U	S'   US-  nO;U R                  X5      U	S'   U R	                  X5      U	S	'   XpR                  U5      -  n[        X5      " U R                  X5      5      n
U R                  U
S
5      nU R                  U
US.U5      $ )a7  
create a trade order

https://coinmate.docs.apiary.io/#reference/order/buy-limit-order/post
https://coinmate.docs.apiary.io/#reference/order/sell-limit-order/post
https://coinmate.docs.apiary.io/#reference/order/buy-instant-order/post
https://coinmate.docs.apiary.io/#reference/order/sell-instant-order/post

:param str symbol: unified symbol of the market to create an order in
:param str type: 'market' or 'limit'
:param str side: 'buy' or 'sell'
:param float amount: how much of currency you want to trade in units of base currency
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
privatePostri  r  rO  buyrX  r3  Instantr4  r#  )rA  r  )	rc  
capitalizerO  amount_to_precisionprice_to_precisionr  ro  rF  r'  )r  r'  r.  r  r3  r4  rK  r  rO  rr  rL  r  s               r  create_ordercoinmate.create_order*  s   " 	!66V$F4L
 8u}#'#;#;F#K $($<$<V$L!iF $ 8 8 HGH#66vEGGood++F4(W)EFh/ 
  	r!  r  c                     U R                  5         SU0nSnU(       a  U R                  U5      nU R                  U R                  XC5      5      nU R	                  US5      nU R                  Xu5      $ )a  
fetches information on an order made by the user

https://coinmate.docs.apiary.io/#reference/order/get-order-by-orderid/post
https://coinmate.docs.apiary.io/#reference/order/get-order-by-clientorderid/post

:param str id: order id
:param str symbol: unified symbol of the market the order was made in
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
r  Nr#  )rc  rO  privatePostOrderByIdro  rx  r*  )r  r  r'  rK  rr  rO  rL  r#  s           r  fetch_ordercoinmate.fetch_orderR  sn     	r
 [[(F,,T[[-IJ~~h/--r!  c                     SU0nU R                  U R                  XC5      5      nU R                  US5      nU R                  U5      $ )aI  
cancels an open order

https://coinmate.docs.apiary.io/#reference/order/cancel-order/post

:param str id: order id
:param str symbol: not used by coinmate 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#  )privatePostCancelOrderWithInforo  rx  r*  )r  r  r'  rK  rr  rL  r#  s          r  cancel_ordercoinmate.cancel_orderi  sI     #B66t{{77ST ~~h/%%r!  c                 "    U R                  5       $ N)milliseconds)r  s    r  noncecoinmate.nonce  s      ""r!  r   GETc           	      8   U R                   S   S   S-   U-   nUS:X  a  U(       a  USU R                  U5      -   -  nOU R                  5         [        U R	                  5       5      nXR
                  -   U R                  -   n	U R                  U R                  U	5      U R                  U R                  5      [        R                  5      n
U R                  U R                  U R
                  UU R                  U
R                  5       S.U5      5      nSS0nXsXeS	.$ )
Nr   r   r&  r   ?)clientIdr@  	publicKey	signaturezContent-Typez!application/x-www-form-urlencoded)urlr  bodyheaders)r  	urlencodecheck_required_credentialsstrr@  r   r   hmacencoder   hashlibsha256ro  upper)r  pathr   r  rK  rJ  rI  rH  r@  authrG  s              r  signcoinmate.sign  s    iiv&,t3(?sT^^F333++-

%E88#dkk1D		$++d"3T[[5Mw~~^I>>$++ HH![[&__.	/
 # D  CG dOOr!  reasonrH  r  rJ  rI  c
                     Uc  g U R                  US5      n
U
b[  U R                  S-   U-   nU R                  U R                  S   X5        U R	                  U R                  S   X5        [        U5      eg )NerrorMessage r  r  )rF  r  throw_exactly_matched_exceptionr  throw_broadly_matched_exceptionr   )r  r_  rW  rH  r  rJ  rI  rL  requestHeadersrequestBodyrY  feedbacks               r  handle_errorscoinmate.handle_errors  sw    
 ''.A#ww}t+H001I<b001I<b))r!   r>  )7__name__
__module____qualname____firstlineno__r   r  r   r	   rP  r   r`  re  rM  r   r   rt  r   rz  r   r   r  dictry  r   r   r  r  r   r  floatr   r  r   r  r  r   r   r   r  r
  r  r  r*  r   r   r
   r3  r7  r;  r@  rU  intr`  __static_attributes____classcell__)r  s   @r  r!   r!      sN   w# wr	 $& X$v, Xt) ) $& ,( , :>b ps p3 pY p, 02 "/3 "/f "/H 04B 'GW 'G7 'GR%4 % %6 %N 6:[_hj Bs B# BUX Bost  pA B6
:s 
:E
T E
X E
Q\ E
N KOWY 6S 6% 6# 6C 6^i 6p -1tRV_a ;c ; ;C ;6< <v < <| 6:UW $=3 $=s $=# $=\`af\g $=L 57 #
 #
;N #
J /3TXac R R3 Rc Rhlmrhs R  *.Dt\^ I3 Ic I Icghmcn I2: :3S 3T Tv T Tl gksu &3 &i &y &RW &`c &P 26b .c .3 .. 37r &s &C &6# &eBSW P*# s  c TX `c  r!  r!   )&ccxt.base.exchanger   ccxt.abstract.coinmater   rP  ccxt.base.typesr   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!   rb  r!  r  <module>rs     s\    ( .  v  v  v  v  v  * 0 . . ) * . 4 %Sx Sr!  