
    !:h$o                    D   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mZmZmZmZmZmZmZmZmZmZm Z m!Z! d dl"m#Z# d dl$m%Z% d dl$m&Z& d dl$m'Z' d d	l$m(Z( d d
l$m)Z) d dl$m*Z* d dl$m+Z+ d dl$m,Z, d dl$m-Z- d dl.m/Z/ d dl0m1Z1  G d dee      Z2y)    )Exchange)ImplicitAPIN)AccountAnyBalancesBool
Conversion
CurrenciesCurrencyDepositAddressIntLedgerEntryLeverageMarginModificationMarket
MarketTypeNumOrder	OrderBook	OrderSide	OrderTypePositionStrStringsFundingRateFundingRatesTradeTradingFeesTransactionTransferEntry)List)ExchangeError)AuthenticationError)ArgumentsRequired)
BadRequest)InvalidOrder)NotSupported)OperationFailed)RateLimitExceeded)OnMaintenance)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdZi fdefdZi fdee	   fdZ
dede	fdZddi fd	ed
ededee   fdZddede	defdZd Zi fdefdZi fdefdZi fd	edefdZi fd	edefdZdddi fd	edededededefdZdddi fd	edededededefdZdi fd	ededededef
dZd Z ddi fded	ededededefdZ!di fded	e"fdZ#di fd	e"fd Z$i fd!efd"Z%di f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dee   fd%Z(dddi fd	e"d
ededee   fd&Z)d'e"fd(Z*dd)ede	defd*Z+d+e"fd,Z,di f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/Z0dde	de/fd0Z1dddi fded	e"d
edefd1Z2dddi fd	e"d
edefd2Z3i fdee4   fd3Z5d4 Z6i fde7fd5Z8de7fd6Z9i fd7ede:fd8Z;dddi fd7e"d
ededefd9Z<dddi fd7e"d
ededee=   fd:Z>dd;ed<e?de=fd=Z@d> ZAd? ZBdddi fd7e"d
ededeeC   fd@ZDdddi fd7e"d
ededeeC   fdAZEdddi fd7e"d
ededeeC   fdBZFddCed<e?deCfdDZGd+e"fdEZHi fd7ededFedGedeIf
dHZJdddi fd7e"d
ededeeI   fdIZKddJed<e?deIfdKZLd+e"de"fdLZMdi fd7ededMedeCfdNZNdi fd7eded	e"fdOZOdd<e?fdPZPdQ ZQdRdSi ddfdTZRdUeSdVedWedXedYedZefd[ZTdde	fd\ZUdddi fd	e"d
edefd]ZVdde	deWfd^ZXi fd	edeWfd_ZYi fd	edeWfd`ZZdi fdae[de\fdbZ]dddi fd	e"d
edefdcZ^di fdde_d	e"fdeZ`i fd	edeafdfZbddgede	deafdhZcdi fdged	e"fdiZdi fd	ededeefdjZfi fd	ededeefdkZgi fd	edeefdlZhi fd	e"fdmZidi fdae[deej   fdnZkddoede	fdpZldi fdqedrededemfdsZndi fdedqedrededemf
dtZodi fded7e"demfduZpdddi fd7e"d
ededeem   fdvZqddwedxe?dye?demfdzZri fdefd{Zsd| Ztd}e_f fd~Zu xZvS )wooreturnc                    | j                  t        t        |          i ddddddg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d)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3di d4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAddBddCddDdi dEddFddGddHddIddJddKddLddMddNddOddPddQddRddSddTddUdi dVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbdcddddeddfddgdddddddhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydydzd{d|d|dzd}d~gdgdddddddddidddddddddddddddii dddddddddddddddddddddddddddddddddddddddddddd	ddddddddddddddddddddzddddiiidddiidddddddddddddddddddddddddddddddddd| j	                  d      | j	                  d      didddddddddddddddi ddidd	dd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dddddȜdddddɜddddddʜddd ddddd̜ddd d ddddd͜ddidМ	ddidddidԜddid d֜d d d֜dלdi di dt
        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        dt        t        t        t        t        t        t        dddt        i      S )Nidr.   namezWOO X	countriesKY	rateLimitd   versionv1	certifiedTprohostnamezwoox.iohasCORSspotmarginswapfutureFoption	addMargincancelAllOrderscancelAllOrdersAftercancelOrdercancelWithdrawcloseAllPositionsclosePositioncreateConvertTradecreateDepositAddresscreateMarketBuyOrderWithCostcreateMarketOrdercreateMarketOrderWithCostcreateMarketSellOrderWithCostcreateOrder$createOrderWithTakeProfitAndStopLosscreateReduceOnlyOrdercreateStopLimitOrdercreateStopLossOrdercreateStopMarketOrdercreateStopOrdercreateTakeProfitOrdercreateTrailingAmountOrdercreateTrailingPercentOrdercreateTriggerOrderfetchAccountsfetchBalancefetchCanceledOrdersfetchClosedOrderfetchClosedOrdersfetchConvertCurrenciesfetchConvertQuotefetchConvertTradefetchConvertTradeHistoryfetchCurrenciesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchLedgerfetchLeveragefetchMarginAdjustmentHistoryfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrderfetchOpenOrders
fetchOrderfetchOrderBookfetchOrdersfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPremiumIndexOHLCVfetchStatusfetchTickerfetchTickers	fetchTimefetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsemulatedfetchTransfersfetchWithdrawalsreduceMarginsandbox)setLeverage	setMarginsetPositionModetransferwithdraw
timeframes1m5m15m30m1h4h12h1d1w1mon1y)r   r   r   r   r   r   r   r   r   1Mr   urlszdhttps://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpgzhttps://api-pub.woox.iozhttps://api.{hostname})pubpublicprivatezhttps://api-pub.staging.woox.iozhttps://api.staging.woox.iozhttps://woox.io/zhttps://docs.woox.io/zFhttps://support.woox.io/hc/en-001/articles/4404611795353--Trading-Feesz%https://woox.io/register?ref=DIJT0CNLgffffff?)urldiscount)logoapitestwwwdocfeesreferralr   get
   )z
hist/klinezhist/trades   )infozinfo/{symbol}system_infomarket_tradestokentoken_networkfunding_rateszfunding_rate/{symbol}funding_rate_historyfutureszfutures/{symbol}zorderbook/{symbol}klinezclient/tokenorder/{oid}zclient/order/{client_order_id}orderszclient/trade/{tid}zorder/{oid}/tradeszclient/tradeszclient/hist_tradeszstaking/yield_historyzclient/holdingzasset/depositzasset/history<   zsub_account/allzsub_account/assetszsub_account/asset_detailzsub_account/ip_restrictionzasset/main_sub_transfer_history   gp=
ף
@)	token_interestztoken_interest/{token}zinterest/historyinterest/repayzfunding_fee/history	positionszposition/{symbol}zclient/transaction_historyclient/futures_leveragex      )orderzorder/cancel_all_afterzasset/main_sub_transferz	asset/ltvasset/withdrawzasset/internal_withdrawr   zclient/account_modezclient/position_modezclient/leverager   zclient/isolated_margin)r   zclient/orderr   r   )r   postdeleter   insuranceFund   )algo/order/{oid}zalgo/ordersbalancesaccountinfor   buypower	referralsreferral_rewardszconvert/exchangeInfozconvert/assetInfozconvert/rfqzconvert/tradezconvert/trades)
algo/orderzconvert/rft   )r   zorder/client/{client_order_id}r   z#algo/order/client/{client_order_id})zalgo/order/{order_id}zalgo/orders/pendingzalgo/orders/pending/{symbol}zorders/pending)r   r   putr   )r   r   )r8   v2v3r   tradingz0.0002z0.0005)	tierBased
percentagemakertakeroptionsr   ERC20ATOMZRX)HTOMGUATOMr   TRONETHBSC)TRXTRC20r   BEP20fillResponseFromRequest$bc830de7-50f3-460b-9ee0-f430f83f9dad)	timeDifferenceadjustForTimeDifferencesandboxMode!createMarketBuyOrderRequiresPriceznetwork-aliases-for-tokensnetworksdefaultNetworkCodeForCurrenciesr   brokerIdfeatures)lastmarkindex)IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg  Z   i'  )r   limitdaysBack	untilDayssymbolRequired)r   triggerr  r  )r   r  r  r  r  i )r   r  r  r  r  r  r  )r   r  r  daysBackCanceledr  r  r  r  r    )	r   rP   createOrdersrw   r|   r{   r~   r_   rx   extendsdefaultr  )r  rP   forSwap)linearinverse)r  r>   r  r@   rA   commonCurrencies
exceptionsz-1000z-1001z-1002z-1003z-1004z-1005z-1006z-1007z-1008z-1009z-1012z-1101z-1102z-1103z-1104z-1105)zCan not placemaintenancezsymbol must not be blankzThe token is not supportedz7Your order and symbol are not valid or already canceledzCInsufficient WOO. Please enable margin trading for leverage trading)exactbroadprecisionMode)deep_extendsuperr.   describeparse_numberr(   r#   r)   r%   r&   r"   r*   r+   )self	__class__s    B/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/woo.pyr"  zwoo.describe   s   c4 9 ; e>
%e>
Ge>
 $e>
 	e>

 te>
 e>
 4e>
 	e>
  [[[ $[ 	[
 %[ %[ T[ "4[ '[ t[ !%[ $U[  [ %d[ '[  /![" $U#[$ ,U%[& 0'[( t)[* 7+[, (-[. '/[0 &t1[2 (3[4 "55[6 (7[8 ,T9[: -d;[< %d=[>  ?[@ A[B &uC[D #EE[F $TG[H )$I[J $TK[L $TM[N +DO[P "4Q[R &tS[T (U[V 1%W[X  Y[Z +D[[\ &t][^ '_[` (a[b #Dc[d *4e[f $Tg[h "5i[j tk[l  m[n /o[p "5q[r s[t !%u[v  w[x dy[z +E{[| !%}[~ "4[@ dA[B !$C[D tE[F #DG[H  I[J 'K[L $UM[N !$O[P (Q[R )%S[T tU[V uW[X Y[Z T[[\ t][^ "5_[` #Da[b $Zc[d !$e[f #Dg[h i[j 4k[l  $"#'  u[e>
J Ke>
d ~467 =;<
 *+ ] C $'ee>
T  *,+-  $%-.+,-.%&-.-.5645'(0123%& $ *A )1  =a  %a	 
 1!  1!  ,Q  1!  4Q  -a  ,R  ,R  .r  1"  7   9"! " >r# $ /16802.035)-15:<795 : &'6779)+.079.03645/27968! &',-&'.1	#W1 1JX ,a   +Q  12+,()+-)-())+024512+--../   +,+-!
 ,->?01CD	  6734<=./	#5  'g{Ue>
L !%"&!..x8!..x8	Me>
\ "#+0$59 ""# 	/ "#""	4
 .t C5]e>
T	 #&*(,$($(%*-
 -2).+06:#'#'"&#'	( #($($)+/27/4#'1$4 %)&+!$$&%**/& ',#'$)*/	# ',!$#'$(*/( ',!$$(%+#'$(*/$ ',!$$(,0%+#'$(*/	*  #IGR y  ) $$ "9  $	 ##q\U	e>
N Oe>
P _0 0 .	
 Z Z Z Z \ Z Z \ \ \ \  \!& &3#00:2<OY[e'Qe>
H YIe>
 e e	    c                     | j                  |      }| j                  |di       }| j                  |d      }|d}n
|dk(  rd}nd}|ddd|dS )	aT  
        the latest known information on the availability of the exchange API

        https://docs.woox.io/#get-system-maintenance-status-public

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
        datastatusNerror0okr  )r*  updatedetar   r   )v1PublicGetSystemInfo	safe_dictsafe_string)r$  paramsresponser)  r*  s        r&  fetch_statuszwoo.fetch_status  sn     --f5 ~~h3!!$1>Fs]F"F
 	
r'  c                 H    | j                  |      }| j                  |d      S )aW  
        fetches the current integer timestamp in milliseconds from the exchange server

        https://docs.woox.io/#get-system-maintenance-status-public

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int: the current integer timestamp in milliseconds from the exchange server
        	timestamp)r0  safe_integer)r$  r3  r4  s      r&  
fetch_timezwoo.fetch_time  s)     --f5   ;77r'  c                     | j                   d   r| j                          | j                  |      }| j                  |dg       }| j	                  |      S )a  
        retrieves data on all markets for woo

        https://docs.woox.io/#exchange-information

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        r   rows)r   load_time_differencev1PublicGetInfo	safe_listparse_marketsr$  r3  r4  r)  s       r&  fetch_marketszwoo.fetch_markets  sR     <<12%%'''/, ~~h3!!$''r'  marketc                    | j                  |d      }|j                  d      }| j                  |d      }d}d}|dk(  rd}d}n	|dk(  rd}d	}| j                  |d
      }| j                  |d      }	| j                  |      }
| j                  |	      }d }d }|
dz   |z   }d }d }d }d}|}|rHd}| j                  |d      }| j                  |      }|
dz   |z   dz   |z   }| j                  d      }d}d}| j                  |d      dk(  }i d|d|d|
d|d|d|d|	d|dd|d|d	|ddddd|d|d|||d d d d | j	                  |d      | j	                  |d      d d d d!| j	                  |d"      | j	                  |d#      d!| j	                  |d$      | j	                  |d%      d!| j	                  |d&      d d!d'| j                  |d(      |d)
S )*Nsymbol_r   FSPOTTr>   PERPr@   r   r   /:1
is_tradingr1   basequotesettlebaseIdquoteIdsettleIdtyper?   rA   rB   activecontractr  	base_tick
quote_tick)amountpriceminmaxbase_minbase_max	quote_min	quote_maxmin_notional)r  rW  rX  costcreated_time)
r  contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedr   )r2  splitsafe_currency_coder#  safe_numbersafe_timestamp)r$  rB  marketIdpartsfirstr>   r@   
marketTyperO  rP  rL  rM  rQ  rN  rD  rc  r  r  r?   rT  rS  s                        r&  parse_marketzwoo.parse_market   s   ##FH5s#  *F?DJf_DJ!!%+""5!,&&v.''0e# F''q1H,,X6FCZ%'#-6F,,S1LFG!!&,73>0
(0
f0
 D0
 U	0

 f0
 f0
 w0
 0
 J0
 D0
 f0
 D0
 e0
 e0
 f0
  !0
" f#0
$ ("**6;?))&,?  
  ++FJ?++FJ?
  ++FK@++FK@
  ++FNC$ **6>B_0
 0	
r'  NrD  sincer  c                     | j                          | j                  |      }d|d   i}|||d<   | j                  | j                  ||            }| j	                  |dg       }| j                  ||||      S )a  
        get the list of most recent trades for a particular symbol

        https://docs.woox.io/#market-trades-public

        :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>`
        rD  r1   r  r;  )load_marketsrB  v1PublicGetMarketTradesextendr>  parse_trades)	r$  rD  rt  r  r3  rB  requestr4  resultResponses	            r&  fetch_tradeszwoo.fetch_tradest  s     	V$fTl
 $GG//GV0LM< &"=  FFr'  tradec                 T   d|v }| j                  |d      }| j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  |d      }| j                  |d      }	| j                  |dd      }
| j                  |
d	      }|||
d	<   t	        j
                  ||      }| j                  |d
      }| j                  |d      }d }|r| j                  |d      dk(  }|rdnd}| j                  ||| j                  |      ||||||	|d |
|d|      S )Nr1   executed_timestamprD  executed_priceexecuted_quantityorder_id	fee_assetfeera  sideis_makerrJ  r   r   )r1   r7  datetimerD  r  rX  rW  ra  r   takerOrMakerrR  r  r   )	rn  r2  safe_marketparse_token_and_fee_tempr,   
string_mulsafe_string_lower
safe_tradeiso8601)r$  r}  rB  isFromFetchOrderr7  ro  rD  rX  rW  r  r  feeCostra  r  r1   r  isMakers                    r&  parse_tradezwoo.parse_trade  se   8 !EM''/CD	##E84!!(F3!  (89!!%)<=##E:6++E;F""3/!CK!!%0%%eV4eT* &&uj9S@G&-77L"Y/( 
  	r'  c                     | j                  ||      }d }|(| j                  ||      }| j                  |      }||d}|S )Nra  currency)r2  rl  )r$  itemfeeTokenKeyfeeAmountKeyr  r  feeCurrencyIdfeeCurrencyCodes           r&  r  zwoo.parse_token_and_fee_temp  sU    ""46 ,,T;?M"55mDO+C 
r'  c           
         | j                          | j                  |      }| j                  |di       }| j                  |d      }| j                  |d      }i }t	        dt        | j                              D ]c  }| j                  |   }||| j                  t        j                  |d            | j                  t        j                  |d            ddd||<   e |S )aL  
        fetch the trading fees for multiple markets

        https://docs.woox.io/#get-account-information-new

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
        r)  makerFeeRatetakerFeeRater   10000T)r   rD  r   r   r   r   )
rv  v3PrivateGetAccountinfor1  r2  rangelensymbolsr#  r,   
string_div)	r$  r3  r4  r)  r   r   resultirD  s	            r&  fetch_trading_feeszwoo.fetch_trading_fees  s     	//7: ~~h3  ~6  ~6q#dll+, 		A\\!_F  **7+=+=eW+MN**7+=+=eW+MN"!F6N		 r'  c                    i }| j                  |      }| j                  |dg       }| j                  |d      }t        |j	                               }t        dt        |            D ]  }||   }||   }	| j                  |      }
d}d}i }t        dt        |	            D ]  }|	|   }| j                  |d      }| j                  |d      }|j                  d      }|d   }| j                  | j                  |d            }|||nt        j                  ||      }||ddd	ddd	d
dddd| j                  |      |d	||<    |||
| j                  |      dd|dddddd	ddd	d|	d||
<    |S )a  
        fetches all available currencies on an exchange

        https://docs.woox.io/#available-token-public

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r;  balance_tokenr   Nfullnamer   rE  decimalsrY  )r   deposit)	r1   networkri  rS  r  r   r  rh  r   crypto)r  r   )r1   r2   coderh  rS  r  r   r  r   rR  ri  r   )v1PublicGetTokenr>  group_bylistkeysr  r  rl  r2  rk  parse_precisionr,   
string_minr#  )r$  r3  r  tokenResponse	tokenRowsnetworksByCurrencyIdcurrencyIdsr  
currencyIdr   r  r2   minPrecisionresultingNetworksjr  	networkIdsplittedunifiedNetworkrh  s                       r&  fetch_currencieszwoo.fetch_currencies*  s    --f5z NN=&"=	#}}YH/4467q#k*+ :	A$QJ+J7H**:6DDL&(1c(m, "1+''< ,,Wg>	$??3/!)! 001A1A':1VW	(1=1E9GL^L^_hjvLwL#- $(#'%
 $(#'$	 ## $!%!2!29!=#%5!.1< !!..|<-    $# 
  $#!	 !+F4LI:	v r'  ra  c                     | j                          | j                  |      }|d   st        | j                  dz         | j	                  |dd|d|      S )a  
        create a market buy order by providing the symbol and cost

        https://docs.woox.io/#send-order

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r>   z9 createMarketBuyOrderWithCost() supports spot orders onlyrB  buyr   rv  rB  r'   r1   create_orderr$  rD  ra  r3  rB  s        r&  !create_market_buy_order_with_costz%woo.create_market_buy_order_with_cost  sU     	V$f~tww)ddee  5$6JJr'  c                     | j                          | j                  |      }|d   st        | j                  dz         | j	                  |dd|d|      S )a  
        create a market sell order by providing the symbol and cost

        https://docs.woox.io/#send-order

        :param str symbol: unified symbol of the market to create an order in
        :param float cost: how much you want to trade in units of the quote currency
        :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: createMarketSellOrderWithCost() supports spot orders onlyrB  sellr   r  r  s        r&  "create_market_sell_order_with_costz&woo.create_market_sell_order_with_cost  sU     	V$f~tww)eeff  64FKKr'  rR  r  rW  rX  c	                     |t        | j                  dz         |t        | j                  dz         ||d<   ||d<   | j                  ||||||      S )a  
        create a trailing order by providing the symbol, type, side, amount, price and trailingAmount

        https://docs.woox.io/#send-algo-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, or number of contracts
        :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
        :param float trailingAmount: the quote amount to trail away from the current market price
        :param float trailingTriggerPrice: the price to activate a trailing order, default uses the price argument
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        z? createTrailingAmountOrder() requires a trailingAmount argumentzE createTrailingAmountOrder() requires a trailingTriggerPrice argumenttrailingAmounttrailingTriggerPricer$   r1   r  )	r$  rD  rR  r  rW  rX  r  r  r3  s	            r&  create_trailing_amount_orderz woo.create_trailing_amount_order  sk      !#DGG.o$opp'#DGG.u$uvv#1 )=%&  tVUFKKr'  c	                     |t        | j                  dz         |t        | j                  dz         ||d<   ||d<   | j                  ||||||      S )a  
        create a trailing order by providing the symbol, type, side, amount, price and trailingPercent

        https://docs.woox.io/#send-algo-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much you want to trade in units of the base currency, or number of contracts
        :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
        :param float trailingPercent: the percent to trail away from the current market price
        :param float trailingTriggerPrice: the price to activate a trailing order, default uses the price argument
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        zA createTrailingPercentOrder() requires a trailingPercent argumentzF createTrailingPercentOrder() requires a trailingTriggerPrice argumenttrailingPercentr  r  )	r$  rD  rR  r  rW  rX  r  r  r3  s	            r&  create_trailing_percent_orderz!woo.create_trailing_percent_order  sk      "#DGG.q$qrr'#DGG.v$vww$3 !)=%&  tVUFKKr'  c                 ^	   | j                  |dd      }| j                  |ddg      }|j                         }| j                          | j	                  |      }	|j                         }
|	d   |
d}d}| j                  d|      \  }}|| j                  |      |d<   | j                  |dd	      }| j                  |d
      }| j                  |d      }| j                  |d      }| j                  |dd| j                  |            }| j                  |dd      }| j                  |dd      }|du}|du}|xs |}|xs& |duxs  |duxs |duxs | j                  |d      du}|dk(  }| j                  |d      }| j                  |d|      }|rdnd}|rdnd}|rdnd}|rdnd}|rdnd}|||<   |s|rd|d<   n|dk(  rd |d<   n
|d!k(  rd"|d<   |r|||<   |s|| j                  ||      ||<   |r|s| j                  |d#d$      } | j                  |d#d$g      }|du}!|	d%   rk|!s| gd}"| | j                  ||       }"nJ| j                  |      }#| j                  |      }$t        j                   |#|$      }%| j                  ||%      }"|"|d$<   n0| j#                  ||      |d<   n|d&k7  r| j#                  ||      ||<   | j%                  |g d'      }&|&|&||<   |rZ|t'        | j(                  d(z         | j                  ||      |d<   d)|d<   |r||d<   n|rt        j*                  |d*      }'|'|d<   n| |d)k7  r| j                  ||      |d<   d+|d<   n||d,|d<   |	d   d-d&g d.}(|(d   })|
d/k(  rd0nd/}*|<| j                  |d|      }+|*d1| j                  ||+      d2d3d4},|)j-                  |,       |<| j                  |d|      }-|*d5| j                  ||-      d2d3d4}.|)j-                  |.       |(g|d<   | j                  |g d6      }d}/|r"| j/                  | j1                  ||            }/n!| j3                  | j1                  ||            }/| j5                  |/d7      }0|0(| j7                  |0d8g       }1| j9                  |1d9   |	      S | j9                  |/|	      }2||2d<   |2S ):a\  
        create a trade order

        https://docs.woox.io/#send-order
        https://docs.woox.io/#send-algo-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated', default 'cross'
        :param float [params.triggerPrice]: The price a trigger order is triggered at
        :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
        :param float [params.takeProfit.triggerPrice]: take profit trigger price
        :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
        :param float [params.stopLoss.triggerPrice]: stop loss trigger price
        :param float [params.algoType]: 'STOP' or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
        :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
        :param str [params.trailingAmount]: the quote amount to trail away from the current market price
        :param str [params.trailingPercent]: the percent to trail away from the current market price
        :param str [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument
        :param str [params.position_side]: 'SHORT' or 'LONG' - if position mode is HEDGE_MODE and the trading involves futures, then is required, otherwise self parameter is not required
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        
reduceOnlyreduce_onlyr1   )rD  r  NrP   margin_moder   	stopPricestopLoss
takeProfitalgoTyper  activatedPricer  callbackValuer  callbackRatechildOrdersMARKETr  clientOrderIdclient_order_idquantityorder_quantityrX  order_pricerR  
order_type	POST_ONLYfokr   iocr   ra  order_amountr>   POSITIONAL_TP_SLclOrdIDr  r  zL createOrder() requires a trailingTriggerPrice parameter for trailing ordersTRAILING_STOP100STOPBRACKETF)rD  r  r  r  BUYSELL	STOP_LOSSCLOSE_POSITIONT)r  r  r   rR  r  TAKE_PROFIT)r  r  r  postOnlyr  r  r   r  r  r  r  r  r)  r;  r   )safe_bool_2omitupperrv  rB  handle_margin_mode_and_paramsencode_margin_modesafe_string_2
safe_valuer2  number_to_stringr  is_post_onlyprice_to_precisioncost_to_precisionr,   r  amount_to_precisionsafe_string_nr$   r1   r  appendv3PrivatePostAlgoOrderrx  v1PrivatePostOrderr1  r>  parse_order)3r$  rD  rR  r  rW  rX  r3  r  	orderTyperB  	orderSiderz  r   r   r  r  r  r  r  r  isTrailingAmountOrderisTrailingPercentOrder
isTrailingisConditionalisMarketr  r  reduceOnlyKeyclientOrderIdKeyorderQtyKeypriceKeytypeKeyra  isPriceProvidedquoteAmountamountStringpriceStringcostRequestr  convertedTrailingPercentoutterOrderr  	closeSider   stopLossOrderr  takeProfitOrderr4  r)  r;  r   s3                                                      r&  r  zwoo.create_order  s   6 %%flMJ
6L-#@AJJL	V$JJL	Tl
 
!??vV
F!%)%<%<Z%HGM"))&.+N??6:6__V\:
##FJ7#11&:PRbdhdydyz  eA   B++F4DoV,,V5FW .d :!0!<*D.D
"  il$&>  i(RVBV  iZdlpZp  iuy  vE  vE  FL  N[  v\  dh  vh(,,V]C$$XtV<(5=.;?AR$1j7G+7)&|$(3%%(-%%(-%%/GM"E- $ 7 7 FGHM%%ffnEDYYv'?@F#4/Of~?t7G"#"&"8"8"FK#'#8#8#@L"&"7"7">K")"4"4\;"OK"&"8"8"MK*5',0,D,DVV,T()++#'#;#;FF#KGK **63bc$(5G$%#+'  3A  )A  B  B(,(?(?H\(]G$%"1GJ$+9('+2+=+=ou+U(*B'%?**.*A*A&,*W'&,
#"
(>"+GJ ,#.!	!K &m4K#,#5EI# $ 0 0>8 T% +$($;$;FM$R,"&' ""=1%"&"2"2:~z"Z% -$($;$;FO$T,"&) ""?3&1]GM"6  $b  c224;;w3OPH..t{{7F/KLH4 ~~h/>>$3D##DGV44  62fr'  c                 2    ddd}| j                  |||      S )NCROSSISOLATED)crossisolatedr2  )r$  modemodess      r&  r  zwoo.encode_margin_mode  s&    "
 tT22r'  r1   c                 X   | j                          | j                  |      }i }	|| j                  ||      |	d<   || j                  ||      |	d<   | j	                  |dd      }
| j                  |d|
      }|du}| j                  |g d      }|| j                  ||      |	d<   | j	                  |d	d
| j                  |            }| j	                  |dd      }| j	                  |dd      }|du}|du}|xs |}|r<|| j                  ||      |	d
<   |r||	d<   n|rt        j                  |d      }||	d<   | j                  |g d      }|xs |duxs | j                  |d      du}d}|rK||	d<   |r"| j                  | j                  |	|            }nl| j                  | j                  |	|            }nJ||	d<   |r"| j                  | j                  |	|            }n!| j!                  | j                  |	|            }| j#                  |di       }| j%                  ||      S )a  
        edit a trade order

        https://docs.woox.io/#edit-order
        https://docs.woox.io/#edit-order-by-client_order_id
        https://docs.woox.io/#edit-algo-order
        https://docs.woox.io/#edit-algo-order-by-client_order_id

        :param str id: order id
        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param float [params.triggerPrice]: The price a trigger order is triggered at
        :param float [params.stopLossPrice]: price to trigger stop-loss orders
        :param float [params.takeProfitPrice]: price to trigger take-profit orders
        :param str [params.trailingAmount]: the quote amount to trail away from the current market price
        :param str [params.trailingPercent]: the percent to trail away from the current market price
        :param str [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrX  r  r  r  r  )r   r  r  r   r   r  r  r  r  r  r  r  )
r  r  r  r  r   r  r   r  r  r  r  oidr)  )rv  rB  r  r  r  r2  safe_number_nr  r,   r  r  r  (v3PrivatePutAlgoOrderClientClientOrderIdrx  $v3PrivatePutOrderClientClientOrderIdv3PrivatePutAlgoOrderOidv3PrivatePutOrderOidr1  r  )r$  r1   rD  rR  r  rW  rX  r3  rB  rz  clientOrderIdUnifiedclientOrderIdExchangeSpecificisByClientOrderr   r  r  r  r	  r
  r  r  r  r4  r)  s                           r&  
edit_orderzwoo.edit_order  s   0 	V$
 #66vuEGG"&":":66"JGJ#11&)_U(,(8(8ARTh(i%7tC))&2st#&*&=&=fl&SGN##11&:PRbdhdydyz  eA   B++F4DoV,,V5FW .d :!0!<*D.D
#/,0,C,CFL`,a()$+9('+2+=+=ou+U(*B'6  $Q  R"x|4'?xT__U[]jEkswEw)FG%&HHU\^dIefDDT[[QXZ`EabGEN88Wf9UV44T[[&5QR ~~h3f--r'  c                    | j                  |ddd      }| j                  |ddg      }|s|t        | j                  dz         | j	                          d}|| j                  |      }i }| j                  |dd      }| j                  |d|      }|du}	d}
|r'||d	<   | j                  | j                  ||            }
nk|d
   |d<   |	r;||d<   | j                  |g d      }| j                  | j                  ||            }
n&||d	<   | j                  | j                  ||            }
d|i}|	r||d<   n||d
<   | j                  | j                  |
      |      S )a2  

        https://docs.woox.io/#cancel-algo-order
        https://docs.woox.io/#cancel-order
        https://docs.woox.io/#cancel-order-by-client_order_id

        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
        :param boolean [params.trigger]: whether the order is a trigger/algo order
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  stopFNz) cancelOrder() requires a symbol argumentr  r  r  r  r1   rD  r  )r  r  r$   r1   rv  rB  r  r2  v3PrivateDeleteAlgoOrderOrderIdrx  v1PrivateDeleteClientOrderv1PrivateDeleteOrderr  )r$  r1   rD  r3  	isTriggerrB  rz  r,  r-  r.  r4  extendParamss               r&  cancel_orderzwoo.cancel_order  s    $$VYF	6Iv#67fn#DGG.Y$YZZ[[(F#11&)_U(,(8(8ARTh(i%7tC"$GJ;;DKKQW<XYH &tGH-J)*6+Z[::4;;wPV;WX&(
#44T[[&5QR '/.KL*+!#L{{4++H5|DDr'  c                 `   | j                          | j                  |dd      }| j                  |ddg      }|r| j                  |      S |t	        | j
                  dz         | j                  |      }d|d   i}| j                  | j                  ||            }| j                  |      gS )a  

        https://docs.woox.io/#cancel-all-pending-orders
        https://docs.woox.io/#cancel-orders
        https://docs.woox.io/#cancel-all-pending-algo-orders

        cancel all open orders in a market
        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.trigger]: whether the order is a trigger/algo order
        :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        r1  r  z* cancelOrders() requires a symbol argumentrD  r1   )
rv  r  r   v3PrivateDeleteAlgoOrdersPendingr$   r1   rB  v1PrivateDeleteOrdersrx  
safe_order)r$  rD  r3  r  rB  rz  r4  s          r&  cancel_all_orderszwoo.cancel_all_ordersA  s     	""669=6FI#6788@@>#DGG.Z$Z[[V$fTl
 --dkk'6.JK OOH%
 	
r'  timeoutc                     | j                          d|dkD  r|ndi}| j                  | j                  ||            }| j                  |      gS )aM  
        dead man's switch, cancel all orders after the given timeout

        https://docs.woox.io/#cancel-all-after

        :param number timeout: time in milliseconds, 0 represents cancel the timer
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: the api result
        trigger_afterr   )rv   v1PrivatePostOrderCancelAllAfterrx  r;  )r$  r=  r3  rz  r4  s        r&  cancel_all_orders_afterzwoo.cancel_all_orders_afterd  sY     	1W1
 88Wf9UV OOH%
 	
r'  c                    | j                          || j                  |      nd}| j                  |dd      }| j                  |ddg      }i }| j	                  |dd      }d}|r'||d<   | j                  | j                  ||            }nO|r'||d<   | j                  | j                  ||            }n&||d<   | j                  | j                  ||            }| j                  |d|      }	| j                  |	|      S )	a  

        https://docs.woox.io/#get-algo-order
        https://docs.woox.io/#get-order

        fetches information on an order made by the user
        :param str id: the 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
        :param boolean [params.trigger]: whether the order is a trigger/algo order
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        Nr1  r  r  r  r&  r  r)  )rv  rB  r  r  r  v3PrivateGetAlgoOrderOidrx  $v1PrivateGetClientOrderClientOrderIdv1PrivateGetOrderOidr1  r  )
r$  r1   rD  r3  rB  r  rz  r  r4  r   s
             r&  fetch_orderzwoo.fetch_order  s	    	)/);V$$""669=6FI#67**69oNGEN44T[[&5QRH)6G%&@@WV\A]^HGEN00Wf1MNHH &(;//r'  c           	         | j                          d}| j                  |dd      \  }}|r| j                  d||||dd      S i }d}| j                  |dd      }| j	                  |d	d      }	| j                  |g d
      }|| j                  |      }|d   |d<   ||s|	r||d<   n||d<   |||d<   nd|d<   |rd|d<   n|	rd|d<   d}
|s|	r"| j                  | j                  ||            }
n!| j                  | j                  ||            }
| j                  |
d|
      }| j                  |d      }| j                  ||||      S )  
        fetches information on multiple orders made by the user

        https://docs.woox.io/#get-orders
        https://docs.woox.io/#get-algo-orders

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: the earliest time in ms to fetch orders for
        :param int [limit]: the maximum number of order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.trigger]: whether the order is a trigger/algo order
        :param boolean [params.isTriggered]: whether the order has been triggered(False by default)
        :param str [params.side]: 'buy' or 'sell'
        :param boolean [params.trailing]: set to True if you want to fetch trailing orders
        :param boolean [params.paginate]: set to True if you want to fetch orders with pagination
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Fr~   paginatepager  Nr1  r  r  )r1  r  r  r1   rD  createdTimeStartstart_tsizer  r  r)  r;  )rv  handle_option_and_params fetch_paginated_call_incrementalr  	safe_boolr  rB  v3PrivateGetAlgoOrdersrx  v1PrivateGetOrdersr  r>  parse_orders)r$  rD  rt  r  r3  rI  rz  rB  r  r  r4  r)  r   s                r&  fetch_orderszwoo.fetch_orders  s   $ 	88PZ[&88PUW\^dflnqrr""669=>>&*e<6#BC[[(F &tGH(.3*+%*	"#GFO!GFO"(GJ"1GJh224;;w3OPH..t{{7F/KLH@ x:f-  >>r'  c                 r    | j                          | j                  |ddi      }| j                  ||||      S )rH  r*  
INCOMPLETErv  rx  rT  r$  rD  rt  r  r3  extendedParamss         r&  fetch_open_orderszwoo.fetch_open_orders  s<    $ 	Vh-EF  ~FFr'  c                 r    | j                          | j                  |ddi      }| j                  ||||      S )rH  r*  	COMPLETEDrW  rX  s         r&  fetch_closed_orderszwoo.fetch_closed_orders-  s<    $ 	Vh-DE  ~FFr'  r  c                 4    dddd}| j                  ||d       S )Nr   r   r   )r  r  	post_onlyr"  )r$  r  timeInForcess      r&  parse_time_in_forcezwoo.parse_time_in_forceC  s)    

 k4@@r'  r   c                 V   | j                  |g d      }| j                  |g d      }| j                  | j                  |dd            }| j	                  |d      }| j                  ||      }|d   }| j                  |dd      }| j                  |dd	      }	| j                  |d
d      }
| j                  |dd      }| j                  |dd      }| j                  |d      }| j                  | j                  |dd            }| j                  | j                  |dd            }| j                  |dd      }| j                  |dd      }| j                  |d      }| j                  |d      }d }d }| j                  |d      }|}| j                  |d      }| j                  |dg       }t        |      }|dkD  rH| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |dd      }| j                  i d |d|d!|d"| j                  |      d#d d$|d| j!                  |      d|d|d%| j#                  |      d&d d'| j%                  |d(      d|d|d|d)|d*|||	|d |
|||d+|d,|      S )-N)r7  rb  createdTime)r  orderIdalgoOrderIdr  r  rD  r  rX  r  r  r  rW  r  rR  r*  
algoStatusr  executedtotalExecutedQuantityaverage_executed_priceaverageExecutedPrice	total_feetotalFeer  feeAssetTransactionsr   r  r   r   updatedTimeupdated_timer1   r7  r  lastTradeTimestamplastUpdateTimestampr  r  r  r  r  r   r  )averagerW  filled	remainingra  tradesr  r   )safe_timestamp_nr  	omit_zeror  r2  r  safe_string_lower_2safe_value_2r  safe_number_2r  rm  r  safe_timestamp_2r;  r  parse_order_statusra  rP  )r$  r   rB  r7  rd  r  ro  rD  rX  rW  ra  r  r*  r  rt  rs  r  feeCurrencytransactionsr   r  r   r  rq  innerChildOrdersinnerChildOrdersLengthr  r  rr  s                                r&  r  zwoo.parse_orderK  s_   Z ))%1]^	$$U,RSt'9'9%ARTc'de##E84!!(F3!""5-A##E+;ZH!!%B,,UL&I	""5(LA%%eV4 1 1%E\ ]^..!3!3E;SUk!lm  Z@((ZHun=''~>#!ooe];"OOK3E#umRH%()9%:"%)"&//2BA"F $0@! D"&"2"2?N"S $ 0 0 O"33E=.Y  
' 
] 
  
 Y/	 

 !$ 
 "#6 
 d--f5 
 f 
 I 
 433I> 
  
 $..> 
 D 
 U 
 L 
  ! 
" ]# 
$ "' 9 
: ; 	r'  r*  c           
      H    |dddddddddd	}| j                  |||      S |S )Nopenclosedcanceledrejected)	NEWFILLEDCANCEL_SENTCANCEL_ALL_SENT	CANCELLEDPARTIAL_FILLEDREJECTEDrV  r\  r"  r$  r*  statusess      r&  r}  zwoo.parse_order_status  sF    ")#-'"(&$%
H ##Hff==r'  c           	         | j                          | j                  |      }d|d   i}|t        |d      }||d<   | j                  | j	                  ||            }| j                  |d      }| j                  |||dddd	      S )
a-  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://docs.woox.io/#orderbook-snapshot-public

        :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
        rD  r1   r  	max_levelr7  bidsasksrX  r  )rv  rB  rZ  v1PublicGetOrderbookSymbolrx  r8  parse_order_book)r$  rD  r  r3  rB  rz  r4  r7  s           r&  fetch_order_bookzwoo.fetch_order_book  s     	V$fTl
 t$E#(GK 224;;w3OP" %%h<	$$Xvy&&RY[effr'  r   c                 ,   | j                          | j                  |      }|d   | j                  | j                  ||      d}|du}|1|/| j	                  |      dz  dz  }	| j                         |	z
  }
||
k  }|r||d<   n|t        |d      |d<   d}|s"| j                  | j                  ||            }n3| j                  | j                  ||            }| j                  |d      }| j                  |d	g       }| j                  |||||      S )
a  

        https://docs.woox.io/#kline-public
        https://docs.woox.io/#kline-historical-data-public

        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
        :param str symbol: unified symbol of the market to fetch OHLCV data for
        :param str timeframe: the length of time each candle represents
        :param int [since]: timestamp in ms of the earliest candle to fetch
        :param int [limit]: max=1000, max=100 when since is defined and is less than(now - (999 * (timeframe in ms)))
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        r1   )rD  rR  Nr  i  
start_timer  r)  r;  )rv  rB  r2  r   parse_timeframemillisecondsrZ  v1PublicGetKlinerx  v1PubGetHistKliner1  r>  parse_ohlcvs)r$  rD  	timeframert  r  r3  rB  rz  useHistEndpointoneThousandCandlesstartWithLimitr4  r;  s                r&  fetch_ohlcvzwoo.fetch_ohlcv  s3    	V$Tl$$T__iK
  t+E$5!%!5!5i!@4!G#!M!..03EEN#n4O$)GL!"5$/GG,,T[[&-IJH, --dkk'6.JKH~~h7H. ~~h3  vy%GGr'  c           	          | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      | j                  |d      gS )Nstart_timestampr  highlowclosevolume)r8  rm  )r$  ohlcvrB  s      r&  parse_ohlcvzwoo.parse_ohlcv>  so     e%67UF+UF+UE*UG,UH-
 	
r'  c                     | j                          d}|| j                  |      }d|i}| j                  | j                  ||            }| j	                  |dg       }	| j                  |	||||      S )a  
        fetch all the trades made from a single order

        https://docs.woox.io/#get-trades

        :param str id: order id
        :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 to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nr&  r;  )rv  rB  v1PrivateGetOrderOidTradesrx  r>  ry  )
r$  r1   rD  rt  r  r3  rB  rz  r4  rv  s
             r&  fetch_order_tradeszwoo.fetch_order_tradesI  s     	[[(F2
 224;;w3OP& &"5  vFFr'  c           	         | j                          d}| j                  |dd      \  }}|r| j                  d||||dd      S i }d}|| j                  |      }|d   |d<   |||d	<   | j	                  d
||      \  }}|||d<   nd|d<   | j                  | j                  ||            }| j                  |dg       }	| j                  |	||||      S )aJ  
        fetch all trades made by the user

        https://docs.woox.io/#get-trade-history

        :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
        :param boolean [params.paginate]: set to True if you want to fetch trades with pagination
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Frw   rI  rJ  r  Nr1   rD  rL  end_trM  r;  )	rv  rN  rO  rB  handle_until_optionv1PrivateGetClientTradesrx  r>  ry  )
r$  rD  rt  r  r3  rI  rz  rB  r4  rv  s
             r&  fetch_my_tradeszwoo.fetch_my_tradess  s    	88R\]&88&RWY^`fhnpstt[[(F &tGH!&GI227GVL#GFO!GFO00Wf1MN0 &"5  vFFr'  c                 n    | j                  |      }| j                  |dg       }| j                  ||      S )aY  
        fetch all the accounts associated with a profile

        https://docs.woox.io/#get-assets-of-subaccounts

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
        r;  )v1PrivateGetSubAccountAssetsr>  parse_accounts)r$  r3  r4  r;  s       r&  fetch_accountszwoo.fetch_accounts  s;     44V<" ~~h3""400r'  c                 \    | j                  |d      }|| j                  |d      |d |dk(  dS )Naccountapplication_idmain)r   r1   r2   r  rR  r"  )r$  r  	accountIds      r&  parse_accountzwoo.parse_account  sB     $$Wi8	""7,<='
 	
r'  c                     | j                          | j                  |      }| j                  |d      }| j                  |      S )ae  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://docs.woox.io/#get-current-holding-get-balance-new

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        r)  )rv  v3PrivateGetBalancesr1  parse_balancer@  s       r&  fetch_balancezwoo.fetch_balance  sC     	,,V40 ~~h/!!$''r'  c                 P   d|i}| j                  |dg       }t        dt        |            D ]g  }||   }| j                  | j	                  |d            }| j                         }| j	                  |d      |d<   | j	                  |d      |d<   |||<   i | j                  |      S )Nr   holdingr   r   totalavailableBalancefree)r>  r  r  rl  r2  r  safe_balance)r$  r4  r  r   r  balancer  r  s           r&  r  zwoo.parse_balance  s    H
 >>(Ir:q#h-( 	#AqkG**4+;+;GW+MNDllnG#//CGG"..w8JKGFO"F4L	#   ((r'  r  c                    | j                          | j                  |      }| j                  |      }| j                  |d|      }| j	                  |d      }|dz   |d   z   }d|i}| j                  | j                  ||            }| j                  |d      }	| j                  |d      }
| j                  |
       ||||
|	dS )as  
        fetch the deposit address for a currency associated with self account

        https://docs.woox.io/#get-token-deposit-address

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        r  rE  r  r   extraaddress)r   r  r  r  tag)rv  r  !default_network_code_for_currencyr2  r  v1PrivateGetAssetDepositrx  check_address)r$  r  r3  r  networkCodeDefaultnetworkCodecodeForExchangerz  r4  r  r  s              r&  fetch_deposit_addresszwoo.fetch_deposit_address  s     	==&!CCDI&&vy:LM69-%+hv.>>_
 00Wf1MN x1""8Y77#"
 	
r'  c                 >   | j                          i }d }|| j                  |      }|d   |d<   |||d<   |||d<   | j                  |d      }| j                  |d      }|||d<   | j	                  | j                  ||            }|| j                  |dg       gS )Nr1   r  rL  pageSizerR  r;  )rv  r  r2  r  v1PrivateGetAssetHistoryrx  r>  )	r$  r  rt  r  r3  rz  r  transactionTyper4  s	            r&  get_asset_history_rowszwoo.get_asset_history_rows2  s    !}}T*H'/~GO$!&GI"'GJ**66:66*&-GFO00Wf1MNF $..62>??r'  c                     | j                  ||||      }| j                  |d      }| j                  |d      }| j                  |||||      S )a?  
        fetch the history of changes, actions done by the user or operations that altered balance of the user

        https://docs.woox.io/#get-asset-history

        :param str [code]: unified currency code, default is None
        :param int [since]: timestamp in ms of the earliest ledger entry, default is None
        :param int [limit]: max number of ledger entries to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
        r   r   )r  r  r>  parse_ledger)r$  r  rt  r  r3  currencyRowsr  r;  s           r&  fetch_ledgerzwoo.fetch_ledgerf  sS     224vN??<3~~lA.  xvFFr'  r  r  c                 Z   | j                  |d      }| j                  ||      }|d   }| j                  ||      }| j                  |d      }| j                  |d      }|dk(  rdnd}| j	                  |d      }	| j                  |d	d
      }
| j                  || j                  |d      || j                  |d      d | j                  |d      | j                  | j                  |d            |d d ||	| j                  |	      | j                  | j                  |d            |
d|      S )Nr   r  rW  
token_sideDEPOSITinoutrb  	fee_token
fee_amountr1   r  tx_idr*  rR  )r   r1   r  r  referenceAccountreferenceIdr*  rW  beforeafter	directionr7  r  rR  r  )
r2  get_currency_from_chaincodesafe_currencyrm  rn  r  safe_ledger_entryparse_transaction_statusr  parse_ledger_entry_type)r$  r  r  networkizedCodecurrencyDefinedr  rW  r  r  r7  r  s              r&  parse_ledger_entryzwoo.parse_ledger_entryw  sD   **49::?HUv&%%dH5!!$1l3!Y.DU	''n=	++D+|L%%""4.''i8 $++D':33D4D4DT84TU""Y/001A1A$1OP'
  ! 	r'  c                 2    ddd}| j                  |||      S )Ntransactionr   )BALANCE
COLLATERALr"  )r$  rR  typess      r&  r  zwoo.parse_ledger_entry_type  s&    $$
 tT22r'  c                     ||S |j                  d      }t        |      }| j                  |d      }| j                  |d|      }|dkD  r|d| j                  |d      z   z  }| j                  |      }|S )NrE  r   r   r   )rk  r  r2  r  )r$  r  r  rp  partsLength	firstPartr  s          r&  r  zwoo.get_currency_from_chaincode  s    O#))#.Ee*K((2I))%I>JQcD$4$4UA$>>>
))*5Hr'  c           	      R    ddi}| j                  |||| j                  ||            S )a  
        fetch all deposits made to an account

        https://docs.woox.io/#get-asset-history

        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch deposits for
        :param int [limit]: the maximum number of deposits structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        r  r  fetch_deposits_withdrawalsrx  r$  r  rt  r  r3  rz  s         r&  fetch_depositszwoo.fetch_deposits  s5     )
 ..tUE4;;wX^C_``r'  c           	      R    ddi}| j                  |||| j                  ||            S )a  
        fetch all withdrawals made from an account

        https://docs.woox.io/#get-asset-history

        :param str code: unified currency code
        :param int [since]: the earliest time in ms to fetch withdrawals for
        :param int [limit]: the maximum number of withdrawals structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
        r  WITHDRAWr  r  s         r&  fetch_withdrawalszwoo.fetch_withdrawals  s5     *
 ..tUE4;;wX^C_``r'  c           	          ddi}| j                  |||| j                  ||            }| j                  |d      }| j                  |d      }| j	                  |||||      S )aV  
        fetch history of deposits and withdrawals

        https://docs.woox.io/#get-asset-history

        :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
        :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
        :param int [limit]: max number of deposit/withdrawals to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        rR  r  r   r   )r  rx  r  r>  parse_transactions)	r$  r  rt  r  r3  rz  r  r  r;  s	            r&  r  zwoo.fetch_deposits_withdrawals  sp     I
 224t{{SZ\bGcd??<3~~lA. &&tXueVLLr'  r  c                    | j                  |d      }| j                  ||      }|d   }| j                  |d      }|dk(  rd}| j                  |dd      }| j                  |d      }| j                  |d	      }	| j	                  |d
      }
i d|d| j                  |dd      d| j                  |d      d|
d| j                  |
      dd d|	d|d| j                  |d      dd dd d|d| j                  |d      d|d| j                  | j                  |d            d| j	                  |d      dd d |d d S )!Nr   r  r  r   
withdrawalr  r  target_addresssource_addressrb  r   r1   withdraw_idtxidr  r7  r  r  addressFrom	addressTor  r  tagFromtagTorR  rW  r  r*  r.  rp  comment)internalr  r  )	r2  r  r  r  rn  r  r  rm  r  )r$  r  r  r  r  r  movementDirectionr  r
  r	  r7  s              r&  parse_transactionzwoo.parse_transaction  s   **;@::?HUv& 22;M
* ,++KlS$$[2BC	&&{4DE''^D	
K
$$$[$F
 D$$[':
 	

 Y/
 t
 ;
 
 4##K9
 t
 T
 %
 d&&{H=
 
 d33D4D4D[RZ4[\
  t**;G!
" t#
$ )
 	
r'  c                 8    dddddd}| j                  |||      S Npendingr-  r  )r  
CONFIRMING
PROCESSINGr\  CANCELEDr"  r  s      r&  r  zwoo.parse_transaction_status	  /    ##"
 &&99r'  fromAccount	toAccountc                 b   | j                          | j                  |      }|d   | j                  |      ||d}| j                  | j	                  ||            }| j                  ||      }	| j                  | j                  di       }
| j                  |
dd      }|r||	d<   ||	d<   ||	d<   |	S )	a  
        transfer currency internally between wallets on the same account

        https://docs.woox.io/#get-transfer-history

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        r1   )r   rW  from_application_idto_application_idr   r   TrW  r  r  )	rv  r  parse_to_numeric!v1PrivatePostAssetMainSubTransferrx  parse_transferr1  r   rP  )r$  r  rW  r  r  r3  r  rz  r4  r   transferOptionsr   s               r&  r   zwoo.transfer	  s     	==&d^++F3#.!*	
 99$++gv:VW &&x:..z2F"&..B[]a"b"!'HX&1H]#$-H[!r'  c                    i }|||d<   |||d<   | j                  |d      }| j                  |dg      }|||d<   | j                  | j                  ||            }| j	                  |dg       }| j                  |d|||      S )av  
        fetch a history of internal transfers made on an account

        https://docs.woox.io/#get-transfer-history

        :param str code: unified currency code of the currency transferred
        :param int [since]: the earliest time in ms to fetch transfers for
        :param int [limit]: the maximum number of  transfers structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: the latest time in ms to fetch entries for
        :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
        NrM  rL  untilr  r;  )r8  r  'v1PrivateGetAssetMainSubTransferHistoryrx  r>  parse_transfers)	r$  r  rt  r  r3  rz  r"  r4  r)  s	            r&  fetch_transferszwoo.fetch_transfers:	  s     #GFO!&GI!!&'26G9-$GG??GU[@\]2 ~~h3##D$ufEEr'  r   c                    | j                  |d      }| j                  ||      }|d   }| j                  |d      }| j                  |d      }d }||rdnd}| j                  |d      || j	                  |      || j                  |d      | j                  |d	      | j                  |d
      | j                  | j                  |d|            |d	S )Nr   r  rb  successr-  failedr1   rW  r  r  r*  )	r1   r7  r  r  rW  r  r  r*  r   )r2  r  rn  rP  r  rm  parse_transfer_status)	r$  r   r  r  r  r  r7  r'  r*  s	            r&  r  zwoo.parse_transferl	  s    , **8W=::?HUv&''.A	..95$T(F""8T2"Y/&&x:++H6KL))(4GH001A1A(HV\1]^

 
	
r'  c                 8    dddddd}| j                  |||      S r  r"  r  s      r&  r)  zwoo.parse_transfer_status	  r  r'  r  c                 @   | j                  ||      \  }}| j                          | j                  |       | j                  |      }||d}|||d<   | j	                  | j
                  di       }| j	                  |di       }	| j                  |d      }
| j                  ||
|
      }| j	                  |	|i       }| j                  |d      }|t        | j                  dz         ||d<   | j                  | j                  ||            }| j                  ||      S )a  
        make a withdrawal

        https://docs.woox.io/#token-withdraw

        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        )rW  r  r  r   r  r1   z% withdraw() require network parameterr   )handle_withdraw_tag_and_paramsrv  r  r  r1  r   safe_string_upperr2  r%   r1   v1PrivatePostAssetWithdrawrx  r  )r$  r  rW  r  r  r3  r  rz  r   currencyNetworksr  r  coinNetworkcoinNetworkIdr4  s                  r&  r   zwoo.withdraw	  s)    99#vFV7#==&
 ?"GG>>$,,
B?>>(JC((;$$Xw@	nn%5y"E((d; TWW'NNOO(224;;w3OP %%h99r'  c                 8   | j                          d}|| j                  |      }|d   }| j                  |      }|d   | j                  ||      d}| j	                  | j                  ||            }| j                  ||      }	| j                  |	||d      S )a  
        repay borrowed margin and interest

        https://docs.woox.io/#repay-interest

        :param str code: unified currency code of the currency to repay
        :param float amount: the amount to repay
        :param str symbol: not used by woo.repayMargin()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
        NrD  r1   )r   rW  )rW  rD  )rv  rB  r  currency_to_precisionv1PrivatePostInterestRepayrx  parse_margin_loan)
r$  r  rW  rD  r3  rB  r  rz  r4  r  s
             r&  repay_marginzwoo.repay_margin	  s     	[[(FH%F==&d^00v>
 224;;w3OP ,,Xx@{{;)
  	r'  c                 6    d | j                  d |      d d d d |dS )N)r1   r  rW  rD  r7  r  r   )rl  )r$  r   r  s      r&  r5  zwoo.parse_margin_loan	  s0     //h?
 	
r'  c                 B    | j                         | j                  d   z
  S )Nr   )r  r   )r$  s    r&  noncez	woo.nonce	  s       "T\\2B%CCCr'  r   GETc                    |d   }|d   }| j                  ||      }	| j                  | j                  d   |         }
|
d|z   dz   z  }
| j                  || j	                  |            }| j                  |      }|dk(  r'|
|dz   |	z   z  }
|r|
d| j                  |      z   z  }
n|dk(  r!|
|	z  }
|r|
d| j                  |      z   z  }
n| j                          |dk(  rz|d	k(  s|d
k(  rp| j                  | j                  dd      }|s@d}| j                  | j                  d|      }|j                  d      dkD  }|r||d<   n||d<   | j                  |      }d}t        | j                               }|
|	z  }
| j                  |d}|dk(  r`||z   dz   |z   dz   |	z   }|dk(  s
|dk(  s|dk(  r| j                  |      }||z  }n#|r!| j                  |      }|
d|z   z  }
|d|z   z  }d|d<   n:| j                  |      }|dk(  s
|dk(  s|dk(  r|}n
|r|
d|z   z  }
|d|z   z  }d|d<   | j!                  | j#                  |      | j#                  | j$                        t&        j(                        |d<   |
|||dS )Nr   r   r   rH  r   ?r   POSTr   r   r   Fr   r   algo	broker_id )z	x-api-keyzx-api-timestampr   PUTDELETEzapplication/jsonzcontent-type|z!application/x-www-form-urlencodedzx-api-signature)r   methodbodyheaders)implode_paramsimplode_hostnamer   r  extract_paramskeysort	urlencodecheck_required_credentialsrP  r   r2  findstrr9  apiKeyjsonhmacencodesecrethashlibsha256)r$  pathsectionrE  r3  rG  rF  r7   accesspathWithParamsr   isSandboxModeapplicationIdr   r5  authtsquerys                     r&  signzwoo.sign	  s   !*,,T6:##DIIe$4V$<=sW}s""64#6#6t#<=f%X6C<.00CsT^^F333u_>!CsT^^F333++-T\%9TW_ $t||]E R$$JM#//j-XH $		& 1B 6I -5z*.6{+f-DTZZ\"B>!C![[#%G $F{S(72S8>IV#v&H:L99V,DDLD $v 6sU{*e+*<'~~f-V#v&H:LDsTz)b *M')-4;;t3DdkkRVR]R]F^`g`n`n)oG%&fdwOOr'  httpCodereasonr   rE  rG  rF  c
                    |sy | j                  |d      }
| j                  |d      }|
sa| j                  dz   | j                  |      z   }| j	                  | j
                  d   ||       | j                  | j
                  d   ||       y )Nr'  r   r  r  )rP  r2  r1   rQ  throw_broadly_matched_exceptionr  throw_exactly_matched_exception)r$  ra  rb  r   rE  rG  rF  r4  requestHeadersrequestBodyr'  	errorCodefeedbacks                r&  handle_errorszwoo.handle_errors9
  s    
 ..95$$Xv6	ww}tyy'::H001I4QYZ001I9V^_r'  c           	         | j                  |d      }| j                  ||      }| j                  |d      }| j                  d      }| j                  |d      }| j                  |d      }| j	                  |d      }	| j                  |d      }
|
dk(  rt        j                  |      n|}||||| j                  |      || j                  |      |	d	S )
NrD  funding_feeUSDr1   rp  funding_ratepayment_typePay)r   rD  r  r7  r  r1   rW  rate)	r2  safe_symbolrl  rn  rm  r,   
string_negr  r#  )r$  incomerB  ro  rD  rW  r  r1   r7  rr  paymentTypes              r&  parse_incomezwoo.parse_incomeH
  s     ##FH5!!(F3!!&-8&&u-fd+''?	7&&v~>0;u0D##F+6"Y/''/	
 		
r'  c                    | j                          d}| j                  |dd      \  }}|r| j                  d||||dddd	      S i }d}|| j                  |      }|d   |d	<   |||d
<   |||d<   nd|d<   | j	                  | j                  ||            }| j                  |di       }	| j                  |	d      }
| j                  |dg       }t        |      }|dkD  r||dz
     }|
|d<   |||dz
  <   | j                  ||||      S )a"  
        fetch the history of funding payments paid and received on self account

        https://docs.woox.io/#get-funding-fee-history

        :param str [symbol]: unified market symbol
        :param int [since]: the earliest time in ms to fetch funding history for
        :param int [limit]: the maximum number of funding history structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
        Frj   rI  rJ  r   r  Nr1   rD  rL  rM  i  metacurrent_pager;  r   )rv  rN  fetch_paginated_call_cursorrB  v1PrivateGetFundingFeeHistoryrx  r1  r8  r>  r  parse_incomes)r$  rD  rt  r  r3  rI  rz  rB  r4  ry  cursorr  resultLengthlastItems                 r&  fetch_funding_historyzwoo.fetch_funding_historyj
  sY    	88AVXbc&334I6SXZ_agioqwyz|  A  A[[(F &tGH!&GI#GFO"GFO55dkk'66RS0 ~~h3""48&"56{!lQ./H%HV'/F<!#$!!&&%??r'  c                    | j                  |d      }| j                  |      }| j                  |d      }| j                  |d      }| j                  |d      }| j                  |d      }i d|d|d   dd dd d	| j                  d
      dd d|d| j	                  |      d| j                  |d      d|d| j	                  |      dd dd dd d| j                  |d      d|d| j	                  |      d|dz   iS )NrD  next_funding_timeest_funding_rate_timestamplast_funding_rate_timestampest_funding_rate_intervalr   	markPrice
indexPriceinterestRater,  estimatedSettlePricer7  r  fundingRateest_funding_ratefundingTimestampfundingDatetimenextFundingRatenextFundingTimestampnextFundingDatetimepreviousFundingRatelast_funding_ratepreviousFundingTimestamppreviousFundingDatetimeintervalh)r2  rB  r8  r#  r  rm  )r$  r  rB  rD  r  estFundingRateTimestamplastFundingRateTimestampintervalStrings           r&  parse_funding_ratezwoo.parse_funding_rate
  s    !!+x8V$#00>QR"&"3"3KA]"^#'#4#4[B_#` ))+7RS
K
fX&
 
 $	

 D--c2
 #D
 0
 %<=
 4++K9KL
  4
 t||,@A
 t
 #D
 "4
 "4#3#3KAT#U
  '(@!
" &t||4L'M#
$ ,%
 	
r'  c                 &    | j                  ||      S )aw  
        fetch the current funding rate interval

        https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        )fetch_funding_rate)r$  rD  r3  s      r&  fetch_funding_intervalzwoo.fetch_funding_interval
  s     &&vv66r'  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      S )an  
        fetch the current funding rate

        https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
        rD  r1   )rv  rB  v1PublicGetFundingRateSymbolrx  r  r$  rD  r3  rB  rz  r4  s         r&  r  zwoo.fetch_funding_rate
  s`     	V$fTl
 44T[[&5QR &&x88r'  r  c                     | j                          | j                  |      }| j                  |      }| j                  |dg       }| j	                  ||      S )a  
        fetch the funding rate for multiple markets

        https://docs.woox.io/#get-predicted-funding-rate-for-all-markets-public

        :param str[]|None symbols: list of unified market symbols
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
        r;  )rv  market_symbolsv1PublicGetFundingRatesr>  parse_funding_rates)r$  r  r3  r4  r;  s        r&  fetch_funding_rateszwoo.fetch_funding_rates
  sW     	%%g.//7" ~~h3''g66r'  c           
         | j                          d}| j                  |dd      \  }}|r| j                  d||||dd      S i }|| j                  |      }|d   }|d   |d<   || j	                  |dz        |d	<   | j                  d
||d      \  }}| j                  | j                  ||            }| j                  |d      }	g }
t        dt        |	            D ]p  }|	|   }| j                  |d      }| j                  |d      }|
j                  || j                  |      | j                  |d      || j!                  |      d       r | j#                  |
d      }| j%                  ||||      S )a  
        fetches historical funding rate prices

        https://docs.woox.io/#get-funding-rate-history-for-one-market-public

        :param str symbol: unified symbol of the market to fetch the funding rate history for
        :param int [since]: timestamp in ms of the earliest funding rate to fetch
        :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest funding rate
        :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
        :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
        Frn   rI  rJ     rD  r1   r  rL  r  gMbP?r;  r   funding_rate_timestampro  )r   rD  r  r7  r  r7  )rv  rN  rO  rB  parse_to_intr  v1PublicGetFundingRateHistoryrx  r>  r  r  r2  r8  r  rs  rm  r  sort_byfilter_by_symbol_since_limit)r$  rD  rt  r  r3  rI  rz  rB  r4  r  ratesr  entryro  r7  sorteds                   r&  fetch_funding_rate_historyzwoo.fetch_funding_rate_history  s    	88AZ\fg&889RTZ\achjprxz|}}[[(FH%F &tGH!%!2!254<!@GI227GVUS55dkk'66RS( &1q#f+& 
	A1IE''x8H))%1IJILL**84#//~F& LL3 	
	 e[100NNr'  r  c                 b    d}|rd}nd}d|i}| j                  | j                  ||            }|S )a~  
        set hedged to True or False for a market

        https://docs.woox.io/#update-position-mode

        :param bool hedged: set to True to use HEDGE_MODE, False for ONE_WAY
        :param str symbol: not used by woo setPositionMode
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: response from the exchange
        N
HEDGE_MODEONE_WAYposition_mode)v1PrivatePostClientPositionModerx  )r$  r  rD  r3  	hedgeModerz  r4  s          r&  set_position_modezwoo.set_position_mode^  sF     	$I!IY
 77GV8TU r'  c                    | j                          | j                  |      }d}|d   r| j                  |      }n{|d   rUd|d   i}d}| j                  d|d      \  }}| j	                  |      |d<   | j                  | j                  ||            }n!t        | j                  d	z   |d
   z   dz         | j                  |di       }| j                  ||      S )a	  
        fetch the set leverage for a market

        https://docs.woox.io/#get-account-information-new

        :param str symbol: unified market symbol
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated'
        :param str [params.position_mode]: *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
        :returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
        Nr>   r@   rD  r1   rr   r   r  & fetchLeverage() is not supported for rR   marketsr)  )rv  rB  r  r  r  !v1PrivateGetClientFuturesLeveragerx  r'   r1   r1  parse_leverage)r$  rD  r3  rB  r4  rz  r   r)  s           r&  fetch_leveragezwoo.fetch_leverage{  s     	V$&>33F;H: F^&,G #J!%!C!COU[]d!eJ%)%<%<Z%HGM"==dkk'SY>Z[HT tww)QQTZ[aTbbeoopp~~h3""400r'  r  c                    | j                  |d      }| j                  ||      }| j                  |d      }| j                  |d      }|}|}| j	                  |dg       }t        dt        |            D ]S  }	| j                  ||	i       }
| j                  |
d      }| j                  |
d      }|dk(  r|}|}D|dk(  r|}L|d	k(  sR|}U ||d   |||d
S )NrD  default_margin_moder  detailsr   position_sideBOTHLONGSHORT)r   rD  r   longLeverageshortLeverage)r2  r  r  r8  r>  r  r  r1  )r$  r  rB  ro  r   spotLeverager  r  r  r  positionpositionLeverager  s                r&  r  zwoo.parse_leverage  s   ##Hh7!!(F3++H6KL
((:>#$..9b9q#g,' 
	1A~~gq"5H#00:F##Ho>Dv~/ 0/ 0
	1 X&$(*
 	
r'  c                    | j                          d|i}d}|| j                  |      }||d   r!| j                  | j                  ||            S |d   rU|d   |d<   d}| j	                  d|d      \  }}| j                  |      |d	<   | j                  | j                  ||            S t        | j                  d
z   |d   z   dz         )a  
        set the level of leverage for a market

        https://docs.woox.io/#update-leverage-setting
        https://docs.woox.io/#update-futures-leverage-setting

        :param float leverage: the rate of leverage(1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets)
        :param str [symbol]: unified market symbol(is mandatory for swap markets)
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated'
        :param str [params.position_side]: *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode.
        :returns dict: response from the exchange
        r  Nr>   r@   r1   rD  rr   r   r  r  rR  r  )	rv  rB  v1PrivatePostClientLeveragerx  r  r  "v1PrivatePostClientFuturesLeverager'   r1   )r$  r  rD  r3  rz  rB  r   s          r&  set_leveragezwoo.set_leverage  s     	
 [[(FNvf~33DKK4PQQF^ &tGH"J!%!C!COU[]d!eJ%)%<%<Z%HGM"::4;;wPV;WXXtww)QQTZ[aTbbeooppr'  c                 *    | j                  ||d|      S )a  
        add margin

        https://docs.woox.io/#update-isolated-margin-setting

        :param str symbol: unified market symbol
        :param float amount: amount of margin to add
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.position_side]: 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
        ADDmodify_margin_helperr$  rD  rW  r3  s       r&  
add_marginzwoo.add_margin  s     ((GGr'  c                 *    | j                  ||d|      S )a  
        remove margin from a position

        https://docs.woox.io/#update-isolated-margin-setting

        :param str symbol: unified market symbol
        :param float amount: amount of margin to remove
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.position_side]: 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
        :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
        REDUCEr  r  s       r&  reduce_marginzwoo.reduce_margin&  s     ((6JJr'  c                     | j                          | j                  |      }|d   d||d}| j                  | j                  ||            S )Nr1   USDT)rD  adjust_tokenadjust_amountaction)rv  rB  !v1PrivatePostClientIsolatedMarginrx  )r$  rD  rW  rR  r3  rB  rz  s          r&  r  zwoo.modify_margin_helper4  sQ    V$Tl"#	
 55dkk'66RSSr'  c                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      S )NrD  r1   )rv  rB  v1PrivateGetPositionSymbolrx  parse_positionr  s         r&  fetch_positionzwoo.fetch_position?  s^    V$fTl
 224;;w3OP2 ""8V44r'  c                     | j                          | j                  |      }| j                  |di       }| j                  |dg       }| j	                  ||      S )Nr)  r   )rv  v3PrivateGetPositionsr1  r>  parse_positions)r$  r  r3  r4  r  r   s         r&  fetch_positionszwoo.fetch_positions`  sX    --f5l &"5NN6;;	##Iw77r'  r  c                    | j                  |d      }| j                  ||      }| j                  |d      }d }t        j                  |d      rd}nd}| j                  |d      }| j	                  |dd      }| j                  |d	      }| j	                  |d
d      }	t        j                  ||	      }
t        j                  |
|      }t        j                  |      }t        j                  ||      }| j                  |d      }| j                  i d|dd d| j                  |d      d	|d| j                  |      dd dd dd dd dd d| j                  |	      d| j                  |      d| j                  |d      d| j                  |      d| j                  |      d| j                  |      dd | j                  |dd      | j                  |      d d | j                  |dd      |d |dk7  d d d 
      S )!NrD  r  r,  longshortrc  r  
mark_pricer7  averageOpenPriceaverage_open_pricepositionSider   r1   r  rr  initialMargininitialMarginPercentagemaintenanceMarginmaintenanceMarginPercentage
entryPricenotionalr  unrealizedPnl	contractsmarginRatioestLiqPriceest_liq_pricer   r  r  )
liquidationPricer  	lastPrice
collateralr   r  r   r  r   r  )r2  r  r,   	string_gtr  rn  
string_subr  
string_abssafe_positionr  r#  rm  r{  ry  )r$  r  rB  rT  rM  r  rc  r  r7  r  priceDifferenceunrealisedPnlr  r  s                 r&  r  zwoo.parse_position  s   b ##Hh7!!(F3)4T3'DD''?&&xlK	''+>	''2DFZ[
!,,Y
C**?DA!!$'%%dI6''.A!! #
H#
$#
 d&&vx8#
 	#

 Y/#
 "4#
 T#
 &t#
  #
 *4#
 $++J7#
 ))(3#
 ((:>#
 T..}=#
 **40#
  D--l;!#
" 4##
$ !% 2 28]O \**95228\=Y"f,!#7#
  	r'  fromCodetoCodec                    | j                          |j                         |j                         | j                  |      d}| j                  | j	                  ||            }| j                  |di       }| j                  |d|      }| j                  |      }	| j                  |d|      }
| j                  |
      }| j                  ||	|      S )a(  
        fetch a quote for converting from one currency to another

        https://docs.woox.io/#get-quote-rfq

        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
        )	sellTokenbuyTokensellQuantityr)  r  r  )	rv  r  r  v3PrivateGetConvertRfqrx  r1  r2  r  parse_conversion)r$  r  r  rW  r3  rz  r4  r)  fromCurrencyIdfromCurrencytoCurrencyId
toCurrencys               r&  fetch_convert_quotezwoo.fetch_convert_quote  s     	!) 11&9

 ..t{{7F/KL" ~~h3))$XF}}^4''j&A]]<0
$$T<DDr'  c                     | j                          d|i}| j                  | j                  ||            }| j                  |di       }| j	                  |      S )aU  
        convert from one currency to another

        https://docs.woox.io/#send-quote-rft

        :param str id: the id of the trade that you want to make
        :param str fromCode: the currency that you want to sell and convert from
        :param str toCode: the currency that you want to buy and convert into
        :param float [amount]: how much you want to trade in units of the from currency
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
        rP  r)  )rv  v3PrivatePostConvertRftrx  r1  r  )	r$  r1   r  r  rW  r3  rz  r4  r)  s	            r&  create_convert_tradezwoo.create_convert_trade&  s^     	r
 //GV0LM ~~h3$$T**r'  c                 T   | j                          d|i}| j                  | j                  ||            }| j                  |di       }| j	                  |d      }| j	                  |d      }d}	d}
|| j                  |      }	|| j                  |      }
| j                  ||	|
      S )a  
        fetch the data for a conversion trade

        https://docs.woox.io/#get-quote-trade

        :param str id: the id of the trade that you want to fetch
        :param str [code]: the unified currency code of the conversion trade
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
        rP  r)  	sellAssetbuyAssetN)rv  v3PrivateGetConvertTraderx  r1  r2  r  r  )r$  r1   r  r3  rz  r4  r)  r	  r  r
  r  s              r&  fetch_convert_tradezwoo.fetch_convert_tradeE  s     	r
 00Wf1MN ~~h3))$<''j9
%==8L#|4J$$T<DDr'  c                 (   | j                          i }| j                  d||      \  }}|||d<   |||d<   | j                  | j                  ||            }| j	                  |di       }| j                  |dg       }| j                  ||dd||      S )a]  
        fetch the users history of conversion trades

        https://docs.woox.io/#get-quote-trades

        :param str [code]: the unified currency code
        :param int [since]: the earliest time in ms to fetch conversions for
        :param int [limit]: the maximum number of conversion structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest conversion to fetch
        :returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
        endTime	startTimerM  r)  tradeVosr  r  )rv  r  v3PrivateGetConvertTradesrx  r1  r>  parse_conversions)	r$  r  rt  r  r3  rz  r4  r)  r;  s	            r&  fetch_convert_trade_historyzwoo.fetch_convert_trade_historyn  s     	229gvN#(GK #GFO11$++gv2NO* ~~h3~~dJ3%%dD+z5RWXXr'  
conversionr
  r  c                 x   | j                  |dd      }| j                  |dd      }| j                  ||      }| j                  |dd      }| j                  ||      }||| j                  |      | j	                  |d      || j                  |dd	      || j                  |d
d      | j                  |d      d d
S )NexpireTimestamprc  r  r  r  r  rP  r  
sellAmountbuyQuantity	buyAmountbuyPrice)
r   r7  r  r1   r
  
fromAmountr  toAmountrX  r  )safe_integer_2r  rl  r  r2  r{  rm  )	r$  r  r
  r  r7  fromCurrr  tor  s	            r&  r  zwoo.parse_conversion  s    H ''
4E}U	%%j+zJ**8\B
JD((Z8"Y/"":y9$,,ZV **:}kR%%j*=
 	
r'  c                 v   | j                          | j                  |      }i }| j                  |dg       }t        dt	        |            D ]j  }||   }| j                  |d      }| j                  |      }|||ddddddd| j                  |d      dddddddddd| j                  |d      d	||<   l |S )
a  
        fetches all available currencies that can be converted

        https://docs.woox.io/#get-quote-asset-info

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        r;  r   r   NtickrY  )rW  r   r  rc  )r   r1   r  r   rR  r2   rS  r  r   r  rh  ri  rj  )	rv  v3PrivateGetConvertAssetInfor>  r  r  r2  rl  rm  rn  )	r$  r3  r4  r  r)  r  r  r1   r  s	            r&  fetch_convert_currencieszwoo.fetch_convert_currencies  s     	44V< ~~h3q#d)$ 	AGE!!%1B**2.D  !--eV<  $#
  $#!
  $#   ..umD5F4L		@ r'  c                     | j                  |      }|d   }t        |j                               }t        dt	        |            D ]  }||   }|dk(  s|c S  | j                  |d      S )Nr   r   r   )r  r  r  r  r  r  )r$  r  currencyItemr   networkKeysr  r  s          r&  r  z%woo.default_network_code_for_currency  sn    }}T*
+8==?+q#k*+ 	A!!nG%	
 {A..r'  enablec                 J    t         t        |   |       || j                  d<   y )Nr   )r!  r.   set_sandbox_moder   )r$  r0  r%  s     r&  r2  zwoo.set_sandbox_mode  s     c4)&1&,]#r'  )N)NN)w__name__
__module____qualname__r   r"  r5  r   r9  r!   r   rA  dictrs  rO  r   r|  r  r  r   r  r
   r  floatr  r  r   r   r   r   r  r  r  r  r/  r   r7  r<  rA  rF  rT  rZ  r]  ra  r  r}  r   r  r  r  r  r  r  r   r  r  r   r  r  r   r  r  r   r  r   r  r  r  r   r  r   r  r  r  r    r   r%  r  r)  r   r6  r5  r9  r`  intrk  rw  r  r   r  r  r  r   r   r  r  boolr  r   r  r  r  r   r  r  r  r  r   r  r  r	   r  r  r  r  r  r,  r  r2  __classcell__)r%  s   @r&  r.   r.      st
   f# fP #% "
H !# 8s 8, $& "($v, "(HR
4 R
F R
h 6:UW 2G3 2Gs 2G# 2G\`af\g 2Gh= =v = =~
 )+ 5{ 5n ') EZ EN RT K K5 K" SU L LE L" w{  LP  gk  tv L3 Li Ly Lbg Lps L  {@ L0 x|  NR  im  vx LC Ly LPY Lch Lqt L  }B L0 gksu p3 pi py pRW p`c pd3 `drv  @B R.S R.# R.Y R.i R.Y\ R.lo R.h 37r /Es /EC /Eb /32 !
 !
F <> 
s 
8 26b A0c A03 A0F *.Dt\^ R?3 R?c R? R?cghmcn R?h /3TXac G G3 Gc Ghlmrhs G, 154VZce G# GS GPS Gjnotju G,As Aj jv j jX   :>b %gs %g3 %gY %gN 26DW[df NH# NHc NHQT NHkoptku NH`	
 	
4 	
 9=4^bkm (GS (G# (GS (GX[ (GT -1tRV_a 7Gc 7G 7GC 7Gr %' 14= 1:
" $& #(( #(J) ) 79 #
# #
^ #
J 26DW[df 2@3 2@c 2@QT 2@kn 2@h (,$TZ\ G GC Gs Gaefqar G"t x ; 83 *.Dt\^ a3 ac a acghsct a" -1tRV_a ac a aC afjkvfw a" 6:[_hj Ms M# MUX Most  pA M>!
T !
X !
Q\ !
F:s : [] #S #% #c #c #an #J +/TPT]_ 0FC 0Fs 0F# 0Fdhivdw 0Fd(
t (
x (
= (
T:C :C : DHPR ':S ':% ':# ':Wb ':R DHPR    e  S  D
 
 D "*%DW[ 9Pvc 3 S # X\ dg  
6  
D 37TX\eg =@C =@s =@RU =@~(
f (
 (
T :< 
7S 
7 
7 68 9 9K 9@ 6:" 77 7 7@ 8<$]ajl =O =OC =OWZ =O~ =A  c : 24 `1S `1 `1D
t 
V 
x 
6 9=R qS q# q@ =? H He HCU H @B KC K KFX K FH 	T3 	TL^ 	T 24 5S 5B 26b :8w :8T(^ :8x^t ^V ^@ MQY[ (EC (E (Ec (E`j (ET W[ce +s +c +3 +PS +jt +> 8<B 'Ec 'E 'E: 'ER 7;\`ik +Y +Y3 +YVY +Yptu  qA +YZ4
4 4
x 4
\d 4
pz 4
l /1 :Z :x	/-t - -r'  r.   )3ccxt.base.exchanger   ccxt.abstract.woor   rU  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    typingr!   ccxt.base.errorsr"   r#   r$   r%   r&   r'   r(   r)   r*   ccxt.base.decimal_to_precisionr+   ccxt.base.preciser,   r.    r'  r&  <module>rC     st    ( )                  * 0 . ' ) ) , . * 4 %B8-(K B8-r'  