
    eiS                       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%dS )    )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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>d0ed1e4de2fd2Z5d3 Z6defd4Z7d5d6i ddfd7Z8d.e9d8ed9ed:ed;ed<efd=Z: xZ;S )?bitteamreturnc                    |                      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i deddfddgddhddiddjddkddlddmddnddoddpddqddrddsddtddudi dvddwddxddyddzdd{dd|dd}dd~ddddddddddddddddddddddddddd	ddddddddddddddddgddddd
iidi dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
id
d
d
d
d
dd
d
d
dddddddd|                     d          |                     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borrowCrossMarginborrowIsolatedMarginborrowMargincancelAllOrderscancelOrdercancelOrderscloseAllPositionsclosePositioncreateDepositAddresscreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderdeposit	editOrderfetchAccountsfetchBalancefetchBidsAsksfetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeefetchDepositWithdrawFeesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchL3OrderBookfetchLedgerfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTrades
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrderfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTradingLimitsfetchTransactionFeefetchTransactionFeesfetchTransactionsfetchTransfersfetchVolatilityHistoryfetchWithdrawalfetchWithdrawalsfetchWithdrawalWhitelistreduceMarginrepayCrossMarginrepayIsolatedMargin)	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?   createOrdersr|   r   r   r   rT   r}   )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    X/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/bitteam.pyr  zbitteam.describe   sr   gt 4 4 = = ? ? PB
)PB
JPB
 $PB
 x	PB

 PB
 PB
 5PB
  AAA %A 	A
 %A %A UA $UA 'A A "4A tA A $UA  A  '!A" t#A A$ 7%A& 9%'A( &u)A* (+A, '-A. (/A0 "51A2 53A4 U5A6  7A8 9A:  ;A< &u=A> "5?A@ +EAAB )%CAD #EEA A AF ,UGAH &tIAJ #EKAL $TMAN 'OAP (QAR "4SAT UAV &uWAX (YAZ 1%[A\  ]A^ +D_A` *5aAb +EcAd &ueAf 'gA A Ah (iAj #EkAl *5mAn $UoAp uqAr "5sAt *5uAv +EwAx )%yAz #E{A| u}A~  A@ !%AAB %eCAD $UEAF &uGAH -eIA A AJ /KAL "5MAN #EOAP +EQAR SAT !%UAV "5WAX &uYAZ +E[A\  ]A^ d_A` $UaAb +EcAd %eeAf !%gAh "4iAj ukA A Al #EmAn doAp !$qAr "5sAt tuAv #EwAx  yAz '{A| $U}A~ !%A@ *5AAB (CAD %eEAF )%GAH )%IAJ uKAL tMA A AN OAP UQAR tSAT "5UAV #EWAX %eYAZ &u[A\ ']A^ $T_A` !%aAb )%cAd "5eAf #EgAh +EiAj kAl #EmAn &uoA Ap  %$"!&#(!!AA A APB
T  UPB
b i901 
 +J> cPB
| @!  )1. 8 +A	
 0 *1 5a *1 / +A / / 9! 0 /  6q!, 3456787889  <=6767  5( (}PB
N $!&"&!..w77!..w77 OPB
` YaPB
d !!! G! G	!
 u! u! *5! u! u! u! ! ! y! y! W!  y!!" 
#!$ 
%! !* ! * *+ ePB
X $&+(-,0,0).+06:#(#("'#(	( ( #($)$)27+0/4#()$ $, %)&+!$$*%+*/& & ',#($)*/	# # ',!$#($)*/( ( '+!$$(%)#($)*/$ $ ',!$$(,0%)#($)*/	* 	*  #AC CJ ## 
 ## SM MYPB
t	 '1('	  '1*;4>(2(2'1&0'4+4 )+?(  u	PB
 P P P	    c                    K   |                      |           d{V }|                     |di           }|                     |dg           }|                     |          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
        Nresultpairs)publicGetTradeApiCcxtPairs
safe_valueparse_markets)r  paramsresponser  marketss        r  fetch_marketszbitteam.fetch_marketsk  sn       88@@@@@@@@n 8R88//&'266!!'***r  marketc                 B   |                      |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 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   r6  r7  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/  r0  r,  r-  r%  r&  rC  minCostr   
quoteInUsdr'  s                   r  parse_marketzbitteam.parse_market  s   ff--%%fd33	!!%++""5!,,&&v..''0022$$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+
$  "++D,@,@AQAQRXZdAeAe,f,fgg**4+?+?@P@PQWYd@e@e+f+fgg    
   
   
 #  $ a1+
 1+
 1+
 1 1 1	r  c                 N  K   |                      |           d{V }|                     |di           }|                     |dg           }|                                  d{V }|                     |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                              }|                     |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

        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
        Nr  
currenciesunified_cryptoasset_idr   r*  r%   r%  FrA  txLimitsminWithdrawmaxWithdraw
minDepositwithdrawCommissionFixed
blockChain depositStatuswithdrawStatusdecimalsr2  r8  )r6  r   rG   )	r%   networkrG   r   r%  feerA  rB  rD  )r%   r)  coder&   rD  r%  rG   r   r`  rA  rB  r2  networks)publicGetTradeApiCurrenciesr  publicGetTradeApiCmcAssetsindex_byrangelenrE  rF  rH  rJ  r  rM  listkeysnetwork_id_to_coderK  )!r  r  r  responseResultrS  statusesResponser  icurrencyr%   r)  ra  r%  rA  rU  rV  rW  rX  r`  rY  feesByNetworkIdrZ  statusesrG   r   
networkIdsrb  networkPrecisiontypeRawj	networkIdnetworkCode
networkFees!                                    r  fetch_currencieszbitteam.fetch_currencies  sD      99&AAAAAAAAv 8R@@__^\2FF
!%!@!@!B!BBBBBBB*  ==)9;STTq#j//** S	 S	A!!}H!!(H55B))(D99I**2..D^^Hh>>F))$*>*>t?O?OPXZe?f?f*g*ghhI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1E1EdFVFVW_akFlFl1m1mnn&&x88G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<<#      $5 F4LL8 r  r   Nr*  	timeframesincer   c                   K   |                                   d{V  |                     |          }|                     | j        ||          }|d         |d}|                     |                     ||                     d{V }	|                     |	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
        Nr%   )r  
resolutionr  data)	load_marketsr"  rE  r   (historyGetApiTwHistoryPairNameResolutionextendr  	safe_listparse_ohlcvs)r  r*  ry  rz  r   r  r"  r|  requestr  r  r}  s               r  fetch_ohlcvzbitteam.fetch_ohlcv  s       !!!!!!!!!V$$%%doy)LL
t$
 
 FFt{{SZ\bGcGcdddddddd8 8R88~~ffb11  vy%GGGr  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Ntohlcv)safe_timestamprK  )r  ohlcvr"  s      r  parse_ohlcvzbitteam.parse_ohlcv  s     s++UC((UC((UC((UC((UC((
 	
r  c                 4  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d          }|                     |||          }|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
        Npairr%   	timestamp)r~  r"  !publicGetTradeApiCmcOrderbookPairr  rF  parse_order_book)	r  r*  r   r  r"  r  r  r  	orderbooks	            r  fetch_order_bookzbitteam.fetch_order_book,  s       !!!!!!!!!V$$F4L
 ??GU[@\@\]]]]]]]]8 %%h<<	))(FIFF	r  c                   K   |                                   d{V  |                     |dd          }d|i}d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                     d{V }|                     |di           }	|                     |	dg           }
|                     |
|||          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>`
        Nr2  allr%   r  r   r  orders)r~  rE  r"  "privateGetTradeApiCcxtOrdersOfUserr  r  r  parse_orders)r  r*  rz  r   r  r2  r  r"  r  r  r  s              r  fetch_orderszbitteam.fetch_orders\  s      !!!!!!!!!66D
 [[((F$TlGFO$GG@@WV\A]A]^^^^^^^^f 8R88"55  >>>r  r%   c                 *  K   |                                   d{V  d|i}d}||                     |          }|                     |                     ||                     d{V }|                     |d          }|                     ||          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>`
        Nr%   r  )r~  r"  privateGetTradeApiCcxtOrderIdr  	safe_dictparse_order)r  r%   r*  r  r  r"  r  r  s           r  fetch_orderzbitteam.fetch_order  s       !!!!!!!!!"
 [[((F;;DKKQW<X<XYYYYYYYYL (33///r  c           	         K   |                                   d{V  ddi}|                     ||||                     ||                     d{V 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>`
        Nr2  r%  r~  r  r  r  r*  rz  r   r  r  s         r  fetch_open_orderszbitteam.fetch_open_orders  u       !!!!!!!!!H
 &&vueT[[RX=Y=YZZZZZZZZZr  c           	         K   |                                   d{V  ddi}|                     ||||                     ||                     d{V 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>`
        Nr2  closedr  r  s         r  fetch_closed_orderszbitteam.fetch_closed_orders  r  r  c           	         K   |                                   d{V  ddi}|                     ||||                     ||                     d{V 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>`
        Nr2  	cancelledr  r  s         r  fetch_canceled_orderszbitteam.fetch_canceled_orders*  su       !!!!!!!!!K
 &&vueT[[RX=Y=YZZZZZZZZZr  r2  sider6  r7  c                   K   |                                   d{V  |                     |          }t          |d                   |||                     ||          d}|dk    r8|t	          | j        dz   |z   dz             |                     ||          |d<   |                     |                     ||                     d{V }	| 	                    |	di           }
| 
                    |
|          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>`
        Nr)  )pairIdr2  r  r6  r   z/ createOrder() requires a price argument for a z orderr7  r  )r~  r"  stramount_to_precisionr   r%   price_to_precision"privatePostTradeApiCcxtOrdercreater  r  r  )r  r*  r2  r  r6  r7  r  r"  r  r  orders              r  create_orderzbitteam.create_order<  s      !!!!!!!!!V$$&-....vv>>	
 
 7??}'2c(cfj(jmu(uvvv#'#:#:65#I#I @@WV\A]A]^^^^^^^^0 x266v...r  c                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |di           }|                     |          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>`
        Nr%   r  )r~  "privatePostTradeApiCcxtCancelorderr  r  r  )r  r%   r*  r  r  r  r  s          r  cancel_orderzbitteam.cancel_orderr  s       !!!!!!!!!"
 @@WV\A]A]^^^^^^^^ (B77'''r  c                 j  K   |                                   d{V  d}i }|.|                     |          }t          |d                   |d<   nd|d<   |                     |                     ||                     d{V }|                     |di           }|g}|                     ||          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"  r  r  r  r  s           r  cancel_all_orderszbitteam.cancel_all_orders  s       !!!!!!!!![[((F #F;$7 8 8GH #GHCCDKKPWY_D`D`aaaaaaaa 8R88  000r  r  c           	         |                      |d          }|                      |d          }|                     ||          }|                      |d          }d }|                      |d          }||                     |          }n|                     |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d|          S )Nr%   r  orderCid	createdAtr  	updatedAtstatusr2  r  r`  r7  quantityexecutedr6  r*  )rn  r;  rateclientOrderIddatetimelastTradeTimestamplastUpdateTimestampr   GTCr   	stopPriceaverager;  filledF)	remainingr`  tradesrD  postOnly)
rE  safe_marketrI  r  parse_order_statusparse_order_typer  rH  
safe_orderiso8601)r  r  r"  r%   marketIdr  r  r  r  r  r  r2  r  feeRawr7  r6  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!!%44!!%44&&vx88G ,,VX>>M 33MBB C
   
" 
] 
  
 Y//	 

 !$ 
 "#6 
 f 
 fX& 
 D 
 5 
 D 
 U 
 D,,UK@@ 
 t 
 f 
  D! 
" f# 
$ - 
  
  
. /  	r  r  c           	      F    ddddddddd}|                      |||          S )Nopenr  canceledrejected)acceptedr  r  partiallyCancelleddeleteinactive	executingrC  rE  r  r  rp  s      r  r  zbitteam.parse_order_status7  s@     #", "	
 	
 &&999r  c                 :    ddd}|                      |||          S )Nr"  r   )r"  r   r  r  s      r  r  zbitteam.parse_order_typeD  s.    
 
 &&999r  c                     |                      ||          }|                      ||          }||d S |                     |          }t          j        ||          S N)rE  rM  r    
string_mul)r  valueObjectvalueKeypreciseObjectprecisionKeyvalueRawStringprecisionRawStringprecisionStrings           r  parse_value_to_pricisionz bitteam.parse_value_to_pricisionK  se    ))+x@@!--m\JJ!%7%?4../ABB!./BBBr  symbolsc                 r  K   |                                   d{V  |                                  d{V }g }t          |t                    sg }t	          dt          |                    D ]4}||         }|                     |          }|                    |           5|                     |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>`
        Nr   r*  )	r~  publicGetTradeApiCmcSummary
isinstancerh  rf  rg  parse_tickerappendfilter_by_array_tickers)r  r  r  r  tickersrm  	rawTickertickers           r  fetch_tickerszbitteam.fetch_tickersS  s       !!!!!!!!!99;;;;;;;;@ (D)) 	Hq#h--(( 	# 	#A I&&y11FNN6""""++GXwGGGr  c                 ^  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |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

        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>`
        Nr&   r%   r  r  )r~  r"  publicGetTradeApiPairNamer  r  r  r  )r  r*  r  r"  r  r  r  r  s           r  fetch_tickerzbitteam.fetch_ticker  s       !!!!!!!!!V$$F4L
 77GV8T8TUUUUUUUUp 8R88~~ffb11  v...r  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   r7  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*  r  r  r  highlowclosebid	bidVolumeask	askVolumevwappreviousClosechanger   r  
baseVolume)quoteVolumerD  )safe_string_lowerr  r  r  rh  rE  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_tickerR  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                   K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||||          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>`
        Nr  r%   )r~  r"  publicGetTradeApiCmcTradesPairr  parse_trades)r  r*  rz  r   r  r"  r  r  s           r  fetch_tradeszbitteam.fetch_trades  s       !!!!!!!!!V$$F4L
 <<T[[RX=Y=YZZZZZZZZ,   65%@@@r  c                 ~  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |||d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          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  r  r'  )
r  r*  rz  r   r  r  r"  r  r  r  s
             r  fetch_my_tradeszbitteam.fetch_my_trades  s       !!!!!!!!![[((F &{ 3GH$GG@@WV\A]A]^^^^^^^^L 8R88"55  >>>r  tradec                    |                      |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|          S )Nr  r*  r%   trade_idr7  r  r  r  isCurrentSider  1000r  r2  r   sellbuymakerOrderIdfeeMakerr   takerOrderIdfeeTakerr6  )rn  r;  )r%   r  r  r  r*  r2  r  takerOrMakerr7  r6  r;  r`  rD  )
rE  r  r  r    r  r  rH  parse_to_int
safe_trader  )r  r,  r"  r  r*  r%   r7  r6  r;  r7  r  r  feeInfor  r  r  r`  intTss                     r  parse_tradezbitteam.parse_trade  s5   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                    K   |                                   d{V  |                     |           d{V }|                     |          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>`
        N)r~  privateGetTradeApiCcxtBalanceparse_balance)r  r  r  s      r  fetch_balancezbitteam.fetch_balance  se       !!!!!!!!!;;FCCCCCCCC!!(+++r  c                    |                                  }|||                     |          d}|                     |di           }|                     |g d          }t	          |                                          }t          dt          |                    D ]}||         }|                     ||          }	|                     |	d          }
|                     |	d          }|                     |	d          }| 	                    |
                                          }|
||d||<   |                     |          S )N)rD  r  r  r  )freeusedtotalr   rB  rC  rD  )millisecondsr  r  omitrh  ri  rf  rg  rE  rH  lowersafe_balance)r  r  r  balancer  balanceByCurrenciesrawCurrencyIdsrm  rawCurrencyIdcurrencyBalancerB  rC  rD  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  ra  c                 ~  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |||d<   |                     |                     ||                     d{V }|                     |di           }|                     |dg           }	|                     |	|||          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)  rn  r   r  transactions)r~  rn  $privateGetTradeApiTransactionsOfUserr  r  r  parse_transactions)
r  ra  rz  r   r  rn  r  r  r  rP  s
             r  fetch_deposits_withdrawalsz"bitteam.fetch_deposits_withdrawalsL  s       !!!!!!!!!}}T**H"*;"7GJ$GGBB4;;wX^C_C_````````r 8R88~~fnbAA&&|XueLLLr  transactionrn  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 )Nrn  r*  r%   r  tx_idr  rZ  linksr   sender	recipientmessager2  r6  r^  r  rD  txidr  r_  addressFromaddress	addressTotagFromtagtagToupdateddescriptionF)r`  commentinternal)
r  rE  rH  rF  parse_transaction_typer  parse_transaction_statusr  rj  r  )r  rT  rn  currencyObject
currencyIdra  r%   r  r[  r  ru  rW  rZ  r\  r^  r`  r2  r6  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 )NrG   
withdrawal)rG   r   r  )r  r2  typess      r  rf  zbitteam.parse_transaction_type	  s.     $
 
 tT222r  c                 :    ddd}|                      |||          S )Npendingok)	approvingsuccessr  r  s      r  rg  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)rF  extract_paramsimplode_paramsr   	urlencodecheck_required_credentialsjsonrg  apiKeysecretstring_to_base64)r  pathr   rz  r  r|  r{  r  endpointry  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  reasonry  rz  r|  r{  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   rs  z/order/r+   z order z
 not foundz/cmc/orderbook/z
 symbolId  rZ  ra  r  r  )
findrG  rE  r   r%   r   throw_broadly_matched_exceptionr  throw_exactly_matched_exceptionr   )r  ra  r  ry  rz  r|  r{  r  requestHeadersrequestBodyrN  orderIdsymbolIdfeedbackrZ  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  )<__name__
__module____qualname__r   r  r   r
   r!  dictrQ  r   rx  r  r	   rh  r  r  r   r  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   rS  r   rj  rf  rg  r  intr  __classcell__)r  s   @r  r"   r"      s       Q# Q Q Q Q Q Qf
 *, b+ b+V b+ b+ b+ b+HB4 BF B B B BH -/ R R: R R R Rh ?CQUdhqs /H /H /H /H3 /H^a /Hx|  ~B  yC /H /H /H /Hb
 
 
4 
 
 
 
( @DB . .S . .S\ . . . .` 04$UYbd m? m? m?C m?s m?imnsit m? m? m? m?^ 8<B 90 90C 90 905 90 90 90 90v 59tZ^gi [ [c [ [TW [nrsxny [ [ [ [$ 7;\`ik [ [ [3 [VY [ptuzp{ [ [ [ [$ 9=4^bkm [ [# [S [X[ [ [ [ [$ mqy{ 4/ 4/ 4/I 4/Y 4/X] 4/fi 4/ 4/ 4/ 4/l 9=R ( (S (# ( ( ( (6 59 1 1c 1 1 1 1>I I Iv I I I I IV: : : : :: : :C C C 6:" 2H 2H7 2H 2H 2H 2H 2Hh 68 I/ I/ I/F I/ I/ I/ I/V| |4 | |6 | | | || <@d[] 'A 'A 'AS 'A 'Abfglbm 'A 'A 'A 'AR 37TX\eg \? \?C \?s \?RU \? \? \? \?|e e ev e e e e eN *, , , , , , ,?* ?* ?* ?* ?*B <@daenp oM oMS oM oM[^ oMuy  {F  vG oM oM oM oMbW
 W
T W
X W
Q\ W
 W
 W
 W
r3 3 3:s : : : : &eBSW P P P P,# s  c TX `c        r  r"   N)& ccxt.async_support.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   6 5 5 5 5 5 - - - - - - m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m  m       * * * * * * 0 0 0 0 0 0 . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . * * * * * * 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %w$ w$ w$ w$ w$h w$ w$ w$ w$ w$r  