
    !:h'k                    d   d dl mZ d dlmZ d dl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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$ 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)ImplicitAPIN)AccountAnyBalances
CurrenciesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)	BadSymbol)InsufficientFunds)InvalidOrder)OrderNotFound)NotSupported)NetworkError)ExchangeNotAvailable)OnMaintenance)RequestTimeout)TRUNCATE)	TICK_SIZE)Precisec                   &    e Zd Zdef fdZi fdefdZdi fdefdZi fde	fdZ
di fd	efd
Zd Zi fdee   fdZdLdededefdZdi fd	e	dedefdZi fd	e	defdZdi fdedefdZdLdededefdZdddi fde	d	ededefdZdddi fd	ededefdZddi fd	e	dededee   fdZdLdedefdZdddi fd	e	dededee   fdZ i fdee!   fdZ"i fde#fdZ$de%fd Z&i fde%fd!Z'dddi fd	ededefd"Z(di fde	d	efd#Z)dddi fd	edededee*   fd$Z+dddi fd	edededee*   fd%Z,dd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fd(Z/d)efd*Z0dLd+edede*fd,Z1i fd	e	d-e2fd.Z3di fd	e	d/e4d0e5d1e2d2e6f
d3Z7di fde	d	efd4Z8di fd	efd5Z9d6 Z:di fd	efd7Z;dLd8e<fd9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@dLd=ed8e<de>fd>ZAd)efd?ZBdi fd:e	d1e2d@e	de>fdAZCdBdCi ddfdDZDdEeEdFe	dGe	dHe	dIedJe	fdKZF xZGS )Mbittradereturnc                    | j                  t        t        |          i ddddddgddd	| j                  d
   dddddddddi dd dddd ddddddddddddddddddd dd!dd"dd#dd$di d%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5ddddddddddddd6d7d8d9d:d;d<d=d>d?d@dAdB
dCdDdEdEdEdEdEdFdGdHdIdJdKdLdMdNdNdOii dPdNdQdNdRdNdSdNdTdUdVdNdWdXdYdUdZdNd[dNd\dNd]dNd^dNd_dNd`dNdadNdbdNdNdNdNdNdNdNdNdUdUdNdNdci dddNdTdUdedUdfdNdgdNdhdNdidNdjdNdkdNdldNdmdNdndNdodNdpdNdqdNdrdNdsdNdNdNdUdUdtdudvdwdMdNdNdNdNdNdNdNdNdxidMdNdNdNdNdNdyii dzdXd{dXd|dNd}d~ddNddNddNddddddddddddNddNddNddXddXdNdNdNdNdtdNdNdi dddNddNddddXddXddddXddddNddNddtddtddtddtddNddNddNdNdNdtddwddddMdd| j                  d      | j                  d      diddddd dddd dddddddddddddd ddddd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ddid	d d dd d dddt        dt        t        di dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        t        t        t        t        t         t         t        t         t         t        t        t        dǜdȜdddddddddϜddddddt"        dddidלdddddddޜdߜ      S )Nidr*   nameBitTrade	countriesJP	rateLimitd   	userAgentchrome39	certifiedFversionv1hostnamezapi-cloud.bittrade.co.jpproThasCORSspotmarginswapfutureoptioncancelAllOrderscancelOrdercancelOrderscreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchAccountsfetchBalancefetchClosedOrdersfetchCurrenciesfetchDepositAddressfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenOrders
fetchOrder)fetchOrderBookfetchOrdersfetchOrderTradesfetchPremiumIndexOHLCVfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingLimitsfetchWithdrawalswithdraw
timeframes1min5min15min30min60min4hour1day1week1mon1year)
1m5m15m30m1h4h1d1w1M1yurlszchttps://user-images.githubusercontent.com/1294454/85734211-85755480-b705-11ea-8b35-0b7f1db33a2f.jpgzhttps://{hostname})marketpublicprivatev2Public	v2Privatezhttps://www.bittrade.co.jpz6https://www.bittrade.co.jp/register/?invite_code=znnq3zhttps://api-doc.bittrade.co.jpz,https://www.bittrade.co.jp/ja-jp/support/fee)logoapiwwwreferraldocfeesr   get   )zreference/currencieszmarket-statuszaccount/ledgerzaccount/withdraw/quotazaccount/withdraw/addresszaccount/deposit/addresszaccount/repayment   zreference/transact-fee-ratezaccount/asset-valuationg?zpoint/accountzsub-user/user-listzsub-user/user-statezsub-user/account-listzsub-user/deposit-addresszsub-user/query-depositzuser/api-keyzuser/uidzalgo-orders/openingzalgo-orders/history)zalgo-orders/specificz
c2c/offers	c2c/offerzc2c/transactionsc2c/repaymentzc2c/accountzetp/referencezetp/transactionszetp/transactionzetp/rebalancez	etp/limitzaccount/transferzpoint/transferzsub-user/managementzsub-user/creationzsub-user/tradable-marketzsub-user/transferabilityzsub-user/api-key-generationzsub-user/api-key-modificationzsub-user/api-key-deletionzsub-user/deduct-modezalgo-orderszalgo-orders/cancel-all-afterzalgo-orders/cancellationr   zc2c/cancellationzc2c/cancel-all
   2   )r   zc2c/transferzetp/creationzetp/redemptionzetp/{transactId}/cancelzetp/batch-cancel)r   post)zhistory/klinezdetail/mergeddepthtradezhistory/tradedetailtickersetp)zcommon/symbolszcommon/currencyszcommon/timestampzcommon/exchangezsettings/currencyszaccount/accountszaccount/accounts/{id}/balancezaccount/accounts/{sub-uid}zaccount/history   zcross-margin/loan-infozmargin/loan-infozfee/fee-rate/getzorder/openOrdersg?zorder/orderszorder/orders/{id}zorder/orders/{id}/matchresultszorder/orders/getClientOrderzorder/historyzorder/matchresultszquery/deposit-withdrawzmargin/loan-orderszmargin/accounts/balance)zcross-margin/loan-orderszcross-margin/accounts/balancezpoints/actionszpoints/orderszsubuser/aggregate-balancezstable-coin/exchange_ratezstable-coin/quotezfutures/transferzorder/batch-orderszorder/orders/placez$order/orders/submitCancelClientOrderz"order/orders/batchCancelOpenOrderszorder/orders/{id}/submitcancelzorder/orders/batchcancelzdw/withdraw/api/createzdw/withdraw-virtual/{id}/cancelzdw/transfer-in/marginzdw/transfer-out/marginzmargin/orderszmargin/orders/{id}/repayzcross-margin/transfer-inzcross-margin/transfer-outzcross-margin/orders)zcross-margin/orders/{id}/repayzstable-coin/exchangezsubuser/transfer)r   r   r   r   r   r   trading0.002)feeSide	tierBased
percentagemakertakerfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceicebergx      )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     )	sandboxrH   createOrdersrZ   r]   r\   r_   rN   r[   )linearinverse)r=   r?   r@   precisionMode
exceptions)zTcontract is restricted of closing positions on API.  Please contact customer servicemaintainzbad-requestzbase-date-limit-errorzapi-not-support-temp-addrtimeoutzgateway-internal-errorz)account-frozen-balance-insufficient-errorzinvalid-amountz!order-limitorder-amount-min-errorz!order-limitorder-amount-max-errorz"order-marketorder-amount-min-errorz order-limitorder-price-min-errorz order-limitorder-price-max-errorzorder-holding-limit-failedz order-orderprice-precision-errorzorder-etp-nav-price-max-errorzorder-orderstate-errorzorder-queryorder-invalid)zorder-update-errorzapi-signature-check-failedzapi-signature-not-validzbase-record-invalidzbase-symbol-trade-disabledzbase-symbol-errorzsystem-maintenancezinvalid symbolzsymbol trade not open nowzinvalid-addresszbase-currency-chain-errorzdw-insufficient-balance)broadexactERC20erc20trc20hrc20algo )ETHTRXHRC20HECOHTALGOOMNIprivate_get_order_ordersfetch_open_orders_v1publicGetCommonSymbols"privateGetAccountAccountsIdBalanceprivatePostOrderOrdersPlacezen-US
AA03022abc)defaultNetworknetworksfetchOrdersByStatesMethodfetchOpenOrdersMethod!createMarketBuyOrderRequiresPricefetchMarketsMethodfetchBalanceMethodcreateOrderMethodcurrencyToPrecisionRoundingModelanguagebrokerThemiszGame.comHitChainPentazSuper BitcoinzBitcoin File)GETGTCHITPNTSBTCBIFI)optionscommonCurrencies)deep_extendsuperr*   describe
userAgentsparse_numberr'   r$   r   r   r%   r#   r   r   r    r   r   r&   )self	__class__s    G/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/bittrade.pyr   zbittrade.describe    s	   h > @ HC
*HC
JHC
 $HC
 	HC

 4HC
 HC
 tHC
 2HC
 4HC
  ... $. 	.
 %. %. "4. t. . /. ,U. 0. t. '. (.  "5!."  #.$ %.& $T'.( "4).* &u+., 1%-..  /.0 &u1.2 #E3.4 *55.6 $U7.8 "59.: ;.< !%=.>  ?.@ dA.B "4C.D dE.F #'#$(*/# $!#&*$( [.HC
r sHC
J }223 4!5 4T7FKHC
f 01)*(!0! 3A 21	
 ,Q 6q 23 ( -a .q 0 3A 1! ' #A  .q!" .q#$ 12&'%&,-)*'()*,-+,)*%&9<*A+Q )! .q	
 ,Q 3A 3A 6q 8 4Q / &q 7 3A $Q  +A!" )!#$ *+()()*+35,./?8t )*)*!"!")*"##$ 	 *+,-,-+,./*C7 5a *1	
 1! +A +A +C ' ,S 9# 6s ( -a  1!!$ -c%& 23'( 569:*+)*5756-.58*A*A -c -c	
 ? =c 9# 3C 1! :1  0!" 1"#$ (%& 3B'( 3A)* 4Q+, .q-. ;<01,.3;8kNgHC
D $!&"&!..w7!..w7EHC
V $&+(,,0,1).+06:#(#("'#(	( #(/4$)$)+/27#()$, %)&+!$$'%&*/& ',#($)*/	# ',!%#($)*/( ',!%$(%)#($)*/$ ',!%$(,0%)#($)*/	*  #ACJ ##
 ##SMWHC
r	 Ys	HC
t	 ly - !:  ,Z  01A	 
 ~  -.B  @AR  %l  8  8  9,  7  7  1,  7   4\! " -m# $ /% & +?2E/B+82;)2*7&/1:'11;/@? &u	HC
D #*""$#!" .H)?59&>&J%B3;#,)8  !!
 '&!sHC
 H H	    c                 H    | j                  |      }| j                  |d      S )a  
        fetches the current integer timestamp in milliseconds from the exchange server
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        data)publicGetCommonTimestampsafe_integerr   paramsresponses      r   
fetch_timezbittrade.fetch_time  s'     008  622r   Nsymbolsc                     | j                          || j                  }i }t        dt        |            D ]+  }||   }| j	                  | j                  |      |      ||<   - |S )Nr   )load_marketsr   rangelenfetch_trading_limits_by_id	market_id)r   r   r   resultisymbols         r   fetch_trading_limitszbittrade.fetch_trading_limits  so     	?llGq#g,' 	]AQZF!<<T^^F=SU[\F6N	] r   r-   c                     d|i}| j                  | j                  ||            }| j                  | j                  |di             S )Nr	  r   )publicGetCommonExchangeextendparse_trading_limits
safe_value)r   r-   r   requestr   s        r   r  z#bittrade.fetch_trading_limits_by_id  sK    b
 //GV0LM" ((62)NOOr   r	  c                 V    |d| j                  |d      | j                  |d      didS )Namountzlimit-order-must-greater-thanzlimit-order-must-less-thanminmax)infolimits)safe_number)r   r  r	  r   s       r   r  zbittrade.parse_trading_limits  s@    " ++F4ST++F4PQ
 	
r   c                 l    | j                  |t        | j                  |   d   d   | j                        S )N	precisioncost)decimal_to_precisionr&   marketsr   )r   r	  r  s      r   cost_to_precisionzbittrade.cost_to_precision  s4    ((xf9Mk9Z[a9bdhdvdvwwr   c                    | j                   d   } t        | |      |      }| j                  |dg       }t        |      }|dk  r*t	        | j
                  dz   | j                  |      z         g }t        dt        |            D ]7  }||   }| j                  |d      }	| j                  |d      }
| j                  |	      }| j                  |
      }| j                  |d      }| j                  |d	d
      }| j                  |dd
      }t        j                  |d
      xs t        j                  |d
      }|dk(  r| j                  d      n| j                  d      }|j                  i d|	|
z   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"k(  d#dd$dd||ddddd| j                  | j                  | j                  |d%                  | j                  | j                  | j                  |d&                  | j                  | j                  | j                  |d'                  d(| j                  d
      | j                  |      | j                  |      d)| j                  |d*      | j                  |d+      d,ddd,| j                  |d-      dd,d.d|d/       : |S )0z
        retrieves data on all markets for huobijp
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r   r   z) fetchMarkets() returned empty response: r   zbase-currencyzquote-currencystatezleverage-ratio1zsuper-margin-leverage-ratioOMG0r   r-   r	  /basequotesettleNbaseIdquoteIdsettleIdtyper=   Tr>   r?   Fr@   rA   activeonlinecontractr   zprice-precisionzamount-precisionzvalue-precision)pricer  r  )r  r  superMaxzmin-order-amtzmax-order-amtr  zmin-order-value)r   r  r/  r  )r   r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr  )r   getattrr  r  r"   r-   jsonr  safe_stringsafe_currency_coder(   	string_gtr   appendparse_precisionr  )r   r   methodr   r  
numMarketsr  r  r   r(  r)  r%  r&  r   leverageRatiosuperLeverageRatior>   fees                     r   fetch_marketszbittrade.fetch_markets  s    23(74(0B //(FB7\
>tww)TTW[W`W`ahWiijjq#g,' ?	AQZF%%fo>F&&v/?@G**62D++G4E$$VW5E ,,V5EsKM!%!1!1&:WY\!]&&}c:hg>O>OPbdg>hF-1U]$##C(ARARSZA[CMM 4fw&4$*u,4 4 	4
 $4 &4 74 D4 4 4 &4 4 %4 %4 5H,4  E!4" $#4$   $"&"!..t/C/CDDTDTU[]nDo/pq"//0D0DTEUEUV\^pEq0rs --d.B.B4CSCSTZ\mCn.op  $005#00?$($5$56H$I!  $//H#//H
  $#
  $//8IJ#&  g4 4?	@ r   tickerr   c                 v   | j                  d |      }| j                  |d      }d }d }d }d }d|v rbt        |d   t              r+| j	                  |d   d      }| j	                  |d   d      }n$| j	                  |d      }| j	                  |d      }d|v rbt        |d   t              r+| j	                  |d   d      }| j	                  |d   d      }n$| j	                  |d      }| j	                  |d      }| j	                  |d      }	| j	                  |d	      }
| j	                  |d
      }| j	                  |d      }| j                  i d|d|d| j                  |      d| j	                  |d      d| j	                  |d      d|d|d|d|dd d|	d	|
d|
dd dd dd dd |||d|      S )Ntsbidr   r   bidSizeaskaskSizeopencloser  volr	  	timestampdatetimehighlow	bidVolume	askVolumevwaplastpreviousClosechanger   average)
baseVolumequoteVolumer  )safe_symbolr   
isinstancelistr9  safe_tickeriso8601)r   rD  r   r	  rN  rG  rR  rI  rS  rK  rL  rY  rZ  s                r   parse_tickerzbittrade.parse_tickerd  sg   D !!$/%%fd3			F?&-.&&ve}a8 ,,VE]A>	&&vu5 ,,VY?	F?&-.&&ve}a8 ,,VE]A>	&&vu5 ,,VY?	/  1%%fh7
&&vu5 !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 3!
 !
 3!
 !
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r   r   c                    | j                          | j                  |      }|d   dd}| j                  | j                  ||            }d|v r|d   s*t	        | j
                  dz   | j                  |      z         | j                  |d      }| j                  |d| j                  |d            }| j                  |||      }	| j                  |d      |	d<   |	S t        | j
                  d	z   | j                  |      z         )
a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :param str symbol: unified symbol of the market to fetch the order book for
        :param int [limit]: the maximum amount of order book entries to return
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
        r-   step0)r	  r+  tickz+ fetchOrderBook() returned empty response: rF  r7   noncez2 fetchOrderBook() returned unrecognized response: )r  r   marketGetDepthr  r   r-   r8  r  r   parse_order_bookr   )
r   r	  r   r   r   r  r   rc  rN  r  s
             r   fetch_order_bookzbittrade.fetch_order_book  s    	V$Tl
 &&t{{7F'CD, XF#*W WZ^ZcZcdlZm mnn??8V4D))$d6G6GRV6WXI**4CF"//i@F7OMDGG&ZZ]a]f]fgo]ppqqr   c                    | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |d   |      }| j                  |d      }||d<   | j                  |      |d<   |S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        r	  r-   rc  rF  rN  rO  )r  r   marketGetDetailMergedr  r`  r   r_  )r   r	  r   r   r  r   rD  rN  s           r   fetch_tickerzbittrade.fetch_ticker  s     	V$fTl
 --dkk'6.JK* ""8F#3V<%%h5	'{!\\)4zr   c                    | j                          | j                  |      }| j                  |      }| j                  |dg       }| j	                  |d      }i }t        dt        |            D ]`  }| j                  ||   d      }| j                  |      }	|	d   }
| j                  ||   |	      }||d<   | j                  |      |d<   |||
<   b | j                  |d|      S )a  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   rF  r   r	  rN  rO  )r  market_symbolsmarketGetTickersr  r   r  r  r9  safe_marketr`  r_  filter_by_array_tickers)r   r   r   r   r   rN  r  r  marketIdr   r	  rD  s               r   fetch_tickerszbittrade.fetch_tickers
  s     	%%g.((0//(FB7%%h5	q#g,' 	$A''
H=H%%h/FH%F&&wqz6:F"+F;!%i!8F:#F6N	$ ++FHgFFr   r   c                 n   | j                  |d      }| j                  ||      }| j                  |dd      }| j                  |d      }| j                  |d      }| j                  |d      }||j                  d      }	|	d   }|	d	   }| j                  |d
      }
| j                  |d      }| j	                  |dd      }t        j                  ||      }d }| j                  |d      }| j                  | j                  |d            }| j                  |d      }|;|t        j                  |d      r#|}| j                  | j                  |d            }|||d}| j	                  |dd      }| j                  |d|      }| j                  |||||| j                  |      |||
||||d      S )Nr	  rF  
created-atorder-id	directionr+  -r   r   roler/  filled-amountr  filled-feeszfee-currencyzfilled-pointsz0.0zfee-deduct-currencyr  currencyztrade-idtradeIdr-   )r  r-   r	  orderrN  rO  r+  sidetakerOrMakerr/  r  r  rB  )r9  r[  safe_integer_2splitsafe_string_2r(   
string_mulr:  	string_eq
safe_trader_  )r   r   r   rp  r	  rN  r}  r~  r+  	typePartsr  r/  r  r  rB  feeCostfeeCurrencyfilledPointsr|  r-   s                       r   parse_tradezbittrade.parse_trade!  s   B ##E84!!(F3''t\B	  
3{3v.

3IQ<DQ<D''v6  0##E?HE!!%0""5-8--d.>.>un.UV''?#W%6%6w%F&"55d6F6FuNc6de'C $$UJ	BeT73"Y/( 
  	r   sincec                     | j                          d|i}| j                  | j                  ||            }| j                  |d   d||      S )a  
        fetch all the trades made from a single order
        :param str id: order id
        :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 to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        r-   r   N)r  #privateGetOrderOrdersIdMatchresultsr  parse_trades)r   r-   r	  r  r   r   r  r   s           r   fetch_order_tradeszbittrade.fetch_order_tradeso  sV     	"
 ;;DKKQW<XY  &!14FFr   c                     | j                          d}i }|| j                  |      }|d   |d<   |||d<   |||d<   | j                  | j                  ||            }| j	                  |d   |||      S )a  
        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr-   r	  sizez
start-timer   )r  r   privateGetOrderMatchresultsr  r  )r   r	  r  r   r   r   r  r   s           r   fetch_my_tradeszbittrade.fetch_my_trades  s     	[[(F &tGH#GFO$)GL!33DKK4PQ  &!165%HHr   i  c                    | j                          | j                  |      }d|d   i}|t        |d      |d<   | j                  | j	                  ||            }| j                  |dg       }g }	t        dt        |            D ]X  }
| j                  ||
   dg       }t        dt        |            D ](  }| j                  ||   |      }|	j                  |       * Z | j                  |	d      }	| j                  |	|d   ||      S )a  
        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        r	  r-   r   r  r   r   rN  )r  r   r  marketGetHistoryTrader  r  r  r  r  r<  sort_byfilter_by_symbol_since_limit)r   r	  r  r   r   r   r  r   r   r  r  tradesjr   s                 r   fetch_tradeszbittrade.fetch_trades  s    	V$fTl
 !%.GFO--dkk'6.JK2 x4q#d)$ 	%A__T!Wfb9F1c&k* %((F;e$%	%
 fk2009I5RWXXr   c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr-   rK  rP  rQ  rL  r  )safe_timestampr  )r   ohlcvr   s      r   parse_ohlcvzbittrade.parse_ohlcv  sn     t,UF+UF+UE*UG,UH-
 	
r   rt   c                 >   | j                          | j                  |      }|d   | j                  | j                  ||      d}|t	        |d      |d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	||||      S )aQ  
        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 exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r-   )r	  periodr   r  r   )	r  r   r9  ri   r  marketGetHistoryKliner  	safe_listparse_ohlcvs)
r   r	  	timeframer  r   r   r   r  r   r   s
             r   fetch_ohlcvzbittrade.fetch_ohlcv  s     	V$Tl&&t	9M
 !%.GFO--dkk'6.JK ~~h3  vy%GGr   c                 N    | j                          | j                  |      }|d   S )a  
        fetch all the accounts associated with a profile
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
        r   )r  privateGetAccountAccountsr   s      r   fetch_accountszbittrade.fetch_accounts  s+     	11&9r   c                     d| j                   d   i}| j                  | j                  ||            }| j                  |dg       }i }t	        dt        |            D ]  }||   }| j                  |d      }| j                  |      }	| j                  |d      }
| j                  |d      }| j                  |d      }| j                  |dd	      }| j                  |d
      }|xr |
xr |xr
 |dk(  xr | }| j                  |d      }| j                  | j                  | j                  |d                  }||	d|||
|d|d|dd| j                  |d      dd| j                  |d      ddd|d||	<     |S )z
        fetches all available currencies on an exchange
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r   r   r   r.   zdeposit-enabledzwithdraw-enabledzcountry-disabledvisibleFr   r-  zdisplay-namezwithdraw-precisioncryptoNr  zdeposit-min-amountzwithdraw-min-amount)r  depositrh   )r-   coder+  r.   r,  r  rh   rB  r  r   r  r  )r   publicGetSettingsCurrencysr  r  r  r  r:  	safe_boolr9  r   r=  r  )r   r   r  r   
currenciesr  r  r{  r-   r  depositEnabledwithdrawEnabledcountryDisabledr  r   r,  r.   r  s                     r   fetch_currencieszbittrade.fetch_currencies  s    Z0
 224;;w3OPR __Xvr:
q#j/* )	A!!}H62B**2.D!__X7HIN"ooh8JKO"ooh8JKOnnXy%@G$$Xw7EssOsRZIZsds`sF##Hn=D))$*>*>t?O?OPXZn?o*pqI   )+&   )#
  $//:NO# 
  $//:OP#! !9F4L)	T r   c                    | j                  |d   dg       }d|i}t        dt        |            D ]  }||   }| j                  |d      }| j	                  |      }d }||v r||   }n| j                         }|d   dk(  r| j                  |d      |d	<   |d   d
k(  r| j                  |d      |d<   |||<    | j                  |      S )Nr   r]  r  r   r{  r+  r   balancefreefrozenused)r  r  r  r9  r:  accountsafe_balance)	r   r   balancesr  r  r  
currencyIdr  r  s	            r   parse_balancezbittrade.parse_balancel  s    ??8F#3VR@)q#h-( 	#AqkG))':>J**:6DGv~ ,,,.v')"&"2"27I"Fv(*"&"2"27I"F"F4L	#   ((r   c                     | j                          | j                          | j                  d   }d| j                  d   d   i} t	        | |      | j                  ||            }| j                  |      S )a!  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        r   r-   r   )r  load_accountsr   accountsr7  r  r  )r   r   r>  r  r   s        r   fetch_balancezbittrade.fetch_balance  sv     	23$--"4(
 )74(Wf)EF!!(++r   c                    | j                          d|i}d }|| j                  |      }|d   |d<   | j                  | j                  dd      } t	        | |      | j                  ||            }	| j                  |	d   |||      S )Nstatesr-   r	  r   r   r   )r  r   r9  r   r7  r  parse_orders)
r   r  r	  r  r   r   r  r   r>  r   s
             r   fetch_orders_by_stateszbittrade.fetch_orders_by_states  s    f
 [[(F &tGH!!$,,0KMgh(74(Wf)EF$   &!165%HHr   c                     | j                          d|i}| j                  | j                  ||            }| j                  |d      }| j	                  |      S )a_  
        fetches information on an order made by the user
        :param str id: order id
        :param str symbol: unified symbol of the market the order was made in
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r-   r   )r  privateGetOrderOrdersIdr  	safe_dictparse_order)r   r-   r	  r   r  r   r}  s          r   fetch_orderzbittrade.fetch_order  sZ     	"
 //GV0LMx0&&r   c                 ,    | j                  d||||      S )a  
        fetches information on multiple orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        zGpre-submitted,submitted,partial-filled,filled,partial-canceled,canceledr  r   r	  r  r   r   s        r   fetch_orderszbittrade.fetch_orders  s4     **+tv|  D  FK  MS  T  	Tr   c                 f    | j                  | j                  dd      } t        | |      ||||      S )a  
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r   r   )r9  r   r7  )r   r	  r  r   r   r>  s         r   fetch_open_orderszbittrade.fetch_open_orders  s8     !!$,,0GI_`$wtV$VUE6BBr   c                 `    |t        | j                  dz         | j                  d||||      S )Nz/ fetchOpenOrdersV1() requires a symbol argumentz&pre-submitted,submitted,partial-filled)r   r-   r  r  s        r   r   zbittrade.fetch_open_orders_v1  s:    >#DGG._$_``**+SU[]bdikqrrr   c                 ,    | j                  d||||      S )a  
        fetches information on multiple closed orders made by the user
        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        z filled,partial-canceled,canceledr  r  s        r   fetch_closed_orderszbittrade.fetch_closed_orders  s!     **+MvW\^cekllr   c                    | j                          i }d }|| j                  |      }|d   |d<   | j                  |d      }|b| j                          t	        dt        | j                              D ]0  }| j                  |   }	|	d   dk(  s| j                  |	d      }|0 n ||d<   |||d<   | j                  |d      }
| j                  | j                  ||
            }| j                  |dg       }| j                  ||||      S )	Nr-   r	  
account-idr   r+  r=   r  r   )r  r   r9  r  r  r  r  omitprivateGetOrderOpenOrdersr  r  r  )r   r	  r  r   r   r  r   	accountIdr  r  omittedr   r   s                r   fetch_open_orders_v2zbittrade.fetch_open_orders_v2  s#   [[(F &tGH$$V\:	 1c$--01 --*6?f, $ 0 0$ ?I , !*#GFO))FL111$++gw2OP, ~~h3  vue<<r   statusc                 8    dddddd}| j                  |||      S )NrK  canceledclosed)zpartial-filledzpartial-canceledfilledr  	submittedr9  r   r  statusess      r   parse_order_statuszbittrade.parse_order_status  s/    $ *"
 &&99r   r}  c                    | j                  |d      }d }d }d }d|v r?|d   j                  d      }|d   }|d   }| j                  | j                  |d            }| j                  |d      }| j                  ||      }| j	                  |d      }	| j                  |d	      }
| j                  |d
      }| j                  |dd      }| j                  |d      }| j                  |dd      }| j                  |dd      }d }||dk(  r|d   n|d   }||d}| j                  i d|d|d|
d|	d| j                  |	      dd d|d   d|dd dd d|d|dd dd d |d
|d!|d ||d d"|      S )#Nr-   r+  rv  r   r   r   r	  rs  client-order-idr  rx  zfield-amountr/  zfilled-cash-amountzfield-cash-amountry  z
field-feessellr&  r%  rz  r  clientOrderIdrN  rO  lastTradeTimestampr   postOnlyr~  r   rX  r  r  )	remainingr  rB  r  )r9  r  r  rn  r   r  
safe_orderr_  )r   r}  r   r-   r~  r+  r  	orderTyperp  rN  r  r  r  r/  r  r  rB  r  s                     r   r  zbittrade.parse_order  sN   @ eT*U?f++C0IQ<DQ<D,,T-=-=eW-MNF##E84!!(F3%%e\:	((0AB!!%2##E?NK  0!!%)=?RS$$UM<H.2fn&/6&>K'C   
E 
" 
 ] 
 	 

 Y/ 
 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
 D 
 t 
 D 
  f! 
" f# 
$ + 
, - 	r   r  c                     | j                          | j                  |      }|d   st        | j                  dz         d|d<   | j	                  |dd|d|      S )a  
        create a market buy order by providing the symbol and cost
        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r=   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr   r   buyN)r  r   r!   r-   create_order)r   r	  r  r   r   s        r   !create_market_buy_order_with_costz*bittrade.create_market_buy_order_with_costl  s`     	V$f~tww)ddee6;23  5$fMMr   r+  r~  r  r/  c                    | j                          | j                          | j                  |      }| j                  d   d   |d   |dz   |z   d}| j	                  |dd      }	|	F| j                  | j                  di       }
| j                  |
d      }|| j                         z   |d<   n|	|d<   | j                  |ddg      }|d	k(  r|d
k(  rd}d}| j                  |ddd      \  }}| j                  |d      }| j                  |d      }|| j                  ||      }nw|rc|t        | j                  dz         | j                  |      }| j                  |      }| j                  |t!        j"                  ||            }n| j                  ||      }||d<   n| j                  ||      |d<   |dk(  s|dk(  s|dk(  s
|dk(  s|dk(  r| j%                  ||      |d<   | j                  d   } t'        | |      | j)                  ||            }| j                  |d      }| j+                  i d|d|ddddddddd|d|d |d|d|d!dd"dddd#dd$dddd%di|      S )&a_  
        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   r-   rv  )r  r	  r+  r  r  Nr   r   r  TrH   r   r  z createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argumentr  r   ioczlimit-makerz
stop-limitzstop-limit-fokr/  r   r   r  rN  rO  r  r  r	  r+  r~  r  r  r  rB  rX  )r  r  r   r  r  r  r   r9  uuidr  handle_option_and_paramsr  amount_to_precisionr   r-   number_to_stringr(   r  price_to_precisionr7  r  r  )r   r	  r+  r~  r  r/  r   r   r  r  r   brokerIdquoteAmountr   r  amountStringpriceStringr>  r   r-   s                       r   r  zbittrade.create_order{  sX    	V$--*40Tl3J%

 **6?DUV __T\\8R@F''5H)1DIIK)?G%&)6G%&6O5F#GHH45=K04-8<8U8UV\^k  nQ  SW  9X5-v##FF3DYYvv.F"66vtD2=&tww  2m  (m  n  n $(#8#8#@L"&"7"7">K"&":":67CUCUVbdoCp"qK"66vvF +GH $ 8 8 HGH7?demt}/DP\H\`dhx`x#66vuEGG12(74(Wf)EFh/  
H 
" 
  
 	 

 !$ 
 d 
 f 
 D 
 D 
 U 
 f 
 d 
  
 D 
 d 
  4! 
" T# 
$ t% 
& ' 	r   c                 p    | j                  d|i      }| j                  | j                  |      |dd      S )a4  
        cancels an open order
        :param str id: order id
        :param str symbol: not used by bittrade cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r-   r  )r-   r  )$privatePostOrderOrdersIdSubmitcancelr  r  )r   r-   r	  r   r   s        r   cancel_orderzbittrade.cancel_order  sC     <<dBZH {{4++H5 8
  	r   c                     | j                          | j                  |dd      }| j                  |ddg      }i }|||d<   n||d<   | j                  | j	                  ||            }| j                  |      S )aC  
        cancel multiple orders
        :param str[] ids: order ids
        :param str symbol: not used by bittrade cancelOrders()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        clientOrderIdszclient-order-idsz	order-ids)r  safe_value_2r  !privatePostOrderOrdersBatchcancelr  parse_cancel_orders)r   idsr	  r   r  r  r   s          r   cancel_orderszbittrade.cancel_orders  s     	**63CEWX6$46H#IJ!#&GK *8G&'99$++gv:VWB ''11r   c                    | j                  |d      }d }||j                  d      }n| j                  |dg       }| j                  |ddg       }g }t	        dt        |            D ]+  }||   }|j                  | j                  ||dd             - t	        dt        |            D ]M  }||   }|j                  | j                  || j                  |d	d
      d| j                  |d      d             O |S )N	successes,successerrorsfailedr   r  )r  r-   r  rt  order_idr  )r  r-   r  r  )	r9  r  r  safe_list_2r  r  r<  r  r  )r   ordersr	  r  r  r  r  r}  s           r   r  zbittrade.parse_cancel_orders  s   : $$V[9	 ooc*GnnVY;G!!&(HbAq#g,' 	AAJEMM$//$+  	 q#f+& 	A1IEMM$//((
JG"!%!1!1%9J!K	+  	 r   c                     | j                          i }d}|| j                  |      }|d   |d<   | j                  | j                  ||            }| j	                  |di       }| j                  d|i      gS )ab  
        cancel all open orders
        :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nr-   r	  r   r  )r  r   +privatePostOrderOrdersBatchCancelOpenOrdersr  r  r  )r   r	  r   r  r   r   r   s          r   cancel_all_orderszbittrade.cancel_all_ordersG  s     	
 [[(F &tGHCCDKKPWY_D`a ~~h3OO 
 	
r   r{  c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  ||      }| j                  ||      }| j                  |d      }| j                  |di       }| j	                  |d      }	| j                  |	||      }
| j                  |
d      }| j                  |       |||||dS )	Naddress
addressTagr{  chainr   r-   network)r{  r  tagr  r  )r9  safe_currencyr:  r  index_bycheck_address)r   depositAddressr{  r  r  r  r  	networkIdr   networksByIdnetworkValuer  s               r   parse_deposit_addresszbittrade.parse_deposit_addressl  s     "">9=~|<%%njA
%%j(;&&z8<$$^W=	??8Z<}}Xt4|Y	J""<;7#"
 	
r   r  c                     ||dkD  rd}| j                          d}|| j                  |      }ddd}||d   |d<   |||d<   | j                  | j                  ||            }| j	                  |d	   |||      S )
a  
        fetch all deposits made to an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr3   r  r   r+  fromr-   r{  r  r   r  r{  privateGetQueryDepositWithdrawr  parse_transactionsr   r  r  r   r   r{  r  r   s           r   fetch_depositszbittrade.fetch_deposits  s     =ECKE}}T*H
 "*4.GJ#GFO66t{{7F7ST&&x'75%PPr   c                     ||dkD  rd}| j                          d}|| j                  |      }ddd}||d   |d<   |||d<   | j                  | j                  ||            }| j	                  |d	   |||      S )
a  
        fetch all withdrawals made from an account
        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr3   rh   r   r#  r-   r{  r  r   r%  r(  s           r   fetch_withdrawalszbittrade.fetch_withdrawals  s     =ECKE}}T*H
 "*4.GJ#GFO66t{{7F7ST&&x'75%PPr   transactionc                    | j                  |d      }| j                  | j                  |d            }| j                  |d      }|dk(  rd}| j                  |d      }|t        j                  |      }i d|d| j                  |dd	      d
| j                  |d      d|d| j                  |      d| j                  |d      d| j                  |d      dd dd d| j                  |d      dd dd d|d| j                  |d      d|d| j                  | j                  |d            d| j                  |d      d d || j                  |      d ddS )Nrs  r{  r+  rh   
withdrawalrB  r  r-   r   txidztx-hashrN  rO  r  r  r  	addressToaddressFromr  zaddress-tagtagTotagFromr  r  r   updatedz
updated-at)r{  r  rate)commentinternalrB  )r   r:  r9  r(   
string_absr  r_  safe_string_upperr  parse_transaction_statusr   )r   r,  r{  rN  r  r+  r  s          r   parse_transactionzbittrade.parse_transaction  s   V %%k<@	&&t'7'7Z'PQV4:D"";6((1G
K
$$$[$?
 D$$[)<
 	

 Y/
 t--k7C
 t''Y?
 
 4
 4##K?
 T
 t
 D
 d&&{H=
 
  d33D4D4D[RY4Z[!
" t((lC#
$  ))'2)
 	
r   c                 L    dddddddddddddddd}| j                  |||      S )Nr  pendingokr  )unknown
confirming	confirmedsafeorphanr  r  	reexaminerejectpasszwallet-rejectzconfirm-errorrepealedzwallet-transferzpre-transferr  r  s      r   r:  z!bittrade.parse_transaction_status  sO      #"""%% (%%
( &&99r   r  c                    | j                  ||      \  }}| j                          | j                  |       | j                  |      }|||d   j	                         d}|||d<   | j                  | j                  di       }| j                  |d      }	| j                  ||	|	      }	|	.|	dk(  r|d   |	z   |d<   n|	|d   z   |d<   | j                  |d      }| j                  | j                  ||            }
| j                  |
|      S )a  
        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        r-   )r  r  r{  zaddr-tagr   r  r   r  )handle_withdraw_tag_and_paramsr  r  r{  lowerr  r   r9  safe_string_lowerr  privatePostDwWithdrawApiCreater  r;  )r   r  r  r  r  r   r{  r  r   r  r   s              r   rh   zbittrade.withdraw#  s     99#vFV7#==& ,,.

 ?"%GJ??4<<R@((;((7GD'!#+D>G#; #*Xd^#; YYvy1F66t{{7F7ST %%h99r   r   r   c                    d}|dk(  r||z  }n)|dk(  s|dk(  r|| j                   z  }n|dk(  s|dk(  r|dz  }|d| j                  ||      z   z  }| j                  || j                  |            }|dk(  s|dk(  r$| j	                          | j                  | j                         d      }	d	d
| j                  |	d}
|dk7  r| j                  |
|      }
| j                  |
      }| j                  |      }dj                  || j                  ||g      }| j                  | j                  |      | j                  | j                        t         j"                  d      }|d| j                  d|i      z   z  }|d|z   z  }|dk(  r| j%                  |      }ddi}nddi}n|r|d| j                  |      z   z  }| j                  | j&                  d   |   d| j                  i      |z   }||||dS )Nr$  r   r   r   r   r   v2T
HmacSHA2562)SignatureMethodSignatureVersionAccessKeyId	TimestampPOST
base64&	Signature?zContent-Typezapplication/jsonz!application/x-www-form-urlencodedr   r9   )urlr>  bodyheaders)r7   implode_paramsr  extract_paramscheck_required_credentialsymdhmsmillisecondsapiKeyr  keysort	urlencodejoinr9   hmacencodesecrethashlibsha256r8  r~   )r   pathr   r>  r   r^  r]  r\  queryrN  r  requestSortedauthpayload	signatures                  r   signzbittrade.signK  s   (?3JCXo3)#34<<CZSK%74KCsT((v666		&$"5"5d";<)sk1++-D$5$5$7=I#/$'#{{&	G ++gu5 LL1M>>-0D iiT BCG		$++g"6DKK8PRYR`R`bjkIC$..+y)ABBBD3:Cyy'"$6
 #$G sT^^F333!!$))E"23"7:
  fdwOOr   httpCodereasonr\  r>  r^  r]  c
                    |y d|v r| j                  |d      }
|
dk(  r| j                  |d      }| j                  dz   |z   }| j                  | j                  d   ||       | j	                  | j                  d   ||       | j                  |d      }| j	                  | j                  d   ||       t        |      y )Nr  errorzerr-code r   r   zerr-msg)r9  r-   throw_broadly_matched_exceptionr   throw_exactly_matched_exceptionr   )r   rt  ru  r\  r>  r^  r]  r   requestHeadersrequestBodyr  r  feedbackmessages                 r   handle_errorszbittrade.handle_errorsy  s    x %%h9F ''*=77S=4/44T__W5MtU]^44T__W5MtU]^**8Y?44T__W5MwX`a#H--r   )N)H__name__
__module____qualname__r   r   r
   r   r   r
  strr  r   r  r  r   r   rC  dictr   r`  r   rg  rj  r   rq  r   r  r  r  r  r]  r  r  r   r  r   r  r   r  r  r  r  r   r  r  r   r  r  r  r  floatr  r   r   r   r  r   r  r  r  r	   r!  r   r)  r+  r;  r:  rh   rs  intr  __classcell__)r   s   @r   r*   r*      ss   I# IV !# 3s 3 7;2 G  :< PS P. :>b 
3 
4x $& m$v, m^O4 O O6 Ob :>b ,rs ,r3 ,rY ,r\ 02 %3 %f %N 04B GW G7 G.L Lv L L\ 9=4^bkm GS G# GS GX[ G" -1tRV_a Ic I IC I. 6:UW 1Y3 1Ys 1Y# 1Y\`af\g 1Yf
 
4 
, 26DW[df  H#  Hc  HQT  Hkoptku  HD %'  4=   ') ^Z ^@) )& $& ,( , <@daenp IS I I[^ I< 26b 'c '3 '  *.Dt\^ 	T3 	Tc 	T 	Tcghmcn 	T /3TXac 
C 
C3 
Cc 
Chlmrhs 
C 26DW[df s3 sc sQT s
 154VZce 	m# 	mS 	mPS 	mjnotju 	m 26DW[df ,=3 ,=c ,=QT ,=\: :O Ov O Ob RT N N5 N gksu M3 Mi My MRW M`c M^ 37r s C ( 04B 12 12f4l /32 #
 #
J
h 
8 *.Dt\^ Q3 Qc Q Qcghsct Q6 -1tRV_a Qc Q QC Qfjkvfw Q6L
T L
X L
Q\ L
\:s :. DHPR &:S &:% &:# &:Wb &:P &eBSW ,P\c 3 S # X\ dg r   r*   )/ccxt.base.exchanger   ccxt.abstract.bittrader   rk  ccxt.base.typesr   r   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   r    r!   r"   r#   r$   r%   ccxt.base.decimal_to_precisionr&   r'   ccxt.base.preciser(   r*    r   r   <module>r     st    ( .  v  v  v  v  v  * 0 - . ' & . ) * ) ) 1 * + 3 4 %kx kr   