
    iǍ                       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 d dlmZ d dlmZ d dl m!Z! d dl"m#Z#  G d dee          Z$dS )    )Exchange)ImplicitAPI)Balances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)OrderNotFound)ExchangeNotAvailable)DECIMAL_PLACES)Precisec                       e Zd Z fdZi fdee         fdZdefdZi fdefdZ	dddi fde
d	ed
edee         fdZd3dedefdZdi fde
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i fde
dedefdZdddi fded	ed
edee         fdZdddi fded	ed
edee         fdZdddi fded	ed
efdZdi fde
dedededef
dZdi fde
defdZdi fdefdZd3dedefdZd Z d Z!d Z"di fd e#de$fd!Z%i fde
de&fd"Z'd3dede&fd#Z(ddi fde
d	ed
edee)         fd$Z*dddi fded	ed
efd%Z+d3dede)fd&Z,i fde-fd'Z.de-fd(Z/dddi fd)ed	ed
edee0         fd*Z1d3d+e2de0fd,Z3d- Z4d. Z5d/d0i ddfd1Z6d2 Z7 xZ8S )4bitteamc                    |                      t          t          |                                           dddg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	d(dd)di d*dd+dd,dd-d	d.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:di d;dd<d	d=dd>d	d?d	d@ddAddBd	dCd	dDd	dEddFd	dGddHddIddJddKdi dLddMd	dNd	dOddPd	dQddRddSddTddUddVd	dWddXddYddZdd[dd\dddddddddd]d^d_d`dadbdcdddedfdfdgdhdidjgdkdldmdiidli dnddoddpddqddrddsddtdduddvddwddxddyddzdd{dd|dd}didddddd~ddddddgddldd	|                     d          |                     d          dit
          i ddddddddddddddddddddddddddddddddddddid	d	ddt          t          t          t          dt          t          t          t          t          t          t          t          t          t          t          t          ddd          S )Nr!   zBIT.TEAMUKzv2.0.6   FCORSspotTmarginswapfutureoption	addMarginborrowMargincancelAllOrderscancelOrdercancelOrderscreateDepositAddresscreateOrdercreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchL3OrderBookfetchLedgerfetchLeveragefetchLeverageTiersfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayMargin)setLeverage	setMarginsetMarginModesetPositionModesignIntransferwithdrawws1515601D)1m5m15m1h1dzQhttps://github.com/ccxt/ccxt/assets/43336371/cf71fe3d-b8b4-40f2-a906-907661b28793zhttps://history.bit.teamzhttps://bit.team)historypublicprivatezhttps://bit.team/z,https://bit.team/auth/sign-up?ref=bitboy2023z(https://bit.team/trade/api/documentation)logoapiwwwreferraldocgetz&api/tw/history/{pairName}/{resolution}ztrade/api/assetztrade/api/currenciesztrade/api/orderbooks/{symbol}ztrade/api/ordersztrade/api/pair/{name}ztrade/api/pairsztrade/api/pairs/precisionsztrade/api/ratesztrade/api/trade/{id}ztrade/api/tradesztrade/api/ccxt/pairsztrade/api/cmc/assetsztrade/api/cmc/orderbook/{pair}ztrade/api/cmc/summaryztrade/api/cmc/tickerztrade/api/cmc/trades/{pair})ztrade/api/ccxt/balanceztrade/api/ccxt/order/{id}ztrade/api/ccxt/ordersOfUserztrade/api/ccxt/tradesOfUserztrade/api/transactionsOfUser)ztrade/api/ccxt/cancel-all-orderztrade/api/ccxt/cancelorderztrade/api/ccxt/ordercreate)r   posttradingz0.002)feeSide	tierBased
percentagetakermakerEthereumERC20ethereumTronTRC20tronBinanceBSCbinancezBinance Smart ChainbscscanBitcoinBTCbitcoinLitecoinLTClitecoinPolygonPOLYGONpolygonPRIZMDecimalufobjecttonchain)USDTBUSD)networksByIdcurrenciesValuedInUsd)400002401000403002404200)zis not allowedzInsufficient fundszInvalid request params inputzmust be a numberzmust be a stringzmust be of typezmust be one ofzOrder not foundzPair with pair namepairNamezService UnavailablezSymbol )exactbroad)idname	countriesversion	rateLimit	certifiedprohas
timeframesurlsr   feesprecisionModeoptions
exceptions)deep_extendsuperr!   describeparse_numberr   r   r   r   r   r   r   )self	__class__s    R/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/bitteam.pyr   zbitteam.describe   s|   gt 4 4 = = ? ?^^^ %^ 	^
 %^ %^ U^ ^ "4^ t^ ^ '^ t^ &u^ (^  '!^" (#^ ^$ "5%^& 5'^( U)^*  +^, -^.  /^0 &u1^2 +E3^4 )%5^6 &t7^8 #E9^: $T;^< '=^> (?^@ "4A^B C^D &uE^ ^ ^F (G^H 1%I^J  K^L +DM^N *5O^P +EQ^R &uS^T #EU^V *5W^X $UY^Z "5[^\ *5]^^ +E_^` #Ea^b uc^d  e^f %eg^ ^ ^h +Ei^j k^l !%m^n  o^p dq^r +Es^t !%u^v "4w^x dy^z !${^| "5}^~ t^@ #EA^B  C^D !%E^F %eG^H )%I^ ^ ^J uK^L tM^N O^P UQ^R tS^T "5U^V #EW^X %eY^Z &u[^\ ']^^ $T_^` !%a^b "5c^d #Ee^f +Eg^h i^j uk^ ^l  %"!&#(!!{^ ^ ^@   l901 
 +J>  @!  )1. 8 +A	
 0 *1 5a *1 / +A / / 9! 0 /  6q!, 3456787889  <=6767  5( (T $!&"&!..w77!..w77  ,!!! G! G	!
 u! u! *5! u! u! u! ! ! y! y! W!  y!!" 
#!$ 
%! !* ! * *+ 8 (1('	  '1*;4>(2(2'1&0'4+4 )+?(  S_B
 _B
 _ _ _	    returnc                     |                      |          }|                     |di           }|                     |dg           }|                     |          S )a(  
        retrieves data on all markets for bitteam
        :see: https://bit.team/trade/api/documentation#/CCXT/getTradeApiCcxtPairs
        :param dict [params]: extra parameters specific to the exchange api endpoint
        :returns dict[]: an array of objects representing market data
        resultpairs)publicGetTradeApiCcxtPairs
safe_valueparse_markets)r   paramsresponser   marketss        r   fetch_marketszbitteam.fetch_markets   sX     226::n 8R88//&'266!!'***r   c                    |                      |d          }|                     |d          }|                    d          }|                      |d          }|                      |d          }|                     |          }|                     |          }|                     |d          }	|                     |d          }
|                     |d          }|                      |d	          }|                     |          }d }|                     | j        d
i           }|                     ||d          }|r-|                     |di           }|                     |d          }| 	                    i d|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 d d d d |
|dd d d d d d d d d |d d d!||d"          S )#Nr   r   _r   r$   activebaseStep	quoteStep	timeStartr   Fsettings	limit_usd	numericIdsymbol/basequotesettlebaseIdquoteIdsettleIdtyper&   Tr'   r(   r)   r*   contract)amountpriceminmax)leverager   r   cost)linearinversecontractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)
safe_stringsafe_integersplitsafe_currency_coder   	parse8601r   	safe_boolsafe_numbersafe_market_structure)r   marketr   r   partsr   r   r   r   r   amountPrecisionpricePrecisionr   r  minCostr   
quoteInUsdr   s                     r   parse_marketzbitteam.parse_market\  s   ff--%%fd33	!!%++""5!,,&&v..''0022++FJ??**6;??$$V[99	..++ $>UWY Z Z^^$95%HH
 	>vz2>>H&&x==G)) 1+
"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+
  f!1+
" #1+
$  ")'    
   
   
 #  $ a1+
 1+
 1+
 1 1 1	r   c                 l   |                      |          }|                     |di           }|                     |dg           }|                                 }|                     |d          }i }t	          dt          |                    D ]}||         }|                     |d          }	|                     |d          }
|                     |	          }| 	                    |dd          }|                     |d	          }|                     |d
i           }|                     |d          }|                     |d          }|                     |d          }d}|                     |di           }i }|                     |d          }|!|dk    r| 
                    |          }|||<   n|}|                     ||
i           }|                     |d          }|                     |d          }t          |                                          }i }|                     |d          }t	          dt          |                    D ]}||         }|                     ||          }|                     ||          }|||||||ddd| 
                    |          | 
                    |          d| 
                    |          ddd|d	||<   |	|
||||||||ddd| 
                    |          | 
                    |          d| 
                    |          ddd|d||<   |S )a)  
        fetches all available currencies on an exchange
        :see: https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiCurrencies
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: an associative dictionary of currencies
        r   
currenciesunified_cryptoasset_idr   r   r   r   Fr   txLimitsminWithdrawmaxWithdraw
minDepositNwithdrawCommissionFixed
blockChain depositStatuswithdrawStatusdecimalsr   )r   r   r7   )	r   networkr7   r   r   feer   r  r  )r   r   coder   r  r   r7   r   r!  r   r  networks)publicGetTradeApiCurrenciesr   publicGetTradeApiCmcAssetsindex_byrangelenr  r  r  r	  r   listkeysnetwork_id_to_coder
  ) r   r   r   responseResultr  statusesResponser   icurrencyr   r   r"  r   r   r  r  r  r  r!  r  feesByNetworkIdr  statusesr7   r   
networkIdsr#  networkPrecisionj	networkIdnetworkCode
networkFees                                    r   fetch_currencieszbitteam.fetch_currencies  s    33F;;v 8R@@__^\2FF
::<<*  ==)9;STTq#j//** Q	 Q	A!!}H!!(H55B))(D99I**2..D^^Hh>>F))(K@@IxR@@H**8]CCK**8]CCK))(LAAJC&*ooh@Y[]&^&^# O))(LAAJ&Z2-=-=''(?@@.1
++"9'7BGGHooh@@Gx1ABBHo224455JH#00:FF1c*oo..  &qM	"55iFF!--oyII
#*& ($%!1 $(#'# #
 $(#4#4[#A#A#'#4#4[#A#A% %
 $(#4#4Z#@#@#'$ $  %-) )%%2 &  "$&  $# 
  $00==#00==! !
  $00<<#     %3 F4LL6 r   r   Nr   sincelimitc                    |                                   |                     |          }|                     | j        ||          }|d         |d}|                     |                     ||                    }	|                     |	di           }
|                     |
dg           }|                     |||||          S )aP  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :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 bitteam api endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r   )r   
resolutionr   data)	load_marketsr  r  r   (historyGetApiTwHistoryPairNameResolutionextendr   	safe_listparse_ohlcvs)r   r   	timeframer9  r:  r   r  r<  requestr   r   r=  s               r   fetch_ohlcvzbitteam.fetch_ohlcvr  s     	V$$%%doy)LL
t$
 
 @@WV\A]A]^^8 8R88~~ffb11  vy%GGGr   r  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Ntohlcv)safe_timestampr
  )r   ohlcvr  s      r   parse_ohlcvzbitteam.parse_ohlcv  s     s++UC((UC((UC((UC((UC((
 	
r   c                    |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |d          }|                     |||          }|S )am  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcOrderbookPair
        :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(default 100, max 200)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: A dictionary of `order book structures <https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure>` indexed by market symbols
        pairr   	timestamp)r>  r  !publicGetTradeApiCmcOrderbookPairr@  r  parse_order_book)	r   r   r:  r   r  rD  r   rR  	orderbooks	            r   fetch_order_bookzbitteam.fetch_order_book  s     	V$$F4L
 99$++gv:V:VWW8 %%h<<	))(FIFF	r   c                    |                                   |                     |dd          }d|i}d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |di           }	|                     |	dg           }
|                     |
|||          S )	a  
        fetches information on multiple orders made by the user
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
        :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  orde structures to retrieve(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :param str [params.type]: the status of the order - 'active', 'closed', 'cancelled', 'all', 'history'(default 'all')
        :returns Order[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   allNr   rQ  r:  r   orders)r>  r  r  "privateGetTradeApiCcxtOrdersOfUserr@  r   rA  parse_orders)r   r   r9  r:  r   r   rD  r  r   r   rY  s              r   fetch_orderszbitteam.fetch_orders  s     	66D
 [[((F$TlGFO$GG::4;;wPV;W;WXXf 8R88"55  >>>r   r   c                    |                                   d|i}d}||                     |          }|                     |                     ||                    }|                     |d          }|                     ||          S )a  
        fetches information on an order
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrderId
        :param int|str id: order id
        :param str symbol: not used by bitteam fetchOrder()
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: An `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   Nr   )r>  r  privateGetTradeApiCcxtOrderIdr@  	safe_dictparse_order)r   r   r   r   rD  r  r   r   s           r   fetch_orderzbitteam.fetch_orderR  s     	"
 [[((F55dkk'66R6RSSL (33///r   c           	          |                                   ddi}|                     ||||                     ||                    S )a:  
        fetch all unfilled currently open orders
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
        :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 order structures to retrieve(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns Order[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   r   r>  r\  r@  r   r   r9  r:  r   rD  s         r   fetch_open_orderszbitteam.fetch_open_orders  L     	H
   t{{7F7S7STTTr   c           	          |                                   ddi}|                     ||||                     ||                    S )ao  
        fetches information on multiple closed orders made by the user
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
        :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 closed order structures to retrieve(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns Order[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   closedrc  rd  s         r   fetch_closed_orderszbitteam.fetch_closed_orders  rf  r   c           	          |                                   ddi}|                     ||||                     ||                    S )ap  
        fetches information on multiple canceled orders made by the user
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
        :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 canceled order structures to retrieve(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   	cancelledrc  rd  s         r   fetch_canceled_orderszbitteam.fetch_canceled_orders  sL     	K
   t{{7F7S7STTTr   r   sider   r   c                    |                                   |                     |          }t          |d                   |||                     ||          d}|dk    r8|t	          | j        dz   |z   dz             |                     ||          |d<   |                     |                     ||                    }	| 	                    |	di           }
| 
                    |
|          S )	a  
        create a trade order
        :see: https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtOrdercreate
        :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 fullfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   )pairIdr   rm  r   r:  Nz/ createOrder() requires a price argument for a z orderr   r   )r>  r  stramount_to_precisionr   r   price_to_precision"privatePostTradeApiCcxtOrdercreater@  r_  r`  )r   r   r   rm  r   r   r   r  rD  r   orders              r   create_orderzbitteam.create_order  s     	V$$&-....vv>>	
 
 7??}'2c(cfj(jmu(uvvv#'#:#:65#I#I ::4;;wPV;W;WXX0 x266v...r   c                     |                                   d|i}|                     |                     ||                    }|                     |di           }|                     |          S )a  
        cancels an open order
        :see: https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelorder
        :param str id: order id
        :param str symbol: not used by bitteam cancelOrder()
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: An `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        r   r   )r>  "privatePostTradeApiCcxtCancelorderr@  r_  r`  )r   r   r   r   rD  r   r   s          r   cancel_orderzbitteam.cancel_order  sq     	"
 ::4;;wPV;W;WXX (B77'''r   c                 N   |                                   d}i }|.|                     |          }t          |d                   |d<   nd|d<   |                     |                     ||                    }|                     |di           }|g}|                     ||          S )a  
        cancel open orders of market
        :see: https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelallorder
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
        Nr   ro  0r   )r>  r  rp  %privatePostTradeApiCcxtCancelAllOrderr@  r   r[  )r   r   r   r  rD  r   r   rY  s           r   cancel_all_orderszbitteam.cancel_all_orders  s     	[[((F #F;$7 8 8GH #GH==dkk'SY>Z>Z[[ 8R88  000r   c           
         |                      |d          }|                      |d          }|                     ||          }|                      |d          }d }|                      |d          }||                     |          }n|                     |d          }|                      |d          }|                     |          }	|                     |                      |d                    }
|                     |                      |d                    }|                      |d	          }|                     |d
          }|                      |d          }|                      |d          }|                      |d          }|                      |d          }d }|E|                      |d          }|                      |d          }|                     |          |d d}|                     i d|d|d|d| 	                    |          dd d|	d|
d|d         d|ddd	|d|d|d|dd d|dd |d |d |dd|          S )Nr   rQ  orderCid	createdAtrR  	updatedAtstatusr   rm  r!  r   	stopPricequantityexecutedr   r   r/  r   rateclientOrderIddatetimelastTradeTimestamplastUpdateTimestamptimeInForceGTCtriggerPriceaverager   F)filled	remainingr!  tradesr  postOnly)
r  safe_marketr  rM  parse_order_statusparse_order_typer   r  
safe_orderiso8601)r   rt  r  r   marketIdr  rR  r  r  r  r  r   rm  feeRawr   r  r   r  r!  feeCostfeeCurrencyIds                        r   r`  zbitteam.parse_order%  s   l eT**##E622!!(F33((
;;	$$UK88	 y11II++E;??I$$UK88	"nnY77(()9)9%)J)JKK$$T%5%5eV%D%DEEv....  00$$UK88	!!%44!!%44&&vx88G ,,VX>>M 33MBB C
   
" 
] 
  
 Y//	 

 !$ 
 "#6 
 f 
 fX& 
 D 
 5 
 D 
 U 
  
 I 
 t 
  f! 
" D# 
$ / 
  
  
0 1  	r   c           	      F    ddddddddd}|                      |||          S )Nopenrh  canceledrejected)acceptedr  rk  partiallyCancelleddeleteinactive	executingr  r  r   r  r1  s      r   r  zbitteam.parse_order_status  s@     #", "	
 	
 &&999r   c                 :    ddd}|                      |||          S )Nr  r:  )r  r:  r  r  s      r   r  zbitteam.parse_order_type  s.    
 
 &&999r   c                     |                      ||          }|                      ||          }||d S |                     |          }t          j        ||          S N)r  parse_precisionr   
string_mul)r   valueObjectvalueKeypreciseObjectprecisionKeyvalueRawStringprecisionRawStringprecisionStrings           r   parse_value_to_pricisionz bitteam.parse_value_to_pricision  se    ))+x@@!--m\JJ!%7%?4../ABB!./BBBr   symbolsc                 V   |                                   |                                 }g }t          |t                    sg }t	          dt          |                    D ]4}||         }|                     |          }|                    |           5|                     |d|          S )aA  
        fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
        :see: https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcSummary
        :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 bitteam api endpoint
        :returns dict: a dictionary of `ticker structures <https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure>`
        r   r   )	r>  publicGetTradeApiCmcSummary
isinstancer)  r'  r(  parse_tickerappendfilter_by_array_tickers)r   r  r   r   tickersr.  	rawTickertickers           r   fetch_tickerszbitteam.fetch_tickers  s     	3355@ (D)) 	Hq#h--(( 	# 	#A I&&y11FNN6""""++GXwGGGr   c                 B   |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     |di           }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiPairName
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: a `ticker structure <https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure>`
        r   r   r   rQ  )r>  r  publicGetTradeApiPairNamer@  r   r_  r  )r   r   r   r  rD  r   r   rQ  s           r   fetch_tickerzbitteam.fetch_ticker   s     	V$$F4L
 11$++gv2N2NOOp 8R88~~ffb11  v...r   c                 @   |                      |d          }|                     ||          }d }d }d }d }|                     |d          }|                     |d          }	|t          |t                    r|	t          |	t                    r|                     |di           }
|                     |
d          }|                     |
d          }|                     |	di           }|                     |d          }|                     |d          }n,|                     |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&|          S )'Ntrading_pairsbidsasksr   r   r  highest_bid
lowest_askvolume24base_volumequoteVolume24quote_volumehighPrice24highest_price_24h
lowPrice24lowest_price_24h	lastPrice
last_pricechange24price_change_percent_24hr   rR  r  r  highlowclosebid	bidVolumeask	askVolumevwappreviousClosechanger   r  
baseVolume)quoteVolumer  )safe_string_lowerr  r   r  r)  r  safe_string_2safe_ticker)r   r  r  r  bestBidPricebestAskPricebestBidVolumebestAskVolumer  r  bestBidbestAskr  r  r  r  r  
changePcnts                     r   r  zbitteam.parse_ticker  s   ` ))&/BB!!(F33vv..vv..:dD#9#9@PWabfhlWmWm@PoodAr22G++GW==L ,,WjAAMoodAr22G++GW==L ,,WjAAMM++FMBBL++FLAAL''
MJJ
((.QQ!!&-9LMM  7IJJ""6;EE''
<VWW
 !
fX&!
!
 !
 D	!

 D!
 3!
 U!
 <!
 !
 <!
 !
 D!
 T!
 d!
 *!
  t!!
" *#!
$ ''!
 !
 !
( )  	r   c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||||          S )a>  
        get the list of most recent trades for a particular symbol
        :see: https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcTradesPair
        :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 bitteam api endpoint
        :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#public-trades>`
        rQ  r   )r>  r  publicGetTradeApiCmcTradesPairr@  parse_trades)r   r   r9  r:  r   r  rD  r   s           r   fetch_tradeszbitteam.fetch_tradesG  sv     	V$$F4L
 66t{{7F7S7STT,   65%@@@r   c                 b   |                                   i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S )a*  
        fetch all trades made by the user
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtTradesofuser
        :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(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns Trade[]: a list of `trade structures <https://github.com/ccxt/ccxt/wiki/Manual#trade-structure>`
        Nr   ro  r:  r   r  )r>  r  "privateGetTradeApiCcxtTradesOfUserr@  r   rA  r  )
r   r   r9  r:  r   rD  r  r   r   r  s
             r   fetch_my_tradeszbitteam.fetch_my_tradesn  s     	[[((F &{ 3GH$GG::4;;wPV;W;WXXL 8R88"55  >>>r   c                    |                      |d          }|                     ||          }|d         }|                     |dd          }|                      |d          }|                     |dd          }|                      |d          }|                      |d	          }	|                      |d
          }
|	t          j        |
d          }
|                     |dd          }d }d }|	dk    r?|dk    rd}n|dk    rd}|                      |d          }|                     |di           }n3|	dk    r-|                      |d          }|                     |di           }|                      |d          }|                      |d          }|                     |          |d d}|                     |
          }|                     |||| 	                    |          |d ||	|||||d|          S )NrQ  r   r   trade_idr   r  r  r  isCurrentSiderR  1000rm  r   r   sellbuymakerOrderIdfeeMakerr   takerOrderIdfeeTakerr   r  )r   rt  rR  r  r   r   rm  takerOrMakerr   r   r   r!  r  )
r  r  r  r   r  r   r  parse_to_int
safe_trader  )r   trader  r  r   r   r   r   r   r  rR  rm  feeInfort  r  r  r!  intTss                     r   parse_tradezbitteam.parse_trade
  s8   n ##E622!!(F33!tZ88  00##E:}EE~66''??$$UK88	#*9f==I!!%887""v~~$$UN;;EooeZ<<GGW$$$$UN;;EooeZ<<G(((;;""7H55//>>
 

 !!),,U++( 
  
   	r   c                 ~    |                                   |                     |          }|                     |          S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtBalance
        :param dict [params]: extra parameters specific to the betteam api endpoint
        :returns dict: a `balance structure <https://github.com/ccxt/ccxt/wiki/Manual#balance-structure>`
        )r>  privateGetTradeApiCcxtBalanceparse_balance)r   r   r   s      r   fetch_balancezbitteam.fetch_balancer  s=     	55f==!!(+++r   c                    |                                  }|||                     |          d}|                     |di           }|                     |g d          }t	          |                                          }t          dt          |                    D ]}||         }|                     ||          }	|                     |	d          }
|                     |	d          }|                     |	d          }| 	                    |
                                          }|
||d||<   |                     |          S )N)r  rR  r  r   )freeusedtotalr   r  r  r	  )millisecondsr  r   omitr)  r*  r'  r(  r  r  lowersafe_balance)r   r   rR  balancer   balanceByCurrenciesrawCurrencyIdsr.  rawCurrencyIdcurrencyBalancer  r  r	  currencyCodes                 r   r  zbitteam.parse_balance}  sR   T %%''	"Y//
 

 8R88"ii0I0I0IJJ1668899q#n--.. 	 	A*1-M"oofmDDO##OV<<D##OV<<D$$_g>>E22=3F3F3H3HIIL% %GL!!
   )))r   r"  c                 b   |                                   d}i }| |                     |          }|d         |d<   |||d<   |                     |                     ||                    }|                     |di           }|                     |dg           }	|                     |	|||          S )a  
        fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet
        :see: https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiTransactionsofuser
        :param str [code]: unified currency code for the currency of the deposit/withdrawals
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal
        :param int [limit]: max number of deposit/withdrawals to return(default 10)
        :param dict [params]: extra parameters specific to the bitteam api endpoint
        :returns dict: a list of `transaction structure <https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure>`
        Nr   r/  r:  r   transactions)r>  r/  $privateGetTradeApiTransactionsOfUserr@  r   rA  parse_transactions)
r   r"  r9  r:  r   r/  rD  r   r   r  s
             r   fetch_deposits_withdrawalsz"bitteam.fetch_deposits_withdrawals  s     	}}T**H"*;"7GJ$GG<<T[[RX=Y=YZZr 8R88~~fnbAA&&|XueLLLr   r/  c                 V   |                      |d          }|                     |d          }|                     ||          }|                     |d          }|                      |d          }|                     |d          }|                     |d          }	|                     |d          }
|
D|                      |dg           }|                      |d	i           }|                     |d          }
|                     |d
          }|                     |d          }|                     |d          }|                     |                     |d                    }|                     |d|d          }|                     |                      |d                    }i d|d|d|d|	d|                     |	          d|                     |
          d|dd d|dd d|dd d|d| 	                    |          d|d|dd d |                     |d          ddS )Nr/  r   r   r   tx_idrR  r  linksr   sender	recipientmessager   r   r  r  r  txidr  r   addressFromaddress	addressTotagFromtagtagToupdateddescriptionF)r!  commentinternal)
r   r  r  r  parse_transaction_typer  parse_transaction_statusr  r+  r   )r   transactionr/  currencyObject
currencyIdr"  r   r   r  rR  r5  r  r  r   r"  r$  r   r   r  s                      r   parse_transactionzbitteam.parse_transaction-  s   ` jAA%%nh??
&&z8<<k400h7700%%k;??	$$[,??	OONGR@@E266J((\BBI&&{H==$$[+>>	{I66**4+;+;K+P+PQQ..{HnV`aa..t{H/U/UVV
K
"
 D
 	

 Y//
 t..y99
 ;
 t
 
 t
 3
 T
 D
 d''//
 
  f!
" t#
$ '']CC)
 
 
 	
r   c                 :    ddd}|                      |||          S )Nr7   
withdrawal)r7   r   r  )r   r   typess      r   r*  zbitteam.parse_transaction_type  s.     $
 
 tT222r   c                 :    ddd}|                      |||          S )Npendingok)	approvingsuccessr  r  s      r   r+  z bitteam.parse_transaction_status  s.    "
 
 &&999r   r   GETc                 &   |                      ||                     |                    }d|                     ||          z   }| j        d         |         |z   }	|                     |          }
|dk    r}|                                  |dk    r|                     |          }nt          |
          dk    r|	d|
z   z  }	| j        dz   | j	        z   }| 
                    |          }d|z   }|d	d
}nt          |
          dk    r|	d|
z   z  }	|	|||dS )Nr   r   r   POSTr   ?:zBasic zapplication/json)AuthorizationzContent-Type)urlmethodbodyheaders)r  extract_paramsimplode_paramsr   	urlencodecheck_required_credentialsjsonr(  apiKeysecretstring_to_base64)r   pathr   r?  r   rA  r@  rD  endpointr>  queryauthauth64	signatures                 r   signzbitteam.sign  s1   ))FD$7$7$=$=>>,,T6:::is#h.w'')++---yy))UqsU{";$t{2D**400F 6)I!* 2 GG ZZ1__3;CfdwOOOr   c
                    |d S |dk    rZ|dk    r|                     d          dk    rN|dk    rH|                    d          }
|                     |
d          }t          | j        dz   |z   d	z             |                     d
          dk    rH|                    d
          }
|                     |
d          }t          | j        dz   |z   d	z             | j        dz   |z   }|                     |d          }|                     |d          }|                     | j        d         ||           |                     | j        d         ||           t          |          d S )N   i  z/ccxt/order/r   r8  z/order/r$   z order z
 not foundz/cmc/orderbook/z
 symbolId  r  r"  r   r   )
findr  r  r   r   r   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r   r"  reasonr>  r?  rA  r@  r   requestHeadersrequestBodyr  orderIdsymbolIdfeedbackr  responseCodes                   r   handle_errorszbitteam.handle_errors  sn   43;;s{{HH^,,11%IIi00E"..ua88G')(;g(E(TUUU88-..!33II&788E#//q99H#DGl$:X$E$TUUUw}t+H&&x;;G++Hf==L001I7T\]]]001I<Yabbb)))tr   r  )9__name__
__module____qualname__r   r   r	   r   r  r   r8  rp  r   r)  rE  rO  r   rV  r   r   r\  ra  re  ri  rl  r   r   floatr
   ru  rx  r|  r`  r  r  r  r   r   r  r   r  r  r   r  r  r  r   r  r  r   r  r   r/  r*  r+  rP  r^  __classcell__)r   s   @r   r!   r!      sZ       ` ` ` ` `D $& `+ `+$v, `+ `+ `+ `+DDf D D D DL ') N NZ N N N N` 26DW[df /H /H# /Hc /HQT /Hkoptku /H /H /H /Hb
 
 
4 
 
 
 
( :>b , ,s ,3 ,Y , , , ,\ *.Dt\^ k? k?3 k?c k? k?cghmcn k? k? k? k?Z 26b 70 70c 703 70U 70 70 70 70r /3TXac U U U3 Uc Uhlmrhs U U U U  154VZce U U# US UPS Ujnotju U U U U  37TX\eg U UC Us URU U U U U  gksu 2/ 2/3 2/i 2/y 2/RW 2/`c 2/ 2/ 2/ 2/h 37r ( (s (C ( ( ( (2 /32 1 1 1 1 1 1:K K K5 K K K KZ: : :: : :C C C 04B 0H 0HW 0H7 0H 0H 0H 0Hd 02 G/ G/3 G/f G/ G/ G/ G/R| |6 |V | | | || 6:UW %A %A3 %As %A# %A\`af\g %A %A %A %AN -1tRV_a Z? Z?c Z? Z?C Z? Z? Z? Z?xf f f5 f f f fP $& 	, 	,( 	, 	, 	, 	,?* ?* ?* ?* ?*B 6:[_hj mM mMs mM# mMUX mMost  pA mM mM mM mM^W
 W
x W
; W
 W
 W
 W
r3 3 3: : : &eBSW P P P P,      r   r!   N)%ccxt.base.exchanger   ccxt.abstract.bitteamr   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   r   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r!    r   r   <module>rl     s	   ( ' ' ' ' ' - - - - - - h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h  h       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . * * * * * * 1 1 1 1 1 1 9 9 9 9 9 9 % % % % % %g" g" g" g" g"h g" g" g" g" g"r   