
    !:h                         d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ  G d dee      Z y)    )Exchange)ImplicitAPI)AnyBalances
CurrenciesIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTradingFees)List)ExchangeError)ArgumentsRequired)InsufficientFunds)InvalidOrder)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdee   fdZdedefdZ	i fde
fdZdi fdedefd	Zd-dedefd
Zdi fdededefdZddi fdedededee   fdZd-dededefdZi fdefdZdefdZdi fdedededededefdZ di fdede!fdZ"dddi fde!dededee   fdZ#dddi fde!dededee   fdZ$d-dededefdZ%d-de!de!fd Z&i fde'fd!Z(d-defd"Z)d#d$i ddfd%Z*d&e+d'ed(ed)ed*ed+efd,Z, xZ-S ).	cryptomusreturnc                    | j                  t        t        |          i ddddddgddd	d
dddddi dd ddddddddddddddddddddddddddddddd di d!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1di d2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBdi dCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRddSdi dTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcdddddddddedfi dgdhdididjdkdldmdndodpdqdrdrdrdrdrdrdsidrdrdrdrdrdrdrdtdrdrdudvdridwdjdxdyddq| j	                  dz      | j	                  dz      d{id|dd}d~ddddddddddddddddddddddddddddddddiddi dt
        t        t        t        di ddt        dddddi i      S )Nidr   name	Cryptomus	countriesCA	rateLimitd   versionv2	certifiedFprohasCORSspotTmarginswapfutureoption	addMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelOrderscancelWithdrawclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchCanceledAndClosedOrdersfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCurrenciesfetchDepositAddressfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchLeverageTiersfetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransfersfetchWithdrawalsreduceMarginsandboxsetLeverage)	setMarginsetPositionModetransferwithdraw
timeframesurlszOhttps://github.com/user-attachments/assets/8e0b1c48-7c01-4177-9224-f1b01d89d7e7zhttps://api.cryptomus.com)publicprivatezhttps://cryptomus.comz"https://doc.cryptomus.com/personalzhttps://cryptomus.com/tariffsz,https://app.cryptomus.com/signup/?ref=JRP4yj)logoapiwwwdocfeesreferralr   get   )zv2/user-api/exchange/marketsz!v2/user-api/exchange/market/pricezv1/exchange/market/assetsz,v1/exchange/market/order-book/{currencyPair}zv1/exchange/market/tickersz(v1/exchange/market/trades/{currencyPair})v2/user-api/exchange/ordersz#v2/user-api/exchange/orders/historyz$v2/user-api/exchange/account/balancez$v2/user-api/exchange/account/tariffszv2/user-api/payment/serviceszv2/user-api/payout/serviceszv2/user-api/transaction/list)r   z"v2/user-api/exchange/orders/marketz%v2/user-api/exchange/orders/{orderId})r   postdeleter   tradingz0.02)
percentagefeeSidemakertakeroptionsbscdashpolygonarbitrumsoltonethtronltcxmrbchdoge	avalanchebtcrub)BEP20DASHPOLYGONARBSOLTONERC20TRC20LTCXMRBCHDOGEAVAXBTCRUBr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   levelr   )!createMarketBuyOrderRequiresPricenetworksnetworksByIdrj   commonCurrencies
exceptions)5006zInsufficient funds.zMinimum amount 15 USDT)exactbroadprecisionModerequiredCredentials)apiKeyuidfeatures)	deep_extendsuperr   describeparse_numberr   r   r   r   )self	__class__s    H/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/cryptomus.pyr   zcryptomus.describe   sP   i ? A PD
+PD
KPD
 $PD
 	PD

 tPD
 PD
 5PD
  ZZZ %Z 	Z
 %Z %Z UZ "5Z 'Z tZ Z !%Z  Z %eZ 'Z  /!Z" $U#Z$ ,U%Z& 0'Z( t)Z* 7+Z, (-Z. '/Z0 &u1Z2 (3Z4 "55Z6 (7Z8 ,U9Z: -e;Z< %e=Z>  ?Z@ AZB /CZD &uEZF #EGZH $UIZJ )%KZL $UMZN $UOZP +EQZR "4SZT &uUZV  WZX +EYZZ &u[Z\ #E]Z^ *5_Z` $UaZb "5cZd ueZf  gZh %eiZj /kZl "5mZn oZp !%qZr  sZt euZv +EwZx !%yZz "4{Z| d}Z~ !$Z@ uAZB #ECZD  EZF 'GZH $UIZJ !%KZL *5MZN (OZP )%QZR uSZT uUZV WZX UYZZ t[Z\ "5]Z^ #D_Z` $UaZb !%cZd #EeZf gZh 5iZj ukZl ##(!!sZPD
F "GPD
H i9: /;7J
IPD
^ 89=>56HI67DE	 89?@@A@A897889 89>?
 @_PD
Z "&$!..v6!..v6	[PD
j 59""(%  "#   "'  $ #"( %  "#   "!'  !$ Q#I'kPD
z {PD
| (*+<.:	 }PD
T YUPD
V "$WPD
^ _PD
 P P	    c                 l    | j                  |      }| j                  |dg       }| j                  |      S )a  
        retrieves data on all markets for the exchange

        https://doc.cryptomus.com/personal/market-cap/tickers

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        result)!publicGetV2UserApiExchangeMarkets	safe_listparse_markets)r   paramsresponser   s       r   fetch_marketszcryptomus.fetch_markets   s9     99&A( (B7!!&))r   marketc                    | j                  |d      }|j                  d      }|d   }|d   }| j                  |      }| j                  |      }| j                  | j                  d      }| j                  i d|d|dz   |z   d|d	|d
|d|dddddd dddddddddddddd dd i dd dd dd d| j                  |d      d| j                  |d      d| j                  |d      dd d | j                  |d       d!d d"d d#d d$d d%| j                  | j                  | j                  |d&                  | j                  | j                  | j                  |d'                  d(d)| j                  |d*      | j                  |d+      d,| j                  |d-      | j                  |d.      d,d d d,d d d,d/d0d d1|      S )2Nsymbol_r   r   r   r    /basequotebaseIdquoteIdactiveTtyper-   subTyper.   Fr/   r0   r1   contractsettlesettleIdcontractSizelinearinverser   r   r   	tierBasedr   expiryexpiryDatetimestrike
optionType	precision	quotePrecbasePrec)amountpricelimitsquoteMinSizequoteMaxSizeminmaxbaseMinSizebaseMaxSize)r   r   leveragecostcreatedinfo)
safe_stringsplitsafe_currency_code	safe_dictr   safe_market_structuresafe_number	safe_boolr   parse_precision)	r   r   marketIdpartsr   r   r   r   r   s	            r   parse_marketzcryptomus.parse_market  s    ##FH5s#q(&&v.''0~~dii3)) 6+
(6+
dSj5(6+
 D6+
 U	6+

 f6+
 w6+
 d6+
 F6+
 t6+
 D6+
 e6+
 E6+
 e6+
 e6+
 6+
  d!6+
" #6+
$ D%6+
& d'6+
( t)6+
* T%%dG4+6+
, T%%dG4-6+
. $..|</6+
0 16+
2 t''i836+
4 d56+
6 d76+
8 d96+
: $;6+
< ++D,@,@AQAQRXZeAf,gh**4+?+?@P@PQWYc@d+ef=6+
D ++FNC++FNC
  ++FMB++FMB
  
  E6+
h ti6+
j Fk6+
 6 6	r   c                 T   | j                  |      }| j                  |d      }i }t        dt        |            D ]  }||   }| j	                  |d      }| j                  |      }||vr||ddddddddddddddi i d||<   | j	                  |d      }	| j                  |	      }
|	|
| j                  |d	      | j                  |d
      d| j                  |d      | j                  |d      ddd| j                  |d      | j                  |d      dd|d	||   d   |
<   | j                  ||   dg       }|j                  |       |||   d<    t        |j                               }t        dt        |            D ]  }||   }| j                  ||         ||<     |S )a  
        fetches all available currencies on an exchange

        https://doc.cryptomus.com/personal/market-cap/assets

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   r   currency_codeNr   )r   deposit)r    coder   r   r!   r   r  r   feer   r   r   network_codemin_withdrawmax_withdrawmin_depositmax_depositcan_withdrawcan_deposit)	r    networkr   r   r  r   r  r   r   r   r   )publicGetV1ExchangeMarketAssetsr   rangelenr   r  network_id_to_coder  r  appendlistkeyssafe_currency_structure)r   r   r   coinsr   inetworkEntry
currencyIdr  	networkIdnetworkCoder   allKeyss                r   fetch_currencieszcryptomus.fetch_currenciesU  s
    77?& x2q#e*% 5	(A 8L)),HJ**:6DFN$ !%  "# $ $(#'%
 $(#'$	 !#+ t. ((~FI11)<K&  $//nM#//nM!
  $//mL#//mL 	 >>,G NN<G!$%5F4L$[1* >>&,;DKK%#'F4L k5	(n v{{}%q#g,' 	FA1:D77tEF4L	F r   Nsymbolsc                     | j                          | j                  |      }| j                  |      }| j                  |d      }| j	                  ||      S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://doc.cryptomus.com/personal/market-cap/tickers

        :param str[] [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>`
        data)load_marketsmarket_symbols publicGetV1ExchangeMarketTickersr   parse_tickers)r   r'  r   r   r)  s        r   fetch_tickerszcryptomus.fetch_tickers  sU     	%%g.88@ ~~h/!!$00r   c                 N   | j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  i d|dd dd dd dd dd d	d d
d dd dd dd d|d|dd dd dd dd | j                  |d      | j                  |d      |d|      S )Ncurrency_pairr   
last_price	timestampdatetimehighlowbid	bidVolumeask	askVolumevwapopencloselastpreviousClosechanger   averagebase_volumequote_volume)
baseVolumequoteVolumer   )r   safe_marketsafe_ticker)r   tickerr   r  r   r=  s         r   parse_tickerzcryptomus.parse_ticker  sS    ##FO<!!(F3!5 !
f!
!
 !
 D	!

 4!
 4!
 !
 4!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6=A++FNC)!
* + 	r   r   limitc           	      H   | j                          | j                  |      }d|d   i}d}| j                  |dd|      \  }}||d<   | j                  | j	                  ||            }| j                  |di       }| j                  |d      }	| j                  |||	dd	d
d      S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://doc.cryptomus.com/personal/market-cap/orderbook

        :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
        :param int [params.level]: 0 or 1 or 2 or 3 or 4 or 5 - the level of volume
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        currencyPairr    r   rj   r   r)  r2  bidsasksr   quantity)r*  r   handle_option_and_params.publicGetV1ExchangeMarketOrderBookCurrencyPairextendr  safe_timestampparse_order_book)
r   r   rI  r   r   requestr   r   r)  r2  s
             r   fetch_order_bookzcryptomus.fetch_order_book  s     	V$F4L
 55f>NPWY^_v FFt{{SZ\bGcd( ~~h3''k:	$$T69ffgWabbr   sincec                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |d      }| j                  ||||      S )a2  
        get the list of most recent trades for a particular symbol

        https://doc.cryptomus.com/personal/market-cap/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(maximum value is 100)
        :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>`
        rK  r    r)  )r*  r   +publicGetV1ExchangeMarketTradesCurrencyPairrQ  r   parse_trades)	r   r   rV  rI  r   r   rT  r   r)  s	            r   fetch_tradeszcryptomus.fetch_trades  sv     	V$F4L
 CCDKKPWY_D`a ~~h/  vue<<r   tradec                 0   | j                  |d      }| j                  | j                  |d      || j                  |      |d   | j                  |d      | j                  |d      | j                  |d      | j                  |d      d d d d d d|d	|      S )
Nr2  trade_idr   r   r   rB  rA  currencyr   )r    r2  r3  r   sider   r   r   takerOrMakerr   orderr  r   )rR  
safe_trader   iso8601)r   r[  r   r2  s       r   parse_tradezcryptomus.parse_trade?  s     ''{;	""5*5"Y/X&$$UF3%%eW5&&un=$$UM:   ! 
" # 	r   c                     | j                          i }| j                  | j                  ||            }| j                  |dg       }| j	                  |      S )a_  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://doc.cryptomus.com/personal/converts/balance

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        r   )r*  )privateGetV2UserApiExchangeAccountBalancerQ  r   parse_balance)r   r   rT  r   r   s        r   fetch_balancezcryptomus.fetch_balance^  sV     	AA$++gW]B^_ (B7!!&))r   c                 .   d|i}t        dt        |            D ]i  }||   }| j                  |d      }| j                  |      }| j	                         }| j                  |d      |d<   | j                  |d      |d<   |||<   k | j                  |      S )Nr   r   rG  	availablefreeheldused)r  r  r   r  accountsafe_balance)r   balancer   r   balanceEntryr"  r  ro  s           r   rh  zcryptomus.parse_balancex  s     G
 q#g,' 	#A"1:L)),AJ**:6DllnG"..|[IGFO"..|VDGFO"F4L	#   ((r   r   r`  r   r   c                 6   | j                          | j                  |      }|d   |dd}| j                  |d      }	|	| j                  |d      }|	|d<   |dk(  }
| j	                  |      }| j	                  |      }d}| j                  |d      \  }}d}|d	k(  r|
r\d
}| j                  |ddd
      \  }}|r5||t        | j                  dz         |t        j                  ||      }n|r|n|}||d<   n||d<   | j                  | j                  ||            }ni|dk(  rL|t        | j                  dz   |z   dz         ||d<   ||d<   | j                  | j                  ||            }nt        | j                  dz         | j                  ||      S )a  
        create a trade order

        https://doc.cryptomus.com/personal/exchange/market-order-creation
        https://doc.cryptomus.com/personal/exchange/limit-order-creation

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit' or for spot
        :param str side: 'buy' or 'sell'
        :param float amount: how much of you want to trade in units of the base currency
        :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders(only for limit orders)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.cost]: *market buy only* the quote quantity that can be used alternative for the amount
        :param str [params.clientOrderId]: a unique identifier for the order(optional)
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r    ccxt)r   	directiontagclientOrderIdNclient_order_idbuyr   r   Tr?   r   z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option of param to False and pass the cost to spend in the amount argumentvaluerN  rI  z0 createOrder() requires a price parameter for a z orderr   z9 createOrder() requires a type parameter(limit or market))r*  r   r   omitnumber_to_stringhandle_param_stringrO  r   r    r   
string_mul(privatePostV2UserApiExchangeOrdersMarketrQ  r   "privatePostV2UserApiExchangeOrdersparse_order)r   r   r   r`  r   r   r   r   rT  rw  sideBuyamountToStringpriceToStringr   r   r   s                   r   create_orderzcryptomus.create_order  s   " 	V$Tl

 ((A$YYv7F)6G%&%-..v6--e4//?f8481<@<Y<YZ`bo  rU  W[  =\9164DL*477  6q  ,q  r  r&11.-P#'4^D#' &4
#DDT[[QXZ`EabHW_}'2d(dgk(knv(vww"0GJ$GG>>t{{7TZ?[\H#DGG.i$ijj &11r   r    c                 v    | j                          i }||d<   | j                  | j                  ||            }|S )a  
        cancels an open limit order

        https://doc.cryptomus.com/personal/exchange/limit-order-cancellation

        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        orderId)r*  +privateDeleteV2UserApiExchangeOrdersOrderIdrQ  )r   r    r   r   rT  r   s         r   cancel_orderzcryptomus.cancel_order  sC     		CCDKKPWY_D`a r   c                 ^   | j                          i }d}|| j                  |      }|d   |d<   |||d<   | j                  | j                  ||            }| j	                  |dg       }g }	t        dt        |            D ](  }
||
   }|	j                  | j                  ||             * |	S )a%  
        fetches information on multiple orders made by the user

        https://doc.cryptomus.com/personal/exchange/history-of-completed-orders

        :param str symbol: unified market symbol of the market orders were made in(not used in cryptomus)
        :param int [since]: the earliest time in ms to fetch orders for(not used in cryptomus)
        :param int [limit]: the maximum number of order structures to retrieve(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.direction]: order direction 'buy' or 'sell'
        :param str [params.order_id]: order id
        :param str [params.client_order_id]: client order id
        :param str [params.limit]: A special parameter that sets the maximum number of records the request will return
        :param str [params.offset]: A special parameter that sets the number of records from the beginning of the list
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr    r   rI  r   r   )	r*  r   (privateGetV2UserApiExchangeOrdersHistoryrQ  r   r  r  r  r  )r   r   rV  rI  r   rT  r   r   r   ordersr   rb  s               r    fetch_canceled_and_closed_ordersz*cryptomus.fetch_canceled_and_closed_orders  s    " 	[[(F &tGH$GG@@WV\A]^P (B7q#f+& 	;A1IEMM$**5&9:	; r   c                     | j                          d}|| j                  |      }i }||d   |d<   | j                  | j                  ||            }| j	                  |dg       }| j                  ||dd      S )a  
        fetch all unfilled currently open orders

        https://doc.cryptomus.com/personal/exchange/list-of-active-orders

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for(not used in cryptomus)
        :param int [limit]: the maximum number of  open orders structures to retrieve(not used in cryptomus)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.direction]: order direction 'buy' or 'sell'
        :param str [params.order_id]: order id
        :param str [params.client_order_id]: client order id
        :param str [params.limit]: A special parameter that sets the maximum number of records the request will return
        :param str [params.offset]: A special parameter that sets the number of records from the beginning of the list
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr    r   r   )r*  r   !privateGetV2UserApiExchangeOrdersrQ  r   parse_orders)	r   r   rV  rI  r   r   rT  r   r   s	            r   fetch_open_orderszcryptomus.fetch_open_orders+  s    " 	[[(F
 &tGH99$++gv:VW( (B7  t<<r   rb  c           	         | j                  |dd      }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |      }| j	                  |di       }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  |d	      }| j                  |d
g       }d }| j	                  |d      }| j                  |d      }|$| j                  |      | j                  |d      d}|| j                  |d      }| j                  |d      }| j                  |d      }| j                  | j                  |d            }| j                  |d      }| j                  i d|d|d|d| j                  |      dd d|d   d|	dd dd d|
d	|d| j                  |d      d| j                  |d      d|d|d|d | j                  |d!      d ||d |d"|      S )#Norder_idr    r   	createdAtdealaverageFilledPricer   ru  r   transactionsr   feeCurrencyr  r^  filledPricerN  rz  staterw  r2  r3  lastTradeTimestamptimeInForcepostOnlyr`  	stopPricestopLossPricetriggerPricer   r   r@  filledfilledQuantity)	remainingstatusr  tradesr   )safe_string_2r   rE  	parse8601r  r  r   r  parse_order_status
safe_orderrd  )r   rb  r   r    r  dateTimer2  r  r  r   r`  r   transactionr  firstTxr  r   r   r  rw  s                       r   r  zcryptomus.parse_order[  s   r z48##E84!!(F3##E;7NN8,	~~eVR0!--d4HIv.{3  0nnT>2>..a0&&w>" 33K@((%8C =$$Wm<E!!%4w/(()9)9%)IJ((@  
" 
] 
  
 Y/	 

 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
 ))%A 
 D,,UOD 
 f 
 D 
  )! 
" d&&u.>?# 
$ - 
. / 	r   r  c                 :    ddddddd}| j                  |||      S )Nr;  closedcanceledexpiredfailed)r   	completedpartially_completed	cancelledr  r  )r   )r   r  statusess      r   r  zcryptomus.parse_order_status  s2    !#)# 
 &&99r   c           	         | j                  |      }| j                  |di       }| j                  |di       }| j                  |d      }| j                  |d      }t        j                  |d      }t        j                  |d      }| j                  |dg       }i }| j                  |      }	t        dt        | j                              D ]<  }
| j                  |
   }||| j                  |      | j                  |      dd|	d	||<   > |S )
aW  
        fetch the trading fees for multiple markets

        https://trade-docs.coinlist.co/?javascript--nodejs#list-fees

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r   current_tariff_stepmaker_percenttaker_percent100tariff_stepsr   T)r   r   r   r   r   r   tiers))privateGetV2UserApiExchangeAccountTariffsr  r   r   
string_divr   parse_fee_tiersr  r  r'  r   )r   r   r   r)  currentFeeTiermakerFeetakerFeefeeTiersr   r  r   r   s               r   fetch_trading_feeszcryptomus.fetch_trading_fees  s    AA&Ib ~~h"5.CRH##NOD##NOD%%h6%%h6>>$;$$X.q#dll+, 
	A\\!_F  **84**84"!F6N
	 r   c                    g }g }t        dt        |            D ]  }||   }| j                  |d      }| j                  |d      }| j                  |d      }	t	        j
                  |	d      }	t	        j
                  |d      }|j                  || j                  |	      g       |j                  || j                  |      g        ||dS )Nr   from_turnoverr  r  r  )r   r   )r  r  r  r   r   r  r  r   )
r   r  r   	takerFees	makerFeesr   tierturnoverr   r   s
             r   r  zcryptomus.parse_fee_tiers!  s    		q#h-( 	CAA;D''o>H$$T?;E$$T?;E&&ue4E&&ue4Eh(9(9%(@ABh(9(9%(@AB	C 
 	
r   r   GETc                 V   | j                  ||      }| j                  || j                  |            }| j                  d   |   dz   |z   }|dk(  r| j	                          d}	d| j
                  i}|dk7  r| j                  |      }|}	d|d<   n'| j                  |      }
t        |
      d	k7  r|d
|
z   z  }| j                  |	      }|| j                  z   }| j                  | j                  |      d      }||d<   n'| j                  |      }
t        |
      d	k7  r|d
|
z   z  }||||dS )Nr   r   r    userIdr  zapplication/jsonzContent-Typer   ?md5sign)urlmethodbodyheaders)implode_paramsr{  extract_paramsr   check_required_credentialsr   json	urlencoder  string_to_base64secrethashencode)r   pathr   r  r   r  r  endpointr  
jsonParamsqueryjsonParamsBase64stringToSign	signatures                 r   r  zcryptomus.sign2  s9   &&tV464#6#6t#<=iis#c)H4)++-J$((G yy(!
*<'v.u:?3;&C#44Z@+dkk9L		$++l";UCI'GFONN6*E5zQsU{"fdwOOr   httpCodereasonr  r  r  r  c
                    |y d|v rO| j                  |d      }
| j                  dz   |z   }| j                  | j                  d   |
|       t	        |      d|v ro| j                  |d      }| j                  dz   |z   }| j                  | j                  d   ||       | j                  | j                  d   ||       t	        |      y )Nr   r   messager   )r   r    throw_exactly_matched_exceptionr   r   throw_broadly_matched_exception)r   r  r  r  r  r  r  r   requestHeadersrequestBodyr  feedbackr  s                r   handle_errorszcryptomus.handle_errorsN  s    X##Hf5Dww}t+H001I4QYZ))(" &&x;Gww}t+H001I7T\]001I7T\]))r   )N).__name__
__module____qualname__r   r   r   r	   r   dictr	  r   r&  r   r   r.  r   rH  strr   r   rU  r   rZ  re  r   ri  rh  r   r   floatr
   r   r  r   r  r  r  r  r  r   r  r  r  intr  __classcell__)r   s   @r   r   r      s{   Q# Qf $& *$v, *@L4 LF L\ ') YZ Yv 04B 1W 17 18"6 "V "H :>b *cs *c3 *cY *cX 6:UW !=3 !=s !=# !=\`af\g !=F v  > $& *( *4) )* gksu >23 >2i >2y >2RW >2`c >2z >2@ 37r s C , >BPTcgpr Fs F# F]` Fw{  }B  xC FP /3TXac .= .=3 .=c .=hlmrhs .=`i iv i iV	: 	: 	: )+ N{ N`
 
" &eBSW P8c 3 S # X\ dg r   r   N)!ccxt.base.exchanger   ccxt.abstract.cryptomusr   ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r     sP    ( / c  c  c  c  c  * . . ) 4 %M+ Mr   