
    !:h                     ,   d dl mZ d dlmZ d dl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 d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dlm!Z! d dlm"Z" d dl#m$Z$ d dl#m%Z% d dl#m&Z& d dl'm(Z(  G d dee      Z)y)    )Exchange)ImplicitAPIN)AnyBalancesCurrencyIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTradeTransactionMarketInterface)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InvalidAddress)InvalidOrder)ExchangeNotAvailable)TRUNCATE)DECIMAL_PLACES)SIGNIFICANT_DIGITS)Precisec                   b    e Zd Zdef fdZd<dededededef
 fdZd	 Z	i fde
e   fd
ZdefdZi fdefdZdi fdededefdZd=dededefdZdi fdedefdZi fdedefdZd=dedefdZdddi fdededede
e   fdZd=dededefdZddi fdededede
e   fdZdi fdede de!de"de#f
d Z$di fd!edefd"Z%d#efd$Z&d=d%edede'fd&Z(dddi fdededede
e'   fd'Z)di fd!edefd(Z*i fd)Z+di fd*ede"d+ede,fd,Z-d=d-ed.e.de,fd/Z/d0 Z0d1 Z1d2d3i ddfd4Z2d5e3d6ed7ed8ed9ed:efd;Z4 xZ5S )>bithumbreturnc                 h   | j                  t        t        |          i ddddddgddd	d
di dd
dd
dddddddddddddddddd
dddddd
dd
ddddi dddd
d dd!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.di d/dd0dd1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=d
d>dd?di d@ddAddBd
dCddDddEddFd
dGddHddId
dJd
dKddLddMddNddOddPdi dQddRddSddTd
dUd
dVd
dWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbd
idcdddedfdgdhdidjdkdldmdndog dpidqg drididsdt| j	                  du      | j	                  du      dvidwt
        dxdddd dddd dddddyddddddddz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dt        t        t        t        t        t        t        t        t        t        t        t        t        dddddddddddd	dddddddiidddddiididdddd      S )Nidr$   nameBithumb	countriesKR	rateLimiti  proThasCORSspotmarginFswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreateReduceOnlyOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchLongShortRatiofetchLongShortRatioHistoryfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistory
fetchOHLCVfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTransferfetchTransfersfetchVolatilityHistoryreduceMarginrepayCrossMarginrepayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawhostnamezbithumb.comurlszOhttps://github.com/user-attachments/assets/c9e0eefb-4777-46b9-8f09-9d7f7c4af82dzhttps://api.{hostname}/publiczhttps://api.{hostname})publicprivatezhttps://www.bithumb.comzhttps://apidocs.bithumb.comz0https://en.bithumb.com/customer_support/info_fee)logoapiwwwdocfeesr   get)zticker/ALL_{quoteId}zticker/{baseId}_{quoteId}zorderbook/ALL_{quoteId}zorderbook/{baseId}_{quoteId}z&transaction_history/{baseId}_{quoteId}znetwork-infozassetsstatus/multichain/ALLz"assetsstatus/multichain/{currency}zwithdraw/minimum/ALLzwithdraw/minimum/{currency}zassetsstatus/ALLzassetsstatus/{baseId}z)candlestick/{baseId}_{quoteId}/{interval}post)zinfo/accountzinfo/balancezinfo/wallet_addresszinfo/tickerzinfo/orderszinfo/user_transactionszinfo/order_detailztrade/placeztrade/cancelztrade/btc_withdrawalztrade/krw_depositztrade/krw_withdrawalztrade/market_buyztrade/market_sellztrade/stop_limitr   tradingz0.0025)makertakerprecisionModefeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyRequiresPricemarketBuyByCostselfTradePreventioniceberg)r   triggerr   symbolRequiredi  )r   limitr   r   r   r   )	sandboxr=   createOrdersfetchMyTradesrk   rh   fetchOrdersfetchClosedOrdersrd   )linearinverse)r0   r2   r3   
exceptions)zBad Request(SSL)zBad Request(Bad Method)zBad Request.(Auth Data)z
Not MemberzInvalid ApikeyzMethod Not Allowed.(Access IP)zMethod Not Allowed.(BTC Adress)zMethod Not Allowed.(Access)zDatabase FailzInvalid Parameter5600zUnknown ErrorzpAfter May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions
timeframes1m3m5m10m30m1h6h12h24h)	r   r   r   r   r   r   r   r   1doptionsquoteCurrencieslimitscostg-C6*?d   minmaxl    rT )BTCKRWcommonCurrenciesArchLootFTC2z	Soda Coin)ALTFTCSOC)deep_extendsuperr$   describeparse_numberr!   r   r   r   r   r   r   )self	__class__s    T/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/bithumb.pyr   zbithumb.describe   s   gt = ? AB
)AB
IAB
 $AB
 	AB

 4AB
  WWW %W 	W
 %W %W UW $UW 'W W tW $UW  W $TW tW  7!W" 9%#W$ (%W& 'W( &u)W* "5+W, +E-W. )%/W0 #E1W2 ,U3W4 '5W6 (7W8 &u9W: ';W< (=W> #E?W@ *5AWB $UCWD uEWF "5GWH *5IWJ +EKWL )%MWN  OWP !%QWR %eSWT $UUWV &uWWX -eYWZ /[W\ "5]W^ #E_W` +EaWb cWd !%eWf "5gWh &uiWj +EkWl dmWn $UoWp +EqWr %esWt "4uWv uwWx #EyWz d{W| !$}W~  W@ 'AWB $UCWD !%EWF *5GWH (IWJ %eKWL )%MWN )%OWP tQWR SWT tUWV  WWX !%YWZ )%[W\ ]W^ #E_W` &uaWb ucWd UeWf  gWh "5iWj EkWl DmWAB
| }AB
~ i=7 14J	AB
R  $  %%SAB
^ !..x8!..x8_AB
j /kAB
n $&+(-,0,1).+06:#(#("'#(	( #($)$)27+0/4#()$, %)%)&+#($)*.	# ',!%#($)*.( $()-#S,\ ##
 ##e6oAB
\ $.+5+>1"52B3A/?!5%/%!. ER]AB
z 
{AB
P ! "'-'*%# !"'*'1%#$QAB
x !"!yAB
 A A	    NmarketIdmarket	delimiter
marketTypec                 0    t         t        |   |||d      S )Nr0   )r   r$   safe_market)r   r   r   r   r   r   s        r   r   zbithumb.safe_market   s    
 Wd/&)VTTr   c                 `    | j                  |t        | j                  |   d   d   t              S )N	precisionamount)decimal_to_precisionr   marketsr    )r   symbolr   s      r   amount_to_precisionzbithumb.amount_to_precision'  s/    ((4<<;OP[;\]e;fhvwwr   c                    K   g }| j                  | j                  di       }t        |j                               }g }t	        dt        |            D ]9  }d||   i}|j                  | j                  | j                  ||                   ; t        j                  |  d{   }t	        dt        |            D ]8  }||   }	|	}
||   }| j                  |d      }| j                  ||	i       }t        |j                               }t	        dt        |            D ]  }||   }|dk(  r||   }| j                  |      }d}t        |t              rt        |      }|dk(  rd}| 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|ddddddddddt        d      t        d      ddddddddddi dd|d
|      }|j                  |        ; |S 7 Xw)aS  
        retrieves data on all markets for bithumb

        https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   r   quoteIdNdatadateTFr'   r   /basequotesettlebaseIdsettleIdtyper0   r1   r2   r3   r4   activecontractr   4)r   pricer   )r   r   r   r   )
r   contractSizeexpiryexpiryDateTimestrike
optionTyper   r   createdinfo)	safe_dictr   listkeysrangelenappendpublicGetTickerALLQuoteIdextendasynciogathersafe_currency_code
isinstancer   int)r   paramsresultr   quotespromisesirequestresultsr   r   responser   	extensioncurrencyIdsj
currencyIdr   r   r   numElementsentrys                         r   fetch_marketszbithumb.fetch_markets*  s     ..7H"Mo**,-q#f+& 	ZA6!9G OOD::4;;wPV;WXY		ZP  11q#f+& @	%A1IEGqzH>>(F3DrBItyy{+K1c+./ 9%(^
'j)..z:fd+"%f+K"a'!&(( -**-*dSj50-* D-* U	-*
 d-* j-* w-* -* F-* D-* e-* E-* e-* e-* f-*  !-*" d#-*$  $$("&*""&"%c(!$S" $(#'%
 $(#'#
 $(#'" !#  $"Y-*Z [-\ e$s9%@	%B E 2s   B!G>#G;$EG>c                    d|i}| j                  |d      }t        | j                  j                               }t	        dt        |            D ]  }||   }| j                         }| j                  |      }| j                  |d      }	| j                  |d|	z         |d<   | j                  |d|	z         |d<   | j                  |d	|	z         |d
<   |||<    | j                  |      S )Nr   r   r   r'   total_totalin_use_used
available_free)r   r   
currenciesr   r   r   accountcurrencysafe_string_lowersafe_stringsafe_balance)
r   r  r  balancescodesr  coder  r  lowerCurrencyIds
             r   parse_balancezbithumb.parse_balance  s    )>>(F3T__))+,q#e*% 	#A8DllnG}}T*H"44XtDO#//(_:TUGG"..x_9TUGFO"..x9WXGFO"F4L	#   ((r   c                    K   | j                          d{    ddi}| j                  | j                  ||             d{   }| j                  |      S 7 B7 w)a  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://apidocs.bithumb.com/v1.2.0/reference/%EB%B3%B4%EC%9C%A0%EC%9E%90%EC%82%B0-%EC%A1%B0%ED%9A%8C

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        Nr  ALL)load_marketsprivatePostInfoBalancer  r'  )r   r  r  r  s       r   fetch_balancezbithumb.fetch_balance  sc      !!!
 44T[[&5QRR!!(++ 	" Ss!   AA,AAAAr   r   c           	      R  K   | j                          d{    | j                  |      }|d   |d   d}|||d<   | j                  | j                  ||             d{   }| j	                  |di       }| j                  |d      }| j                  |||dd	d
d      S 7 7 Bw)ac  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C

        :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   r   r   r   countr   	timestampbidsasksr   quantity)r*  r   publicGetOrderbookBaseIdQuoteIdr  r   safe_integerparse_order_book)	r   r   r   r  r   r  r  r   r0  s	            r   fetch_order_bookzbithumb.fetch_order_book  s      !!!V$X&i(
 $GG==dkk'SY>Z[[* ~~h3%%dK8	$$T69ffgWabb? 	" \s#   B'B#AB'"B%#AB'%B'tickerc                    | j                  |d      }| j                  d |      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  i d|d|d| j	                  |      d	| j                  |d
      d| j                  |d      d| j                  |d      dd d| j                  |d      dd dd d|d|d|dd dd dd dd |||d|      S )Nr   opening_priceclosing_priceunits_traded_24Hacc_trade_value_24Hr   r0  datetimehigh	max_pricelow	min_pricebid	buy_price	bidVolumeask
sell_price	askVolumevwapopencloselastpreviousClosechange
percentageaverage)
baseVolumequoteVolumer   )r5  safe_symbolr!  safe_tickeriso8601)	r   r8  r   r0  r   rJ  rK  rQ  rR  s	            r   parse_tickerzbithumb.parse_ticker  s   & %%ff5	!!$/8  9%%f.@A
&&v/DE !
f!
!
 Y/!
 D$$V[9	!

 4##FK8!
 4##FK8!
 !
 4##FL9!
 !
 D!
 D!
 U!
 E!
 T!
 d!
  $!!
" t#!
$ %&)!
* + 	r   symbolsc           	      l  K   | j                          d{    i }| j                  | j                  di       }t        |j	                               }g }t        dt        |            D ]9  }d||   i}|j                  | j                  | j                  ||                   ; t        j                  |  d{   }	t        dt        |            D ]  }||   }
|	|   }| j                  |di       }| j                  |d      }| j                  |d      }t        |j	                               }t        dt        |            D ]P  }||   }||   }| j                  |      }|dz   |
z   }| j                  |      }||d<   | j!                  ||      ||<   R  | j#                  |d|      S 7 7 w)	aN  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all

        :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   r   r   r   r   r   r   )r*  r   r   r   r   r   r   r   r   r  r  r  r5  omitr  r   rV  filter_by_array_tickers)r   rW  r  r  r   r	  r
  r  r  	responsesr   r  r   r0  tickersr  r  r  r8  r   r   r   s                         r   fetch_tickerszbithumb.fetch_tickers  s     !!!..7H"Mo**,-q#f+& 	ZA6!9G OOD::4;;wPV;WXY		Z
 "..(33	q#f+& #	CA1IE |H, >>(FB7D))$7Iiif-Gw||~.K1c+./ C(^
j)..z:e+))&1!*v!%!2!266!BvC9#	CH ++FHgFF_ 	" 4s#   F4F/B$F4;F2<C4F42F4c                   K   | j                          d{    | j                  |      }|d   |d   d}| j                  | j                  ||             d{   }| j	                  |di       }| j                  ||      S 7 n7 +w)a	  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C

        :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   r.  r   )r*  r   publicGetTickerBaseIdQuoteIdr  r   rV  )r   r   r  r   r  r  r   s          r   fetch_tickerzbithumb.fetch_tickerY  s      !!!V$X&i(
 ::4;;wPV;WXX( ~~h3  v..7 	" Ys"   B	BAB	B*B	B	c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nr                  )r5  safe_number)r   ohlcvr   s      r   parse_ohlcvzbithumb.parse_ohlcv  sn     eQ'UA&UA&UA&UA&UA&
 	
r   r   sincec                 T  K   | j                          d{    | j                  |      }|d   |d   | j                  | j                  ||      d}| j	                  | j                  ||             d{   }| j                  |dg       }	| j                  |	||||      S 7 7 .w)a  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://apidocs.bithumb.com/v1.2.0/reference/candlestick-rest-api

        :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   )r   r   intervalr   )r*  r   r!  r   )publicGetCandlestickBaseIdQuoteIdIntervalr  	safe_listparse_ohlcvs)
r   r   	timeframerj  r   r  r   r  r  r   s
             r   fetch_ohlcvzbithumb.fetch_ohlcv  s      !!!V$X&i((()YO

 GGT[]cHdee0 ~~h3  vy%GGA 	" fs"   B(B$A B(7B&8-B(&B(tradec                    d }| j                  |d      }|i|j                  d      }t        |      }|dkD  r5|d   }|d   }t        |      dk  rd|z   }| j                  |dz   |z         }n| j	                  |dd      }||dz  }d }	| j                  |d	      }
|
d
k(  rdnd}
| j                  |d      }| j                  d |      }| j                  |d      }| j                  | j                  |dd            }| j                  |d      }d }| j                  |d      }|(| j                  |d      }| j                  |      }||d}| j                  |||| j                  |      |d   d |	|
d ||||d|      S )Ntransaction_date rb  r      0MbP?ibr   rF  sellbuycont_nor   units_tradedunitsr  feefee_currency)r   r  r   )r'   r   r0  r>  r   orderr   sidetakerOrMakerr   r   r   r~  )r!  splitr   	parse8601safe_integer_productr   fix_comma_numbersafe_string_2common_currency_code
safe_traderU  )r   rr  r   r0  transactionDatetimepartsnumPartstransactionDatetransactionTimer   r  r'   priceStringamountString
costStringr~  feeCostStringfeeCurrencyIdfeeCurrencyCodes                      r   parse_tradezbithumb.parse_trade  s   0 	"..u6HI*'--c2E5zH!|"'("'('!+&)O&;O NN?S+@?+RS	 55e=OQVW	 $Iv.%-veeY/!!$/&&ug6,,T-?-?~W^-_`%%eW5
((6$ ,,UNCM"77FO%+C "Y/X&  " 
  	r   c                 (  K   | j                          d{    | j                  |      }|d   |d   d}|||d<   | j                  | j                  ||             d{   }| j	                  |dg       }| j                  ||||      S 7 w7 -w)aM  
        get the list of most recent trades for a particular symbol

        https://apidocs.bithumb.com/v1.2.0/reference/%EC%B5%9C%EA%B7%BC-%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD

        :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*  r   (publicGetTransactionHistoryBaseIdQuoteIdr  rn  parse_trades	r   r   rj  r   r  r   r  r  r   s	            r   fetch_tradeszbithumb.fetch_trades  s      !!!V$X&i(
 $GGFFt{{SZ\bGcdd ~~h3  vue<<1 	" es"   BBAB"B#,BBr   r  r   r   c                   K   | j                          d{    | j                  |      }|d   |d   |d}d}	|dk(  r||d<   |dk(  rd	nd
|d<   nd| j                  |      z   }	 t        | |	      | j	                  ||             d{   }
| j                  |
d      }|t        | j                  dz         | j                  |
||||d|      S 7 7 Jw)a  
        create a trade order

        https://apidocs.bithumb.com/v1.2.0/reference/%EC%A7%80%EC%A0%95%EA%B0%80-%EC%A3%BC%EB%AC%B8%ED%95%98%EA%B8%B0
        https://apidocs.bithumb.com/v1.2.0/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EC%88%98%ED%95%98%EA%B8%B0
        https://apidocs.bithumb.com/v1.2.0/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EB%8F%84%ED%95%98%EA%B8%B0

        :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   )order_currencypayment_currencyr}  privatePostTradePlacer   r   rz  rC  rF  r   privatePostTradeMarketorder_idz) createOrder() did not return an order id)r   r   r   r  r'   )	r*  r   
capitalizegetattrr  r!  r   r'   
safe_order)r   r   r   r  r   r   r  r   r  methodr  r'   s               r   create_orderzbithumb.create_order1  s       !!!V$$Tl &w

 )7?$GG(,eEGFO-0EEF.v.t{{7F/KLLh
3:tww)TTUU 
  	# 	" Ms#   CCA3C
CA	CCr'   c                 p  K   |t        | j                  dz         | j                          d{    | j                  |      }|d|d   |d   d}| j	                  | j                  ||             d{   }| j                  |d      }| j                  | j                  |d|i      |      S 7 7 <w)	a  
        fetches information on an order made by the user

        https://apidocs.bithumb.com/v1.2.0/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%83%81%EC%84%B8-%EC%A1%B0%ED%9A%8C

        :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>`
        Nz( fetchOrder() requires a symbol argumentrb  r   r   )r  r/  r  r  r   r  )r   r'   r*  r   privatePostInfoOrderDetailr  r   parse_order)r   r'   r   r  r   r  r  r   s           r   fetch_orderzbithumb.fetch_orderZ  s      >#DGG.X$XYY!!!V$$Vn &w	
 88Wf9UVV8 ~~h/D:r2B CVLLK 	" Ws"   .B6B2AB67B48;B64B6statusc                 4    dddd}| j                  |||      S )NrJ  closedcanceled)Pending	CompletedCancel)r!  )r   r  statusess      r   parse_order_statuszbithumb.parse_order_status  s)    ! 

 &&99r   r  c                 ~   | j                  |dd      }| j                  |dd      }|dk(  rdnd}| j                  | j                  |d            }| j                  |d	d
      }d}t	        j
                  |d      rd}| j                  | j                  |dd            }	| j                  | j                  |d            }
|
|dk(  rd}
n|dk7  r|	}
d }| j                  |d      }| j                  |d      }| j                  |      }| j                  |      }|
||dz   |z   }|| j                  d |      }|d   }| j                  |d      }| j                  |dg       }| j                  i d|d|dd d|d| j                  |      dd d|d|dd d d d|d
|d!d d"|	d#d d$d d%d |
|d |d&|      S )'N
order_daterx  r   r  rC  rz  ry  order_statusorder_pricer   r   rw  r   	order_qtyr}  units_remainingr  r  r  r  r   r   r  r   r   r'   clientOrderIdr0  r>  lastTradeTimestampr   postOnlyr   r   r   rP  filled)	remainingr  r~  trades)r  r  r  r!  r"   string_equalsr  r  r   rn  r  rU  )r   r  r   r0  sidePropertyr  r  r   r   r   r  r   r   r   r   r   r'   	rawTradess                     r   r  zbithumb.parse_order  s   R --e\5I	))%@%.uV(()9)9%)PQ""5-A  ,D&&t'9'9%g'VW))$*:*:5BS*TU	!	:%"	!!%)9:""5*<=&&v.''05#4CZ%'F>%%dF3FH%FeZ0NN5*b9	  
E 
" 
 T 
 	 

 Y/ 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D 
 f 
 D 
  t! 
" d# 
$ #+ 
, - 	r   c                 f  K   |t        | j                  dz         | j                          d{    | j                  |      }|d}||d   |d   d}|||d<   | j	                  | j                  ||             d{   }| j                  |dg       }| j                  ||||      S 7 |7 -w)	aH  
        fetch all unfilled currently open orders

        https://apidocs.bithumb.com/v1.2.0/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of open order structures to retrieve
        :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>`
        Nz- fetchOpenOrders() requires a symbol argumentr   r   r   )r/  r  r  afterr   )r   r'   r*  r   privatePostInfoOrdersr  rn  parse_ordersr  s	            r   fetch_open_orderszbithumb.fetch_open_orders  s      >#DGG.]$]^^!!!V$=E$Vn &w

 $GG33DKK4PQQ$ ~~h3  vue<<= 	" Rs"   .B1B-AB1B/,B1/B1c                 r  K   |t        | j                  dz         d|v }|st        | j                  dz         | j                  |      }|d   dk(  rdnd}| j                  |ddg      }|||d	   |d
   d}| j	                  | j                  ||             d{   }| j                  d|i      S 7 w)a  
        cancels an open order

        https://apidocs.bithumb.com/v1.2.0/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C%ED%95%98%EA%B8%B0

        :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>`
        Nz) cancelOrder() requires a symbol argumentr  z7 cancelOrder() requires a `side` parameter(sell or buy)rz  rC  rF  r  r   r   )r  r   r  r  r   )r   r'   r   rY  privatePostTradeCancelr  r  )	r   r'   r   r  side_in_paramsr   r  r  r  s	            r   cancel_orderzbithumb.cancel_order   s      >#DGG.Y$YZZ F*#DGG.g$ghhV$50uu6FJ#78 $Vn &w	
 44T[[&5QRR H 
  	 Ss   BB7B5B7c                 ~   K   d|d   i}| j                  |d   |d   | j                  ||             d {   S 7 w)Nr  r'   r   )r  r  )r   r  r  r  s       r   cancel_unified_orderzbithumb.cancel_unified_orderD  sH     E&M
 &&uT{E(OT[[QXZ`Eabbbbs   4=;=r%  addressc                   K   | j                  ||      \  }}| j                  |       | j                          d{    | j                  |      }|||d   d}|dk(  s|dk(  s|dk(  s
|dk(  s|dk(  r;| j	                  |d	      }| |t        | j                  d
z   |z   dz         |||d	<   | j                  | j                  ||             d{   }	| j                  |	|      S 7 7 w)a  
        make a withdrawal

        https://apidocs.bithumb.com/v1.2.0/reference/%EC%BD%94%EC%9D%B8-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0-%EA%B0%9C%EC%9D%B8

        :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  XRPXMREOSSTEEMTONdestinationru  zA withdraw() requires a tag argument or an extra destination param)
handle_withdraw_tag_and_paramscheck_addressr*  r  r!  r   r'   privatePostTradeBtcWithdrawalr  parse_transaction)
r   r%  r   r  tagr  r  r  r  r  s
             r   r   zbithumb.withdrawJ  s     99#vFV7#!!!==& 

 5=DEMTU]dgoQUY^Q^**6=AK+"5'#(<  @C  )C  D  D),&;;DKKQW<XYY %%h99# 	" Zs"   :C.C*BC.C,C.,C.transactionr  c                     | 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 d |dS )Nr'   txidr0  r>  networkaddressFromr  	addressTor   r   r  r%  r  updatedtagFromr  tagTocomment)internalr~  r   )safe_currency)r   r  r  s      r   r  zbithumb.parse_transactionl  s     %%dH5
$
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 	
r   c                     |y |}|j                  d      dkD  r'|j                  dd      }|j                  d      dkD  r'|S )N, )findreplace)r   	numberStrfinalNumberStrs      r   r  zbithumb.fix_comma_number  sP    "!!#&++33C<N !!#&+r   c                 "    | j                         S N)milliseconds)r   s    r   noncezbithumb.nonce  s      ""r   r   GETc                    d| j                  ||      z   }| j                  | j                  d   |         |z   }| j                  || j	                  |            }	|dk(  r|	r|d| j                  |	      z   z  }n| j                          | j                  | j                  d|i|	            }t        | j                               }
|dz   |z   dz   |
z   }| j                  | j                  |      | j                  | j                        t        j                        }| j                  |      }dd| j                   ||
d	}||||d
S )Nr   r   r   ?endpoint zapplication/jsonz!application/x-www-form-urlencoded)AcceptzContent-TypezApi-KeyzApi-Signz	Api-Nonce)urlr  bodyheaders)implode_paramsimplode_hostnamer   rY  extract_params	urlencodecheck_required_credentialsr  strr  hmacencodesecrethashlibsha512string_to_base64apiKey)r   pathr   r  r  r  r  r  r  queryr  auth	signaturesignature64s                 r   signzbithumb.sign  s<   ,,T6::##DIIe$4S$9:XE		&$"5"5d";<(?sT^^E222++->>$++H/# D 

%Ed?T)D058D		$++d"3T[[5Mw~~^I//	:K, C;;'"G fdwOOr   httpCodereasonr  r  r  r  c
                 $   |y d|v r| j                  |d      }
| j                  |d      }|
c|
dk(  ry |dk(  ry | j                  dz   |z   }| j                  | j                  |
|       | j                  | j                  ||       t	        |      y )Nr  message0000u8   거래 진행중인 내역이 존재하지 않습니다.ru  )r!  r'   throw_exactly_matched_exceptionr   r   )r   r  r  r  r  r  r  r  requestHeadersrequestBodyr  r  feedbacks                r   handle_errorszbithumb.handle_errors  s    x %%h9F&&x;G!V# ZZ77S=7244T__fhW44T__gxX#H--r   )NNNNr  )6__name__
__module____qualname__r   r   r   r	   r   r   r   r   r  r   r'  r,  r   r   r   r7  dictr   rV  r   r   r]  r`  r   ri  rq  r   r  r  r   r   floatr
   r  r  r  r   r  r  r  r  r   r   r   r  r  r  r  r  r  __classcell__)r   s   @r   r$   r$      s   B# BHUC U URU Ujm U  zI Ux *, wV wr) ) *, , ,  @DB *cS *c *cS\ *cX.4 . .6 .` 6:" 9G7 9G 9Gv 68 %/ %/F %/N
 
4 
( 8<$]ajl -H -HC -HWZ -Hquvzq{ -H^F Fv F FP <@d[] $= $=S $= $=bfglbm $=L mqy{ ' 'I 'Y 'X] 'fi 'R 8<B 2MC 2M 2Mh: :Z Zv Z Zx 59tZ^gi ,=c ,= ,=TW ,=nrsxny ,=\ 9=R "S "# "H 8: c JNVX  :3  :  :  :]h  :D
T 
X 
Q\ 
<# &eBSW P2c 3 S # X\ dg r   r$   )* ccxt.async_support.base.exchanger   ccxt.abstract.bithumbr   r  r  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   r   r   r   r   r   r   r   ccxt.base.decimal_to_precisionr   r    r!   ccxt.base.preciser"   r$    r   r   <module>r&     sh    6 -   r  r  r  r  r  * 0 - . ' + ) 1 3 9 = %hh hr   