
    E#is                         S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJ r   S SK!J"r"   " S S\\5      r#g)    )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                   T  ^  \ rS rSrS\4U 4S jjr0 4S\4S jjr0 4S\\	   4S jjr
S\4S jr0 4S\4S jjrS0 4S	\S
\S\4S jjrS0 4S\S\4S jjr0 4S	\S\4S jjrS1S\S\	S\4S jjrS1S\S\	S\4S jjrSS0 4S	\S\S
\S\\   4S jjrS0 4S	\S\S\S\S\4
S jjr S0 4S\S	\!4S jjr"S\!4S jr#S1S\S\	S\$4S  jjr%SSS0 4S	\!S\S
\S\\$   4S! jjr&SSS0 4S	\!S\S
\4S" jjr'S0 4S\S	\!4S# jjr(S0 4S$\S\\)   4S% jjr*S&S'0 SS4S( jr+S)\,S*\S+\S,\S-\S.\4S/ jr-S0r.U =r/$ )2coinone   returnc                   > U R                  [        [        U ]  5       SSS/SSS0 SS _SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS	_SS_SS_SS_SS	_SS_SS_0 SS_SS_SS_SS_SS_SS	_SS_S S_S!S_S"S_S#S_S$S_S%S_S&S_S'S_S(S	_S)S_E0 S*S	_S+S_S,S_S-S_S.S_S/S_S0S_S1S_S2S_S3S_S4S_S5S_S6S_S7S_S8S_S9S_S:S_E0 S;S_S<S_S=S_S>S_S?S_S@S_SAS	_SBS_SCS_SDS_SES_SFS	_SGS_SHS_SIS_SJS	_SKS_E0 SLS_SMS	_SNS	_SOS_SPS_SQS_SRS_SSS_STS_SUS_SVS_SWS_SXS	_SYS	_SZS	_S[S_S\S_ESSSSSSSS	S].ES^S_S`SaSbSc.SdSeSf.S	S	Sg.Sh/ SiQ0Sh/ SjQ0Sk/ SlQ0Sk/ SmQ0Sk/ SnQ0So.SpSS	SqSqSr.0SSSS SSSS SSSSSs.SSSSSSSSt.S SSuSvSvS	Sw.SSSS	Sx.SS SSS	Sy.S S S Sz.	S S S{.S S S{.S|.[        [
        [        [        [        S}.S~S0S.5      $ )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   )	sandboxr5   createOrdersre   rl   ri   fetchOrdersrD   
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    F/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/coinone.pyr   coinone.describe   s   gt = ?^^^ %^ 	^
 %^ %^ 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l !&"&""	  %&+(-,0,1).+06:#(#("'#(	( #($)$)+027/4#()$, %)&+!$$*%+*.& ',#($)*.	# ',!%#($)*.( $()-"&_0d ##
 ##m:v '$! $	 {!iWB
 W W	    c                 R   U R                  U5      n0 nU R                  US/ 5      n[        S[        U5      5       H  nXE   nU R	                  US5      nU R                  U5      nU R	                  USS5      S:H  n	U R	                  USS5      S:H  n
US:w  a  S	OS
nU R                  UUUU R	                  US5      SU
U	U R                  US5      U R                  U R                  U R	                  US5      5      5      SSS.U R                  US5      SS.S.0 US.5      X8'   M     U$ )z
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_currenciescoinone.fetch_currencies1  s^    --f5* ^^HlB?
q#j/*AME!!%2B**2.D $ 0 08I2 NRZ Z#//7GLPXX $8FD77((7+-''/?@!..t/C/CDDTDTUZ\kDl/mn  $#
  $//7NO#!	 +9 FL +< r   c                    SS0nU R                  U5      nU R                  US/ 5      n/ n[        S[        U5      5       GH  nU R	                  XF5      nU R                  US5      nU R                  US5      n	U R                  US5      n
U R                  U	5      nU R                  U
5      nUR                  0 SU_SUS-   U-   _S	U_S
U_SS_SU	_SU
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SSSSSSU R                  S5      U R                  S5      U R                  S5      S.SSS.SSS.SSS.SSS.S.SUS .
E5        GM	     U$ )!z
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_marketscoinone.fetch_marketsq  s+    e
 99'BD ..9b9q#g,'AOOG/E!!%.B++E3DEF,,U4DEG**62D++G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!..v6 --f5  $#!
  $#
  $#
  $#$  a1 1 (r r   c                 l   SU0nU R                  U/ SQ5      n[        UR                  5       5      n[        S[	        U5      5       HZ  nXE   nX6   nU R                  U5      nU R                  5       n	U R                  US5      U	S'   U R                  US5      U	S'   XU'   M\     U R                  U5      $ )Nr   )	errorCoder
  normalWalletsr   availfreebalancetotal)	omitlistkeysr   r  r  accountr  safe_balance)
r   r	  r
  balancescurrencyIdsr  
currencyIdr1  r   r6  s
             r   parse_balancecoinone.parse_balance  s    )99X (
 
 8==?+q#k*+A$J*G**:6DllnG"..w@GFO#//CGG"4L ,   ((r   c                 f    U R                  5         U R                  U5      nU R                  U5      $ )a1  
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v2PrivatePostAccountBalancer;  )r   r  r	  s      r   fetch_balancecoinone.fetch_balance  s1     	33F;!!(++r   Nr   r   c           	          U R                  5         U R                  U5      nUS   US   S.nUb  X%S'   U R                  U R                  XS5      5      nU R	                  US5      nU R                  XdS   USSS	S
5      $ )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  size	timestampr   bidsasksr  qty)r>  market/v2PublicGetOrderbookQuoteCurrencyTargetCurrencyextendsafe_integerparse_order_book)r   r   r   r  rI  r)  r	  rE  s           r   fetch_order_bookcoinone.fetch_order_book  s     	V$$Wo%f~
 #FOGGT[Hde0 %%h<	$$Xh/?FTZ\cejkkr   symbolsc                    U R                  5         U R                  U5      nSS0nSnSnUbT  U R                  US5      nU R                  U5      nUS   US'   US   US'   U R	                  U R                  X25      5      nO U R                  U R                  X25      5      nU R                  US/ 5      nU R                  Xq5      $ )	a  
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  )	r>  market_symbolsr  rI  /v2PublicGetTickerNewQuoteCurrencyTargetCurrencyrK  r%  r   parse_tickers)r   rP  r  r)  rI  r	  firstdatas           r   fetch_tickerscoinone.fetch_tickers)  s     	%%g.e
 $$Wa0E[['F(.wG$%)/G%&KKDKKX_LhiH==dkk'>Z[HD ~~h	26!!$00r   c                    U R                  5         U R                  U5      nUS   US   S.nU R                  U R                  XB5      5      nU R	                  US/ 5      nU R                  US0 5      nU R                  Xs5      $ )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  rC  r  r   )r>  rI  rS  rK  r   	safe_dictparse_ticker)r   r   r  rI  r)  r	  rV  r   s           r   fetch_tickercoinone.fetch_tickerg  s     	V$$Wo%f~
 GGT[HdeD ~~h	26a,  00r   r   rI  c                    U R                  US5      nU R                  US5      nU R                  US/ 5      nU R                  US/ 5      nU R                  US5      nU R                  US5      nU R                  U5      n	U R                  U5      n
U R	                  0 SU	S-   U
-   _SU_S	U R                  U5      _S
U R                  US
5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SU R                  US5      _SS _SU R                  US5      _SU_SU_SS _SS _SS _SS _U R                  US5      U R                  US5      US.EU5      $ )NrE  last	best_asks	best_bidsr  r  r   r  datetimehighlowbidr  	bidVolumerH  ask	askVolumevwapopenrU  closepreviousClosechanger   averagetarget_volumequote_volume)
baseVolumequoteVolumer   )rL  r  r   r  safe_tickeriso8601)r   r   rI  rE  r_  rG  rF  r  r  r  r  s              r   r[  coinone.parse_ticker  s   6 %%fk:	/~~fk26~~fk26!!&*;<""6+;<&&v.''0 !
dSj5(!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##D'2!
 ))$6!
 4##D'2!
 ))$6!
 D!
 D$$VW5!
 T!
 D!
 T!
 d!
  $!!
" t#!
$ **6?C++FNC)!
* + 	r   tradec                 T   U R                  US5      nU R                  S U5      nU R                  US5      nS nUb  U(       a  SOSnU R                  US5      nU R                  US5      nU R                  US5      nU R                  US5      n	S n
U	bT  [        R
                  " U	5      n	U R                  US	5      n[        R
                  " U5      nUS:X  a  US
   OUS   nU	UUS.n
U R                  U R                  US5      UUU R                  U5      UUS   S US UUS U
S.U5      $ )NrE  is_seller_makersellbuyr  rH  orderIdr   feeRater  r  )r  currencyrater   r   )r   r   rE  rb  orderr   r   sidetakerOrMakerr  r   r  r   )rL  safe_market	safe_boolr  r   
string_abs
safe_tradert  )r   rv  rI  rE  isSellerMakerr  priceStringamountStringr{  feeCostStringr   feeRateStringfeeCurrencyCodes                r   parse_tradecoinone.parse_trade  sV   0 %%e[9	!!$/u.?@$*6D&&ug6''u5""5)4((6$#..}=M ,,UI>M#..}=M26&.fWovf~O%+%C
 ""5$/"Y/X&  " 
  	r   sincec                    U R                  5         U R                  U5      nUS   US   S.nUb  [        US5      US'   U R                  U R	                  Xd5      5      nU R                  US/ 5      nU R                  XX#5      $ )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  rC     rD  transactions)r>  rI  r   ,v2PublicGetTradesQuoteCurrencyTargetCurrencyrK  r   parse_trades)	r   r   r  r   r  rI  r)  r	  rV  s	            r   fetch_tradescoinone.fetch_trades  s     	V$$Wo%f~
 !%oGFODDT[[QXEab& ~~h;  u<<r   r   r  r   r  c                 @   US:w  a  [        U R                  S-   5      eU R                  5         U R                  U5      nUUS   US.nSU R	                  U5      -   U R	                  U5      -   n	[        X	5      " U R                  X5      5      n
U R                  X5      $ )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  r}  rH  privatePostOrder)r   r   r>  rI  
capitalizegetattrrK  parse_order)r   r   r   r  r   r  r  rI  r)  methodr	  s              r   create_ordercoinone.create_order>  s     7?*S STTV$t

 $dood&;;dood>SS4(W)EF 11r   r   c                     Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nUUS   S.nU R	                  U R                  XS5      5      nU R                  Xd5      $ )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>`
z( fetchOrder() requires a symbol argumentr   )order_idr}  )r   r   r>  rI  v2PrivatePostOrderQueryOrderrK  r  )r   r   r   r  rI  r)  r	  s          r   fetch_ordercoinone.fetch_ordera  sw     >#DGG.X$XYYV$t
 44T[[5QR, 11r   statusc                 6    SSSSSS.nU R                  X!U5      $ )Nrj  closedcanceled)livepartially_filledpartially_canceledfilledr  )r  )r   r  statusess      r   parse_order_statuscoinone.parse_order_status  s-     &"("
 &99r   r  c                    U R                  US5      nU R                  US5      nU R                  US5      nS nS nUb  U R                  U5      nUb  U R                  U5      nS nUb  Ub  US-   U-   nU R                  XS5      nU R                  USS5      n	U R	                  USS5      n
U
S	:X  a  S
n
OU
S:X  a  Sn
U R                  US5      nU R	                  USS5      nU R                  US5      nUS:X  a%  Ub"  Ub  [
        R                  " X5      nU(       a  SnU R                  U5      nS nU R                  US5      nUb   U
S
:X  a  UOUnUU R                  US5      US.nU R                  0 SU_SU_SS _SU	_SU R                  U	5      _SS _SU_SS_SS _SS _SU
_SU R                  US5      _S S _S!S _S"U R                  US#5      _S$U_S%U R                  US&5      _UUUS S'.EU5      $ )(Nr{  baseCurrencytargetCurrencyr  rE  	updatedAtr   r  rg  ry  re  rz  	remainQtyoriginalQtyrH  r  r  r  r   r|  )r  r~  r}  r   r   clientOrderIdrb  lastTradeTimestampr   r   r   postOnlyr  r   r  rn  averageExecutedPricer   r  executedQty)	remainingr  r   r   )
r  r  r  safe_timestamp_2safe_string_2r   	string_ltr  
safe_orderrt  )r   r  rI  r   r  r  r  r  r   rE  r  remainingStringr  r  
isLessThanr   r  r  s                     r   r  coinone.parse_order  s   X eY/!!%8""5*:;**62D++G4E5#4CZ%'F%%fc:F))%kJ	!!%85=DU]D**5+>))%F!!%2V+,2J$..M
'F((0((6$(,eTO%((	:+C
   
E 
" 
 T 
 	 

 Y/ 
 !$ 
 f 
 G 
 4 
  
 D 
 T%%eW5 
 D 
 D 
 t''/EF 
  l! 
" d&&um<# 
$ )+ 
, - 	r   c                    Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nSUS   0nU R	                  U R                  Xd5      5      nU R                  US/ 5      nU R                  XX#5      $ )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>`
zG fetchOpenOrders() allows fetching closed orders with a specific symbolr}  r   limitOrders)r   r   r>  rI  privatePostOrderLimitOrdersrK  r   parse_orders)	r   r   r  r   r  rI  r)  r	  r  s	            r   fetch_open_orderscoinone.fetch_open_orders  s     >*s sttV$t
 33DKK4PQ$ nnX}bA  eCCr   c                    Uc  [        U R                  S-   5      eU R                  5         U R                  U5      nSUS   0nU R	                  U R                  Xd5      5      nU R                  US/ 5      nU R                  XX#5      $ )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>`
z+ fetchMyTrades() requires a symbol argumentr}  r   completeOrders)r   r   r>  rI   v2PrivatePostOrderCompleteOrdersrK  r   r  )	r   r   r  r   r  rI  r)  r	  r  s	            r   fetch_my_tradescoinone.fetch_my_trades$  s     >#DGG.[$[\\V$t
 88W9UV* 2BBG  FFr   c                    Uc  [        U R                  S-   5      eU R                  US5      nU R                  US5      nU R                  US5      nUb  Ub  Uc  [        U R                  S-   5      eU R	                  5         UUUUU R                  U5      S.nU R                  U R                  Xs5      5      nU R                  U5      $ )a  
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>`
z 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  rH  is_askz\ cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.)r  r  rH  r  r}  )	r   r   r  rL  r>  	market_idv2PrivatePostOrderCancelrK  r  )	r   r   r   r  r  rH  isAskr)  r	  s	            r   cancel_ordercoinone.cancel_orderL  s     >#DGG  /_  %_  `  `  1vu-!!&(3Ms{#DGG  /M  %M  N  Nv.
 00W1MN x((r   codesc                 Z   U R                  5         U R                  U5      nU R                  US0 5      n[        UR	                  5       5      n0 n[        S[        U5      5       H  nXW   nXH   n	U	(       a  U	S:X  a  M  UR                  S5      n
U R                  U
S5      nU R                  U
S5      nU R                  U5      nU R                  Xm5      nUc  U	USSSS.nU R                  USU	5      nU R                  U5        XS'   XS	'   US
:X  d  US:X  a
  XS
'   X/US	'   XU'   M     U$ )a5  
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   r}  networkaddresstagr  r   r  memo)r>  "v2PrivatePostAccountDepositAddressrZ  r4  r5  r   r  splitr&  r  r  check_address)r   r  r  r	  r  r5  r
  r  keyvaluepartsr:  
secondPartr   depositAddressr  s                   r   fetch_deposit_addressescoinone.fetch_deposit_addressesn  sI    	::6B x"EM&&()q#d)$A'C!&Eu}IIcNE2J2J**:6D!__V:N%! $##" &&~y%HGw'(/9%%,6"e#zV';(-u%*1)9v&)4L3 %4 r   r   GETc                 .   U R                  X5      nU R                  X@R                  U5      5      nU R                  S   S   S-   n	US:X  a  U R                  S   S   S-   n	SnO7US:X  a  U R                  S   S   S-   n	OUS:X  a  U R                  S   S   S-   n	US:X  a#  X-  n	U(       a  U	SU R	                  U5      -   -  n	OU R                  5         X-  n	[        U R                  5       5      n
U R                  U R                  U R                  U
S	.U5      5      nU R                  U5      nUnU R                  R                  5       nU R                  U R                  U5      U R                  U5      [         R"                  5      nS
UUS.nXXeS.$ )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_paramsr3  extract_paramsr   	urlencodecheck_required_credentialsstrr  jsonrK  r   string_to_base64r   upperhmacencodehashlibsha512)r   pathr   r  r  r  r  r)  queryr  r  r  payloadr   	signatures                  r   signcoinone.sign  s   %%d3		&"5"5d";<iiv&,*))E":.4CCK))E";/#5CM!))E"=1C7C(?NCsT^^E222++-NC

%E99T[[ $*  D ++D1GD[[&&(F		$++g"6F8KW^^\I 2%,'0G
 dOOr   r   reasonr  r  r  r  c
                     Uc  g U R                  US5      n
U
b?  U
S:w  a9  U R                  S-   U-   nU R                  U R                  X5        [	        U5      eg )N
error_code0 )r  r   throw_exactly_matched_exceptionr   r   )r   r   r   r  r  r  r  r	  requestHeadersrequestBodyr-  feedbacks               r   handle_errorscoinone.handle_errors  s`    
 $$X|<	 Y#%5ww}t+H00)V))r    )N)0__name__
__module____qualname____firstlineno__r   r   r   r  r   r
   r*  r   r;  r@  r  r	   r   rN  r   r   rW  r   r\  dictr[  r   r  r  r   r   floatr   r  r   r  r  r   r  r  r  r  r   r  r  intr	  __static_attributes____classcell__)r   s   @r   r   r      s   X# Xt ') >Z >@ $& i$v, iV) )$ $& ,( , :>b ,ls ,l3 ,lY ,l\ 04B <1W <17 <1| 02 413 41f 41l84 8 86 8t; ;v ; ;z 6:UW (=3 (=s (=# (=\`af\g (=T gksu !23 !2i !2y !2RW !2`c !2F 26b &2c &23 &2P: :h hv h hT /3TXac %D %D3 %Dc %Dhlmrhs %DN -1tRV_a &Gc &G &GC &GP 37r  )s  )C  )D 8<B 4W 44P^K_ 4l &eBSW  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   r   <module>r     sY    ( -  f  f  f  f  f  * . ' & * * 4 %}h }r   