
    ":h                     0   d dl mZ d dlmZ d dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lm Z  d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dl&m'Z' d dl(m)Z)  G d dee      Z*y)    )Exchange)ImplicitAPIN)AnyBalancesDepositAddressIntMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickers
OrderBooksTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)ArgumentsRequired)InsufficientFunds)InvalidOrder)OrderNotFound)DDoSProtection)RateLimitExceeded)ExchangeNotAvailable)InvalidNonce)	TICK_SIZE)Precisec                   Z    e Zd Zdef fdZdefdZi fdefdZi fdee	   fdZ
di fdededefd	Zddi fd
ededefdZd5dede	defdZi fdedefdZdi fd
edefdZi fdedefdZd5dede	defdZddi fdedededee   fdZi fdefdZdi fdededede de!f
dZ"di fdede#fdZ$de#fd Z%d5d!ede	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fd%Z*i fd&ede+fd'Z,i fd&ede+fd(Z-di fd&ede d)ede.fd*Z/d+d,i ddfd-Z0d.e1d/ed0ed1ed2ed3efd4Z2 xZ3S )6yobitreturnc                 j   | j                  t        t        |          i ddddddg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d-dd.dd/dd0di d1dd2dd3dd4dd5dd6dd7dd8dd9dd:dd;dd<dd=dd>dd?dd@ddAdi dBddCddDddEddFddGddHddIddJddKddLddMddNddOddPddQddRdi dSddTddUddVddWddXddYddZdd[dd\dd]dd^dd_dd`ddaddbddcddddddddddddedfdgdhdidjdkdldmdndodpdpdpdpdqidrdpdpdpdpdpdpdpdpdsididtdududvdwi idxdyi dzd{d|d}d~dddddddddddddddddddddddddddddi ddddddddddddddddddddddddddddddddddi ddddddddÓddœddǓddɓdd˓dd͓ddϓddѓddӓddՓddדddٓddۓddݓi ddߓddddddddddddddddddddddddddddddddi 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dddddddi d d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIddJdKdLdMdNdOt        dPt
        t
        t
        t
        t
        t        t        t        dQi dRt        dSt        dTt        dUt        dVt
        dWt
        dXt
        dYt        dZt        d[t        d\t        d]t
        d^t
        d_t        d`t        dat        dbt
        dct        idddeddddd ddd dddddfddddddddgd ddhdididdjdddddkdd ddddld d d dm	d d dnd d dndodpi       S (q  Nidr%   nameYoBit	countriesRU	rateLimiti  version3proFhasCORSspotTmarginswapfutureoption	addMargincancelOrdercloseAllPositionsclosePositioncreateDepositAddresscreateMarketOrdercreateOrdercreateReduceOnlyOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrderfetchBalancefetchBorrowInterestfetchBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryfetchBorrowRatesfetchBorrowRatesPerSymbolfetchCrossBorrowRatefetchCrossBorrowRatesfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchFundingHistoryfetchFundingIntervalfetchFundingIntervalsfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchGreeksfetchIndexOHLCVfetchIsolatedBorrowRatefetchIsolatedBorrowRatesfetchIsolatedPositionsfetchLeveragefetchLeveragesfetchLeverageTiersfetchLiquidationsfetchMarginAdjustmentHistoryfetchMarginModefetchMarginModesfetchMarketLeverageTiersfetchMarketsfetchMarkOHLCVfetchMarkPricesfetchMyLiquidationsfetchMySettlementHistoryfetchMyTradesfetchOpenInterestfetchOpenInterestHistoryfetchOpenOrdersfetchOptionfetchOptionChain
fetchOrderfetchOrderBookfetchOrderBooksfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsForSymbolfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchSettlementHistoryfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionsfetchTransferfetchTransfersfetchUnderlyingAssetsfetchVolatilityHistoryfetchWithdrawalsreduceMarginrepayCrossMargin)repayIsolatedMarginsetLeverage	setMarginsetMarginModesetPositionModetransferwithdrawwsurlszchttps://user-images.githubusercontent.com/1294454/27766910-cdcbfdae-5eea-11e7-9859-03fea873272d.jpgzhttps://yobit.net/apizhttps://yobit.net/tapi)publicprivatezhttps://www.yobit.netzhttps://www.yobit.net/en/api/zhttps://www.yobit.net/en/fees/)logoapiwwwdocfeesr   get   )zdepth/{pair}infozticker/{pair}ztrades/{pair}post)ActiveOrdersCancelOrderGetDepositAddressgetInfo	OrderInfor   TradeHistoryWithdrawCoinsToAddressr   gMb`?)makertakerr   )tradingfundingcommonCurrenciesAIRAirCoinANIANICoinANTAntsCoinATMCHAATMASN	AscensionASTAstral
AutumncoinAUR
AuroraCoinBABBabelBANBANcoinBCCBCHBCSBitcoinStakeBITSBitstarBLNBulleonBNSzBenefit Bonus CoinBOTBOTcoinBONBONESBPCBitcoinPremiumBSTBitStoneBTS
Bitshares2CATBitClaveCBCCryptoBossCoinCMT	CometCoinCOINzCoin.comCOVz
Coven CoinCOVXCPC	CapricoinCREDIT	CreditbitCSCryptoSpotsDCTDiscountDFT	DraftCoinDGDDarkGoldCoinDIRTDIRTYDROP
FaucetCoinDSHDASHEGCEverGreenCoinEGGEggCoinEKOEkoCoinENTERENTRCEPCExperienceCoinESCEdwardSnowdenEUROPEEUROPEXTLifeExtensionFUND
FUNDChainsFUNKFUNKCoinFXFCoinGCCGlobalCryptocurrencyGENGenstakeGENEGenesiscoinGMRGimmerGOLDGoldMintGOTzGiotto CoinGSX
GlowSharesGTGTcoinHTML5HTMLHYPERXHYPERICNiCoinINSANEINSNJNT	JointCoinJPCJupiterCoinJWLJewelsKNCz
KingN CoinLBTCXLiteBitcoinLIZILiZiLOCLocoCoinLOCXLUNYRLUN	LunarCoinLUNAz	Luna CoinMASKz
Yobit MASKMDTMidnightMEMEzMemez TokenMISMIScoinMM
MasterMintNAV
NavajoCoinNBT	NiceBytesOMGOMGameONXOnixPACz$PACPLAYPlayCoinPIVXDarknetPUREPurePOSPUTIN	PutinCoinSPACE	SpacecoinSTK	StakeCoinSUBSubscriptioPAYEPAYPLCzPlatin CoinRAI
RaiderCoinRCNRCoinREPRepublicoinRURRUBSBTCzSuper BitcoinSMC	SmartCoinSOLOSoloCoinSOULSoulCoinSTARStarCoinSUPER	SuperCoinTNSTranscodiumTTC
TittieCoinUNIUniverseUSTUservice
VolumeCoinXINCoin
SummitCoinRatecoinBSV)VOLXINXMTXRABCHNoptions   ERC20TRC20BEP20)ETHTRXBSC)maxUrlLengthfetchOrdersRequiresSymbolnetworksprecisionMode
exceptions)803804805806807831832833zInvalid pair namezinvalid api keyzinvalid signz"api key dont have trade permissionzinvalid parameterzinvalid orderz*The given order has already been cancelledzRequests too oftenznot availablezdata unavailablezexternal service unavailablezTotal transaction amountz?The given order has already been closed and cannot be cancelledzInsufficient fundszinvalid keyzinvalid noncez.Total order amount is less than minimal amountzRate Limited)exactbroadfeatures)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg  i )r  limitdaysBack	untilDayssymbolRequired)r  triggerr  r  )r  r  r  r  r  )	sandboxr>   createOrdersrh   rn   rk   fetchOrdersfetchClosedOrders
fetchOHLCV)linearinverse)r3   r5   r6   orders)deep_extendsuperr%   describer"   r   r   r   r   r   r   r    r!   r   )self	__class__s    R/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/yobit.pyr  zyobit.describe   s!   eT ; = b@
'b@
Gb@
 $b@
 	b@

 sb@
 5b@
  ^^^ %^ 	^
 %^ %^ U^ t^ $U^  ^ '^ $U^ t^ (^ '^  (!^" "5#^$ %^& &u'^( "5)^* +E+^, )%-^. #E/^0 ,U1^2 '3^4 (5^6 &t7^8 (9^: 1%;^<  =^> &u?^@ 'A^B (C^D #EE^F *5G^H $UI^J uK^L "5M^N *5O^P +EQ^R )%S^T  U^V !%W^X %eY^Z $U[^\ /]^^ "5_^` #Ea^b +Ec^d e^f !%g^h "5i^j &uk^l +Em^n  o^p $Uq^r +Es^t "4u^v uw^x #Ey^z d{^| !$}^~ "4^@  A^B 'C^D $UE^F !%G^H *5I^J (K^L %eM^N )%O^P )%Q^R tS^T U^V tW^X "5Y^Z #D[^\ $U]^^  _^` !%a^b (c^d )%e^f #Eg^h i^j #Ek^l (-$"!&#(! {^b@
L }57 /68	Mb@
` () !)*)*	 ()'(-.#$%&!"()23	ab@
L ""
 Mb@
^  l!yl!yl! zl! %	l!
 {l! xl! |l! |l! wl! yl! ul! ~l! 	l! yl! +l!  y!l!" w#l!$ '%l!& z'l!( |)l!* z+l!, '-l!. {/l!0 
1l!2 |3l!4 5l!6 {7l!8 +9l!: m;l!< z=l!> {?l!@ ~Al!B Cl!D El!F vGl!H Il!J yKl!L yMl!N Ol!P 'Ql!R Sl!T 'Ul!V Wl!X Yl!Z 
[l!\ g]l!^ -_l!` zal!b cl!d xel!f 
gl!h }il!j |kl!l hml!n ol!p 'ql!r wsl!t &ul!v {wl!x }yl!z x{l!| |}l!~ l!@ Al!B zCl!D El!F Gl!H {Il!J Kl!L Ml!N zOl!P Ql!R ySl!T lUl!V |Wl!X {Yl!Z x[l!\ v]l!^ v_l!` 
al!b 	cl!d 	el!f gl!h il!j {kl!l }ml!n vol!p }ql!r |sl!t wul!v }wl!x uyl!z {l!| {}l!~ 
l!@ 
Al!B 
Cl!D El!F }Gl!H |Il!J zKl!L zMl!N $ #!Wl!_b@
x  $-1"""yb@
J YKb@
L ''''',,(	'%': #$7 9:M	
 ( $\ A, ). $%9 '(< 34H / VWc )*; "#6  $\!" El#$ #$5%Mb@
L	 $&+(-,1,0).+06:#(#("'#(	( #($)$)+027/4#()$, %)&+!%$*%+*.& ',#($)*/	# ',!%#($)*.( $()-"&_0d ##
 ##m:M	b@
B bCb@
 b b	    c                    | j                  |di       }| j                  |d      }||| j                  |      d}| j                  |di       }| j                  |di       }t        | j	                  ||      j                               }t        dt        |            D ]W  }||   }	| j                  |	      }
| j                         }| j                  ||	      |d<   | j                  ||	      |d<   |||
<   Y | j                  |      S )	Nr&   server_time)r   	timestampdatetimefundsfunds_incl_ordersr   freetotal)	safe_dictsafe_integeriso8601listextendkeysrangelensafe_currency_codeaccountsafe_stringsafe_balance)r  responsebalancesr  resultr  r  currencyIdsi
currencyIdcoder  s               r  parse_balancezyobit.parse_balance  s   >>(Hb9%%h>	"Y/

 ~~h4x)<bA4;;tU388:;q#k*+ 	#A$QJ**:6DllnG"..tZ@GFO#//zBGG"F4L	#   ((r  c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)aD  

        https://yobit.net/en/api

        query for balance and get the amount of funds available for trading or funds locked in orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
        N)load_marketsprivatePostGetInfor  )r  paramsr  s      r  fetch_balancezyobit.fetch_balance  sI      !!!00884 !!(++7 	"8s   A	AA	AA	A	c                   K   | j                  |       d{   }| j                  |di       }t        |j                               }g }t	        dt        |            D ]  }||   }||   }|j                  d      \  }	}
|	j                         }|
j                         }| j                  |      }| j                  |      }| j                  |d      }| j                  |d      }t        j                  |d      }|j                  i d|d	|d
z   |z   d|d|ddd|	d|
ddddddddddddddd|dk(  ddddd| j                  |      | j                  |      ddddd| j                  | j                  | j                  |d                  | j                  | j                  | j                  |d                  dddd| j!                  |d      | j!                  |d       d| j!                  |d!      | j!                  |d"      d| j!                  |d#      ddd$d|d%        |S 7 %w)&z

        https://yobit.net/en/api

        retrieves data on all markets for yobit
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        Npairsr   _hiddenfee100r(   symbol/basequotesettlebaseIdquoteIdsettleIdtyper3   Tr4   Fr5   r6   r7   activecontractr  decimal_places)amountprice)minmax
min_amount
max_amount	min_price	max_price	min_total)r  r  r  cost)r  r   r   contractSizeexpiryexpiryDatetimestrike
optionType	precisionlimitscreatedr   )publicGetInfor  r  r  r  r  splitupperr  r  r  r#   
string_divappendparse_numberparse_precisionsafe_number)r  r  r  marketsr  r  r  r(   marketr  r  r  r  r  	feeStrings                  r  fetch_marketszyobit.fetch_markets  s     ++F33& ..7B7GLLN#q#d)$ >	AaBR[F hhsmOFG<<>DMMOE**40D++E2E&&vx8F((7I**9e<IMM 2b2$*u,2 2 	2
 $2 &2 72 D2 2 2 %2 2 %2 %2 6Q;2  E!2" $#2$  **95**95 $"&""//0D0DTEUEUV\^nEo0pq!..t/C/CDDTDTU[]mDn/op  $#!
  $//E#//E
  $//D#//D
  $//D#$  c2 2>	~ k 4s   H?H<H%H?Nr  r  c                 Z  K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }|d   |v }|s!t	        | j
                  dz   |d   z   dz         ||d      }| j                  ||      S 7 7 Jw)a  

        https://yobit.net/en/api

        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
        :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
        Npairr(   r   r  z% order book is empty or not available)r  r  publicGetDepthPairr  r   r(   parse_order_book)	r  r  r  r  r  requestr  market_id_in_reponse	orderbooks	            r  fetch_order_bookzyobit.fetch_order_book  s      !!!V$F4L
 $GG00Wf1MNN &t 8##x0@ @Cj jkkVD\*	$$Y77 	" Os#   B+B'AB+B)A	B+)B+symbolsc                   K   | j                          d{    d}|edj                  | j                        }t        |      dkD  r^t        | j                        }t	        | j
                  dz   t        |      z   dz         | j                  |      }dj                  |      }d|i}|||d<   | j                  | j                  ||             d{   }i }t        |j                               }t        dt        |            D ]0  }	||	   }
| j                  |
      }| j                  ||
   |      ||<   2 |S 7 )7 lw)	aR  

        https://yobit.net/en/api

        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data for multiple markets
        :param str[]|None symbols: list of unified market symbols, all symbols fetched if None, default is None
        :param int [limit]: max number of entries per orderbook to return, default is None
        :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 symbol
        N-ro  z fetchOrderBooks() has zy symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooksr   r  r   )r  joinidsr  r   r(   str
market_idsr  r  r  r  r  safe_symbolr  )r  r  r  r  r  numIdsr  r  r  r  r(   r  s               r  fetch_order_bookszyobit.fetch_order_books4  sM     !!!?((488$C3x$TXX#DGG.G$G#f+$U  YT  %T  U  U//'*C((3-CC
 $GG00Wf1MNN8==?#q#c(# 	IAQB%%b)F!228B<HF6N	I 1 	"" Os#   ED?B>EEA*EEtickerr  c                    | j                  |d      }| j                  |d      }| j                  i d| j                  d |      d|d| j	                  |      d| j                  |d      d| j                  |d      d| j                  |d	      d
d d| j                  |d      dd dd dd d|d|dd dd dd d| j                  |d      | j                  |d      | j                  |d      |d|      S )Nupdatedlastr  r  r  highlowbidbuy	bidVolumeasksell	askVolumevwapopenclosepreviousClosechange
percentageaverageavgvol_curvol)
baseVolumequoteVolumer   )safe_timestampr  safe_tickerr  r  )r  r  r  r  r  s        r  parse_tickerzyobit.parse_tickerY  s    ''	:	/ !
d&&tV4!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FF3!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t''6#!
$ **69=++FE:)!
* + 	r  	idsStringc                 @  K   d|i}| j                  | j                  ||             d {   }i }t        |j                               }t	        dt        |            D ]7  }||   }||   }	| j                  |      }
|
d   }| j                  |	|
      ||<   9 |S 7 pw)Nr   r   r  )publicGetTickerPairr  r  r  r  r  safe_marketr,  )r  r-  r  r  tickersr  r  kr(   r  r  r  s               r  fetch_tickers_helperzyobit.fetch_tickers_helper  s     I
 00Wf1MNNGLLN#q#d)$ 	?AaBR[F%%b)FH%F!..vv>F6N	?  Os   )BBA1Bc                 v  K   d}| j                  |dd      \  }}||st        | j                  dz         | j                          d{    g }| j	                  | j
                  dd      }d}|r| j                  }d}t        d	t        | j                              D ]T  }| j                  |   }	|dk(  rdnd
}
||
|	z   z  }t        |      |kD  s2|j                  | j                  ||             d}V |dk7  r|j                  | j                  ||             n| j                  |      }| j                  |      }t        |      }d
j                  |      }t        |      |z   }||kD  rEt        | j                  dz   t        |      z   dz   t        |      z   dz   t        |      z   dz         |j                  | j                  ||             t!        j"                  |  d{   }i }t        d	t        |            D ]*  }| j%                  ||   d|      }| j'                  ||      }, |S 7 7 Mw)a  

        https://yobit.net/en/api

        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param dict [params.all]: you can set to `true` for convenience to fetch all tickers from self exchange by sending multiple requests
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
        NallFzs fetchTickers() requires "symbols" argument or use `params["all"] = True` to send multiple requests for all marketsrv  ro  (    r   r
  z' fetchTickers() is being requested for z$ markets(which has an URL length of z- characters), but it exceedes max URL length(zK), please pass limisted symbols array to fetchTickers to fit in one requestr  )handle_param_boolr   r(   r  r  rn  r  r  r  r  r  r3  market_symbolsr  r  r  asynciogatherfilter_by_array_tickersr  )r  r  r  
allSymbolspromises	maxLengthlenghtOfBaseUrlr  r  r(   prefix	idsLengthr-  actualLength	resultAllfinalResultr  s                    r  fetch_tickerszyobit.fetch_tickers  sw     
!33FE5I
F?:#DGG  /d  %d  e  e!!!%%dllNDI	llGC1c$((m, XXa[ #r	v{"s8i'OOD$=$=c6$JKC by 9 9#v FG))'2G//'*C #CIIy>O;Li''2[([^abk^l(l  pV  )V  Y\  ]i  Yj  )j  m\  )\  _b  cl  _m  )m  p}  )}  ~  ~OOD55iHI!..(33	q#i.) 	;A11)A,'RF++k6:K	; ? 	"4 4s-   AH9
H4BH9DH9)H7*AH97H9c                 N   K   | j                  |g|       d{   }||   S 7 	w)a  

        https://yobit.net/en/api

        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
        :param str symbol: unified symbol of the market to fetch the ticker for
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
        N)rF  )r  r  r  r1  s       r  fetch_tickerzyobit.fetch_ticker  s.      **F8V<<v =s   %#
%tradec                 *   | j                  |d      }| j                  |d      }|dk(  rd}n|dk(  rd}| j                  |dd      }| j                  |d	d
      }| j                  |d      }| j                  |d      }| j                  ||      }	| j                  |d      }
| j	                  |      }| j	                  |
      }d}d }| j                  |d      }|(| j                  |d      }| j                  |      }||d}| j                  |d      }|N|L| j                  |	||||d      }| j                  |d      | j                  |d      | j                  |d      d}| j                  |||| j                  |      |	||d ||
d ||d|      S )Nr  r  r  r  r  r  rater  trade_idtidorder_idr   r  r  
commissioncommissionCurrency)r  currencyis_your_orderr   rQ  r  rQ  r  rK  )r(   orderr  r  r  r  sidetakerOrMakerr  r  r  r  r   )
r*  r  safe_string_2r  r  r  r  calculate_fee
safe_trader  )r  rI  r  r  rU  priceStringr(   rT  marketIdr  amountStringr  r  r  r  feeCostStringfeeCurrencyIdfeeCurrencyCodeisYourOrderfeeInNumberss                       r  parse_tradezyobit.parse_trade  s   0 ''{;	v.5=DU]D((@z59  
3##E62!!(F3''x8!!+.""<0((=$ ,,U4HIM"55mDO%+C &&uo>"{#11&$feU\] $ 0 0z J ,,\6B ,,\6B
 "Y/  " 
  	r  sincec                 j  K   | j                          d{    | j                  |      }d|d   i}|||d<   | j                  | j                  ||             d{   }t	        |t
              rt        |      }|dk(  rg S | j                  ||d   g       }	| j                  |	|||      S 7 7 Rw)a   

        https://yobit.net/en/api

        get the list of most recent trades for a particular symbol
        :param str symbol: unified symbol of the market to fetch trades for
        :param int [since]: timestamp in ms of the earliest trade to fetch
        :param int [limit]: the maximum amount of trades to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
        Nr   r(   r  r   )	r  r  publicGetTradesPairr  
isinstancer  r  	safe_listparse_trades)
r  r  rc  r  r  r  r  r  numElementsr  s
             r  fetch_tradeszyobit.fetch_trades  s      !!!V$F4L
 $GG11$++gv2NOO h%h-Ka	&,;  >>5 	" Ps#   B3B/AB3B1AB31B3c                 T  K   | j                          d{    | j                  |       d{   }| j                  |di       }t        |j	                               }i }t        dt        |            D ]  }||   }| j                  ||i       }| j                  |dd      }	| j                  |d      }
| j                  |d      }| j                  t        j                  |
d            }| j                  t        j                  |d            }||	||dd	d
||	<    |S 7 7 w)a3  

        https://yobit.net/en/api

        fetch the trading fees for multiple markets
        :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
        Nr  r   r  	fee_buyer
fee_sellerr  TF)r   r  r   r   r#  	tierBased)r  r  r  r  r  r  r  r  r  r  r#   r  )r  r  r  r  	marketIdsr  r  r[  r   r  takerStringmakerStringr   r   s                 r  fetch_trading_feeszyobit.fetch_trading_fees>  s+     !!!++F33( x"5&	q#i.) 	A |H>>%26D%%hc:F**4=K**4>K%%g&8&8e&LME%%g&8&8e&LME ""F6N	  Q 	"3s    D(D#D(D&C4D(&D(r  rU  r  r  c                   K   |dk(  rt        | j                  dz         | j                          d{    | j                  |      }|d   || j	                  ||      | j                  ||      d}| j                  | j                  ||             d{   }	| j                  |	d      }
| j                  |
|      S 7 7 *w)a~  

        https://yobit.net/en/api

        create a trade order
        :param str symbol: unified symbol of the market to create an order in
        :param str type: must be 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r  z' createOrder() allows limit orders onlyNr(   )r   r  r  rK  r&   )
r   r(   r  r  amount_to_precisionprice_to_precisionprivatePostTrader  r  parse_order)r  r  r  rU  r  r  r  r  r  r  r  s              r  create_orderzyobit.create_orderq  s      8*S STT!!!V$4L..vv>++FE:	
 ..t{{7F/KLL, (3//? 	" Ms"   1CC A#CC)CCr(   c                    K   | j                          d{    dt        |      i}| j                  | j                  ||             d{   }| j	                  |di       }| j                  |      S 7 ^7 *w)aT  

        https://yobit.net/en/api

        cancels an open order
        :param str id: order id
        :param str symbol: not used by yobit cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrN  r&   )r  intprivatePostCancelOrderr  r  rw  )r  r(   r  r  r  r  r  s          r  cancel_orderzyobit.cancel_order  s{      !!!B
 44T[[&5QRR( (B7''3 	" Ss!   A9A55A9A7)A97A9statusc                 6    ddddd}| j                  |||      S )Nr  closedcanceled)012r/   )r  )r  r}  statusess      r  parse_order_statuszyobit.parse_order_status  s,    	
 &&99r  rT  c                    | j                  |dd      }| j                  | j                  |dd            }|dk(  r| j                  |d      }d}| j                  |dd	      }| j                  |d
      }| j	                  ||      }| j                  |d      }| j                  |dd      }	| j                  |dd      }
| j                  |d      }d }d}| j                  |d      }| j                  i d|d|dd d|d|d| j                  |      dd d|dd dd d|d|dd dd d|d|	d |
||d d d!|      S )"Nr(   rN  r}  r  r  init_order_idr  timestamp_createdr  r   start_amountr  remainsreceivedz0.0rK  r  r  r   clientOrderIdr  r  r  lastTradeTimestampr  postOnlyrU  r  r  r  	remainingfilled)r}  r  r$  trades)rW  r  r  safe_timestamp_2r  
safe_orderr  )r  rT  r  r(   r}  r  r[  r  r  r  r  r  r  r  rU  s                  r  rw  zyobit.parse_order  s   | tZ8(()9)9%6)RS9!!%9BF))%1DmT	##E62!!(F3!!%8&&uh	B	!!%U;  /v.  
E 
" 
 T 
 f	 

  
 Y/ 
 !$ 
 D 
 4 
  
 D 
 U 
 D 
 D 
 f 
  ! 
" f# 
$ + 
, - 	r  c                 6  K   | j                          d{    dt        |      i}| j                  | j                  ||             d{   }t	        |      }| j                  |di       }| j                  | j                  d|i||               S 7 ~7 Jw)al  

        https://yobit.net/en/api

        fetches information on an order made by the user
        :param str id: order id
        :param str symbol: not used by yobit fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NrN  r&   r(   )r  rz  privatePostOrderInfor  r  r  rw  )r  r(   r  r  r  r  r  s          r  fetch_orderzyobit.fetch_order6  s      !!!B
 224;;w3OPPW(B7" T2Jr
 CDD/ 	" Qs"   BB5BBA	BBc                 T  K   |t        | j                  dz         | j                          d{    i }d}|| j                  |      }|d   |d<   | j	                  | j                  ||             d{   }| j                  |di       }	| j                  |	|||      S 7 s7 -w)a  

        https://yobit.net/en/api

        fetch all unfilled currently open orders
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of open order structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
        Nz- fetchOpenOrders() requires a symbol argumentr(   r   r&   )r   r(   r  r  privatePostActiveOrdersr  r  parse_orders)
r  r  rc  r  r  r  r  marketInnerr  r  s
             r  fetch_open_orderszyobit.fetch_open_ordersZ  s      >#DGG.]$]^^!!!++f-K)$/GFO55dkk'66RSS0 (B7  >>? 	" Ts"   .B(B$AB(8B&9,B(&B(c                   K   |t        | j                  dz         | j                          d{    | j                  |      }d|d   i}|||d<   || j	                  |dz        |d<   | j                  | j                  ||             d{   }| j                  |di       }t        |j                               }	g }
t        d	t        |	            D ]L  }| j                  |	|      }| j                  | j                  ||   d
|i      |      }|
j                  |       N | j                  |
|d   ||      S 7 7 w)a  

        https://yobit.net/en/api

        fetch all trades made by the user
        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentr   r(   countr  rc  r&   r   rL  r  )r   r(   r  r  parse_to_intprivatePostTradeHistoryr  r  r  r  r  r  r  rb  r  filter_by_symbol_since_limit)r  r  rc  r  r  r  r  r  r  r  r  r  r(   rI  s                 r  fetch_my_tradeszyobit.fetch_my_trades  s`     >#DGG.[$[\\!!!V$ F4L	
 $GG#00>GG55dkk'66RSS" (B76;;=!q#c(# 	!A!!#q)B$$T[[B> &E MM% 	! 009I5RWXXW 	"" Ts#   .ED?A EEB.EEr  c                    K   ddi}| j                  || j                  ||             d{   }| j                  |d      }| j                  |       ||dd|d   dS 7 2w)a`  

        https://yobit.net/en/api

        create a currency deposit address
        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
        need_newr   Naddressr   )rQ  r  tagnetworkr   )fetch_deposit_addressr  r  check_address)r  r  r  r  r  r  s         r  create_deposit_addresszyobit.create_deposit_address  sz      
 33D$++gv:VWW""8Y77#V$
 	
 Xs   *A!A3A!c                   K   | j                          d{    | j                  |      }|d   }| j                  | j                  di       }| j	                  |d      }| j                  |||      }|*|dk7  r||j                         z   }| j                  |d      }|dd}| j                  | j                  ||             d{   }| j                  |d   d	      }	| j                  |	       ||d|	dd
S 7 7 4w)a\  
        fetch the deposit address for a currency associated with self account

        https://yobit.net/en/api

        :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>`
        Nr(   rx  r  rp  r   )coinNamer  r&   r  )r   rQ  r  r  r  )r  rQ  r  rn  safe_string_upperr  loweromitprivatePostGetDepositAddressr  r  )
r  r  r  rQ  r  rx  r  r  r  r  s
             r  r  zyobit.fetch_deposit_address  s     !!!==&d^
>>$,,
B?((;""8Wg>'!''--/9
YYvy1F"
 ::4;;wPV;WXX""8H#5yA7#
 	
# 	" Ys"   C?C;B1C?C=	3C?=C?r  c                   K   | j                  ||      \  }}| j                  |       | j                          d{    | j                  |      }|d   ||d}|t	        | j
                  dz         | j                  | j                  ||             d{   }i d|ddddddddd	dd
dddddddddddddddddddddddddddS 7 7 Dw)a  

        https://yobit.net/en/api

        make a withdrawal
        :param str code: unified currency code
        :param float amount: the amount to withdraw
        :param str address: the address to withdraw to
        :param str tag:
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
        Nr(   )r  r  r  z withdraw() does not support the tag argument yet due to a lack of docs on withdrawing with tag/memo on behalf of the exchange.r   txidr  rQ  r  r  r}  r  r  r  addressFrom	addressTor  tagFromtagTor  rS  )commentr  )handle_withdraw_tag_and_paramsr  r  rQ  r   r(   !privatePostWithdrawCoinsToAddressr  )	r  r  r  r  r  r  rQ  r  r  s	            r  r   zyobit.withdraw  s     99#vFV7#!!!==& 
 ?  +l  !l  m  m??GU[@\]]
H
$
 D
 D	

 
 t
 d
 d
 
 
 t
 4
 
 4
 t
  T!
" t#
$  '
 	
 	" ^s#   :C CAC CAC C r   GETc                    | j                   d   |   }| j                  || j                  |            }|dk(  r| j                          | j	                         }	| j                  | j                  |	|d|            }| j                  | j                  |      | j                  | j                        t        j                        }
d| j                  |
d}n|dk(  rB|d| j                  z   dz   | j                  ||      z   z  }|rf|d| j                  |      z   z  }nN|d| j                  ||      z   z  }|d	k(  r|r/|d| j                  |      z   z  }n|r| j                  |      }d
di}||||dS )Nr   r   )noncemethodz!application/x-www-form-urlencoded)Content-TypeKeySignr   r  ?r  r  zapplication/json)urlr  bodyheaders)r   r  extract_paramscheck_required_credentialsr  	urlencoder  hmacencodesecrethashlibsha512apiKeyr.   implode_paramsjson)r  pathr   r  r  r  r  r  queryr  	signatures              r  signz
yobit.sign3  su   iis#		&$"5"5d";<)++-JJLE>>$++/ # D 		$++d"3T[[5Mw~~^I C{{!G
 H_3%+d.A.A$.OOOCsT^^E2223,,T6:::C3!666C99U+D&(:G fdwOOr  httpCodereasonr  r  r  r  c
                    |y d|v r| j                  |d      }
t        |
t              r|
dk(  s|
dk(  rd}
nd}
|
s| j                  |d      }| j                  |d      }| j                  dz   |z   }| j                  | j                  d	   ||       | j                  | j                  d	   ||       | j                  | j                  d
   ||       t        |      y )Nsuccesstruer  TFr  errorr  r  r  )	
safe_valuerf  r  r  r(   throw_exactly_matched_exceptionrz  throw_broadly_matched_exceptionr   )r  r  r  r  r  r  r  r  requestHeadersrequestBodyr  r  messagefeedbacks                 r  handle_errorszyobit.handle_errorsT  s     6 ooh	:G'3'v%7c>"G#G''&9**8W=77S=4/44T__W5MtU]^44T__W5MwX`a44T__W5MwX`a#H--r  )N)4__name__
__module____qualname__r   r  r   r  r  r   r	   r  r  r   r   r  r   r   r  dictr   r,  r   r3  rF  rH  r   rb  rj  r   rr  r   r   floatr
   rx  r   r|  r  r   rw  r  r  r  r   r  r  r   r   r  rz  r  __classcell__)r  s   @r  r%   r%      s   c# cJ) )( *, $, $,L *, ^V ^@ @DB 8S 8 8S\ 82 :>DY[ #w #c #`j #J%4 % %6 %N AC C w  6:" .7 . .` 68  F H Hv H HT <@d[] &? &?S &? &?bfglbm &?P /1 1[ 1f mqy{ /0 /0I /0Y /0X] /0fi /0b 9=R $(S $(# $(L: :c cv c cJ 8<B "EC "E "EH 59tZ^gi -?c -? -?TW -?nrsxny -?^ 37TX\eg 9YC 9Ys 9YRU 9Yv >@ 
 
N 
0 =? !
 !
> !
F JNVX 2
3 2
 2
 2
]h 2
h &eBSW PB,c ,3 ,S ,# ,X\ ,dg ,r  r%   )+ ccxt.async_support.base.exchanger   ccxt.abstract.yobitr   r:  r  ccxt.base.typesr   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    r!   ccxt.base.decimal_to_precisionr"   ccxt.base.preciser#   r%    r  r  <module>r     sh    6 +   @  @  @  @  @  * 0 . . ) * + . 1 ) 4 %fHk fr  