
    !: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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%y)    )Exchange)ImplicitAPI)Any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)	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ddi fd	ed
edede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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 d=dededefdZ!def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)d=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di fd	ed
edefd(Z-d=d)edede+fd*Z.i fde/fd+Z0de/fd,Z1dddi fd-ed
ededee2   fd.Z3d=d/ed0e4de2fd1Z5d2 Z6defd3Z7d4d5i ddfd6Z8d-e9d7ed8ed9ed:ed;efd<Z: xZ;S )>bitteam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dddddddddedfdgdhdidjdkdldmdndodpdpdqdrdsdtgdudvdwdxd
iidwi dyd
dzd
d{d
d|d
d}d
d~d
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
id
d
d
d
d
dd
d
d
dddqdddwdd| j	                  d      | j	                  d      didt
        di ddddddddddddddddddddddddddddddddddddiddddddddd d ddd dddddddddddddd dddddddddddddddddddd d ddddddd d d ddddddid	d d dd d dddt        t        t        t        dt        t        t        t        t        t        t        t        t        t        t        t        dd      S )Nidr"   namezBIT.TEAM	countriesUKversionzv2.0.6	rateLimit   	certifiedFprohas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fetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistory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
timeframes1515601D)1m5m15m1h1durlszOhttps://github.com/user-attachments/assets/b41b5e0d-98e5-4bd3-8a6e-aeb230a4a135z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docr   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feestradingz0.002)feeSide	tierBased
percentagetakermakerprecisionModeoptions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features)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventionicebergd   i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   daysBackCanceledr   r   r   r   r   i  )	sandboxr;   createOrdersre   rj   ri   rm   rK   rf   )linearinverse)r0   r2   r3   
exceptions)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)deep_extendsuperr"   describeparse_numberr   r   r   r   r   r   r   )self	__class__s    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/bitteam.pyr   zbitteam.describe   s	   gt = ? qB
)qB
JqB
 $qB
 x	qB

 qB
 qB
 5qB
  bbb %b 	b
 %b %b Ub b "4b tb b 'b tb &ub (b  '!b" (#b$ "5%b& 5'b( U)b*  +b, -b.  /b0 &u1b2 +E3b4 )%5b6 &t7b8 #E9b: $T;b< '=b> (?b@ "4AbB CbD &uEbF (GbH 1%IbJ  KbL +DMbN *5ObP +EQbR &uSbT #EUbV *5WbX $UYbZ "5[b\ *5]b^ +E_b` #Eabb ucbd  ebf %egbh +Eibj kbl !%mbn  obp dqbr +Esbt !%ubv "4wbx dybz !${b| "5}b~ tb@ #EAbB  CbD 'EbF $UGbH !%IbJ *5KbL (MbN %eObP )%QbR uSbT tUbV WbX UYbZ t[b\ "5]b^ #E_b` %eabb &ucbd 'ebf $Tgbh !%ibj "5kbl %*,1 %$$"!&#(!!CbqB
V WqB
d i901
 +J>eqB
~ @!  )1. 8 +A	
 0 *1 5a *1 / +A / / 9! 0 /  6q!, 3456787889 <=67675(qB
P $!&"&!..w7!..w7QqB
b YcqB
f !!! G! G	!
 u! u! *5! u! u! u! ! ! y! y! W!  y!!" 
#!$ 
%!* ! *+gqB
Z $&+(-,0,0).+06:#(#("'#(	( #($)$)27+0/4#()$, %)&+!$$*%+*/& ',#($)*/	# ',!$#($)*/( '+!$$(%)#($)*/$ ',!$$(,0%)#($)*/	*  #ACJ ##
 ##SM[qB
v '1('	 '1*;4>(2(2'1&0'4+4 )+?(wqB
 q q	    c                     | j                  |      }| j                  |di       }| j                  |dg       }| j                  |      S )a$  
        retrieves data on all markets for bitteam

        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_marketsL  sL     226:n 8R8//&'26!!'**r   marketc                    | j                  |d      }| j                  |d      }|j                  d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }| j	                  |d      }	| j                  |d      }
| j                  |
      }d }| j	                  | j                  di       }| j                  ||d	      }|r%| j	                  |d
i       }| j                  |d      }| j                  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 | j                  | j                  | j                  |d                  | j                  | j                  | j                  |d                  dd d d d d d d d d |d d d!||d"      S )#Nr&   r%   _r   r+   active	timeStartr   Fsettings	limit_usd	numericIdsymbol/basequotesettlebaseIdquoteIdsettleIdtyper0   Tr1   r2   r3   r4   contractbaseStep	quoteStep)amountpriceminmax)r   r  r  cost)r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_integersplitsafe_currency_coder   	parse8601r   	safe_boolsafe_numbersafe_market_structurer   parse_precision)r   r  r%   r
  partsr  r  r  r  r  r  r$  minCostr   
quoteInUsdr  s                   r   parse_marketzbitteam.parse_market  s   ff-%%fd3	!!%+""5!,&&v.''02$$V[9	..+ $>UWY Z^^$95%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+
$  "++D,@,@AQAQRXZdAe,fg**4+?+?@P@PQWYd@e+fg  
  
  
 #$ a1+
 1 1	r   c                    | j                  |      }| j                  |di       }| j                  |dg       }| j                         }| j                  |d      }i }t	        dt        |            D ]  }||   }| j                  |d      }	| j                  |d      }
| j                  |	      }| j                  |dd      }| j                  | j                  | j                  |d	                  }| j                  |d
i       }| j                  |d      }| j                  |d      }| j                  |d      }d}| j                  |di       }i }| j                  |d      }||dk7  r| j                  |      }|||<   n|}| j                  ||
i       }| j                  |d      }| j                  |d      }t        |j                               }i }| j                  | j                  | j                  |d                  }| j                  |d      }t	        dt        |            D ]t  }||   }| j                  ||      }| j                  ||      } |||||| |ddd| j                  |      | j                  |      d| j                  |      ddd|d	||<   v |	|
||||||||ddd| j                  |      | j                  |      d| j                  |      ddd||d||<    |S )a%  
        fetches all available currencies on an exchange

        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  r   rA   )	r%   networkrA   r   r  feer"  r#  r%  )r%   r
  coder&   r%  r  rA   r   rA  r"  r#  r  networks)publicGetTradeApiCurrenciesr   publicGetTradeApiCmcAssetsindex_byrangelenr&  r'  r)  r+  r   r.  listkeysnetwork_id_to_coder,  )!r   r   r   responseResultr4  statusesResponser   icurrencyr%   r
  rB  r  r"  r6  r7  r8  r9  rA  r:  feesByNetworkIdr;  statusesrA   r   
networkIdsrC  networkPrecisiontypeRawj	networkIdnetworkCode
networkFees!                                    r   fetch_currencieszbitteam.fetch_currencies  sk    33F;v 8R@__^\2F
::<*  ==)9;STq#j/* S	A!!}H!!(H5B))(D9I**2.D^^Hh>F))$*>*>t?O?OPXZe?f*ghIxR@H**8]CK**8]CK))(LAJC&*ooh@Y[]&^#$&O))(LAJ&Z2-=''(?@.1
+"9'7BGHooh@Gx1ABHo2245JH#001E1EdFVFVW_akFl1mn&&x8G1c*o. &qM	"55iF!--oyI
#*& ($%!1 $(#'#
 $(#4#4[#A#'#4#4[#A%
 $(#4#4Z#@#'$ %-)%	: &  "$&  $#
  $00=#00=!
  $00<#   $5F4LqS	h r   r   Nr  sincer   c                 F   | j                          | j                  |      }| j                  | j                  ||      }|d   |d}| j	                  | j                  ||            }	| j                  |	di       }
| j                  |
dg       }| j                  |||||      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  	timeframerZ  r   r   r  r\  requestr   r   r]  s               r   fetch_ohlcvzbitteam.fetch_ohlcv  s     	V$%%dooy)L
t$
 @@WV\A]^8 8R8~~ffb1  vy%GGr   c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Ntohlcv)safe_timestampr,  )r   ohlcvr  s      r   parse_ohlcvzbitteam.parse_ohlcv  sn     s+UC(UC(UC(UC(UC(
 	
r   c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |d      }| j                  |||      }|S )ai  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        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  sy     	V$F4L
 99$++gv:VW8 %%h<	))(FIF	r   c                 N   | j                          | j                  |dd      }d|i}d}|| j                  |      }|d   |d<   |||d<   | j                  | j	                  ||            }| j                  |di       }	| j                  |	dg       }
| j                  |
|||      S )	a  
        fetches information on multiple orders made by the user

        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  rZ  r   r   r  rd  r  r   r   ry  s              r   fetch_orderszbitteam.fetch_orders=  s     	6D
 [[(F$TlGFO$GG::4;;wPV;WXf 8R8"5  >>r   r%   c                     | j                          d|i}d}|| j                  |      }| j                  | j                  ||            }| j	                  |d      }| j                  ||      S )a  
        fetches information on an order

        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_order  sx     	"
 [[(F55dkk'66RSL (3//r   c           	      r    | j                          ddi}| j                  |||| j                  ||            S )a6  
        fetch all unfilled currently open orders

        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  rZ  r   r   rd  s         r   fetch_open_orderszbitteam.fetch_open_orders  @     	H
   t{{7F7STTr   c           	      r    | j                          ddi}| j                  |||| j                  ||            S )ak  
        fetches information on multiple closed orders made by the user

        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  closedr  r  s         r   fetch_closed_orderszbitteam.fetch_closed_orders  r  r   c           	      r    | j                          ddi}| j                  |||| j                  ||            S )al  
        fetches information on multiple canceled orders made by the user

        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  	cancelledr  r  s         r   fetch_canceled_orderszbitteam.fetch_canceled_orders  s@     	K
   t{{7F7STTr   r  sider  r  c                    | j                          | j                  |      }t        |d         ||| j                  ||      d}|dk(  r5|t	        | j
                  dz   |z   dz         | j                  ||      |d<   | j                  | j                  ||            }	| j                  |	di       }
| j                  |
|      S )a  
        create a trade order

        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 fulfilled, 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  r  r  r   z/ 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  r  r  r  r   r  rd  r   orders              r   create_orderzbitteam.create_order  s     	V$&-...vv>	
 7?}'2c(cfj(jmu(uvv#'#:#:65#I ::4;;wPV;WX0 x26v..r   c                     | j                          d|i}| j                  | j                  ||            }| j                  |di       }| j	                  |      S )a  
        cancels an open order

        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_orderS  s_     	"
 ::4;;wPV;WX (B7''r   c                    | j                          d}i }|#| j                  |      }t        |d         |d<   nd|d<   | j                  | j	                  ||            }| j                  |di       }|g}| j                  ||      S )a  
        cancel open orders of market

        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
  r  0r   )r^  r  r  %privatePostTradeApiCcxtCancelAllOrderr`  r   r{  )r   r  r   r  rd  r   r   ry  s           r   cancel_all_orderszbitteam.cancel_all_ordersn  s     	[[(F #F;$7 8GH #GH==dkk'SY>Z[ 8R8  00r   r  c           	         | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }d }| j                  |d      }|| j                  |      }n| j                  |d      }| j                  |d      }| j                  |      }	| j	                  | j                  |d            }
| j                  | j                  |d            }| j                  |d	      }| j                  |d
      }| j                  |d      }| j                  |d      }| j                  |d      }d }|9| j                  |d      }| j                  |d      }| j                  |      |d d}| j                  i d|d|d|d| j                  |      dd d|	d|
d|d   d|ddd	|d|d| j                  |d      dd d|dd d|d |d |dd|      S )Nr%   rq  orderCid	createdAtrr  	updatedAtstatusr  r  rA  r  quantityexecutedr  r  )rO  r  rateclientOrderIddatetimelastTradeTimestamplastUpdateTimestampr   GTCr   	stopPriceaverager  filledF)	remainingrA  tradesr%  postOnly)
r&  safe_marketr*  rm  parse_order_statusparse_order_typer   r)  
safe_orderiso8601)r   r  r  r%   marketIdr  rr  r  r  r  r  r  r  feeRawr  r  r  rA  feeCostfeeCurrencyIds                       r   r  zbitteam.parse_order  s   l eT*##E62!!(F3((
;	$$UK8	 y1I++E;?I$$UK8	"nnY7(()9)9%)JK$$T%5%5eV%DEv..  0!!%4!!%4&&vx8G ,,VX>M 33MBC
   
" 
] 
  
 Y/	 

 !$ 
 "#6 
 f 
 fX& 
 D 
 5 
 D 
 U 
 D,,UK@ 
 t 
 f 
  D! 
" f# 
$ - 
. / 	r   r  c           	      >    ddddddddd}| j                  |||      S )Nopenr  canceledrejected)acceptedr  r  partiallyCancelleddeleteinactive	executingr$  r&  r   r  rQ  s      r   r  zbitteam.parse_order_status  s8     #", "	
 &&99r   c                 2    ddd}| j                  |||      S )Nr  r   )r  r   r  r  s      r   r  zbitteam.parse_order_type%  s&    
 &&99r   c                     | j                  ||      }| j                  ||      }||y | j                  |      }t        j                  ||      S N)r&  r.  r    
string_mul)r   valueObjectvalueKeypreciseObjectprecisionKeyvalueRawStringprecisionRawStringprecisionStrings           r   parse_value_to_pricisionz bitteam.parse_value_to_pricision,  sZ    ))+x@!--m\J!%7%?../AB!!./BBr   symbolsc                    | j                          | j                         }g }t        |t              sg }t	        dt        |            D ])  }||   }| j                  |      }|j                  |       + | j                  |d|      S )a=  
        fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market

        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
isinstancerI  rG  rH  parse_tickerappendfilter_by_array_tickers)r   r  r   r   tickersrN  	rawTickertickers           r   fetch_tickerszbitteam.fetch_tickers4  s     	335@ (D)Hq#h-( 	#A I&&y1FNN6"	# ++GXwGGr   c                    | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  |di       }| j                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        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_tickerh  s     	V$F4L
 11$++gv2NOp 8R8~~ffb1  v..r   r  c                    | j                  |d      }| j                  ||      }d }d }d }d }| j                  |d      }| j                  |d      }	|t        |t              r|	t        |	t              ro| j                  |di       }
| j                  |
d      }| j                  |
d      }| j                  |	di       }| j                  |d      }| j                  |d      }n$| j                  |d      }| j                  |d      }| j                  |d	d
      }| j                  |dd      }| j                  |dd      }| j                  |dd      }| j                  |dd      }| j                  |d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&|      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  rI  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_ticker3  s   ` ))&/B!!(F3vv.vv.:dD#9@PWabfhlWmoodAr2G++GW=L ,,WjAMoodAr2G++GW=L ,,WjAM++FMBL++FLAL''
MJ
((.Q!!&-9LM  7IJ""6;E''
<VW
 !
fX&!
!
 !
 D	!

 D!
 3!
 U!
 <!
 !
 <!
 !
 D!
 T!
 d!
 *!
  t!!
" *#!
$ ''!
( ) 	r   c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||||      S )a:  
        get the list of most recent trades for a particular symbol

        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  rZ  r   r   r  rd  r   s           r   fetch_tradeszbitteam.fetch_trades  sd     	V$F4L
 66t{{7F7ST,   65%@@r   c                 $   | j                          i }d}|| j                  |      }|d   |d<   |||d<   | j                  | j                  ||            }| j	                  |di       }| j                  |dg       }	| j                  |	|||      S )a&  
        fetch all trades made by the user

        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
  r  r   r   r  )r^  r  "privateGetTradeApiCcxtTradesOfUserr`  r   ra  r  )
r   r  rZ  r   r   rd  r  r   r   r  s
             r   fetch_my_tradeszbitteam.fetch_my_trades  s     	[[(F &{ 3GH$GG::4;;wPV;WXL 8R8"5  >>r   tradec                 F   | j                  |d      }| j                  ||      }|d   }| j                  |dd      }| j                  |d      }| j                  |dd      }| j                  |d      }| j                  |d	      }	| j                  |d
      }
|	t        j                  |
d      }
| j                  |dd      }d }d }|	dk(  r5|dk(  rd}n|dk(  rd}| j                  |d      }| j                  |di       }n*|	dk(  r%| j                  |d      }| j                  |di       }| j                  |d      }| j                  |d      }| j                  |      |d}| j                  |
      }| j                  |||| j                  |      |d ||	|||||d|      S )Nrq  r  r%   trade_idr  r  r  r  isCurrentSiderr  1000r  r  r   sellbuymakerOrderIdfeeMakerr   takerOrderIdfeeTakerr  )rO  r  )r%   r  rr  r  r  r  r  takerOrMakerr  r  r  rA  r%  )
r&  r  r  r    r  r   r)  parse_to_int
safe_trader  )r   r  r  r  r  r%   r  r  r  r  rr  r  feeInfor  r  r  rA  intTss                     r   parse_tradezbitteam.parse_tradex  s   n ##E62!!(F3!tZ8  0##E:}E~6''?$$UK8	#**9f=I!!%87"v~$$UN;EooeZ<GW$$$UN;EooeZ<G(((;""7H5//>
 !!),U+( 
  	r   c                 f    | j                          | j                  |      }| j                  |      S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        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_balance  s1     	55f=!!(++r   c                    | j                         }||| j                  |      d}| j                  |di       }| j                  |g d      }t	        |j                               }t        dt        |            D ]w  }||   }| j                  ||      }	| j                  |	d      }
| j                  |	d      }| j                  |	d      }| j                  |j                               }|
||d||<   y | j                  |      S )N)r%  rr  r  r   )freeusedtotalr   r#  r$  r%  )millisecondsr  r   omitrI  rJ  rG  rH  r&  r)  lowersafe_balance)r   r   rr  balancer   balanceByCurrenciesrawCurrencyIdsrN  rawCurrencyIdcurrencyBalancer#  r$  r%  currencyCodes                 r   r   zbitteam.parse_balance  s   T %%'	"Y/

 8R8"ii0IJ16689q#n-. 	A*1-M"oofmDO##OV<D##OV<D$$_g>E22=3F3F3HIL%GL!	   ))r   rB  c                 $   | j                          d}i }|| j                  |      }|d   |d<   |||d<   | j                  | j                  ||            }| j	                  |di       }| j                  |dg       }	| j                  |	|||      S )a  
        fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet

        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
  rO  r   r   transactions)r^  rO  $privateGetTradeApiTransactionsOfUserr`  r   ra  parse_transactions)
r   rB  rZ  r   r   rO  rd  r   r   r1  s
             r   fetch_deposits_withdrawalsz"bitteam.fetch_deposits_withdrawals-  s     	}}T*H"*;"7GJ$GG<<T[[RX=YZr 8R8~~fnbA&&|XueLLr   transactionrO  c                    | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d      }
|
8| j                  |dg       }| j                  |d	i       }| j                  |d      }
| j                  |d
      }| j                  |d      }| j                  |d      }| j	                  | j                  |d            }| j                  |d|d      }| j                  | j                  |d            }i d|d|d|d|	d| j                  |	      d| j                  |
      d|dd d|dd d|dd d|d| j                  |      d|d|dd d | j                  |d      ddS )NrO  r  r%   r   tx_idrr  r;  linksr   sender	recipientmessager  r  r?  r  r%  txidr  r@  addressFromaddress	addressTotagFromtagtagToupdateddescriptionF)rA  commentinternal)
r   r&  r)  r'  parse_transaction_typer  parse_transaction_statusr  rK  r   )r   r5  rO  currencyObject
currencyIdrB  r%   r   r<  rr  rV  r8  r;  r=  r?  rA  r  r  r  s                      r   parse_transactionzbitteam.parse_transaction  s`   ` jA%%nh?
&&z8<k40h70%%k;?	$$[,?	OONGR@E26J((\BI&&{H=$$[+>	{I6**4+;+;K+PQ..{HnV`a..t{H/UV
K
"
 D
 	

 Y/
 t..y9
 ;
 t
 
 t
 3
 T
 D
 d''/
 
  f!
" t#
$ '']C)
 	
r   c                 2    ddd}| j                  |||      S )NrA   
withdrawal)rA   r   r  )r   r  typess      r   rG  zbitteam.parse_transaction_type  s&     $
 tT22r   c                 2    ddd}| j                  |||      S )Npendingok)	approvingsuccessr  r  s      r   rH  z bitteam.parse_transaction_status  s&    "
 &&99r   r   GETc                    | j                  || j                  |            }d| j                  ||      z   }| j                  d   |   |z   }	| j	                  |      }
|dk(  ru| j                          |dk(  r| j                  |      }nt        |
      dk7  r|	d|
z   z  }	| j                  dz   | j                  z   }| j                  |      }d|z   }|d	d
}nt        |
      dk7  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jsonrH  apiKeysecretstring_to_base64)r   pathr   r[  r   r]  r\  rd  endpointrZ  queryauthauth64	signatures                 r   signzbitteam.sign	  s   ))FD$7$7$=>,,T6::iis#h.w')++-yy)UqsU{";;$t{{2D**40F 6)I!* 2G Z1_3;CfdwOOr   reasonrZ  r[  r]  r\  c
                    |y |dk7  r5|dk(  r|j                  d      dk\  rF|dk(  rA|j                  d      }
| j                  |
d      }t        | j                  dz   |z   d	z         |j                  d
      dk\  rA|j                  d
      }
| j                  |
d      }t        | j                  dz   |z   d	z         | j                  dz   |z   }| j                  |d      }| j                  |d      }| j                  | j                  d   ||       | j                  | j                  d   ||       t        |      y )N   i  z/ccxt/order/r   rT  z/order/r+   z order z
 not foundz/cmc/orderbook/z
 symbolId  r;  rB  r   r   )
findr(  r&  r   r%   r   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r   rB  rm  rZ  r[  r]  r\  r   requestHeadersrequestBodyr/  orderIdsymbolIdfeedbackr;  responseCodes                   r   handle_errorszbitteam.handle_errors	  s;   3;s{HH^,1%IIi0E"..ua8G')(;g(E(TUU88-.!3II&78E#//q9H#DGGl$:X$E$TUUww}t+H&&x;G++Hf=L001I7T\]001I<Yab))r   r  )<__name__
__module____qualname__r   r   r   r
   r  dictr2  r   rY  r  r	   rI  re  ro  r   rv  r   r   r|  r  r  r  r  r   r   floatr   r  r  r  r  r  r  r  r   r   r  r   r  r  r   r	  r  r  r   r!  r   r   r4  r   rK  rG  rH  rl  intrz  __classcell__)r   s   @r   r"   r"      s   r# rh	 $& b+$v, b+HB4 BF BH ') RZ Rh 26DW[df /H# /Hc /HQT /Hkoptku /Hb
 
4 
( :>b .s .3 .Y .` *.Dt\^ m?3 m?c m? m?cghmcn m?^ 26b 90c 903 90U 90v /3TXac U U3 Uc Uhlmrhs U$ 154VZce U# US UPS Ujnotju U$ 37TX\eg UC Us URU U$ gksu 4/3 4/i 4/y 4/RW 4/`c 4/l 37r (s (C (6 /32 1 1>I Iv I IV: ::C 04B 2HW 2H7 2Hh 02 I/3 I/f I/V|4 | |6 || 6:UW 'A3 'As 'A# 'A\`af\g 'AR -1tRV_a \?c \? \?C \?|e ev e eN $& ,( ,?* ?*B 6:[_hj oMs oM# oMUX oMost  pA oMbW
T W
X W
Q\ W
r3:s : &eBSW P,# s  c TX `c 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   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr   ccxt.base.preciser    r"    r   r   <module>r     s\    ( - m  m  m  m  m  * 0 . ' & . * 1 4 %X$h X$r   