
    ei                     4   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)dS )    )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                       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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&e'fd*Z+di fd+ede"d,ed-ede,f
d.Z-d?d/ed0e.de,fd1Z/d2 Z0d3 Z1d4d5i ddfd6Z2d7e3d8ed9ed:ed;ed<efd=Z4 xZ5S )@bithumbreturnc                    |                      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dd
dbdcdddedfdgdhdidjdkdldmdndog dpidqg drididsdt|                     du          |                     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fetchCurrencies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fetchMyTradesrl   ri   fetchOrdersfetchClosedOrdersre   )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    X/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/bithumb.pyr   zbithumb.describe   sU   gt 4 4 = = ? ? BB
)BB
IBB
 $BB
 	BB

 4BB
  XXX %X 	X
 %X %X UX $UX 'X X tX $UX  X $TX tX  7!X" 9%#X X$ (%X& 'X( &u)X* "5+X, +E-X. )%/X0 #E1X2 ,U3X4 '5X6 (7X8 "59X: &u;X< '=X> (?X@ #EAXB *5CXD $UEX X XF uGXH "5IXJ *5KXL +EMXN )%OXP  QXR !%SXT %eUXV $UWXX &uYXZ -e[X\ /]X^ "5_X` #EaXb +EcXd eXf !%gX X Xh "5iXj &ukXl +EmXn doXp $UqXr +EsXt %euXv "4wXx uyXz #E{X| d}X~ !$X@  AXB 'CXD $UEXF !%GXH *5IX X XJ (KXL %eMXN )%OXP )%QXR tSXT UXV tWXX  YXZ !%[X\ )%]X^ _X` #EaXb &ucXd ueXf UgXh  iXj "5kX Xl " oX X XBB
~ BB
@ i=7  14J	 	ABB
T    $    %% %UBB
` !..x88!..x88 aBB
l /mBB
p $&+(-,0,1).+06:#(#("'#(	( ( #($)$)27+0/4#()$ $, %)%)&+#($)*.	# # ',!%#($)*.( ( $()-#S, ,\ ## 
 ## e6 6qBB
^ $.+5+>1"52B3A/?!5%/%!. ER _BB
| 
 
}BB
R ! "'-'*% %# !"'*'1% %#$ $SBB
z !"! !{BB
 B B B	    NmarketIdmarket	delimiter
marketTypec                 Z    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TTr   c                 t    |                      |t          | j        |         d         d         t                    S )N	precisionamount)decimal_to_precisionr   marketsr    )r   symbolr   s      r   amount_to_precisionzbithumb.amount_to_precision(  s0    ((4<;OP[;\]e;fhvwwwr   c                   K   g }|                      | j        di           }t          |                                          }g }t	          dt          |                    D ]H}d||         i}|                    |                     |                     ||                               It          j
        |  d{V }t	          dt          |                    D ]y}||         }	|	}
||         }|                      |d          }|                      ||	i           }t          |                                          }t	          dt          |                    D ]}||         }|dk    r||         }|                     |          }d}t          |t                    rt          |          }|dk    rd}|                     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
|          }|                    |           {|S )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+  sj      ..7H"MMo**,,--q#f++&& 	Z 	ZA6!9G OOD::4;;wPV;W;WXXYYYYH  1111111q#f++&& @	% @	%A1IEGqzH>>(F33DrBBItyy{{++K1c+..// 9% 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%t r   c                 ,   d|i}|                      |d          }t          | j                                                  }t	          dt          |                    D ]}||         }|                                 }|                     |          }|                     |d          }	| 	                    |d|	z             |d<   | 	                    |d|	z             |d<   | 	                    |d	|	z             |d
<   |||<   | 
                    |          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3T_))++,,q#e**%% 	# 	#A8DllnnG}}T**H"44XtDDO#//(_:TUUGG"..x_9TUUGFO"..x9WXXGFO"F4LL  (((r   c                    K   |                                   d{V  ddi}|                     |                     ||                     d{V }|                     |          S )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  s       !!!!!!!!!
 44T[[&5Q5QRRRRRRRR!!(+++r   r   r   c           	        K   |                                   d{V  |                     |          }|d         |d         d}|||d<   |                     |                     ||                     d{V }|                     |di           }|                     |d          }|                     |||dd	d
d          S )aa  
        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   r1  s	            r   fetch_order_bookzbithumb.fetch_order_book  s       !!!!!!!!!V$$X&i(
 
 $GG==dkk'SY>Z>Z[[[[[[[[* ~~h33%%dK88	$$T69ffgWabbbr   tickerc                 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d dd |||d|          S )Nr   opening_priceclosing_priceunits_traded_24Hacc_trade_value_24Hr   r1  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   )r6  safe_symbolr"  safe_tickeriso8601)	r   r9  r   r1  r   rK  rL  rR  rS  s	            r   parse_tickerzbithumb.parse_ticker  s   & %%ff55	!!$//88  99%%f.@AA
&&v/DEE !
f!
!
 Y//!
 D$$V[99	!

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

        https://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   rW  )r   r   r  r   r  r  r   s          r   fetch_tickerzbithumb.fetch_tickerZ  s       !!!!!!!!!V$$X&i(
 
 ::4;;wPV;W;WXXXXXXXX( ~~h33  v...r   c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Nr                  )r6  safe_number)r   ohlcvr   s      r   parse_ohlcvzbithumb.parse_ohlcv  s     eQ''UA&&UA&&UA&&UA&&UA&&
 	
r   r   	timeframesincec                 z  K   |                                   d{V  |                     |          }|d         |d         |                     | j        ||          d}|                     |                     ||                     d{V }|                     |dg           }	|                     |	||||          S )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   rk  rl  r   r  r   r  r  r   s
             r   fetch_ohlcvzbithumb.fetch_ohlcv  s       !!!!!!!!!V$$X&i((()YOO
 

 GGT[]cHdHdeeeeeeee0 ~~h33  vy%GGGr   tradec                    d }|                      |d          }||                    d          }t          |          }|dk    rD|d         }|d         }t          |          dk     rd|z   }|                     |dz   |z             }n|                     |dd          }||dz  }d }	|                      |d	          }
|
d
k    rdnd}
|                      |d          }|                     d |          }|                      |d          }|                     |                     |dd                    }|                      |d          }d }|                      |d          }|0|                      |d          }|                     |          }||d}| 	                    |||| 
                    |          |d         d |	|
d ||||d|          S )Ntransaction_date rc  r      0MbP?ibr   rG  sellbuycont_nor   units_tradedunitsr  feefee_currency)r   r   r   )r'   r   r1  r?  r   orderr   sidetakerOrMakerr   r   r   r  )r"  splitr   	parse8601safe_integer_productr   fix_comma_numbersafe_string_2common_currency_code
safe_traderV  )r   rs  r   r1  transactionDatetimepartsnumPartstransactionDatetransactionTimer   r  r'   priceStringamountString
costStringr  feeCostStringfeeCurrencyIdfeeCurrencyCodes                      r   parse_tradezbithumb.parse_trade  s    0 	"..u6HII*'--c22E5zzH!||"'("'(''!++&)O&;O NN?S+@?+RSS		 55e=OQVWW	 $Iv..%--vveeY//!!$//&&ug66,,T-?-?~W^-_-_``%%eW55
((66$ ,,UNCCM"77FFO%+ C "Y//X&  " 
  
   	r   c                 P  K   |                                   d{V  |                     |          }|d         |d         d}|||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )aK  
        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/  r0  r   )r+  r   (publicGetTransactionHistoryBaseIdQuoteIdr  rp  parse_trades	r   r   rl  r   r  r   r  r  r   s	            r   fetch_tradeszbithumb.fetch_trades  s       !!!!!!!!!V$$X&i(
 
 $GGFFt{{SZ\bGcGcdddddddd ~~h33  vue<<<r   r   r  r   r   c                   K   |                                   d{V  |                     |          }|d         |d         |d}d}	|dk    r||d<   |dk    rd	nd
|d<   nd|                     |          z   }	 t          | |	          |                     ||                     d{V }
|                     |
d          }|t          | j        dz             |                     |
||||d|          S )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   r{  rD  rG  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_order2  s>       !!!!!!!!!V$$$Tl &w
 

 )7??$GG(,eeEGFOO-0E0EEF.v..t{{7F/K/KLLLLLLLLh
33:tw)TTUUU 
  
   	r   r'   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d|d         |d         d}|                     |                     ||                     d{V }|                     |d          }|                     |                     |d|i          |          S )	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 argumentrc  r   r   )r  r0  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_order[  s       >#DG.X$XYYY!!!!!!!!!V$$$Vn &w	
 
 88Wf9U9UVVVVVVVV8 ~~h//D:r2B C CVLLLr   statusc                 <    dddd}|                      |||          S )NrK  closedcanceled)Pending	CompletedCancel)r"  )r   r  statusess      r   parse_order_statuszbithumb.parse_order_status  s1    ! 
 

 &&999r   r  c                    |                      |dd          }|                     |dd          }|dk    rdnd}|                     |                     |d                    }|                     |d	d
          }d}t	          j        |d          rd}|                     |                     |dd                    }	|                     |                     |d                    }
|
|dk    rd}
n|dk    r|	}
d }|                     |d          }|                     |d          }|                     |          }|                     |          }|
||dz   |z   }||                     d |          }|d         }|                     |d          }| 	                    |dg           }| 
                    i d|d|dd d|d|                     |          dd d|d|dd d d d|d
|d!d d"|	d#d d$d d%d |
|d |d&|          S )'N
order_datery  r   r  rD  r{  rz  order_statusorder_pricer   r   rx  r   	order_qtyr~  units_remainingr  r  r  r  r   r   r  r   r   r'   clientOrderIdr1  r?  lastTradeTimestampr   postOnlyr   r   r   rQ  filled)	remainingr  r  trades)r  r  r  r"  r"   string_equalsr  r  r   rp  r  rV  )r   r  r   r1  sidePropertyr  r  r   r   r   r  r   r   r   r   r   r'   	rawTradess                     r   r  zbithumb.parse_order  s   R --e\5II	))%@@%..uuV(()9)9%)P)PQQ""5-AA ,, 	D&&t'9'9%g'V'VWW))$*:*:5BS*T*TUU	!!		:%%"	!!%)9::""5*<==&&v..''005#4CZ%'F>%%dF33FH%FeZ00NN5*b99	  
E 
" 
 T 
 	 

 Y// 
 !$ 
 f 
 D 
 4 
  
 D 
 U 
 D 
 f 
 D 
  t! 
" d# 
$ #+ 
  
  
, -  	r   c                   K   |t          | j        dz             |                                  d{V  |                     |          }|d}||d         |d         d}|||d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )	aF  
        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   )r0  r  r  afterr   )r   r'   r+  r   privatePostInfoOrdersr  rp  parse_ordersr  s	            r   fetch_open_orderszbithumb.fetch_open_orders  s       >#DG.]$]^^^!!!!!!!!!V$$=E$Vn &w
 

 $GG33DKK4P4PQQQQQQQQ$ ~~h33  vue<<<r   c                   K   |t          | j        dz             d|v }|st          | j        dz             |                     |          }|d         dk    rdnd}|                     |ddg          }|||d	         |d
         d}|                     |                     ||                     d{V }|                     d|i          S )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)r{  rD  rG  r   r   r   )r  r   r  r  r   )r   r'   r   rZ  privatePostTradeCancelr  r  )	r   r'   r   r  side_in_paramsr   r  r  r  s	            r   cancel_orderzbithumb.cancel_order!  s      >#DG.Y$YZZZ F* 	i#DG.g$ghhhV$$500uuu6FJ#788 $Vn &w	
 
 44T[[&5Q5QRRRRRRRR H 
   	r   c                    K   d|d         i}|                      |d         |d         |                     ||                     d {V S )Nr  r'   r   )r  r  )r   r  r  r  s       r   cancel_unified_orderzbithumb.cancel_unified_orderE  sZ      E&M
 &&uT{E(OT[[QXZ`EaEabbbbbbbbbr   r&  addresstagc                   K   |                      ||          \  }}|                     |           |                                  d{V  |                     |          }|||d         d}|dk    s|dk    s|dk    s|dk    s|dk    r>|                     |d	          }||t          | j        d
z   |z   dz             |||d	<   |                     |                     ||                     d{V }	| 	                    |	|          S )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destinationrv  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  r  r  r   r  r  r  s
             r   r   zbithumb.withdrawK  s[      99#vFFV7###!!!!!!!!!==&& 
 

 5==DEMMTU]]dgooQUY^Q^Q^**6=AAK+"5'#(<  @C  )C  D  D  D),&;;DKKQW<X<XYYYYYYYY %%h999r   transactionr   c                     |                      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'   txidr1  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_transactionm  s
    %%dH55
$
D
 
 	

 t
 4
 t
 
 d
 D
 (
 d
 t
 t
 4
  T!
" t#
$ )
 
 
 	
r   c                     |d S |}|                     d          dk    r/|                    dd          }|                     d          dk    /|S )N, )findreplace)r   	numberStrfinalNumberStrs      r   r  zbithumb.fix_comma_number  sa    4"!!#&&+++33C<<N !!#&&++r   c                 *    |                                  S N)milliseconds)r   s    r   noncezbithumb.nonce  s      """r   r   GETc                    d|                      ||          z   }|                     | j        d         |                   |z   }|                     ||                     |                    }	|dk    r|	r|d|                     |	          z   z  }n|                                  |                     |                     d|i|	                    }t          | 	                                          }
|dz   |z   dz   |
z   }| 
                    |                     |          |                     | j                  t          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   rZ  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  st   ,,T6:::##DIe$4S$9::XE		&$"5"5d";";<<(?? 3sT^^E2222++--->>$++H/# #  D 

%%Ed?T)D058D		$++d"3"3T[[5M5Mw~^^I//	::K, C;'" G fdwOOOr   httpCodereasonr  r  r  r  c
                 :   |d S d|v r|                      |d          }
|                      |d          }|
d|
dk    rd S |dk    rd S | j        dz   |z   }|                     | j        |
|           |                     | j        ||           t	          |          d S )Nr  message0000u8   거래 진행중인 내역이 존재하지 않습니다.rv  )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    4x %%h99F&&x;;G!V##4 ZZZ47S=7244T_fhWWW44T_gxXXX#H---tr   )NNNNr  )6__name__
__module____qualname__r   r   r   r	   r   r   r   r   r  r   r(  r-  r  r   r   r8  dictr   rW  r   r   r^  ra  r   rj  rr  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$      sx       C# C C C C C CJU UC U URU Ujm U  zI U U U U U Ux x x *, w wV w w w wr) ) ) ) ) *, , , , , , ,  @DB *c *cS *c *cS\ *c *c *c *cX. .4 . .6 . . . .` 6:" 9G 9G7 9G 9G 9G 9G 9Gv 68 %/ %/ %/F %/ %/ %/ %/N
 
 
4 
 
 
 
( ?CQUdhqs -H -H -H -H3 -H^a -Hx|  ~B  yC -H -H -H -H^F F Fv F F F F FP <@d[] $= $= $=S $= $=bfglbm $= $= $= $=L mqy{ ' ' 'I 'Y 'X] 'fi ' ' ' 'R 8<B 2M 2MC 2M 2M 2M 2M 2Mh: : : : :Z Z Zv Z Z Z Z Zx 59tZ^gi ,= ,=c ,= ,=TW ,=nrsxny ,= ,= ,= ,=\ 9=R " "S "# " " " "H ?A c c c c c c QU]_  :  :3  :  :  :#  :do  :  :  :  :D
 
T 
X 
Q\ 
 
 
 
<  # # # &eBSW P P P 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'     sK   6 5 5 5 5 5 - - - - - -   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  r  r  r  r  r  r  r  r  r  r  r  r  r       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' + + + + + + ) ) ) ) ) ) 1 1 1 1 1 1 3 3 3 3 3 3 9 9 9 9 9 9 = = = = = = % % % % % %i i i i ih i i i i ir   