
    i                         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!dS )    )Exchange)ImplicitAPIN)Balances
CurrenciesIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickersTrade)List)ExchangeError)ArgumentsRequired)
BadRequest)	BadSymbol)OrderNotFound)OnMaintenance)	TICK_SIZE)Precisec                       e Zd Z fdZi fdef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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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 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di fdeded	efdZ$di fdedefdZ%di fdee         fd Z&d!d"i ddfd#Z'd$ Z( xZ)S )&coinonec                 |   |                      t          t          |                                           dddg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	d+dd,d	d-dd.d	d/d	d0d	d1dd2dd3dd4dd5dd6d	d7d	d8d	d9dd:dddd	d;d<d=d>d?d@dAdBdCdDd	d	dEdFg dGidFg dHidIg dJidIg dKidIg dLidMdNdd	dOdOdPit          t
          t          t          t          dQdRdSidT          S )UNr   CoinOneKRi  v2FCORSspotTmarginswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchLeveragefetchLeverageTiersfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTradesfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchPositionfetchPositionModefetchPositionsfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickersfetchTradesreduceMarginsetLeverage)setMarginModesetPositionModewszchttps://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpgzhttps://api.coinone.co.krz#https://api.coinone.co.kr/public/v2zhttps://api.coinone.co.kr/v2zhttps://api.coinone.co.kr/v2.1)restv2Public	v2Privatev2_1Privatezhttps://coinone.co.krzhttps://doc.coinone.co.kr)logoapiwwwdoc)apiKeysecretget)	orderbookticker
ticker_utctrades)range_unitszmarkets/{quote_currency}z*markets/{quote_currency}/{target_currency}z,orderbook/{quote_currency}/{target_currency}z)trades/{quote_currency}/{target_currency}zticker_new/{quote_currency}z-ticker_new/{quote_currency}/{target_currency}zticker_utc_new/{quote_currency}z1ticker_utc_new/{quote_currency}/{target_currency}
currencieszcurrencies/{currency}z(chart/{quote_currency}/{target_currency}post)account/deposit_addresszaccount/btc_deposit_addressaccount/balancezaccount/daily_balanceaccount/user_infoaccount/virtual_accountzorder/cancel_allorder/cancelorder/limit_buyorder/limit_sellorder/complete_ordersorder/limit_orderszorder/order_infotransaction/auth_numbertransaction/historytransaction/krw/historytransaction/btcztransaction/coin)rk   rj   rl   rm   rn   ro   rp   rr   rq   zorder/query_orderrs   rv   rt   ru   )zaccount/balance/allrk   zaccount/trade_feez4account/trade_fee/{quote_currency}/{target_currency}zorder/limitrn   zorder/cancel/allzorder/open_orderszorder/open_orders/allrq   zorder/complete_orders/allz
order/inforu   ztransaction/coin/historyz!transaction/coin/withdrawal/limit)publicrY   privaterZ   r[   tradinggMb`?)	tierBased
percentagetakermaker)405104108107SOCz	Soda Coin)idname	countries	rateLimitversionprohasurlsrequiredCredentialsr]   feesprecisionMode
exceptionscommonCurrencies)	deep_extendsuperr   describer   r   r   r   r   )self	__class__s    R/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/ccxt/coinone.pyr   zcoinone.describe   s)   gt 4 4 = = ? ?777 %7 	7
 %7 %7 U7 t7 $U7  7 $U7 t7 (7 '7 (7  "5!7" #7 7$ +E%7& )%'7( $U)7* '+7, (-7. "4/70 (172 &u374 #E576 *5778 $U97: "5;7< *5=7> +E?7@  A7B %eC7D "5E7 7 7F G7H !%I7J  K7L +EM7N "4O7P dQ7R !$S7T  U7V $UW7X !%Y7Z %e[7\ )%]7^ t_7` a7b tc7d e7f ug7 7h "'#(m7 7 7r ~7 E!?#C	  /2
 
 $ $        "    .    &     CT Tl !&"&""	  '$$ !	  {!gvB
 vB
 v v v	    returnc                    |                      |          }i }|                     |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     |          }	|                     |dd          }
|                     |dd          }|
dk    }|dk    }||	|||o||||                     |d	          |                     |                     |                     |d
                              ddd|                     |d          dddi d||	<   |S )a  
        fetches all available currencies on an exchange
        :see: https://docs.coinone.co.kr/reference/currencies
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        rh   r   symbolr   withdraw_status deposit_statusnormalwithdrawal_feemax_precisionNminmaxwithdrawal_min_amount)amountwithdraw)r   codeinfor   activedepositr   fee	precisionlimitsnetworks)	v2PublicGetCurrencies
safe_valuerangelensafe_stringsafe_currency_codesafe_numberparse_numberparse_precision)r   paramsresponseresultrh   ientryr   r   r   withdrawStatusdepositStatusisWithdrawEnabledisDepositEnableds                 r   fetch_currencieszcoinone.fetch_currencies   s    --f55* __X|R@@
q#j//** 	 	AqME!!%22B##E622D**2..D!--e5FKKN ,,U4DbIIM .( :,8+@0@+-''/?@@!..t/C/CDDTDTUZ\kDlDl/m/mnn  $# 
  $//7NOO#! !	 	 ) F4LL, r   c                    ddi}|                      |          }|                     |dg           }g }t          dt          |                    D ].}|                     ||          }|                     |d          }|                     |d          }	|                     |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d|                     d          |                     d          |                     d          ddddddddddddddd|d 
           0|S )!a  
        retrieves data on all markets for coinone
        :see: https://docs.coinone.co.kr/v1.0/reference/tickers
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        quote_currencyKRWtickersr   r   target_currencyr   /basequotesettleNbaseIdquoteIdsettleIdtyper#   Tr$   Fr%   r&   r'   r   contractlinearz1e-4z1e-8)r   pricecostr   )leverager   r   r   )
inversecontractSizeexpiryexpiryDatetimestrike
optionTyper   r   createdr   )	!v2PublicGetTickerNewQuoteCurrencyr   r   r   r   safe_string_upperr   appendr   )r   r   requestr   r   r   r   r   r   r   r   r   r   s                r   fetch_marketszcoinone.fetch_markets  s    e
 99'BBD //(Ir::q#g,,'' 8	 8	AOOGQ//E!!%..B++E3DEEF,,U4DEEG**622D++G44EMM 1b1$*u,1 1 	1
 $1 &1 71 D1 1 1 %1 1 %1 %1 $1  E!1" $#1$   $"&""//77!..v66 --f55   $#! !
  $# 
  $# 
  $#  $  a1 1 1 1 1 1 1d r   c                    d|i}|                      |g d          }t          |                                          }t          dt	          |                    D ]r}||         }||         }|                     |          }|                                 }	|                     |d          |	d<   |                     |d          |	d<   |	||<   s|                     |          S )Nr   )	errorCoder   normalWalletsr   availfreebalancetotal)	omitlistkeysr   r   r   accountr   safe_balance)
r   r   r   balancescurrencyIdsr   
currencyIdr   r   r   s
             r   parse_balancezcoinone.parse_balancex  s    (#99X (
 (
 (
  
 8==??++q#k**++ 	# 	#A$QJz*G**:66DllnnG"..w@@GFO#//CCGG"F4LL  (((r   c                 ~    |                                   |                     |          }|                     |          S )a]  
        query for balance and get the amount of funds available for trading or funds locked in orders
        :see: https://docs.coinone.co.kr/v1.0/reference/v21
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        )load_marketsv2PrivatePostAccountBalancer   )r   r   r   s      r   fetch_balancezcoinone.fetch_balance  s=     	33F;;!!(+++r   Nr   limitc           	      D   |                                   |                     |          }|d         |d         d}|||d<   |                     |                     ||                    }|                     |d          }|                     ||d         |dd	d
d          S )a5  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :see: https://docs.coinone.co.kr/v1.0/reference/orderbook
        :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   Nsize	timestampr   bidsasksr   qty)r   market/v2PublicGetOrderbookQuoteCurrencyTargetCurrencyextendsafe_integerparse_order_book)r   r   r   r   r   r   r   r   s           r   fetch_order_bookzcoinone.fetch_order_book  s     	V$$$Wo%f~
 
 #GFOGGT[]cHdHdee0 %%h<<	$$Xvh/?FTZ\cejkkkr   symbolsc                    |                                   |                     |          }ddi}d}d}|k|                     |d          }|                     |          }|d         |d<   |d         |d<   |                     |                     ||                    }n)|                     |                     ||                    }|                     |dg           }|                     ||          S )	aP  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :see: https://docs.coinone.co.kr/v1.0/reference/tickers
        :see: https://docs.coinone.co.kr/v1.0/reference/ticker
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        r   r   Nr   r   r   r   r   )	r   market_symbolsr   r   /v2PublicGetTickerNewQuoteCurrencyTargetCurrencyr   r   	safe_listparse_tickers)r   r  r   r   r   r   firstdatas           r   fetch_tickerszcoinone.fetch_tickers  s     	%%g..e
 $$Wa00E[[''F(.wG$%)/G%&KKDKKX_agLhLhiiHH==dkk'SY>Z>Z[[HD ~~h	266!!$000r   c                 P   |                                   |                     |          }|d         |d         d}|                     |                     ||                    }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :see: https://docs.coinone.co.kr/v1.0/reference/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>`
        r   r   r   r   r   )r   r   r  r   r   	safe_dictparse_ticker)r   r   r   r   r   r   r  rd   s           r   fetch_tickerzcoinone.fetch_ticker  s     	V$$$Wo%f~
 
 GGT[]cHdHdeeD xB77a,,  000r   r   c                    |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |          }	|                     |          }
|                     i 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|          S )Nr   last	best_asks	best_bidsr   r   r   r   datetimehighlowbidr   	bidVolumer   ask	askVolumevwapopenr  closepreviousClosechanger{   averagetarget_volumequote_volume)
baseVolumequoteVolumer   )r   r   r   r   safe_tickeriso8601)r   rd   r   r   r  r   r   r   r   r   r   s              r   r  zcoinone.parse_ticker1  sO   6 %%fk::	//v{33v{33!!&*;<<""6+;<<&&v..''00 !
dSj5(!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##D'22!
 ))$66!
 4##D'22!
 ))$66!
 D!
 D$$VW55!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6?CC++FNCC)!
 !
 !
* +  	r   c                    |                      |d          }|                     d |          }|                     |d          }d }||rdnd}|                     |d          }|                     |d          }|                     |d          }|                     |d          }	d }
|	Zt	          j        |	          }	|                     |d	          }t	          j        |          }|dk    r|d
         n|d         }|	||d}
|                     |                     |d          |||                     |          ||d         d |d ||d |
d|          S )Nr   is_seller_makersellbuyr   r   orderIdr   feeRater   r   )r   currencyrater   r   )r   r   r   r  orderr   r   sidetakerOrMakerr   r   r   r   )r   safe_marketr   r   r   
string_abs
safe_trader$  )r   trader   r   isSellerMakerr.  priceStringamountStringr)  feeCostStringr   feeRateStringfeeCurrencyCodes                r   parse_tradezcoinone.parse_tradek  s   0 %%e[99	!!$///@AA$*566D&&ug66''u55""5)44((66$#.}==M ,,UI>>M#.}==M26&..fWoovf~O%+% C
 ""5$//"Y//X&  " 
  
   	r   sincec                 P   |                                   |                     |          }|d         |d         d}|t          |d          |d<   |                     |                     ||                    }|                     |dg           }|                     ||||          S )a-  
        get the list of most recent trades for a particular symbol
        :see: https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders
        :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   N   r   transactions)r   r   r   ,v2PublicGetTradesQuoteCurrencyTargetCurrencyr   r  parse_trades)	r   r   r;  r   r   r   r   r   r  s	            r   fetch_tradeszcoinone.fetch_trades  s     	V$$$Wo%f~
 
 !%ooGFODDT[[QXZ`EaEabb& ~~h;;  vue<<<r   r   r.  r   r   c                    |dk    rt          | j        dz             |                                  |                     |          }||d         |d}d|                     |          z   |                     |          z   }	 t          | |	          |                     ||                    }
|                     |
|          S )a  
        create a trade order
        :see: https://doc.coinone.co.kr/#tag/Order-V2/operation/v2_order_limit_buy
        :see: https://doc.coinone.co.kr/#tag/Order-V2/operation/v2_order_limit_sell
        :param str symbol: unified symbol of the market to create an order in
        :param str type: must be '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 fullfilled, 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   z' createOrder() allows limit orders onlyr   )r   r+  r   privatePostOrder)r   r   r   r   
capitalizegetattrr   parse_order)r   r   r   r.  r   r   r   r   r   methodr   s              r   create_orderzcoinone.create_order  s     7??*S STTTV$$t
 

 $dood&;&;;dood>S>SS(74((Wf)E)EFF &111r   r   c                    |t          | j        dz             |                                  |                     |          }||d         d}|                     |                     ||                    }|                     ||          S )a?  
        fetches information on an order made by the user
        :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 argumentr   )order_idr+  )r   r   r   r   v2PrivatePostOrderQueryOrderr   rF  )r   r   r   r   r   r   r   s          r   fetch_orderzcoinone.fetch_order  s     >#DG.X$XYYYV$$t
 
 44T[[&5Q5QRR, &111r   c                 @    dddddd}|                      |||          S )Nr  closedcanceled)livepartially_filledpartially_canceledfilledrO  )r   )r   statusstatusess      r   parse_order_statuszcoinone.parse_order_status  s7     &"("
 
 &&999r   c           	      d   |                      |d          }|                      |d          }|                      |d          }d }d }||                     |          }||                     |          }d }|!||dz   |z   }|                     ||d          }|                     |dd          }	|                     |dd          }
|
d	k    rd
}
n|
dk    rd}
|                      |d          }|                     |dd          }|                      |d          }|dk    r||t          j        ||          }|rd}|                     |          }d }|                      |d          }|$|
d
k    r|n|}||                      |d          |d}|                     i d|d|dd d|	d| 	                    |	          dd d|dddd dd d|
d|                      |d          d d d!d d"d d#|                      |d$          d%||                      |d&          |||d d'|          S )(Nr)  baseCurrencytargetCurrencyr   r   	updatedAtr   r.  r  r'  r  r(  	remainQtyoriginalQtyr   rT  rP  rO  r   r*  )r   r,  r+  r   r   clientOrderIdr  lastTradeTimestampr   r   timeInForcepostOnlyr   	stopPricetriggerPricer   r  averageExecutedPricer   executedQty)rS  	remainingrT  r   rf   )
r   r   r0  safe_timestamp_2safe_string_2r   	string_ltrV  
safe_orderr$  )r   r-  r   r   r   r   r   r   r   r   r.  remainingStringr6  rT  
isLessThanr   r7  r9  s                     r   rF  zcoinone.parse_order"  s(   X eY//!!%88""5*:;;**622D++G44E5#4CZ%'F%%ffc::F))%kJJ	!!%885==DDU]]D**5+>>))%FF!!%22V+,2J$.MM
 ('F((00((66$(,eeTO%((	::+ C
   
E 
" 
 T 
 	 

 Y// 
 !$ 
 f 
 G 
 4 
  
 D 
 T%%eW55 
  
 D 
 D 
  t''/EFF! 
" l# 
$ &&um<<(- 
  
  
. /  	r   c                 J   |t          | j        dz             |                                  |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        NzG fetchOpenOrders() allows fetching closed orders with a specific symbolr+  r   limitOrders)r   r   r   r   privatePostOrderLimitOrdersr   r  parse_orders)	r   r   r;  r   r   r   r   r   rm  s	            r   fetch_open_orderszcoinone.fetch_open_orders  s     >*s stttV$$t
 33DKK4P4PQQ$ nnX}bAA  feUCCCr   c                 J   |t          | j        dz             |                                  |                     |          }d|d         i}|                     |                     ||                    }|                     |dg           }|                     ||||          S )a  
        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr+  r   completeOrders)r   r   r   r    v2PrivatePostOrderCompleteOrdersr   r  r@  )	r   r   r;  r   r   r   r   r   rr  s	            r   fetch_my_tradeszcoinone.fetch_my_trades  s     >#DG.[$[\\\V$$t
 88Wf9U9UVV* 2BBGG  FFFr   c                    |t          | j        dz             |                     |d          }|                     |d          }|                     |d          }|||t          | j        dz             |                                  |||||                     |          d}|                     |                     ||                    }|S )aD  
        cancels an open 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>`
        Nz cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder.r   r   is_askz\ cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.)rJ  r   r   rv  r+  )r   r   r   r   r   	market_idv2PrivatePostOrderCancelr   )	r   r   r   r   r   r   isAskr   r   s	            r   cancel_orderzcoinone.cancel_order  s    >#DG  /_  %_  `  `  `  11vu--!!&(33Ms{#DG  /M  %M  N  N  Nv..
 
 00Wf1M1MNN r   codesc                    |                                   |                     |          }|                     |di           }t          |                                          }i }t          dt          |                    D ]}||         }||         }	|	r|	dk    r|                    d          }
|                     |
d          }|                     |
d          }|                     |          }|                     ||          }||dd|	d}| 	                    |d|	          }| 
                    |           ||d<   ||d	<   |d
k    s|dk    r|	|d
<   ||	g|d	<   |||<   |S )a]  
        fetch deposit addresses for multiple currencies and chain types
        :param str[]|None codes: list of unified currency codes, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
        walletAddressr   z-1_   N)r+  addresstagr   r  r   r  memo)r   "v2PrivatePostAccountDepositAddressr   r   r   r   r   splitr   r   check_address)r   r{  r   r   r}  r   r   r   keyvaluepartsr   
secondPartr   depositAddressr  s                   r   fetch_deposit_addresseszcoinone.fetch_deposit_addresses  s    	::6BB /2FFM&&(())q#d))$$ 	* 	*Aq'C!#&E u}}IIcNNE22J22J**:66D!__VT::N% $#!	" " &&~y%HHGw'''(/N9%%,N6"e##zV';';(-u%*15)9v&)F4LLr   rw   GETc                    |                      ||          }|                     ||                     |                    }| j        d         d         dz   }	|dk    r| j        d         d         dz   }	d}n9|dk    r| j        d         d         dz   }	n|dk    r| j        d         d         dz   }	|dk    r#|	|z  }	|r|	d|                     |          z   z  }	n|                                  |	|z  }	t          |                                           }
|                     | 	                    | j
        |
d	|                    }|                     |          }|}| j                                        }|                     |                     |          |                     |          t           j                  }d
||d}|	|||dS )Nr]   rX   r   rY   rw   rZ   r[   ?)access_tokennoncezapplication/json)zContent-TypezX-COINONE-PAYLOADzX-COINONE-SIGNATURE)urlrG  bodyheaders)implode_paramsr   extract_paramsr   	urlencodecheck_required_credentialsstrr  jsonr   r`   string_to_base64ra   upperhmacencodehashlibsha512)r   pathr]   rG  r   r  r  r   queryr  r  r  payloadra   	signatures                  r   signzcoinone.sign3  s   %%dF33		&$"5"5d";";<<iv&,*)E":.4CCCK)E";/#5CCM!!)E"=1C7C(??7NC 3sT^^E2222++---7NC

%%E99T[[ $* *    D ++D11GD[&&((F		$++g"6"6F8K8KW^\\I 2%,'0 G
 fdwOOOr   c
                    |d S d|v r]|d         }
|
dk    rN|                      |d          }| j        dz   |z   }|                     | j        ||           t	          |          nt	          | j        dz   |z             d S )Nr   successr    )r   r   throw_exactly_matched_exceptionr   r   )r   r   reasonr  rG  r  r  r   requestHeadersrequestBodyr   r   feedbacks                r   handle_errorszcoinone.handle_errorsU  s    4xh'F"" !,,X{CC	7S=4/44T_iQYZZZ#H--- #  # 4555tr   )N)*__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r	  r   r  r  r   r:  rA  r   r   floatr	   rH  r   rL  rV  r
   rF  rp  rt  rz  r  r  r  __classcell__)r   s   @r   r   r      s       w w w w wr ') = =Z = = = =~ $& g g$v, g g g gR) ) ) ) )$ $& 	, 	,( 	, 	, 	, 	, :>b *l *ls *l3 *lY *l *l *l *lX 04B :1 :1W :17 :1 :1 :1 :1x 02 21 213 21f 21 21 21 21h8 86 8V 8 8 8 8t; ; ;5 ; ; ; ;z 6:UW &= &=3 &=s &=# &=\`af\g &= &= &= &=P gksu 2 23 2i 2y 2RW 2`c 2 2 2 2B 26b %2 %2c %23 %2 %2 %2 %2N: : :i i i5 i i i iV /3TXac %D %D %D3 %Dc %Dhlmrhs %D %D %D %DN -1tRV_a &G &Gc &G &GC &G &G &G &GP 37r    s  C        D :>b 3 3T#Y 3 3 3 3j &eBSW  P  P  P  PD      r   r   )"ccxt.base.exchanger   ccxt.abstract.coinoner   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   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>r     s   ( ' ' ' ' ' - - - - - -  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q  Q       * * * * * * . . . . . . ' ' ' ' ' ' & & & & & & * * * * * * * * * * * * 4 4 4 4 4 4 % % % % % %O O O O Oh O O O O Or   