
    ei]                         d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ 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
CurrenciesDepositAddress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def 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d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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dee(         fd$Z)d%d&i ddfd'Z*d(e+d)ed*ed+ed,ed-efd.Z, xZ-S )0coinonereturnc                    |                      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i d;dd<dd=dd>dd?dd@ddAd	dBddCddDddEddFd	dGddHddIddJd	dKdi dLddMd	dNd	dOddPddQddRddSddTddUddVddWddXd	dYd	dZd	d[dd\ddddddddd	d]d^d_d`dadbdcdddedfd	d	dgdhg diidhg djidkg dlidkg dmidkg dnidodpdd	dqdqdridddd dddd dddddsddddddddtd ddudvdvd	dwdddd	dxdd ddd	dyd d d dz	d d d{d d d{d|t          t
          t          t          t          d}d~did          S )Nr   CoinOneKR2   v2FCORSspotTmarginswapfutureoption	addMarginborrowCrossMarginborrowIsolatedMarginborrowMargincancelOrdercloseAllPositionsclosePositioncreateMarketOrdercreateOrder$createOrderWithTakeProfitAndStopLoss&createOrderWithTakeProfitAndStopLossWscreatePostOnlyOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchClosedOrdersfetchCrossBorrowRatefetchCrossBorrowRatesfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetwork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fetchMyTradesfetchOpenInterestfetchOpenInterestHistoryfetchOpenInterestsfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchVolatilityHistoryreduceMargin)repayCrossMarginrepayIsolatedMarginrepayMarginsetLeverage	setMargin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)r   r   r   r   r   r   r   r   r   zorder/query_orderr   r   r   r   )zaccount/balance/allr   zaccount/trade_feez4account/trade_fee/{quote_currency}/{target_currency}zorder/limitr   zorder/cancel/allzorder/open_orderszorder/open_orders/allr   zorder/complete_orders/allz
order/infor   ztransaction/coin/historyz!transaction/coin/withdrawal/limit)publicr   privater   r   tradinggMb`?)	tierBased
percentagetakermaker)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventionicebergd   i )r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   )	sandboxr4   createOrdersrd   rk   rh   fetchOrdersrC   
fetchOHLCV)linearinverse)r'   r)   r*   )104107108405SOCz	Soda Coin)idname	countries	rateLimitversionprohasurlsrequiredCredentialsr   feesfeaturesprecisionMode
exceptionscommonCurrencies)	deep_extendsuperr   describer   r   r   r   r   )self	__class__s    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/coinone.pyr   zcoinone.describe   sr   gt 4 4 = = ? ?^^^ %^ 	^
 %^ %^ U^ $U^ '^ ^ t^ $U^  ^ $U^ t^  7!^" 9%#^ ^$ &u%^& ('^( ')^* (+^, "5-^. /^0 &u1^2 "53^4 +E5^6 )%7^8 #E9^: ,U;^< $U=^> '?^@ (A^B "4C^D &uE^ ^ ^F (G^H 1%I^J &uK^L 'M^N (O^P #EQ^R *5S^T $UU^V uW^X "5Y^Z *5[^\ +E]^^ )%_^`  a^b !%c^d %ee^f $Ug^ ^ ^h &ui^j -ek^l /m^n "5o^p #Eq^r +Es^t u^v !%w^x "5y^z &u{^| +E}^~  ^@ $UA^B +EC^D %eE^F "4G^H uI^ ^ ^J #EK^L dM^N !$O^P  Q^R 'S^T $UU^V !%W^X *5Y^Z ([^\ %e]^^ )%_^` )%a^b tc^d e^f tg^h )%i^j k^ ^l %*',$$"!&#({^ ^ ^@ ~7 E!?#C	  /2
 
 $ $        "    .    &     CT Tl !&"&""	   %&+(-,0,1).+06:#(#("'#(	( ( #($)$)+027/4#()$ $, %)&+!$$*%+*.& & ',#($)*.	# # ',!%#($)*.( ( $()-"&_0 0d ## 
 ## m: :v '$! $	  {!iWB
 WB
 W W W	    c                    |                      |          }i }|                     |dg           }t          dt          |                    D ]}||         }|                     |d          }|                     |          }|                     |dd          dk    }	|                     |dd          dk    }
|dk    rd	nd
}|                     ||||                     |d          d|
|	|                     |d          |                     | 	                    |                     |d                              ddd|                     |d          dddi |d          ||<   |S )a  
        fetches all available currencies on an exchange

        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
        r   r   symbolwithdraw_status normaldeposit_statusKRWcryptofiatr   Nwithdrawal_feemax_precisionminmaxwithdrawal_min_amount)amountwithdraw)r   codeinfor   activedepositr   fee	precisionlimitsnetworkstype)
v2PublicGetCurrencies	safe_listrangelensafe_stringsafe_currency_codesafe_currency_structuresafe_numberparse_numberparse_precision)r   paramsresponseresultr   ientryr   r   isWithdrawEnabledisDepositEnabledr   s               r   fetch_currencieszcoinone.fetch_currencies1  s    --f55* ^^HlB??
q#j//** 	 	AqME!!%22B**2..D $ 0 08I2 N NRZ Z#//7GLLPXX $88FD77((77+-''/?@@!..t/C/CDDTDTUZ\kDlDl/m/mnn  $# 
  $//7NOO#! !	 	 +9 9  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

        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_currencyr   tickersr   r   target_currencyr   /basequotesettleNbaseIdquoteIdsettleIdr   r'   Tr(   Fr)   r*   r+   r   contractr   z1e-4z1e-8)r   pricecostr   )r   r   r  r  )
r   contractSizeexpiryexpiryDatetimestrike
optionTyper   r   createdr   )
!v2PublicGetTickerNewQuoteCurrencyr   r   r   
safe_valuer   safe_string_upperr  appendr  )r   r  requestr  r  r  r	  r
  r   r  r  r  r  s                r   fetch_marketszcoinone.fetch_marketsq  s    e
 99'BBD ..9b99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   r2  s
             r   parse_balancezcoinone.parse_balance  s    )99X (
 (
 (
  
 8==??++q#k**++ 	# 	#A$QJz*G**:66DllnnG"..w@@GFO#//CCGG"F4LL  (((r   c                 ~    |                                   |                     |          }|                     |          S )aW  
        query for balance and get the amount of funds available for trading or funds locked in orders

        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v2PrivatePostAccountBalancer7  )r   r  r  s      r   fetch_balancezcoinone.fetch_balance  s=     	33F;;!!(+++r   Nr   r   c           	      D   |                                   |                     |          }|d         |d         d}|||d<   |                     |                     ||                    }|                     |d          }|                     ||d         |dd	d
d          S )a/  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        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)r9  market/v2PublicGetOrderbookQuoteCurrencyTargetCurrencyextendsafe_integerparse_order_book)r   r   r   r  rC  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 )	aD  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://docs.coinone.co.kr/v1.0/reference/tickers
        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  )	r9  market_symbolsr   rC  /v2PublicGetTickerNewQuoteCurrencyTargetCurrencyrE  r"  r   parse_tickers)r   rI  r  r&  rC  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

        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   )r9  rC  rL  rE  r   	safe_dictparse_ticker)r   r   r  rC  r&  r  rO  r   s           r   fetch_tickerzcoinone.fetch_tickerg  s     	V$$$Wo%f~
 
 GGT[]cHdHdeeD ~~h	266a,,  000r   r   rC  c                    |                      |d          }|                     |d          }|                     |dg           }|                     |dg           }|                     |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  	bidVolumerB  ask	askVolumevwapopenrN  closepreviousClosechanger   averagetarget_volumequote_volume)
baseVolumequoteVolumer   )rF  r   r   r  safe_tickeriso8601)r   r   rC  r?  rV  rA  r@  r  r  r  r  s              r   rS  zcoinone.parse_ticker  sS   6 %%fk::	//~~fk266~~fk266!!&*;<<""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   tradec                    |                      |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  rB  orderIdr   feeRater  r  )r  currencyrater   r   )r   r   r?  rY  orderr   r   sidetakerOrMakerr  r   r  r   )rF  safe_market	safe_boolr   r   
string_abs
safe_traderk  )r   rl  rC  r?  isSellerMakerrv  priceStringamountStringrq  feeCostStringr   feeRateStringfeeCurrencyCodes                r   parse_tradezcoinone.parse_trade  s   0 %%e[99	!!$//u.?@@$*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

        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)r9  rC  r   ,v2PublicGetTradesQuoteCurrencyTargetCurrencyrE  r   parse_trades)	r   r   r  r   r  rC  r&  r  rO  s	            r   fetch_tradeszcoinone.fetch_trades  s     	V$$$Wo%f~
 
 !%ooGFODDT[[QXZ`EaEabb& ~~h;;  vue<<<r   r   rv  r   r  c                    |dk    rt          | j        dz             |                                  |                     |          }||d         |d}d|                     |          z   |                     |          z   }	 t          | |	          |                     ||                    }
|                     |
|          S )a  
        create a trade order

        https://doc.coinone.co.kr/#tag/Order-V2/operation/v2_order_limit_buy
        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 fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        r   z' createOrder() allows limit orders onlyr   )r  rs  rB  privatePostOrder)r   r   r9  rC  
capitalizegetattrrE  parse_order)r   r   r   rv  r   r  r  rC  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 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 argumentr   )order_idrs  )r   r   r9  rC  v2PrivatePostOrderQueryOrderrE  r  )r   r   r   r  rC  r&  r  s          r   fetch_orderzcoinone.fetch_ordera  s     >#DG.X$XYYYV$$t
 
 44T[[&5Q5QRR, &111r   statusc                 @    dddddd}|                      |||          S )Nra  closedcanceled)livepartially_filledpartially_canceledfilledr  )r   )r   r  statusess      r   parse_order_statuszcoinone.parse_order_status  s7     &"("
 
 &&999r   ru  c                 b   |                      |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'|          S )(Nrq  baseCurrencytargetCurrencyr  r?  	updatedAtr   rv  r^  ro  r\  rp  	remainQtyoriginalQtyrB  r  r  r  r   rr  )r  rt  rs  r   r   clientOrderIdrY  lastTradeTimestampr   r   r   postOnlyr  r   r  re  averageExecutedPricer   r  executedQty)	remainingr  r   r   )
r   r  rx  safe_timestamp_2safe_string_2r   	string_ltr  
safe_orderrk  )r   ru  rC  r   r  r  r  r  r   r?  rv  remainingStringr~  r  
isLessThanr   r  r  s                     r   r  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! 
" d&&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 symbolrs  r   limitOrders)r   r   r9  rC  privatePostOrderLimitOrdersrE  r   parse_orders)	r   r   r  r   r  rC  r&  r  r  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 argumentrs  r   completeOrders)r   r   r9  rC   v2PrivatePostOrderCompleteOrdersrE  r   r  )	r   r   r  r   r  rC  r&  r  r  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 )aB  
        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  rB  is_askz\ cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.)r  r  rB  r  rs  )	r   r   r  rF  r9  	market_idv2PrivatePostOrderCancelrE  r  )	r   r   r   r  r  rB  isAskr&  r  s	            r   cancel_orderzcoinone.cancel_orderL  s    >#DG  /_  %_  `  `  `  11vu--!!&(33Ms{#DG  /M  %M  N  N  Nv..
 
 00Wf1M1MNN x(((r   codesc                    |                                   |                     |          }|                     |di           }t          |                                          }i }t          dt          |                    D ]}||         }||         }	|	r|	dk    r|                    d          }
|                     |
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   rs  networkaddresstagr  r   r  memo)r9  "v2PrivatePostAccountDepositAddressrR  r0  r1  r   r   splitr#  r  r   check_address)r   r  r  r  r  r1  r  r	  keyvaluepartsr6  
secondPartr   depositAddressr  s                   r   fetch_deposit_addresseszcoinone.fetch_deposit_addressesn  s    	::6BB x"EE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   r   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   r   r  r   r   r   r   ?)access_tokennoncezapplication/json)zContent-TypezX-COINONE-PAYLOADzX-COINONE-SIGNATURE)urlr  bodyheaders)implode_paramsr/  extract_paramsr   	urlencodecheck_required_credentialsstrr  jsonrE  r   string_to_base64r   upperhmacencodehashlibsha512)r   pathr   r  r  r  r  r&  queryr  r  r  payloadr   	signatures                  r   signzcoinone.sign  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   r   reasonr  r  r  r  c
                     |d S |                      |d          }
|
>|
dk    r8| j        dz   |z   }|                     | j        |
|           t	          |          d S )N
error_code0 )r   r   throw_exactly_matched_exceptionr   r   )r   r   r  r  r  r  r  r  requestHeadersrequestBodyr)  feedbacks               r   handle_errorszcoinone.handle_errors  sq    4
 $$X|<<	 Y#%5%5w}t+H00)XVVV)))tr   )N).__name__
__module____qualname__r   r   r   r  r   r
   r'  r   r7  r;  r  r	   r   rH  r   r   rP  r   rT  dictrS  r   r  r  r   r   floatr   r  r   r  r  r   r  r  r  r  r   r  r  intr  __classcell__)r   s   @r   r   r      sM       X# X X X X X Xt ') > >Z > > > >@ $& i i$v, i i i iV) ) ) ) )$ $& , ,( , , , , :>b ,l ,ls ,l3 ,lY ,l ,l ,l ,l\ 04B <1 <1W <17 <1 <1 <1 <1| 02 41 413 41f 41 41 41 41l8 84 8 86 8 8 8 8t; ; ;v ; ; ; ; ;z 6:UW (= (=3 (=s (=# (=\`af\g (= (= (= (=T gksu !2 !23 !2i !2y !2RW !2`c !2 !2 !2 !2F 26b &2 &2c &23 &2 &2 &2 &2P: : : : :h h hv h h h h hT /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 8<B 4 4W 44P^K_ 4 4 4 4l &eBSW  P  P  P  PD# s  c TX `c        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   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   ( ' ' ' ' ' - - - - - -  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f  f       * * * * * * . . . . . . ' ' ' ' ' ' & & & & & & * * * * * * * * * * * * 4 4 4 4 4 4 % % % % % %} } } } }h } } } } }r   