
     f2                         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 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)BalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrTickerTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)InsufficientFunds)InvalidOrder)OrderNotFound)InvalidNonce)	TICK_SIZEc                   T    e Zd Z fdZi fdee   fdZdefdZd7dedede	fdZ
i fd	ede	fd
Zdi fd	ededefdZd7dededefdZddi fd	edededee   fdZi fdefdZd7dedefdZdddi fd	edededee   fdZdefdZi fdefdZdefdZd7dededefdZdi fd	edede de!de"f
dZ#di fd ed	efd!Z$di fd e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'i fd%efd&Z(di fd%ede!d'efd(Z)d7d)ed*e*de+fd+Z,d, Z-d-d.i ddfd/Z.d0e/d1ed2ed3ed4ed5efd6Z0 xZ1S )8bitbankc                    | j                  t        t        |          dddgdi dd ddddd	dd
dddddddddddddddddddddddddi ddddddddddddddddddd dd!dd"dd#dd$dd%dd&dd'di d(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7dd8ddddddd9d:d;d<d=d>d?d@dAdBdCdD
dEdFdGdHdHdIdJdKdLdMdNg dOig dPg dQdRdNdSgidIt        dTt
        t
        t
        t
        t        t        t        t        t        t        t        t        t        t        t        dUidV      S )WNr   JPv1CORSspotTmarginFswapfutureoption	addMargincancelAllOrderscancelOrdercloseAllPositionsclosePositioncreateOrdercreateReduceOnlyOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositAddressfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTradesfetchTradingFeefetchTradingFeesfetchTransferfetchTransfersreduceMargin)setLeveragesetMarginModesetPositionModetransferwithdraw1min5min15min30min1hour4hour8hour12hour1day1week)
1m5m15m30m1h4h8h12h1d1wz
bitbank.cczchttps://user-images.githubusercontent.com/1294454/37808081-b87f2d9c-2e59-11e8-894d-c1900b7584fe.jpgzhttps://public.{hostname}zhttps://api.{hostname})publicprivatemarketszhttps://bitbank.cc/zhttps://docs.bitbank.cc/zhttps://bitbank.cc/docs/fees/)logoapiwwwdocfeesget)z{pair}/tickertickerstickers_jpyz{pair}/depthz{pair}/transactionsz{pair}/transactions/{yyyymmdd}z*{pair}/candlestick/{candletype}/{yyyymmdd}z{pair}/circuit_break_info)	zuser/assetsuser/spot/orderzuser/spot/active_orderszuser/spot/trade_historyzuser/deposit_historyzuser/withdrawal_accountzuser/withdrawal_historyzspot/status
spot/pairs)rx   zuser/spot/cancel_orderzuser/spot/cancel_orderszuser/spot/orders_infozuser/request_withdrawal)ru   postry   exact)200012000220003200052000440020400214002540013400145000850009500106000160005)idname	countriesversionhas
timeframeshostnameurlsrq   precisionMode
exceptions)deep_extendsuperr   describer   r   r   r   r   r   r   r   )self	__class__s    F/var/www/html/py/new-venv/lib/python3.12/site-packages/ccxt/bitbank.pyr   zbitbank.describe   s   gt = ?999 %9 	9
 %9 %9 U9 "59 t9 $U9  9 t9 (9 9 +E9  )%!9" '#9$ (%9& &t'9( &u)9* #E+9, *5-9. $U/90 "5192 *5394 +E596  798 %e99: "5;9< !%=9>  ?9@ dA9B +EC9D "4E9F dG9H !$I9J  K9L 'M9N $UO9P !%Q9R *5S9T (U9V %eW9X )%Y9Z t[9\ t]9^ "5_9` #Da9b  c9d !%e9f g9h  %!&#(! q9v  %}977
 -17
  	
* $C&N '0000)))***-**.)RB
 R R	    returnc                     | j                  |      }| j                  |d      }| j                  |dg       }| j                  |      S )a`  
        retrieves data on all markets for bitbank
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#get-all-pairs-info
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        datapairs)marketsGetSpotPairs
safe_valueparse_markets)r   paramsresponser   r   s        r   fetch_marketszbitbank.fetch_markets   sI     ++F38 x0gr2!!%((r   c                    | j                  |d      }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }i d|d|dz   |z   d|d|d	d d
|d|dd ddddddddddddd| j                  |d      dddd d | j                  |d      | j                  |d      d d d d d | j	                  | j                  | j                  |d                  | j	                  | j                  | j                  |d                  dd d d| j                  |d      | j                  |d       dd d dd d dd!d |d"S )#Nr   
base_assetquote_assetr   symbol/basequotesettlebaseIdquoteIdsettleIdtyper"   Tr#   Fr$   r%   r&   active
is_enabledcontractlineartaker_fee_rate_quotemaker_fee_rate_quoteamount_digitsprice_digits)amountprice)minmaxunit_amountlimit_max_amount)leverager   r   cost)inversetakermakercontractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedinfo)safe_stringsafe_currency_coder   safe_numberparse_numberparse_precision)r   entryr   r   r   r   r   s          r   parse_marketzbitbank.parse_market   s+   eV,!!%6""5-8&&v.''02
"2
dSj5(2
 D2
 U	2

 d2
 f2
 w2
 2
 F2
 D2
 e2
 E2
 e2
 e2
 dooe\:2
  !2
" d#2
$ %%e-CD%%e-CD "++D,@,@AQAQRWYhAi,jk**4+?+?@P@PQVXf@g+hi  
  ++E=A++E3EF
  
  $ c2
 2	
r   Ntickermarketc                    | j                  d |      }| j                  |d      }| j                  |d      }| j                  i d|d|d| j	                  |      d| j                  |d      d| j                  |d      d| j                  |d      d	d d
| j                  |d      dd dd dd d|d|dd dd dd dd | j                  |d      d |d|      S )N	timestamplastr   datetimehighlowbidbuy	bidVolumeasksell	askVolumevwapopenclosepreviousClosechange
percentageaveragevol)
baseVolumequoteVolumer   )safe_symbolsafe_integerr   safe_tickeriso8601)r   r   r   r   r   r   s         r   parse_tickerzbitbank.parse_ticker  sw   !!$/%%fk:	/ !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FF3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **659)!
* + 	r   r   c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  ||      S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/public-api.md#ticker
        :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>`
        pairr   r   )load_marketsr   publicGetPairTickerextend	safe_dictr   )r   r   r   r   requestr   r   s          r   fetch_tickerzbitbank.fetch_ticker(  sp     	V$F4L
 ++DKK,HI~~h3  v..r   limitc                 
   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  |d      }| j                  ||d   |      S )ar  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/public-api.md#depth
        :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   r   r   r   r   )r   r   publicGetPairDepthr   r   r   parse_order_book)	r   r   r   r   r   r   r   	orderbookr   s	            r   fetch_order_bookzbitbank.fetch_order_book9  s     	V$F4L
 **4;;w+GHOOHfb9	%%i=	$$Yx0@)LLr   tradec                    | j                  |d      }| j                  d |      }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  |d      }d }| j                  |d      }	|	|d   |	d	}| j                  |d
      }
| j                  |d      }| j                  |d      }| j	                  || j                  |      |d   ||
|||||d ||d|      S )Nexecuted_atr   r   transaction_idtrade_idmaker_takerfee_amount_quoter   )currencyr   order_idr   sider   )r   r   r   r   orderr   r	  takerOrMakerr   r   r   feer   )r   safe_marketr   safe_string_2
safe_trader   )r   r   r   r   priceStringamountStringr   r  r  feeCostStringorderIdr   r	  s                r   parse_tradezbitbank.parse_tradeL  s*    %%e];	!!$/&&ug6''x8'7D''}=((0BC$"7O%C ""5*5v.v."Y/X&( " 
  	r   sincec                    | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j                  |dg       }	| j                  |	|||      S )ac  
        get the list of most recent trades for a particular symbol
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/public-api.md#transactions
        :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   transactions)r   r   publicGetPairTransactionsr   r   	safe_listparse_trades)
r   r   r  r   r   r   r   r   r   tradess
             r   fetch_tradeszbitbank.fetch_tradesx  s     	V$F4L
 11$++gv2NOx4nb9  >>r   c                 ~   | j                          | j                  |      }| j                  |di       }| j                  |dg       }i }t        dt	        |            D ][  }||   }| j                  |d      }| j                  |      }	|	d   }
||
| j                  |d      | j                  |d      dd	d
||
<   ] |S )a  
        fetch the trading fees for multiple markets
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#get-all-pairs-info
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r   r   r   r   r   r   r   TF)r   r   r   r   r   	tierBased)r   r   r   rangelenr   r  r   )r   r   r   r   r   resultir   marketIdr   r   s              r   fetch_trading_feeszbitbank.fetch_trading_fees  s     	++F3: x4gr2q#e*% 	A8D''f5H%%h/FH%F ))$0FG))$0FG""F6N	 r   c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )N   r               )r   r   )r   ohlcvr   s      r   parse_ohlcvzbitbank.parse_ohlcv  sn     eQ'UA&UA&UA&UA&UA&
 	
r   rc   c                    |.|d}| j                  |      }| j                         |dz  |z  z
  }| j                          | j                  |      }|d   | j	                  | j
                  ||      | j                  |d      d}| j                  | j                  ||            }	| j                  |	di       }
| j                  |
dg       }| j                  |di       }| j                  |dg       }| j                  |||||      S )	a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/public-api.md#candlestick
        :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   
candletypeyyyymmddr   candlestickr   r+  )parse_timeframemillisecondsr   r   r   r   r1  *publicGetPairCandlestickCandletypeYyyymmddr   r   r  parse_ohlcvs)r   r   	timeframer  r   r   durationr   r   r   r   r2  firstr+  s                 r   fetch_ohlcvzbitbank.fetch_ohlcv  s    =}++I6H%%'(T/E*AAEV$4L**4??IyQeR0

 BB4;;wX^C_`& x4oodM2>Q3ugr2  	5%HHr   c                    |d d d}| j                  |di       }| j                  |dg       }t        dt        |            D ]~  }||   }| j                  |d      }| j	                  |      }| j                         }	| j                  |d      |	d<   | j                  |d      |	d	<   | j                  |d
      |	d<   |	||<    | j                  |      S )N)r   r   r   r   assetsr   assetfree_amountfreelocked_amountusedonhand_amounttotal)r   r  r   r   r   accountsafe_balance)
r   r   r!  r   r<  r"  balance
currencyIdcoderD  s
             r   parse_balancezbitbank.parse_balance  s    

 x4x4q#f+& 	#AQiG))'7;J**:6DllnG"..wFGFO"..wHGFO#//IGG"F4L	#   ((r   c                 f    | j                          | j                  |      }| j                  |      S )a  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#assets
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )r   privateGetUserAssetsrI  )r   r   r   s      r   fetch_balancezbitbank.fetch_balance  s4     	,,V4D !!(++r   statusc                 8    dddddd}| j                  |||      S )Nr   closedcanceled)UNFILLEDPARTIALLY_FILLEDFULLY_FILLEDCANCELED_UNFILLEDCANCELED_PARTIALLY_FILLED)r   )r   rM  statusess      r   parse_order_statuszbitbank.parse_order_statusF  s/     &$!+)3
 &&99r   r
  c           	         | j                  |d      }| j                  |d      }| j                  ||      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |d      }
| j                  | j                  |d	            }| j	                  |d
      }| j	                  |d      }| j                  i 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|||	d d |d|      S )Nr  r   
ordered_atr   start_amountexecuted_amountremaining_amountaverage_pricerM  r   r	  r   clientOrderIdr   r   lastTradeTimestampr   timeInForcepostOnly	stopPricetriggerPricer   r   r   )filled	remainingr  r  r   )r   r  r   rW  safe_string_lower
safe_orderr   )r   r
  r   r   r#  r   r   r   rd  re  r   rM  r   r	  s                 r   parse_orderzbitbank.parse_orderP  s   eZ0##E62!!(F3%%e\:	  0!!%8!!%):;$$U,>?	""5/:(()9)9%)JK%%eV4%%eV4  
" 
T 
 Y/ 
 	 

 !$ 
 f 
 fX& 
 D 
 4 
  
 D 
 U 
  
 D 
 D 
  w! 
" f# 
$ "- 
. / 	r   r   r	  r   r   c                 6   | j                          | j                  |      }|d   | j                  ||      ||d}|dk(  r| j                  ||      |d<   | j	                  | j                  ||            }	| j                  |	d      }
| j                  |
|      S )a  
        create a trade order
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#create-new-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   r   r	  r   r   r   r   )r   r   amount_to_precisionprice_to_precisionprivatePostUserSpotOrderr   r   rh  )r   r   r   r	  r   r   r   r   r   r   r   s              r   create_orderzbitbank.create_orderv  s     	V$4L..vv>	
 7?#66vuEGG00Wf1MN~~h/f--r   r   c                     | j                          | j                  |      }||d   d}| j                  | j                  ||            }| j	                  |d      }| j                  |      S )a  
        cancels an open order
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#cancel-order
        :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   r   )r   r   privatePostUserSpotCancelOrderr   r   rh  r   r   r   r   r   r   r   r   s           r   cancel_orderzbitbank.cancel_order  so     	V$4L
 66t{{7F7ST0 x0%%r   c                     | j                          | j                  |      }||d   d}| j                  | j                  ||            }| j	                  |d      }| j                  ||      S )a  
        fetches information on an order made by the user
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#fetch-order-information
        :param str id: the 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   ro  r   )r   r   privateGetUserSpotOrderr   r   rh  rq  s           r   fetch_orderzbitbank.fetch_order  sq     	V$4L
 //GV0LM. ~~h/f--r   c                 H   | j                          | j                  |      }d|d   i}|||d<   || j                  |dz        |d<   | j                  | j	                  ||            }| j                  |di       }| j                  |dg       }	| j                  |	|||      S )aS  
        fetch all unfilled currently open orders
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#fetch-active-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   countr.  r  r   orders)r   r   parse_to_intprivateGetUserSpotActiveOrdersr   r   r  parse_orders)
r   r   r  r   r   r   r   r   r   rx  s
             r   fetch_open_orderszbitbank.fetch_open_orders  s     	V$F4L
 $GG#00>GG66t{{7F7STx4h3  >>r   c                 V   | j                          i }d}|| j                  |      }|d   |d<   |||d<   || j                  |dz        |d<   | j                  | j	                  ||            }| j                  |di       }| j                  |dg       }	| j                  |	|||      S )	aA  
        fetch all trades made by the user
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#fetch-trade-history
        :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   rw  r.  r  r   r  )r   r   ry  privateGetUserSpotTradeHistoryr   r   r  r  )
r   r   r  r   r   r   r   r   r   r  s
             r   fetch_my_tradeszbitbank.fetch_my_trades  s     	[[(F$TlGFO$GG#00>GG66t{{7F7STx4h3  >>r   rH  c                 :   | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  |di       }| j	                  |dg       }| j	                  |di       }| j                  |d      }	||	dd|dS )	a  
        fetch the deposit address for a currency associated with self account
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#get-withdrawal-accounts
        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r=  r   r   accountsr   addressN)r  r  tagnetworkr   )r   r  privateGetUserWithdrawalAccountr   r   r   )
r   rH  r   r  r   r   r   r  firstAccountr  s
             r   fetch_deposit_addresszbitbank.fetch_deposit_address  s     	==&Xd^
 77GV8TUx4??4R8xB7""<; 
 	
r   r  c                 B   | j                  ||      \  }}d|vrt        | j                  dz         | j                          | j	                  |      }|d   |d}| j                  | j                  ||            }| j                  |di       }	| j                  |	|      S )a  
        make a withdrawal
        :see: https://github.com/bitbankinc/bitbank-api-docs/blob/38d6d7c6f486c793872fd4b4087a0d090a04cd0a/rest-api.md#new-withdrawal-request
        :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>`
        uuidz  uuid is required for withdrawalr   )r=  r   r   )	handle_withdraw_tag_and_paramsr   r   r   r   privatePostUserRequestWithdrawalr   r   parse_transaction)
r   rH  r   r  r  r   r  r   r   r   s
             r   rX   zbitbank.withdraw/  s     99#vFV& *L LMM==&d^
 88Wf9UV$ ~~h3%%dH55r   transactionr  c                     | j                  |d      }| j                  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 |dS )Ntxidr   r   r   r  addressFromr  	addressTor   r   r  rH  rM  updatedtagFromr  tagTocomment)internalr  r   )r   safe_currency)r   r  r  r  s       r   r  zbitbank.parse_transactionX  s   " V4%%dH5
$
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 	
r   c                 "    | j                         S N)r4  )r   s    r   noncezbitbank.nonce  s      ""r   rm   GETc           	         | j                  || j                  |            }| j                  | j                  d   |         dz   }|dk(  s|dk(  r0|| j	                  ||      z  }|r|d| j                  |      z   z  }n| j                          t        | j                               }	|	}
|| j                  dz   | j	                  ||      z   z  }|dk(  r| j                  |      }|
|z  }
n;|
d| j                  z   dz   |z   z  }
|r!| j                  |      }|d|z   z  }|
d|z   z  }
d| j                  |	| j                  | j                  |
      | j                  | j                        t        j                         d}||||d	S )
Nrq   r   rm   ro   ?POSTzapplication/json)zContent-Typez
ACCESS-KEYzACCESS-NONCEzACCESS-SIGNATURE)urlmethodbodyheaders)omitextract_paramsimplode_hostnamer   implode_params	urlencodecheck_required_credentialsstrr  r   jsonapiKeyhmacencodesecrethashlibsha256)r   pathrq   r  r   r  r  queryr  r  auths              r   signzbitbank.sign  s   		&$"5"5d";<##DIIe$4S$9:S@8O	!14&&tV44CsT^^E222++-

%ED4<<#%(;(;D&(IIICyy'dll*S0477 NN51E3;&CC%K'D 2"kk %$(IIdkk$.?T[[AY[b[i[i$j	G fdwOOr   httpCodereasonr  r  r  r  c
                    |y | j                  |d      }
| j                  |d      }|
r|s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/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEi dFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdSdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgddddhdidjdkdldm	}| j                  |dn      }| j                  ||do      }| j                  | j                  dp   ||       t        | j                  dqz   | j                  |      z         y )rNsuccessr   10000zURL does not exist10001z/A system error occurred. Please contact support10002z>Invalid JSON format. Please check the contents of transmission1000310005z?A timeout error occurred. Please wait for a while and try againr|   zAPI authentication failedr}   zIllegal API keyr~   zAPI key does not existr   zAPI Nonce does not existr   zAPI signature does not exist20011zTwo-step verification failed20014zSMS authentication failed30001z!Please specify the order quantity30006zPlease specify the order ID30007z!Please specify the order ID array30009zPlease specify the stock30012zPlease specify the order price30013zTrade Please specify either30015zPlease specify the order type30016zPlease specify asset name30019zPlease specify uuid30039z)Please specify the amount to be withdrawn40001zThe order quantity is invalid40006zCount value is invalid40007zEnd time is invalid40008zend_id Value is invalid40009zThe from_id value is invalidr   zThe order ID is invalidr   zThe order ID array is invalid40015zToo many specified orders40017zIncorrect issue namer   zThe order price is invalidr   z%The trading classification is invalid40022zStart date is invalid40024zThe order type is invalidr   zIncorrect asset name40028zuuid is invalid40048z#The amount of withdrawal is illegal50003zsCurrently, self account is in a state where you can not perform the operation you specified. Please contact support50004zbCurrently, self account is temporarily registered. Please try again after registering your account50005z9Currently, self account is locked. Please contact support50006r   z*User identification has not been completedr   zYour order does not existr   zCan not cancel specified order50011zAPI not foundr   z)The number of possessions is insufficient60002z>It exceeds the quantity upper limit of the tender buying order60003z(The specified quantity exceeds the limit60004z-The specified quantity is below the thresholdr   z&The specified price is above the limitz,The specified price is below the lower limitzAWe are unable to accept orders transaction is currently suspendedzGOrder can not be accepted because purchase order is currently suspendedz?We can not accept orders because we are currently unsubscribed z^We are currently temporarily restricting orders to be carried out. Please use the limit order.zPWe are temporarily raising the minimum order quantity system load is now rising.)	600067000170002700037000470005700067000970010rH  Errorr{    )r   r   r   throw_exactly_matched_exceptionr   r   r   r  )r   r  r  r  r  r  r  r   requestHeadersrequestBodyr  r   errorMessagesrH  messages                  r   handle_errorszbitbank.handle_errors  s   ##Hi8x0d=#-=#J=# Y=# J	=#
 Z=# 4=# *=# 1=# 3=# 7=# 7=# 4=# <=# 6=# <=#  3!=#" 9#=#$ 6%=#& 8'=#( 4)=#* .+=#, D-=#. 8/=#0 11=#2 .3=#4 25=#6 77=#8 29=#: 8;=#< 4==#> /?=#@ 5A=#B @C=#D 0E=#F 4G=#H /I=#J *K=#L >M=#N   OO=#P }Q=#R TS=#T TU=#V EW=#X 4Y=#Z 9[=#\ ]=#^ D_=#` Ya=#b Cc=#d He=#f Ag=#h HJJJ\bZyky=#M| ##D&1D&&}dGDG001I4QXY#		(0C CDDr   r  )2__name__
__module____qualname__r   r   r   r   r   dictr   r   r  r   r   r   r   r   r  r  r   r$  listr,  r:  r   rI  rL  r   rW  r
   rh  r   r   floatr	   rm  rr  ru  r|  r  r  rX   r   r   r  r  r  intr  __classcell__)r   s   @r   r   r      s   Sj $& %)$v, %)N8
V 8
t4  6 6 02 /3 /f /" :>b Ms M3 MY M&* *v * *X 6:UW ?3 ?s ?# ?\`af\g ?( )+ 5{ 5n
 
4 
( 26DW[df .I# .Ic .IQT .Ikoptku .I`) )& $& *,( *,X: :$ $v $ $L gksu .3 .i .y .RW .`c .4 37r (&s (&C (&T 26b '.c '.3 '.R /3TXac ? ?3 ?c ?hlmrhs ?0 -1tRV_a ?c ? ?C ?2 79 
# 
6 DHPR '6S '6% '6# '6R(
T (
X (
Q\ (
T# &eBSW P:Hc H3 HS H# HX\ Hdg Hr   r   )!ccxt.base.exchanger   ccxt.abstract.bitbankr   r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr   r    r   r   <module>r     sS    ( -  W  W  W  W  * 0 - . ) * ) 4Uh Ur   