
    eim                    l   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.dS )    )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                   t    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dOd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dOd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dOdedefdZdddi fd	e	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+Z0dOd,edede*fd-Z1i fd	e	d.e2fd/Z3di fd	e	d0e4d1e5d2e2d3e6f
d4Z7di fde	d	efd5Z8di fd6ee	         d	efd7Z9d8 Z:di fd	efd9Z;dOd: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@dOd?ed:e<de>fd@ZAd*efdAZBdi fd<e	d2e2dBe	dCede>f
dDZCdEdFi ddfdGZDdHeEdIe	dJe	dKe	dLedMe	fdNZF xZGS )Pbittradereturnc                 V   |                      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|                     d          |                     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    Y/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/bittrade.pyr   zbittrade.describe    s
   h 5 5 > > @ @ 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 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 8kN NgHC
D $!&"&!..w77!..w77 EHC
V $&+(,,0,1).+06:#(#("'#(	( ( #(/4$)$)+/27#()$ $, %)&+!$$'%&*/& & ',#($)*/	# # ',!%#($)*/( ( ',!%$(%)#($)*/$ $ ',!%$(,0%)#($)*/	* 	*  #AC CJ ## 
 ## SM 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C
 HC
 H H H	    c                 h   K   |                      |           d{V }|                     |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
        Ndata)publicGetCommonTimestampsafe_integerr   paramsresponses      r   
fetch_timezbittrade.fetch_time  sC       66v>>>>>>>>  6222r   Nsymbolsc                   K   |                                   d {V  || j        }i }t          dt          |                    D ]<}||         }|                     |                     |          |           d {V ||<   =|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  s       !!!!!!!!!?lGq#g,,'' 	c 	cAQZF#'#B#B4>>RXCYCY[a#b#bbbbbbbF6NNr   r-   c                    K   d|i}|                      |                     ||                     d {V }|                     |                     |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  sm      b
 55dkk'66R6RSSSSSSSS" ((62)N)NOOOr   r	  c                 f    |d|                      |d          |                      |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  sP    " ++F4STT++F4PQQ 
 
 	
r   c                 t    |                      |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  s2    ((xf9Mk9Z[a9bdhdvwwwr   c                   K   | j         d         } t          | |          |           d{V }|                     |dg           }t          |          }|dk     r-t	          | j        dz   |                     |          z             g }t          dt          |                    D ]}||         }|                     |d          }	|                     |d          }
| 	                    |	          }| 	                    |
          }|                     |d	          }|                     |d
d          }|                     |dd          }t          j        |d          pt          j        |d          }|dk    r|                     d          n|                     d          }|                    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|                     |                     |                     |d%                              |                     |                     |                     |d&                              |                     |                     |                     |d'                              d(|                     d          |                     |          |                     |          d)|                     |d*          |                     |d+          d,ddd,|                     |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   Nr   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settle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  s4      23.v..v66666666B //(FB77\\
>>tw)TTW[W`W`ahWiWiijjjq#g,,'' ?	 ?	AQZF%%fo>>F&&v/?@@G**622D++G44E$$VW55E ,,V5EsKKM!%!1!1&:WY\!]!]&}c::hg>OPbdg>h>hF-1U]]$##C(((ARARSZA[A[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[]nDoDo/p/pqq"//0D0DTEUEUV\^pEqEq0r0rss --d.B.B4CSCSTZ\mCnCn.o.opp   $0055#00??$($5$56H$I$I! !  $//HH#//HH 
  $# 
  $//8IJJ#  &  g4 4 4 4 4 4 4j r   tickerr   c                 >   |                      d |          }|                     |d          }d }d }d }d }d|v rt          |d         t                    r9|                     |d         d          }|                     |d         d          }n,|                     |d          }|                     |d          }d|v rt          |d         t                    r9|                     |d         d          }|                     |d         d          }n,|                     |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 )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  s   D !!$//%%fd33			F??&-.. @&&ve}a88 ,,VE]A>>		&&vu55 ,,VY??	F??&-.. @&&ve}a88 ,,VE]A>>		&&vu55 ,,VY??	//  11%%fh77
&&vu55 !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 3!
 !
 3!
 !
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ %&)!
 !
 !
* +  	r   r   c                   K   |                                   d{V  |                     |          }|d         dd}|                     |                     ||                     d{V }d|v r|d         s-t	          | j        dz   |                     |          z             |                     |d          }|                     |d|                     |d                    }| 	                    |||          }	|                     |d          |	d	<   |	S t          | j        d
z   |                     |          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
        Nr-   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  si      !!!!!!!!!V$$Tl
 
 ,,T[[&-I-IJJJJJJJJ, XF# o*W WZ^ZcZcdlZmZm mnnn??8V44D))$d6G6GRV6W6WXXI**4CCF"//i@@F7OMDG&ZZ]a]f]fgo]p]ppqqqr   c                 x  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     |d         |          }|                     |d          }||d<   |                     |          |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>`
        Nr	  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
 33DKK4P4PQQQQQQQQ* ""8F#3V<<%%h55	'{!\\)44zr   c                 T  K   |                                   d{V  |                     |          }|                     |           d{V }|                     |dg           }|                     |d          }i }t          dt          |                    D ]y}|                     ||         d          }|                     |          }	|	d         }
| 	                    ||         |	          }||d<   | 
                    |          |d<   |||
<   z|                     |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>`
        Nr   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
  sD      !!!!!!!!!%%g....v66666666//(FB77%%h55	q#g,,'' 	$ 	$A''
H==H%%h//FH%F&&wqz6::F"+F;!%i!8!8F:#F6NN++FHgFFFr   r   c                    |                      |d          }|                     ||          }|                     |dd          }|                      |d          }|                      |d          }|                      |d          }|%|                    d          }	|	d         }|	d	         }|                      |d
          }
|                      |d          }|                     |dd          }t          j        ||          }d }|                      |d          }|                     |                      |d                    }|                      |d          }|B|t          j        |d          r+|}|                     |                      |d                    }|||d}|                     |dd          }|                      |d|          }| 	                    |||||| 
                    |          |||
||||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!  s1   B ##E844!!(F33''t\BB	  
33{33v..

3IQ<DQ<D''v66  00##E?HEE!%00""5-88--d.>.>un.U.UVV''??#W%6w%F%F&"55d6F6FuNc6d6dee' C $$UJ	BBeT733"Y//( 
  
   	r   sincec                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |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>`
        Nr-   r   )r  #privateGetOrderOrdersIdMatchresultsr  parse_trades)r   r-   r	  r  r   r   r  r   s           r   fetch_order_tradeszbittrade.fetch_order_tradeso  s       !!!!!!!!!"
 AA$++gW]B^B^________  &!14FFFr   c                 <  K   |                                   d{V  d}i }| |                     |          }|d         |d<   |||d<   |||d<   |                     |                     ||                     d{V }|                     |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!99$++gv:V:VWWWWWWWW  &!165%HHHr   i  c                   K   |                                   d{V  |                     |          }d|d         i}|t          |d          |d<   |                     |                     ||                     d{V }|                     |dg           }g }	t          dt          |                    D ]p}
|                     ||
         dg           }t          dt          |                    D ]3}|                     ||         |          }|		                    |           4q| 
                    |	d          }	|                     |	|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>`
        Nr	  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  sv      !!!!!!!!!V$$fTl
 !%..GFO33DKK4P4PQQQQQQQQ2 x44q#d))$$ 	% 	%A__T!Wfb99F1c&kk** % %((F;;e$$$$% fk22009I5RWXXXr   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr-   rK  rP  rQ  rL  r  )safe_timestampr  )r   ohlcvr   s      r   parse_ohlcvzbittrade.parse_ohlcv  s     t,,UF++UF++UE**UG,,UH--
 	
r   rt   	timeframec                   K   |                                   d{V  |                     |          }|d         |                     | j        ||          d}|t	          |d          |d<   |                     |                     ||                     d{V }|                     |dg           }	|                     |	||||          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
        Nr-   )r	  periodr   r  r   )	r  r   r9  ri   r  marketGetHistoryKliner  	safe_listparse_ohlcvs)
r   r	  r  r  r   r   r   r  r   r   s
             r   fetch_ohlcvzbittrade.fetch_ohlcv  s       !!!!!!!!!V$$Tl&&t	9MM
 
 !%..GFO33DKK4P4PQQQQQQQQ ~~h33  vy%GGGr   c                    K   |                                   d{V  |                     |           d{V }|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
        Nr   )r  privateGetAccountAccountsr   s      r   fetch_accountszbittrade.fetch_accounts  s\       !!!!!!!!!77????????r   c                   K   d| j         d         i}|                     |                     ||                     d{V }|                     |dg           }i }t	          dt          |                    D ]M}||         }|                     |d          }|                     |          }	|                     |d          }
|                     |d          }|                     |d          }|                     |d	d
          }|                     |d          }|o|
o
|o|dk    o| }|                     |d          }| 	                    | 
                    |                     |d                              }||	d|||
|d|d|dd|                     |d          dd|                     |d          ddd|d||	<   O|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   Nr   r   r.   zdeposit-enabledzwithdraw-enabledzcountry-disabledvisibleFr   r-  zdisplay-namezwithdraw-precisioncryptor  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
 88Wf9U9UVVVVVVVVR __Xvr::
q#j//** )	 )	A!!}H622B**2..D!__X7HIIN"ooh8JKKO"ooh8JKKOnnXy%@@G$$Xw77EssOsRZIZsds`sF##Hn==D))$*>*>t?O?OPXZn?o?o*p*pqqI   )+&   )# 
  $//:NOO#   
  $//:OPP#! !  !9 F4LL< r   c                    |                      |d         dg           }d|i}t          dt          |                    D ]}||         }|                     |d          }|                     |          }d }||v r	||         }n|                                 }|d         dk    r|                     |d          |d	<   |d         d
k    r|                     |d          |d<   |||<   |                     |          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**:66DGv~~ ,,,..v'))"&"2"27I"F"Fv(**"&"2"27I"F"F"F4LL  (((r   c                 B  K   |                                   d{V  |                                  d{V  | j        d         }d| j        d         d         i} t	          | |          |                     ||                     d{V }|                     |          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>`
        Nr   r-   r   )r  load_accountsr   accountsr7  r  r  )r   r   r>  r  r   s        r   fetch_balancezbittrade.fetch_balance  s       !!!!!!!!!  """""""""23$-"4(
 /v..t{{7F/K/KLLLLLLLL!!(+++r   c                 d  K   |                                   d {V  d|i}d }| |                     |          }|d         |d<   |                     | j        dd          } t	          | |          |                     ||                     d {V }	|                     |	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h.v..t{{7F/K/KLLLLLLLL$   &!165%HHHr   c                    K   |                                   d{V  d|i}|                     |                     ||                     d{V }|                     |d          }|                     |          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>`
        Nr-   r   )r  privateGetOrderOrdersIdr  	safe_dictparse_order)r   r-   r	  r   r  r   r}  s          r   fetch_orderzbittrade.fetch_order  s       !!!!!!!!!"
 55dkk'66R6RSSSSSSSSx00&&&r   c                 D   K   |                      d||||           d{V 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,canceledNr  r   r	  r  r   r   s        r   fetch_orderszbittrade.fetch_orders  sf       001z  }C  EJ  LQ  SY  Z  Z  Z  Z  Z  Z  Z  Z  	Zr   c                    K   |                      | j        dd          } t          | |          ||||           d{V 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   N)r9  r   r7  )r   r	  r  r   r   r>  s         r   fetch_open_orderszbittrade.fetch_open_orders  sU       !!$,0GI_``*WT6**65%HHHHHHHHHr   c                 v   K   |t          | j        dz             |                     d||||           d {V 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  sT      >#DG._$_```001Y[achjoqwxxxxxxxxxr   c                 D   K   |                      d||||           d{V 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,canceledNr  r  s        r   fetch_closed_orderszbittrade.fetch_closed_orders  s;       001SU[]bdikqrrrrrrrrrr   c                   K   |                                   d {V  i }d }| |                     |          }|d         |d<   |                     |d          }|r|                                  d {V  t	          dt          | j                            D ]5}| j        |         }	|	d         dk    r|                     |	d          }| n6||d<   |||d<   |                     |d          }
|                     | 	                    ||
                     d {V }| 
                    |dg           }|                     ||||          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011  -*6?f,, $ 0 0$ ? ?I , )#GFO))FL1177GW8U8UVVVVVVVV, ~~h33  vue<<<r   statusc                 @    dddddd}|                      |||          S )NrK  canceledclosed)zpartial-filledzpartial-canceledfilledr  	submittedr9  r   r  statusess      r   parse_order_statuszbittrade.parse_order_status  s7    $ *"
 
 &&999r   r}  c                    |                      |d          }d }d }d }d|v rT|d                             d          }|d         }|d         }|                     |                      |d                    }|                      |d          }|                     ||          }|                     |d          }	|                      |d	          }
|                      |d
          }|                     |dd          }|                      |d          }|                     |dd          }|                     |dd          }d }||dk    r|d         n|d         }||d}|                     i d|d|d|
d|	d|                     |	          dd d|d         d|dd dd d|d|dd dd d |d
|d!|d ||d d"|          S )#Nr-   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  s   @ eT**U??f++C00IQ<DQ<D,,T-=-=eW-M-MNNF##E844!!(F33%%e\::	((0ABB!!%22##E?NKK  00!!%)=?RSS$$UM<HH.2fnn&//6&>K' C   
E 
" 
 ] 
 	 

 Y// 
 !$ 
 fX& 
 D 
 4 
  
 D 
 U 
 D 
 t 
 D 
  f! 
" f# 
$ + 
  
  
, -  	r   r  c                    K   |                                   d{V  |                     |          }|d         st          | j        dz             d|d<   |                     |dd|d|           d{V 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>`
        Nr=   z9 createMarketBuyOrderWithCost() supports spot orders onlyFr   r   buy)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~ 	ftw)ddeee6;23&&vxdFSSSSSSSSSr   r+  r~  r  r/  c                   K   |                                   d{V  |                                  d{V  |                     |          }| j        d         d         |d         |dz   |z   d}|                     |dd          }	|	M|                     | j        di           }
|                     |
d          }||                                 z   |d<   n|	|d<   | 	                    |ddg          }|d	k    r|d
k    rd}d}| 
                    |ddd          \  }}|                     |d          }| 	                    |d          }||                     ||          }n|rm|t          | j        dz             |                     |          }|                     |          }|                     |t!          j        ||                    }n|                     ||          }||d<   n|                     ||          |d<   |dk    s|dk    s|dk    s|dk    s|dk    r|                     ||          |d<   | j        d         } t'          | |          |                     ||                     d{V }|                     |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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>`
        Nr   r-   rv  )r  r	  r+  r  r  r   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{  s      !!!!!!!!!  """""""""V$$-*40Tl3J%
 

 **6?DUVV __T\8R@@F''55H)1DIIKK)?G%&&)6G%&6O5F#GHHH45==K04-8<8U8UV\^k  nQ  SW  9X  9X5-v##FF33DYYvv..F"66vtDD2 G=&tw  2m  (m  n  n  n $(#8#8#@#@L"&"7"7">">K"&":":67CUVbdoCpCp"q"qKK"66vvFF +GH $ 8 8 H HGH7??demmt}/D/DP\H\H\`dhx`x`x#66vuEEGG12.v..t{{7F/K/KLLLLLLLLh//  
H 
" 
  
 	 

 !$ 
 d 
 f 
 D 
 D 
 U 
 f 
 d 
  
 D 
 d 
  4! 
" T# 
$ t% 
  
& '  	r   c                    K   |                      d|i           d{V }|                     |                     |          |dd          S )a2  
        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-   Nr  )r-   r  )$privatePostOrderOrdersIdSubmitcancelr  r  )r   r-   r	  r   r   s        r   cancel_orderzbittrade.cancel_order  si       BBD":NNNNNNNN {{4++H55 8
 8
   	r   idsc                 >  K   |                                   d{V  |                     |dd          }|                     |ddg          }i }|||d<   n||d<   |                     |                     ||                     d{V }|                     |          S )aA  
        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>`
        NclientOrderIdszclient-order-idsz	order-ids)r  safe_value_2r  !privatePostOrderOrdersBatchcancelr  parse_cancel_orders)r   r  r	  r   r  r  r   s          r   cancel_orderszbittrade.cancel_orders  s       !!!!!!!!!**63CEWXX6$46H#IJJ!#&GK  *8G&'??GU[@\@\]]]]]]]]B ''111r   c                 l   |                      |d          }d }||                    d          }n|                     |dg           }|                     |ddg           }g }t	          dt          |                    D ]6}||         }|                    |                     ||dd                     7t	          dt          |                    D ]`}||         }|                    |                     ||                     |d	d
          d|                      |d          d                     a|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  se   : $$V[99	 ooc**GGnnVY;;G!!&(HbAAq#g,,'' 	 	AAJEMM$//$+ +      
 q#f++&& 	 	A1IEMM$//((
JGG"!%!1!1%9J!K!K	+ +       r   c                 B  K   |                                   d{V  i }d}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |di           }|                     d|i          gS )a`  
        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II$++V]_eJfJfgggggggg ~~h33OO  
 	
r   r{  c                    |                      |d          }|                      |d          }|                      |d          }|                     ||          }|                     ||          }|                      |d          }|                     |di           }|                     |d          }	|                     |	||          }
|                      |
d          }|                     |           |||||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A
%%j(;;&&z8<<$$^W==	??8Z<<}}Xt44|Y	JJ""<;;7###"
 
 	
r   r  c                 L  K   ||dk    rd}|                                   d{V  d}||                     |          }ddd}||d         |d<   |||d<   |                     |                     ||                     d{V }|                     |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       =ECKKE!!!!!!!!!}}T**H
 
 "*4.GJ#GFO<<T[[RX=Y=YZZZZZZZZ&&x'75%PPPr   c                 L  K   ||dk    rd}|                                   d{V  d}||                     |          }ddd}||d         |d<   |||d<   |                     |                     ||                     d{V }|                     |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       =ECKKE!!!!!!!!!}}T**H
 
 "*4.GJ#GFO<<T[[RX=Y=YZZZZZZZZ&&x'75%PPPr   transactionc                 F   |                      |d          }|                     |                     |d                    }|                     |d          }|dk    rd}|                     |d          }|t          j        |          }i d|d|                     |dd	          d
|                     |d          d|d|                     |          d|                     |d          d|                     |d          dd dd d|                     |d          dd dd d|d|                     |d          d|d| 	                    |                     |d                    d|                      |d          d d || 
                    |          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  s4   V %%k<@@	&&t'7'7Z'P'PQQV44:D"";66(11G
K
$$$[$??
 D$$[)<<
 	

 Y//
 t--k7CC
 t''Y??
 
 4
 4##K??
 T
 t
 D
 d&&{H==
 
  d33D4D4D[RY4Z4Z[[!
" t((lCC#
$  ))'22 )
 
 
 	
r   c                 T    dddddddddddddddd}|                      |||          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  sW      #"""%% (%%
 
( &&999r   r  r  c                   K   |                      ||          \  }}|                                  d{V  |                     |           |                     |          }|||d                                         d}|||d<   |                     | j        di           }|                     |d          }	|                     ||	|	          }	|	9|	dk    r|d         |	z   |d<   n|	|d         z   |d<   | 	                    |d          }| 
                    |                     ||                     d{V }
|                     |
|          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>`
        Nr-   )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FV!!!!!!!!!7###==&& ,,..
 

 ?"%GJ??4<R@@((;;((7GDD'!!#+D>G#;  #*Xd^#; YYvy11F<<T[[RX=Y=YZZZZZZZZ %%h999r   r   r   c                 B   d}|dk    r||z  }n(|dk    s|dk    r|| j         z  }n|dk    s|dk    r|dz  }|d|                     ||          z   z  }|                     ||                     |                    }|dk    s|dk    rC|                                  |                     |                                 d          }	d	d
| j        |	d}
|dk    r|                     |
|          }
| 	                    |
          }| 
                    |          }d                    || j        ||g          }|                     |                     |          |                     | j                  t           j        d          }|d| 
                    d|i          z   z  }|d|z   z  }|dk    r|                     |          }ddi}n"ddi}n|r|d| 
                    |          z   z  }|                     | 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  sj   (??3JCCXoo3)#3#34<CCZSK%7%74KCsT((v6666		&$"5"5d";";<<)sk11++---D$5$5$7$7==I#/$'#{&	 G ++gu55 LL11M>>-00D iiT BCCG		$++g"6"6DK8P8PRYR`bjkkIC$..+y)ABBBBD3:Cyy''"$6
 #$G  4sT^^F3333!!$)E"23"7:
   fdwOOOr   httpCodereasonr\  r>  r^  r]  c
                    |d S d|v r|                      |d          }
|
dk    r|                      |d          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           |                      |d          }|                     | j        d         ||           t          |          d S )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    4x %%h99F  ''*==7S=4/44T_W5MtU]^^^44T_W5MtU]^^^**8Y??44T_W5MwX`aaa#H---tr   )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*      so	       I# I I I I I IV ') 3 3S 3 3 3 3 =A  '     @B P P3 P P P P. :>b 
 
3 
 
 
 
4x x x *, m mV m m m m^O O4 O O6 O O O Ob @DB ,r ,rS ,r ,rS\ ,r ,r ,r ,r\ 68 % % %F % % % %N 6:" G G7 G G G G G.L L Lv L L L L L\ ?CQUdhqs G G3 G G3 G^a G G G G" 37TX\eg I IC Is IRU I I I I. <@d[] 1Y 1Y 1YS 1Y 1Ybfglbm 1Y 1Y 1Y 1Yf
 
 
4 
 
 
 
, ?CQUdhqs  H  H  H  H3  H^a  Hx|  ~B  yC  H  H  H  HD +-    g         -/ ^ ^: ^ ^ ^ ^@) ) ) ) )& *, , , , , , , BFTXgktv I I3 Ic Iad I I I I< 8<B ' 'C ' ' ' ' '  04$UYbd 	Z 	Z 	ZC 	Zs 	Zimnsit 	Z 	Z 	Z 	Z 59tZ^gi 
I 
Ic 
I 
ITW 
Inrsxny 
I 
I 
I 
I 8<$]ajl y y yC yWZ y y y y
 7;\`ik 	s 	s 	s3 	sVY 	sptuzp{ 	s 	s 	s 	s 8<$]ajl ,= ,= ,=C ,=WZ ,= ,= ,= ,=\: : : : :O O Ov O O O O Ob XZ T Tc T T T T T mqy{ M M MI MY MX] Mfi M M M M^ 9=R  S #    ( AER 12 12tCy 12# 12 12 12 12f4 4 4l 59 #
 #
c #
 #
 #
 #
J
 
h 
 
 
 
8 04$UYbd Q Q QC Qs Qimnyiz Q Q Q Q6 37TX\eg Q QC Qs QRU Qlpq|l} Q Q Q Q6L
 L
T L
X L
Q\ L
 L
 L
 L
\:s : : : :. QU]_ &: &:3 &: &: &:# &:do &: &: &: &:P &eBSW ,P ,P ,P ,P\c 3 S # X\ dg        r   r*   )/ ccxt.async_support.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     s   6 5 5 5 5 5 . . . . . .  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v  v       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' & & & & & & . . . . . . ) ) ) ) ) ) * * * * * * ) ) ) ) ) ) ) ) ) ) ) ) 1 1 1 1 1 1 * * * * * * + + + + + + 3 3 3 3 3 3 4 4 4 4 4 4 % % % % % %k k k k kx k k k k kr   