
    ein                    P   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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+ d dl,m-Z-  G d dee          Z.dS )    )Exchange)ImplicitAPIN)AnyBalances
CurrenciesCurrencyDepositAddressIntMarginModificationMarketNumOrder	OrderBook	OrderSide	OrderTypeStrStringsTickerTickers
OrderBooksTradeTradingFeesTransaction)List)ExchangeError)AuthenticationError)PermissionDenied)ArgumentsRequired)
BadRequest)InsufficientFunds)InvalidOrder)OrderNotFound)RateLimitExceeded)OnMaintenance)InvalidNonce)	TICK_SIZE)Precisec                       e Zd Zdef fdZi fdefdZdWdedede	fdZ
i fded	ede	fd
Zi fded	ede	fdZi fdefdZi fdZi fdZd Zdi fdefdZdi fdefdZdWdefdZi fdefdZi fdee         fdZdddi fdededededee         f
dZdWdedefdZde fdZ!i fde fdZ"di fdedede#fdZ$ddi fd edede%fd!Z&dWd"edede'fd#Z(di fd ede)fd$Z*i fdede'fd%Z+dWd&edede,fd'Z-ddi fdedededee,         fd(Z.dddi fde/dedefd)Z0i fded*e1d+efd,Z2i fded+efd-Z3i fded+efd.Z4di fded/e5d*e1d	ed0e6f
d1Z7di fd2ede/fd3Z8di fd2ede/fd4Z9dddi fd2ede/dedefd5Z:dddi fde/dededee;         fd6Z<d7 Z=d8 Z>dWd9e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i fd2eded/e5d*e1d	e6d0e6fd<ZAi fd=edeBfd>ZCd? ZDdi fd=ed	ed@edAe/deEf
dBZFdCe/fdDZGdWdEededeEfdFZHdddi fd=e/dededeeE         fdGZIdddi fd=e/dededeeE         fdHZJdi fd2ed=e/fdIZKdi fd2ed=e/fdJZLdddi fd=e/dededeeE         fdKZMdLdMi ddfdNZNdO ZOdPePdQedRedSedTedUefdVZQ xZRS )Xexmoreturnc                    |                      t          t          |                                           dddgddi dd ddd	dd
dddddddddddddddddddddddddddi ddddddddddddddd dd!dd"dd#dd$d%d&dd'dd(dd)dd*di d+dd,dd-dd.dd/dd0dd1dd2dd3d%d4dd5dd6dd7dd8dd9dd:dd;di d<dd=dd>dd?dd@ddAddBddCddDd%dEddFddGddHddIddJddKddLddMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d[d\d]d\d^d_gd`dadbdcddgidbg deidfg dgidhdbdd|                     di          |                     di          djdddkdldmdndodpdqidrdidsdddd dddd dddddtddddddddud ddd d ddvdddddwdd ddddxd d dydzid{	d d d|d d d|d}d~dit
          i dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          dt          it          t          t          ddd          S )Nr)   EXMOLTd   zv1.1CORSspotTmarginswapFfutureoption	addMargincancelOrdercancelOrderscreateDepositAddresscreateMarketBuyOrdercreateMarketBuyOrderWithCostcreateMarketOrderWithCostcreateOrdercreateStopLimitOrdercreateStopMarketOrdercreateStopOrder	editOrderfetchAccountsfetchBalancefetchCanceledOrdersfetchCurrenciesfetchDepositfetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchDepositsfetchDepositsWithdrawalsfetchDepositWithdrawFeeemulatedfetchDepositWithdrawFeesfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRatesfetchIndexOHLCVfetchMarginModefetchMarketsfetchMarkOHLCVfetchMyTrades
fetchOHLCVfetchOpenInterestHistoryfetchOpenOrders
fetchOrderfetchOrderBookfetchOrderBooksfetchOrderTradesfetchPositionfetchPositionHistoryfetchPositionModefetchPositionsfetchPositionsHistoryfetchPositionsRiskfetchPremiumIndexOHLCVfetchTickerfetchTickersfetchTradesfetchTradingFeefetchTradingFeesfetchTransactionFeesfetchTransactionsfetchTransferfetchTransfersfetchWithdrawalfetchWithdrawalsreduceMargin	setMargintransferwithdraw1515304560120180240DWM)1m5m15m30m45m1h2h3h4h1d1w1Mzchttps://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpgzhttps://api.exmo.comzhttps://exmo.me)publicprivatewebzhttps://exmo.me/?ref=131685z%https://exmo.me/en/api_doc?ref=131685zhttps://exmo.com/en/docs/fees)logoapiwwwreferraldocfeesgetzctrl/feesAndLimitszen/docs/fees)	currencyzcurrency/list/extended
order_bookpair_settingstickertradescandles_historyrequired_amountzpayments/providers/crypto/listpost)(	user_infoorder_createorder_cancelstop_market_order_createstop_market_order_canceluser_open_ordersuser_tradesuser_cancelled_ordersorder_tradesdeposit_addresswithdraw_cryptwithdraw_get_txidexcode_createexcode_load
code_checkwallet_historywallet_operationszmargin/user/order/createzmargin/user/order/updatezmargin/user/order/cancelzmargin/user/position/closezmargin/user/position/margin_addz"margin/user/position/margin_removezmargin/currency/listzmargin/pair/listzmargin/settingszmargin/funding/listzmargin/user/infozmargin/user/order/listzmargin/user/order/historyzmargin/user/order/tradeszmargin/user/order/max_quantityzmargin/user/position/listz'margin/user/position/margin_remove_infoz$margin/user/position/margin_add_infozmargin/user/wallet/listzmargin/user/wallet/historyzmargin/user/trade/listzmargin/tradeszmargin/liquidation/feed)r   r   r   z0.004)feeSide	tierBased
percentagemakertaker)r   r   )tradingtransactionERC20TRC20)ETHTRXmethodfetchPrivateTradingFeesfillResponseFromRequest)networksri   r1   )IOCFOKPOGTD)
marginModetriggerPricetriggerPriceTypetriggerDirectionstopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedselfTradePreventiontrailingleveragemarketBuyByCostmarketBuyRequiresPriceiceberg)r   limitdaysBack	untilDayssymbolRequired)r   triggerr   r   )r   r   r   r   r   r     )	sandboxr<   createOrdersrV   rZ   rY   fetchOrdersfetchClosedOrdersrW   )linearinverse)r0   r2   r3   GMTz	GMT Token14033314043440005400094001540016400174003240033400345005250054503045017350277503195032150381)zrange period is too longzinvalid syntaxzAPI rate limit exceeded)exactbroad)idname	countries	rateLimitversionhas
timeframesurlsr   r   optionsfeaturescommonCurrenciesprecisionMode
exceptions)deep_extendsuperr)   describeparse_numberr&   r!   r   r   r%   r   r$   r   r#   r    r"   )self	__class__s    U/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/async_support/exmo.pyr  zexmo.describe   s   dD 1 1 : : < <EEE $E 	E
 %E %E TE tE E 'E 'E /E ,TE tE 'E  (!E" "4#E E$ T%E&  'E( )E* &t+E, "4-E. /E0 &t1E2 (3E4 1%5E6  7E8 +D9E: *:;E< +D=E> &u?E@ #EAEB *5CED $UEE E EF "5GEH "5IEJ KEL !%MEN  OEP dQER +ESET "4UEV jWEX !$YEZ "4[E\ #D]E^  _E` 'aEb $UcEd !%eEf (gE E Eh %eiEj )%kEl tmEn oEp tqEr "5sEt #DuEv 'wEx $ZyEz  {E| !%}E~ "4E@ #DAEB CED UEEF EGEH DIE EN   ~45, 
 )9; 8   ,&  
 
 
  ) ) )+)@ @F  %!%"&!..w77!..w77  "'"'     #" 
 7% .t   %&*(,,0,1).+06:#'#'"&#'	( ( #(/4$)$(+/27#()$ $, %)&*!$$(%)*.& & ',#($)*/	# # ',!%#($)*/( ( $()-#_2 2h ## 
 ## q< <| {! 'lj 0 \	
 ] ] 0 - - . . . ] ] \  \!" \#$ \% * 1;&0/@ + G^?
 ^?
 ^ ^ ^	    symbolc                   K   |                                   d {V  |                     |          }|d         |d}d }|dk    r0|                     |                     ||                     d {V }n5|dk    r/|                     |                     ||                     d {V }|                     ||          }|                     | j        di           }	|                     |	dd          }
|
r
||d<   ||d	<   |S )
Nr   )position_idquantityaddreducer1   r   Ttypeamount)	load_marketsmarket&privatePostMarginUserPositionMarginAddextend)privatePostMarginUserPositionMarginRemoveparse_margin_modification
safe_valuer   	safe_bool)r  r  r  r  paramsr  requestresponser1   r   r   s              r  modify_margin_helperzexmo.modify_margin_helper>  s>     !!!!!!!!!V$$!$<
 
 5==!HHU\^dIeIeffffffffHHX!KKDKKX_agLhLhiiiiiiiiH //&AA//$,"=="&..:SUY"Z"Z" 	&!F6N%F8r  Ndatar  c                 l    ||                      d |          d dd d |                     |d          dd d d
S )Nisolatedquoteok)
infor  r  r   r  totalcodestatus	timestampdatetime)safe_symbolr  )r  r  r  s      r  r  zexmo.parse_margin_modificationU  sO    
 &&tV44$OOFG44
 
 	
r  r  c                 B   K   |                      ||d|           d{V S )a  
        remove margin from a position

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#eebf9f25-0289-4946-9482-89872c738449

        :param str symbol: unified market symbol
        :param float amount: the amount of margin to remove
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        r  Nr  r  r  r  r  s       r  reduce_marginzexmo.reduce_marginf  s4       ..vvxPPPPPPPPPr  c                 B   K   |                      ||d|           d{V S )a  
        add margin

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#143ef808-79ca-4e49-9e79-a60ea4d8c0e3

        :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
        :returns dict: a `margin structure <https://docs.ccxt.com/?id=margin-structure>`
        r  Nr(  r)  s       r  
add_marginzexmo.add_margins  s4       ..vvufMMMMMMMMMr  c                 >  K   |                      | j        di           }|                     |dd          }|                     |d|          }|                     |d          }|dk    r|                     |           d{V S |                     |           d{V S )a  
        fetch the trading fees for multiple markets

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#90927062-256c-4b03-900f-2b99131f9a54
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#7de7e75c-5833-45a8-b937-c2276d235aaa

        :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
        ri   r   r   N)r  r   safe_stringomitfetch_private_trading_feesfetch_public_trading_fees)r  r  r   defaultMethodr   s        r  fetch_trading_feeszexmo.fetch_trading_fees  s       //$,0BBGG(((<UVV!!&(MBB68,,...88@@@@@@@@@77?????????r  c                 `  K   |                                   d {V  |                     |           d {V }|                     |dg           }i }t          dt	          |                    D ]}||         }|                     |d          }|                     |d d          }|                     |d          }	|                     |d          }
|                     t          j	        |	d                    }|                     t          j	        |
d                    }||||ddd	||<   |S )
Npairsr   r   _trade_maker_feetrade_taker_fee100Tr   r  r   r   r   r   )
r  privatePostMarginPairListr  rangelenr.  r&  r  r'   
string_div)r  r  r  r5  resultipairmarketIdr  makerStringtakerStringr   r   s                r  r0  zexmo.fetch_private_trading_fees  sV     !!!!!!!!!77????????< '266q#e**%% 	 	A8D''f55H%%hc::F**41BCCK**41BCCK%%g&8e&L&LMME%%g&8e&L&LMME "! F6NN r  c                 P  K   |                                   d {V  |                     |           d {V }i }t          dt          | j                            D ]}| j        |         }|                     |          }|                     ||d         i           }|                     |d          }|                     |d          }	|                     t          j
        |d                    }
|                     t          j
        |	d                    }|||
|ddd||<   |S )Nr   r   commission_maker_percentcommission_taker_percentr9  Tr:  )r  publicGetPairSettingsr<  r=  symbolsr  r  r.  r  r'   r>  )r  r  r  r?  r@  r  r  feerC  rD  r   r   s               r  r1  zexmo.fetch_public_trading_fees  sE     !!!!!!!!!33F;;;;;;;;  q#dl++,, 	 	A\!_F[[((F//(F4L"==C**30JKKK**30JKKK%%g&8e&L&LMME%%g&8e&L&LMME "! F6NN r  c                     ||dk    rd S |dk    rdS |                     d          dk    }|                    d          }|d                             dd          }t          |          }|dk    r|rt	          | j        dz   |z             |S )N- r   % zN parseFixedFloatValue() detected an unsupported non-zero percentage-based fee )findsplitreplacefloatr   r   )r  inputisPercentagepartsvaluer?  s         r  parse_fixed_float_valuezexmo.parse_fixed_float_value  s    Mu||4B;;1

31,C  a  b))uQJJLJ*z z  ~C  !C  D  D  Dr  codesc                   K   |                                   d{V  |                     |           d{V }i }t          |                                          }t	          dt          |                    D ]}||         }||                     ||          s#ddd||<   |                     |          }|                     |d          }	| 	                    ||	g           }
t	          dt          |
                    D ]V}|
|         }|                     |d          }|                     |d          }| 
                    |          }|||         |<   W|
||         d<   || j        d<   |S )	a  
 @deprecated
        please use fetchDepositWithdrawFees instead

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction fees structures <https://docs.ccxt.com/?id=fees-structure>`
        Nr   )depositrs   r   r  commission_descr   transactionFees)r  $publicGetPaymentsProvidersCryptoListlistkeysr<  r=  in_arrayr   r.  r  rX  r   )r  rY  r  
cryptoListr?  cryptoListKeysr@  r"  r   
currencyId	providersjprovider	typeInnercommissionDescrJ  s                   r  fetch_transaction_feeszexmo.fetch_transaction_fees  s      !!!!!!!!!DDVLLLLLLLL
F joo//00q#n--.. 	- 	-A!!$D tU)C)C   F4L }}T**H))(D99J
JCCI1c)nn-- . .$Q< ,,Xv>>	!%!1!1(<M!N!N22>BB*-tY''#,F4L  *0&'r  c                    K   |                                   d{V  |                     |           d{V }|                     ||          }|| j        d<   |S )a  
        fetch deposit and withdraw fees

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2

        :param str[]|None codes: list of unified currency codes
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `transaction fees structures <https://docs.ccxt.com/?id=fees-structure>`
        Nr]  )r  r^  parse_deposit_withdraw_feesr   )r  rY  r  r  r?  s        r  fetch_deposit_withdraw_feesz exmo.fetch_deposit_withdraw_fees@  sz       !!!!!!!!!BB6JJJJJJJJ( 11(EBB*0&'r  r   c                    |                      |          }t          dt          |                    D ]}||         }|                     |d          }|                     |d          }|                     ||                     |d                    }|                     |d          }	g }
d }|	*|	                    d          }
t          |
          }|dk    }|                     |d         |          }|d d d	d d d	d
|d         |<   |                     |                     |
d                    |d	|d         |         |<   |                     |          S )Nr   r  r   r"  r\  rN     r   )rJ  r   rs   r[  )	deposit_withdraw_feer<  r=  r.  network_id_to_coderQ  r  rX  $assign_default_deposit_withdraw_fees)r  rJ  r   r?  r@  rg  r  	networkIdnetworkCoderi  splitCommissionDescr   splitCommissionDescLengthnetworks                 r  parse_deposit_withdraw_feezexmo.parse_deposit_withdraw_feed  s   " **3//q#c((## 	 	A1vH##Hf55D((6::I11)T=M=MhX^=_=_``K!--h8IJJN"$J)&4&:&:3&?&?#,/0C,D,D)6!;
oofZ&8+FFG  $&*! !
  $&*   	3 	3z";/ 33D4D4DEXZ[4\4\]](5 5F:{+D11 88@@@r  c                   K   g }|                     |                     |                     |                     |                     |                     t          j        |  d{V }|d         }|d         }i }t          dt          |                    D ]U}||         }|                     |d          }	|                     |	          }
d}i }| 	                    ||	          }|d}nt          dt          |                    D ]}||         }|                     |d          }|
                    |	dz   d          }|
                    d	d          }d
}|
                    |d          }|                     |          }||vr||dddddddddddg d||<   |                     |d          }|                     |d          }|                     |d          }|                     |d          }||         }|dk    r(||d<   ||d         d         d<   ||d         d         d<   n-|dk    r'||d<   ||d         d         d<   ||d         d         d<   | 	                    |d          }|                     |           ||d<   |||<   |                     |	|
|                     |d          |dddd|                     d          ddddddd||d|d          ||
<   W|S )a  
        fetches all available currencies on an exchange

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#7cdf0ca8-9ff6-4cf3-aa33-bcec83155c49
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an associative dictionary of currencies
        Nr      r   cryptofiatrO  rM  ()minmaxrp  )r   rx  activer[  rs   rJ  limitsr   r  r  r  enabledr[  r  rs   r   description1e-8)r   re  )r   r"  r   r  r  r[  rs   rJ  	precisionr  r   r   )appendpublicGetCurrencyListExtendedr^  asynciogatherr<  r=  r.  safe_currency_code	safe_listrR  rr  r  safe_currency_structurer  )r  r  promises	responsescurrencyListrb  r?  r@  r   rd  r"  r  r   re  rf  rg  r   rt  replaceCharru  rh  minValuemaxValueactiveProvidernetworkEntryr   s                             r  fetch_currencieszexmo.fetch_currencies  s      ::6BBCCC 	AA&IIJJJ2 ".(3333333	 |q\
q#l++,, Q	 Q	A#AH))(F;;J**:66DDHz:>>I q#i..11 -9 -9A(|H++Hf==D $Z#-=r B BI ) 1 1#r : :I"%K ) 1 1+r B BI"&"9"9)"D"DK'833"+'2&*'+(,#' ,0+/-" -"
 ,0+/," ,"	' 	' %'#1 1-& !% 0 06 B BI#//%@@H#//%@@H%)^^Hi%H%HN#+K#8L I--2@Y/CKX.y9%@CKX.y9%@@"j003AZ0DLX.z:5ADLX.z:5A>>,??DKK)))+/L(,8H[))77 ((=AA !..v66  $#! !
  $#   	 	 !)!*  %19 9  F4LL4 r  c                   K   g }|                     |                     |                     i }|                     d          }|r(|                     |                     |                     t	          j        |  d{V }|d         }|r4|d         }|                     |d          }|                     |d          }t          |	                                          }	g }
t          dt          |	                    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uddddddddddddd|                     t%          j        |d                    |                     t%          j        |d                    ddddd|                     d           |                     |                     |                     |d!                              d"d|                     |d#          d$|                     |d%          |                     t%          j        ||                    d$|                     |d&          |                     |d'          d$|                     |d(          |                     |d)          d$d*d|d+           |
S ),a;  
        retrieves data on all markets for exmo

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#7de7e75c-5833-45a8-b937-c2276d235aaa

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict[]: an array of objects representing market data
        FNr   r{  r5  r   r6  /rG  rF  max_quantitymax_order_quantityr   r  baser  settlebaseIdquoteIdsettleIdr  r0   Tr1   r2   r3   r4   r  contractr   r9  r  price_precision)r  pricer   r  min_quantity	min_price	max_price
min_amount
max_amount)r   r  r  cost)r   r   r   contractSizeexpiryexpiryDatetimestrike
optionTyper  r  createdr   )r  rH  check_required_credentialsr;  r  r  r  index_byr_  r`  r<  r=  	safe_dictrR  rQ  r  r.  r  r'   r>  parse_precisionsafe_number
string_max)r  r  r  marginPairsDictfetchMarginr  spotResponsemarginPairsr5  r`  r?  r@  r   r  marginMarketr  r  r  r  r  rD  rC  maxQuantitymarginMaxQuantitys                           r  fetch_marketszexmo.fetch_markets  sP      226::;;;  !#55e<< 	DOOD::6BBCCC< ".(3333333	 | 	;#A,KNN;88E"mmE6::OL%%''((q#d))$$ >	 >	AaB!"%F>>/2>>LZZS))F$ll3//OFG**622D++G44E**63MNNK**63MNNK**6>BBK $ 0 0?S T TMM 2b2&2 2 	2
 $2 &2 72 D2 2 2 ,d22 2 %2 %2 $2  E!2" $#2$  **7+=k5+Q+QRR**7+=k5+Q+QRR $"&""//77!..t/C/CDDTDTU[]nDoDo/p/pqq   $#//
CC! !
  $//GG#001CKQb1c1cdd 
  $//DD#//DD 
  $//EE#//EE  $  c2 2 2 2 2 2 2f r  r   	timeframesincer   c                   K   |                                   d{V  |                     |          }|                     |dd          }|du}|d         |                     | j        ||          d}	d}
|                     |          }|                     |                                 dz            }|=|rt          ||          n|}|d}nt          ||
          }|||z  z
  dz
  |	d	<   ||	d
<   nr|                     |dz            |	d	<   |rt          ||          |	d
<   nA||
}nt          ||
          }| 	                    |||z            }t          ||          |	d
<   | 
                    |d          }|                     |                     |	|                     d{V }|                     |dg           }|                     |||||          S )a
  
        fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#65eeb949-74e5-4631-9184-c38387fe53e8

        :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]: the maximum amount of candles to fetch
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param int [params.until]: timestamp in ms of the latest candle to fetch
        :returns int[][]: A list of candles ordered, open, high, low, close, volume
        NuntilgMbP?r   )r  
resolutioni  r   r{  fromtocandles)r  r  safe_integer_productr.  r   parse_timeframeparse_to_intmillisecondsr  sumr/  publicGetCandlesHistoryr  r  parse_ohlcvs)r  r  r  r  r   r  r  r  untilIsDefinedr  maxLimitdurationnowr  r  r  s                   r  fetch_ohlcvzexmo.fetch_ohlcv  s      !!!!!!!!!V$$))&'5AAt+Tl**4?IyQQ
 
 ''	22 1 1 3 3d :;;=$2;UCB}E8,, EH$459GFOGDMM"//==GFO - #E3=$EEx00EXXeUX%566 #B67++55dkk'66R6RSSSSSSSS ..9b99  &)UEJJJr  c           	         |                      |d          |                     |d          |                     |d          |                     |d          |                     |d          |                     |d          gS )Ntohlcv)safe_integerr  )r  ohlcvr  s      r  parse_ohlcvzexmo.parse_ohlcv  s     eS))UC((UC((UC((UC((UC((
 	
r  c                    d|i}|                      |d          }|t          |                                          }t          dt	          |                    D ]}||         }||         }|                     |          }|                                 }	|                     |d          |	d<   |                     |d          |	d<   |                     |d          |	d<   |	||<   n|                      |di           }
|                      |d	i           }t          |
                                          }t          dt	          |                    D ]r}||         }|                     |          }|                                 }	||
v r|                     |
|          |	d<   ||v r|                     ||          |	d<   |	||<   s|                     |          S )
Nr   walletsr   usedfreebalancer!  balancesreserved)	r  r_  r`  r<  r=  r  accountr.  safe_balance)r  r  r?  r  currencyIdsr@  rd  itemr   r  r  r  r"  s                r  parse_balancezexmo.parse_balance  s   )//(I66w||~~..K1c+..// + +(^
z*22:>>,,.."&"2"24"@"@"&"2"24"@"@#'#3#3D)#D#D #*x  + ??8Z<<D??8Z<<Dtyy{{++K1c+..// ' '(^
..z::,,..%%&*&6&6tZ&H&HGFO%%&*&6&6tZ&H&HGFO&t  (((r  c                 R  K   |                                   d{V  d}|                     d|          \  }}|dk    rt          | j        dz             d}|dk    r|                     |           d{V }n|                     |           d{V }|                     |          S )aD  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#59c5160f-27a1-4d9a-8cfb-7979c7ffaac6
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#c8388df7-1f9f-4d41-81c4-5a387d171dc6

        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: *isolated* fetches the isolated margin balance
        :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
        NrB   crossz does not support cross marginr  )r  handle_margin_mode_and_paramsr   r   privatePostMarginUserWalletListprivatePostUserInfor  )r  r  r   r  s       r  fetch_balancezexmo.fetch_balance	  s       !!!!!!!!!
!??PVWW
F  TW'GGHHH##!AA&IIIIIIIIHH "55f========H !!(+++r  c                 Z  K   |                                   d{V  |                     |          }d|d         i}|||d<   |                     |                     ||                     d{V }|                     ||d                   }|                     ||d         ddd          S )aY  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#c60c51a8-e683-4f45-a000-820723d37871

        :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
        NrA  r   r   r  bidask)r  r  publicGetOrderBookr  r  parse_order_book)r  r  r   r  r  r  r  r?  s           r  fetch_order_bookzexmo.fetch_order_book7  s       !!!!!!!!!V$$F4L
 $GG00Wf1M1MNNNNNNNN&,77$$VVH-=tUERRRr  rI  c                   K   |                                   d{V  d}|ld                    | j                  }t          |          dk    r>t          | j                  }t	          | j        dz   t          |          z   dz             n*|                     |          }d                    |          }d|i}|||d<   |                     | 	                    ||                     d{V }i }t          |                                          }	t          dt          |	                    D ]A}
|	|
         }|                     |          }|                     ||         |dd	d
          ||<   B|S )a  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data for multiple markets

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#c60c51a8-e683-4f45-a000-820723d37871

        :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,i   z fetchOrderBooks() has zy symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooksrA  r   r   r  r  )r  joinidsr=  r   r   str
market_idsr  r  r_  r`  r<  r&  r  )r  rI  r   r  r  numIdsr  r  r?  	marketIdsr@  rB  r  s                r  fetch_order_bookszexmo.fetch_order_booksM  s      !!!!!!!!!?((48$$C3xx$TX#DG.G$G#f++$U  YT  %T  U  U  U  //'**C((3--CC
 $GG00Wf1M1MNNNNNNNN))	q#i..)) 	c 	cA |H%%h//F!228H3EvtUZ\abbF6NNr  r   c                 n   |                      |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|          S )Nupdated
last_trader  r$  r%  highlowr  	buy_price	bidVolumer  
sell_price	askVolumevwapopencloselastpreviousClosechanger   averageavgvolvol_curr)
baseVolumequoteVolumer   )safe_timestampsafe_marketr.  safe_tickeriso8601)r  r   r  r$  r
  s        r  parse_tickerzexmo.parse_tickerq  s    ''	::	!!$//55 !
fX&!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FK88!
 !
 4##FL99!
 !
 D!
 D!
 T!
 D!
 T!
 d!
  $!!
" t''66#!
$ **6599++FJ??)!
 !
 !
* +  	r  c                   K   |                                   d{V  |                     |          }|                     |           d{V }i }t          |                                          }t          dt          |                    D ]X}||         }|                     |dd          }|d         }	|                     ||          }
| 	                    |
|          ||	<   Y| 
                    |d|          S )a7  
        fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#4c8e6459-3503-4361-b012-c34bb9f7e385

        :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>`
        Nr   r6  r  )r  market_symbolspublicGetTickerr_  r`  r<  r=  r  r  r  filter_by_array_tickers)r  rI  r  r  r?  r  r@  rB  r  r  r   s              r  fetch_tickerszexmo.fetch_tickers  s      !!!!!!!!!%%g..--f55555555  ))	q#i..)) 	? 	?A |H%%hc::FH%F__Xx88F!..vv>>F6NN++FHgFFFr  c                    K   |                                   d{V  |                     |           d{V }|                     |          }|                     ||d                  |          S )a  
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#4c8e6459-3503-4361-b012-c34bb9f7e385

        :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>`
        Nr   )r  r  r  r  )r  r  r  r  r  s        r  fetch_tickerzexmo.fetch_ticker  s       !!!!!!!!!--f55555555V$$  &,!7@@@r  tradec                 t   |                      |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |d          }|                     |dd          }	d }
|                     |d	          }|                     ||d
          }|d         }|                     |d          }d }||rdnd}|                     |d|          }d }|                     |d          }|_|                     |d          }|                     |          }|                     |d          }|t          j        |dd          }|||d}|                     |||| 	                    |          |||
|	|||||d|          S )Ndatetrade_idorder_idr  r
  r  r  
trade_typerA  r6  r  is_makerr   r   	exec_typecommission_amountcommission_currencycommission_percent1000   )r  r   rate)r   r   r$  r%  r  orderr  sidetakerOrMakerr  r  r  rJ  )
r  r.  safe_string_2r  r  r  r'   r>  
safe_trader  )r  r  r  r$  r   orderIdpriceStringamountString
costStringr.  r  rB  r  isMakertakerOrMakerDefaultr/  rJ  feeCostStringfeeCurrencyIdfeeCurrencyCodefeeRateStrings                        r  parse_tradezexmo.parse_trade  s   T ''v66	eZ00""5*55&&ug66''z::%%eX66
!!%>>##E622!!(FC88!//%44"-4"A'''''{<OPP((0CDD$ ,,U4IJJM"55mDDO ,,U4HIIM( ' 2=&" M M%+% C
 "Y//( " 
  
   	r  c                 @  K   |                                   d{V  |                     |          }d|d         i}|                     |                     ||                     d{V }|                     ||d         g           }|                     ||||          S )aC  
        get the list of most recent trades for a particular symbol

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#5a5a9c0d-cf17-47f6-9d62-6d4404ebd5ac

        :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>`
        NrA  r   )r  r  publicGetTradesr  r  parse_trades)	r  r  r  r   r  r  r  r  r  s	            r  fetch_tradeszexmo.fetch_trades%  s       !!!!!!!!!V$$F4L
 --dkk'6.J.JKKKKKKKK. ~~htb99  vue<<<r  c                   K   |t          | j        dz             d}|                     d|          \  }}|dk    rt          | j        dz             |                                  d{V  |                     |          }|d         }|dk    }|d}i }	|r||	d	<   n||	d
<   |||	d<   |                     |dd          }
|
|	d<   d}|r0|                     |                     |	|                     d{V }nE| 	                    |                     |	|                     d{V }| 
                    |d          }g }t          |                                          }t          dt          |                    D ]W}||         }|                     |dd          }||         }|                     ||||          }|                     ||          }X|                     |||          S )aE  
        fetch all trades made by the user

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#b8d8d9af-4f46-46a1-939b-ad261d79f452  # spot
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#f4b1aaf8-399f-403b-ab5e-4926d967a106  # margin

        :param str symbol: a symbol is required but it can be a single string, or a non-empty array
        :param int [since]: the earliest time in ms to fetch trades for
        :param int [limit]: *required for margin orders* the maximum number of trades structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint

 EXCHANGE SPECIFIC PARAMETERS
        :param int [params.offset]: last deal offset, default = 0
        :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nz+ fetchMyTrades() requires a symbol argumentrV   r  z" only isolated margin is supportedr   r  r.   rA  	pair_namer   offsetr   r   r6  )r   r   r  r   r  r  r  privatePostUserTradesr  privatePostMarginTradesr  r_  r`  r<  r=  r  r?  array_concatfilter_by_since_limit)r  r  r  r   r  r   r  rA  isSpotr  rC  r  responseFromExchanger?  marketIdsInnerr@  rB  resultMarketitemsr   s                       r  fetch_my_tradeszexmo.fetch_my_tradesP  sH       >#DG.[$[\\\
!??QWXX
F  TW'KKLLL!!!!!!!!!V$$d|z)=E 	("GFOO#'GK $GG""68Q77" -	G!77GV8T8TUUUUUUUUHH2 *.)E)EdkkRY[aFbFb)c)c#c#c#c#c#c#c & ';XFFHhmmoo..q#n--.. 	7 	7A%a(H++HdC@@LX&E&&ulE5IIF&&vv66FF))&%???r  r.  r  c                    K   |                                   d{V  |                     |d|i          }|                     |d||d|           d{V S )a/  
        create a market order by providing the symbol, side and cost

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd

        :param str symbol: unified symbol of the market to create an order in
        :param str side: 'buy' or 'sell'
        :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>`
        Nr  r  r  r  create_order)r  r  r.  r  r  s        r  create_market_order_with_costz"exmo.create_market_order_with_cost  ss       !!!!!!!!!Vfd^44&&vxtT6RRRRRRRRRr  c                    K   |                                   d{V  |                     |d|i          }|                     |dd|d|           d{V S )a  
        create a market buy order by providing the symbol and cost

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd

        :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>`
        Nr  r  buyrO  r  r  r  r  s       r  !create_market_buy_order_with_costz&exmo.create_market_buy_order_with_cost  ss       !!!!!!!!!Vfd^44&&vxdFSSSSSSSSSr  c                    K   |                                   d{V  |                     |d|i          }|                     |dd|d|           d{V S )a  
        create a market sell order by providing the symbol and cost

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd

        :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>`
        Nr  r  sellrO  rT  s       r  "create_market_sell_order_with_costz'exmo.create_market_sell_order_with_cost  ss       !!!!!!!!!Vfd^44&&vxtVTTTTTTTTTr  r  r  c                 (  K   |                                   d{V  |                     |          }|dk    o|du }d}	|                     d|          \  }	}|	dk    rt          | j        dz             |	dk    }
|                     |g d          }|                     |d          }d	|d
         i}| |                     |d         |          |d<   n|                     |d         |          |d<   | 	                    |dd          }|5| 
                    |dd          }|t          | j        dz             ||d<   |                     |d          }|
s|t          | j        dz             |                     |g d          }||                     |d         |          |d<   d}|
rC|l|dk    rt          | j        dz             ||d<   |                     ||          |d<   |                     |                     ||                     d{V }n`|                     |d          }d}|                     |dk    |dk    |          \  }}|                     |d          }|rdn|                     |d         |          |d<   |dk    r||d<   n|dk    r|dnd}d|z   |z   |d<   |rd|d<   n|||d<   |                     |                     ||                     d{V }n|=|                     ||          |d<   |dk    r	d |z   |d<   n2|dk    r	d!|z   |d<   n#||d<   n|dk    s|dk    r|d"z   |z   |d<   n||d<   |                     |                     ||                     d{V }|                     ||          S )#a-  
        create a trade order

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#de6f4321-eeac-468c-87f7-c4ad7062e265  # stop market
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#3561b86c-9ff1-436e-8e68-ac926b7eb523  # margin

        :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 at which a trigger order is triggered at
        :param str [params.timeInForce]: *spot only* 'fok', 'ioc' or 'post_only'
        :param boolean [params.postOnly]: *spot only* True for post only orders
        :param float [params.cost]: *spot only* *market orders only* the cost of the order in the quote currency for market orders
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr  r<   r   only supports isolated marginr  r   	stopPrice
stop_pricer  rA  r   r  r
  	client_idclientOrderIdzC createOrder() client order id must be an integer / numeric literalr   zI createOrder requires an extra param params["leverage"] for margin orders)r\  r]  r   r   r^  r_  r  r  r   zI createOrder() cannot create stop limit orders for spot, only stop marketr  trigger_pricer&  	post_onlyr   r   _totalrM  market_r]  stop_limit_stop_r6  )r  r  r  r   r   safe_string_nr.  amount_to_precisioncost_to_precisionsafe_value_2safe_integer_2r  r   r/  price_to_precision privatePostStopMarketOrderCreater  handle_post_onlyprivatePostOrderCreate privatePostMarginUserOrderCreateparse_order)r  r  r  r.  r  r  r  r  isMarketr   rH  r   r  r  r_  r   r  execType
isPostOnlyr   marketSuffixs                        r  rP  zexmo.create_order  s     ( !!!!!!!!!V$$H$95D=
!??vVV
F  TW'GGHHH
*))&2]2]2]^^//F4L
 <"&":":6(;KV"T"TGJ"&"8"89I4"P"PGJ))&+OO$ //_UUM$ +p!pqqq'4$##FJ77 	{8+#DG.y$yzzz6  $D  $D  $D  E  E#66vh7GOOGG &	a'7??$TW/z%z{{{&*GFO/3/F/Fv|/\/\GO,!%!F!Ft{{SZ\bGcGc!d!ddddddd++FK@@!
%)%:%:48;KXYdMdfl%m%m"
F"..v}EE(0#f11d6M6MfU]N^`e6f6f 7??&*GFOOX%%040@88rL&/$&6&EGFO 7+6GK(( ,+6GK(!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ'(,(?(?(U(U%7??&3d&:GFOOX%%&-nGFOO&*GFOO7??dh&6&6&*Sj4&7GFOO&*GFO!BB4;;wX^C_C_````````H&111r  r   c                   K   |                                   d{V  i }|                     |dd          }|                     |ddg          }d}|                     d|          \  }}|dk    rt	          | j        dz             d}|dk    r5||d<   |                     |                     ||                     d{V }nk|r5||d	<   |                     |                     ||                     d{V }n4||d<   | 	                    |                     ||                     d{V }| 
                    |          S )
a!  
        cancels an open order

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#1f710d4b-75bc-4b65-ad68-006f863a3f26
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#a4d0aae8-28f7-41ac-94fd-c4030130453d  # stop market
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#705dfec5-2b35-4667-862b-faf54eca6209  # margin

        :param str id: order id
        :param str symbol: not used by exmo cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param boolean [params.trigger]: True to cancel a trigger order
        :param str [params.marginMode]: set to 'cross' or 'isolated' to cancel a margin order
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr   stopr6   r  rZ  r  r#  parent_order_id)r  ri  r/  r  r   r    privatePostMarginUserOrderCancelr   privatePostStopMarketOrderCancelprivatePostOrderCancelrp  )r  r   r  r  r  r   r   r  s           r  cancel_orderzexmo.cancel_orderA  s      !!!!!!!!!##FIv>>6Iv#677
!??vVV
F  TW'GGHHH*$$"$GJ!BB4;;wX^C_C_````````HH
  [-/)*!%!F!Ft{{SZ\bGcGc!d!ddddddd
 ')
#!%!<!<T[[RX=Y=Y!Z!ZZZZZZZ )))r  c                   K   |                                   d{V  dt          |          i}|                     |                     ||                     d{V }|                     |          }t          |          |d<   |S )a  
        *spot only* fetches information on an order made by the user

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#cf27781e-28e5-4b39-a52d-3110f5d22459  # spot

        :param str id: order id
        :param str symbol: not used by exmo fetchOrder
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr#  r   )r  r  privatePostOrderTradesr  rp  )r  r   r  r  r  r  r-  s          r  fetch_orderzexmo.fetch_orderq  s       !!!!!!!!!B
 44T[[&5Q5QRRRRRRRR,   **"ggdr  c                   K   d}|                      d|          \  }}|dk    rt          | j        dz             d}||                     |          }dt	          |          i}d}	|dk    r0|                     |                     ||                     d{V }	n/|                     |                     ||                     d{V }	|                     |	d          }
| 	                    |
|||          S )a  
        fetch all the trades made from a single order

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#cf27781e-28e5-4b39-a52d-3110f5d22459  # spot
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#00810661-9119-46c5-aec5-55abe9cb42c7  # margin

        :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
        :param str [params.marginMode]: set to "isolated" to fetch trades for a margin order
        :returns dict[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
        Nr]   r  rZ  r#  r  r   )
r  r   r   r  r   privatePostMarginUserOrderTradesr  r}  r  r?  )r  r   r  r  r   r  r   r  r  r  r   s              r  fetch_order_tradeszexmo.fetch_order_trades  s$      
!??@RTZ[[
F  TW'GGHHH[[((FB
 ##!BB4;;wX^C_C_````````HH$ "88Wf9U9UVVVVVVVVH4 (33  >>>r  c                 ,  K   |                                   d{V  d}||                     |          }|d         }d}|                     d|          \  }}|dk    p|dk    }d}g }	|rc|                     |           d{V }|                     |ddi          }|                     |d          }
|                     |
||||          }	n|                     |           d{V }t          |	                                          }t          d	t          |                    D ]l}||         }|                     |          }|                     |ddi          }|                     ||         ||||          }|                     |	|          }	m|	S )
a  
        fetch all unfilled currently open orders

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#0e135370-daa4-4689-8acd-b6876dee9ba1  # spot open orders
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#a7cfd4f0-476e-4675-b33f-22a46902f245  # margin

        :param str symbol: unified market symbol
        :param int [since]: the earliest time in ms to fetch open orders for
        :param int [limit]: the maximum number of  open orders structures to retrieve
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: set to "isolated" for margin orders
        :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr  rY   r  r  r#  r  ordersr   )r  r  r  privatePostMarginUserOrderListr  r  parse_ordersprivatePostUserOpenOrdersr_  r`  r<  r=  r  rF  )r  r  r  r   r  r  r   isMarginr  r  responseOrdersr  r@  rB  marketInnerparsedOrderss                   r  fetch_open_orderszexmo.fetch_open_orders  s      !!!!!!!!![[((FH%F
!??@QSYZZ
F7*I
j0H =	A!@@HHHHHHHHH8 [[&*  F "__Xx@@N&&~vueVTTFF!;;FCCCCCCCCH$ X]]__--I1c)nn-- A A$Q<"..x88Vf.    $00(1C[RWY^`fgg**6<@@r  c                 v    |d S ddi}|                     d          dk    rd}|                     |||          S )Ncancel_startedcanceledcancelr   )rP  r.  r  r#  statusess      r  parse_statuszexmo.parse_status<  sN    >4j
 ;;x  A%%F&&999r  c                 R    ddddddddddddddd}|                      |||          S )NrS  rW  )	limit_buy
limit_sell
market_buymarket_sellstop_buy	stop_sellstop_limit_buystop_limit_selltrailing_stop_buytrailing_stop_sellstop_market_sellstop_market_buyrS  rW  r.  )r  	orderTyper.  s      r  
parse_sidezexmo.parse_sideF  sR     !#%!&"( &$
 
  i;;;r  r-  c           
      j   |                      |dd          }|                     |ddd          }|                     |d|          }|                      |dd          }|                     |          }d }d|v r	|d         }n7d	|v r3d
|v r/|dk    r|d	         dz   |d
         z   }n|d
         dz   |d	         z   }|                     ||          }|d         }	|                     |d          }
|
 |dk    rdnd}|                     ||          }
|                     |d          }|                     |d          }|                     |dg           }|                     |d          }|                     |d          }|dk    rd }d }|dk    r|dk    r|}|                     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'|          S )(Nr#  rw  
event_timer  gư>r  
order_typerA  in_currencyout_currencyrS  r6  r  r
  	in_amount
out_amountr  r  r   r^  r]  0rW  r   r_  r%  r$  lastTradeTimestampr  r#  order_statusr   postOnlyr.  r   r  filled	remaining)r  r   rJ  r   )r0  safe_integer_product_2r  r  r  r.  r  r  
safe_orderr  r  r  )r  r-  r  r   	eventTimer$  r  r.  rB  r  r  amountFieldr  r  transactionsr_  r   r  s                     r  rp  zexmo.parse_orderY  s   ` z3DEE//|YPXYY	''y)DD	&&uflCC	y))U??V}HHu$$>U+B+Bu}} /#5n8MM 036}9MM!!(F33!!!%44>*.%--++lK%%e[99F  00x00uh;;))%==''|<<3LY&%8%8D  
" 
] 
 Y// 
 	 

 !$";";E9h"W"W 
 d''(8(8(O(OPP 
 f 
 D 
 4 
  
 D 
 U 
 L 
 D 
 f 
  d! 
" # 
$ "+ 
  
  
, -  	r  c                 p  K   |                                   d{V  d}|                     d|          \  }}|dk    rt          | j        dz             |d}|dk    }||                     |          }|d         }d|i}||nd	|d
<   ||d<   d}	||                     |          }	d}
|r`|                     |                     ||                     d{V }
|                     |ddi          }|                     |
|	|||          S |                     |                     ||                     d{V }| 	                    |d          }|                     ||	|||          }g }t          d	t          |                    D ]+}||         }|d         dk    r|                    |           ,|S )a5  
        fetches information on multiple canceled orders made by the user

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#1d2524dd-ae6d-403a-a067-77b50d13fbe5  # margin
        https://documenter.getpostman.com/view/10287440/SzYXWKPi#a51be1d0-af5f-44e4-99d7-f7b04c6067d0  # spot canceled orders

        :param str symbol: unified market symbol of the market orders were made in
        :param int [since]: timestamp in ms of the earliest order, default is None
        :param int [limit]: max number of orders to return, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :param str [params.marginMode]: set to "isolated" for margin orders
        :returns dict: a list of `order structures <https://docs.ccxt.com/?id=order-structure>`
        Nr   r  rZ  r.   r  r  r   r   rC  r#  r  rL  )r  r  r   r   r  privatePostUserCancelledOrdersr  r  !privatePostMarginUserOrderHistoryr  r<  r=  r  )r  r  r  r   r  r   rH  r  r  r  r  responseSwaprL  r  r?  r@  r-  s                    r  fetch_canceled_orderszexmo.fetch_canceled_orders  s!      !!!!!!!!!
!??vVV
F  TW'GGHHH=E
*++f--K *FU
 ',&7EEa [[((F 5	!@@WV\A]A]^^^^^^^^H [[**  F $$XvueVLLL!%!G!GT[]cHdHd!e!eeeeeeeL2 OOL'::E&&ufeUFKKFF1c&kk** ) )q	?j00MM%(((Mr  c                 V  K   |                                   d{V  |                     |          }d}	|                     d|          \  }	}|	dk    rt          | j        dz             |                     |g d          }
|                     |ddg          }d|i}|||d	<   ||                     |d
         |          |d<   |
|                     |d
         |
          |d<   |                     | 	                    ||                     d{V }| 
                    |          S )a  
        *margin only* edit a trade order

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#f27ee040-c75f-4b59-b608-d05bd45b7899  # margin

        :param str id: order id
        :param str symbol: unified CCXT market symbol
        :param str type: not used by exmo editOrder
        :param str side: not used by exmo editOrder
        :param float [amount]: how much of the currency you want to trade in units of the 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]: stop price for stop-market and stop-limit orders
        :param str params['marginMode']: must be set to isolated

 EXCHANGE SPECIFIC PARAMETERS
        :param int [params.distance]: distance for trailing stop orders
        :param int [params.expire]: expiration timestamp in UTC timezone for the order. order will not be expired if expire is 0
        :param str [params.comment]: optional comment for order. up to 50 latin symbols, whitespaces, underscores
        :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
        Nr@   r  z8 editOrder() can only be used for isolated margin ordersr[  r   r\  r#  r
  r  r  r]  )r  r  r  r   r   safe_number_nr/  rk   privatePostMarginUserOrderUpdater  rp  )r  r   r  r  r.  r  r  r  r  r   r   r  r  s                r  
edit_orderzexmo.edit_order7  sa     , !!!!!!!!!V$$
!??VTT
F##TW'aabbb))&2]2]2]^^6NK#@AA
 "(GJ#66vh7GOOGG#$($;$;F8<Ll$[$[GL!>>t{{7TZ?[?[\\\\\\\\)))r  r"  c                 V  K   |                                   d{V  |                     |           d{V }|                     ||          }d}d}|r:|                    d          }|d         }t	          |          }|dk    r|d         }|                     |           ||d||dS )a  
        fetch the deposit address for a currency associated with self account

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#c8f9ced9-7ab6-4383-a6a4-bc54469ba60e

        :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  r   r{  )r   r   rx  addresstag)r  privatePostDepositAddressr.  rQ  r=  check_address)	r  r"  r  r  depositAddressr  r  addressAndTagnumPartss	            r  fetch_deposit_addresszexmo.fetch_deposit_addressa  s       !!!!!!!!!77???????? ))(D99 	'*0055M#A&G=))H!||#A&7###
 
 	
r  c                     |                      |d          }t          |                                          }t          |          }|dk    r| j        |d                  S d S )NrA  r{  r   )r  r_  r`  r=  markets)r  r   tradesBySymbolrI  
numSymbolss        r  get_market_from_tradeszexmo.get_market_from_trades  sX    vv66~**,,--\\
??<
++tr  r  r  c                   K   |                      ||          \  }}|                                  d{V  |                     |          }||d         |d}|||d<   |                     | j        di           }|                     |d          }	|                     ||	|	          }	|	|	|d<   |                     |d          }|                     | 	                    ||                     d{V }
| 
                    |
|          S )a  
        make a withdrawal

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#3ab9c34d-ad58-4f87-9c57-2e2ea88a8325

        :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  invoicer   rx  	transport)handle_withdraw_tag_and_paramsr  r   r  r   safe_string_upperr.  r/  privatePostWithdrawCryptr  parse_transaction)r  r"  r  r  r  r  r   r  r   rx  r  s              r  rs   zexmo.withdraw  s/      99#vFFV!!!!!!!!!==&& 
 

 ?!$GI??4<R@@((;;""8Wg>>#*GK YYvy11F66t{{7F7S7STTTTTTTT%%h999r  r#  c                 @    dddddd}|                      |||          S )Nr  pending)transferredpaidr  
processing	verifyingr  r  s      r  parse_transaction_statuszexmo.parse_transaction_status  s7     #"
 
 &&999r  r   c                    |                      |dd          }|                     |d          }|t          j        |          }|                     |d          }|5|                     |di           }|                     |d          }|dk    r|}|                     |d          }|                     |dd	          }	|                     |	|          }
d }d }|                     |d
          }|dk    r|}n`|dk    rZ|}|V|                    d          }t          |          }|dk    r,|                     |d          }|	                    dd          }d d d d}| j
        d         d         s|dk    rdnd}|                     |d          }|I|                     | j        di           }|                     ||
i           }|                     ||          }|                     |d          }|dk    rd}|8|dk    rt          j        ||          }|                     |          |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*S )+Ndtr  r  txidextrarM  r  currr   r  r[  
withdrawal:ro  r{  rO  )r   r  r,  r   r   rs   
commissionr]  rg  cashbackr  r  r   r   r#  task_idrx  r#  r$  r%  r  addressFrom	addressTor  tagFromtagTor  )commentinternalrJ  )safe_timestamp_2r.  r'   
string_absr  r0  r  rQ  r=  rR  r   r   
string_subr  r  safe_string_lowerr  r  )r  r   r   r$  r4  r  r  	extraTxidr  rd  r"  r  r  r  rV  r  rJ  keyfeeCostr]  codeFeesrg  s                         r  r  zexmo.parse_transaction  s   h ))+tYGG	''X>>#"-l;;LV44<OOK"==E((77IB V44''VZHH
&&z8<<"";	::9GG\!!G"c**u::q=="..ua88G%ooc266G
 
 y'5 	'!%!5!5**IC&&{LAAG"&//$,@QSU"V"V???D"EE**8S99''Z@@H:%%"<''#*#5lG#L#LL"//88F"&J
K
$$$[*iHH
 D
 D	

 
 t''Z@@
 d''55
 d33D4J4J;X`4a4abb
 
 Y//
 w
 4
 
 4
 t
  T!
" t**;	BB#
$ )
 
 
 	
r  c                 D  K   |                                   d{V  i }||                     |dz            |d<   d}||                     |          }|                     |                     ||                     d{V }|                     |d         |||          S )a  
        fetch history of deposits and withdrawals

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#31e69a33-4849-4e6a-b4b4-6d574238f6a7

        :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>`
        Nr   r!  history)r  r  r   privatePostWalletHistoryr  parse_transactions)r  r"  r  r   r  r  r   r  s           r  fetch_deposits_withdrawalszexmo.fetch_deposits_withdrawals3	  s       !!!!!!!!!"//==GFO}}T**H66t{{7F7S7STTTTTTTT> &&x	':HeUSSSr  c                 T  K   |                                   d{V  d}ddi}|||d<   | |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a8  
        fetch all withdrawals made from an account

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#97f1becd-7aad-4e0e-babe-7bbe09e33706

        :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>`
        Nr  rs   r   r   r   rL  r  r   privatePostWalletOperationsr  r  r  	r  r"  r  r   r  r   r  r  rL  s	            r  fetch_withdrawalszexmo.fetch_withdrawalsg	  s       !!!!!!!!!J
 $GG}}T**H"*4.GJ99$++gv:V:VWWWWWWWW6 x"55&&uhuEEEr  c                 r  K   |                                   d{V  d}|dd}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch data on a currency withdrawal via the withdrawal id

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#97f1becd-7aad-4e0e-babe-7bbe09e33706

        :param str id: withdrawal id
        :param str code: unified currency code of the currency withdrawn, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
        Nrs   r#  r  r   r   rL  r   r  r   r  r  r  r  r  	r  r   r"  r  r   r  r  rL  firsts	            r  fetch_withdrawalzexmo.fetch_withdrawal	  s       !!!!!!!!!
 
 }}T**H"*4.GJ99$++gv:V:VWWWWWWWW6 '266ua,,%%eX666r  c                 r  K   |                                   d{V  d}|dd}| |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     |di           }|                     ||          S )a  
        fetch information on a deposit

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#97f1becd-7aad-4e0e-babe-7bbe09e33706

        :param str id: deposit id
        :param str code: unified currency code, default is None
        :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   rL  r   r  r  s	            r  fetch_depositzexmo.fetch_deposit	  s       !!!!!!!!!
 
 }}T**H"*4.GJ99$++gv:V:VWWWWWWWW6 '266ua,,%%eX666r  c                 T  K   |                                   d{V  d}ddi}|||d<   | |                     |          }|d         |d<   |                     |                     ||                     d{V }|                     |dg           }|                     ||||          S )a-  
        fetch all deposits made to an account

        https://documenter.getpostman.com/view/10287440/SzYXWKPi#97f1becd-7aad-4e0e-babe-7bbe09e33706

        :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>`
        Nr  r[  r   r   r   rL  r  r  s	            r  fetch_depositszexmo.fetch_deposits
  s       !!!!!!!!!I
 $GG}}T**H"*4.GJ99$++gv:V:VWWWWWWWW6 x"55&&uhuEEEr  r   GETc                    | j         d         |         dz   }|dk    r|| j        dz   z  }||z  }|dk    s|dk    r|r|d|                     |          z   z  }n|dk    r|                                  |                                 }|                     |                     d|i|                    }d| j        |                     |                     |          |                     | j	                  t          j                  d	}||||d
S )Nr   r  r   r   ?r   noncez!application/x-www-form-urlencoded)zContent-TypeKeySign)urlr   bodyheaders)r   r   	urlencoder  r	  r  apiKeyhmacencodesecrethashlibsha512)	r  pathr   r   r  r  r  r  r	  s	            r  signz	exmo.sign5
  s   is#c)%<<4<#%%Ct8OO 4sT^^F3333I++---JJLLE>>$++w.>"G"GHHD C{		$++d"3"3T[[5M5Mw~^^ G
 fdwOOOr  c                 *    |                                  S N)r  )r  s    r  r	  z
exmo.nonceH
  s      """r  httpCodereasonr  r   r  r  c
                    |d S d|v rd|vr|                      |di           }
|                     |
d          }|                     |
d          }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           t          |          d|v sd|v r"|                     |dd	          }t          |t                    r|d
k    s|dk    rd}nd	}|sd }| 
                    |dd          }|                    d          }t          |          }|dk    r@|d                             d          }t          |          }|dk    r|d         n|d         }| j        dz   |z   }|                     | j        d         ||           |                     | j        d         ||           t          |          d S )Nerrorr?  msgr"  rO  r   r   errmsgFtruert   Tr  r{  r   )r  r.  r   throw_exactly_matched_exceptionr   throw_broadly_matched_exceptionr   r  
isinstancer  r0  rQ  r=  )r  r  r  r  r   r  r  r  requestHeadersrequestBody	errorCodemessageErrorr"  feedbacksuccessmessage
errorPartsr  errorSubPartsnumSubPartss                       r  handle_errorszexmo.handle_errorsK
  s   4x(h*>*> '2>>I++Iu==L##Iv66Dw}t+H001I4QYZZZ001I<Yabbb)))  h(&:&:
 nnXx??G'3'' $v%%7c>>"GG#G .,,XwII$]]3//
z??a<<$.qM$7$7$<$<M"%m"4"4K0;a=++mTUFVD7S=4/44T_W5MtU]^^^44T_W5MwX`aaa#H---tr  r  )S__name__
__module____qualname__r   r  r  r  dictr   r   r  rS  r*  r,  r   r3  r0  r1  rX  r   rj  rm  r   ry  r   r  r   r  r
   r_  r  r  r   r  r  r   r  r   r  r   r  r   r  r  r   r<  r@  r   rM  r   rQ  rU  rX  r   r   rP  r{  r~  r  r   r  r  r  rp  r  r  r	   r  r  r   rs   r  r  r  r  r  r  r  r  r	  intr.  __classcell__)r  s   @r  r)   r)      s
       _# _ _ _ _ _ _B	 LN      .
 
d 
F 
N` 
 
 
 
" FH Q Q# Qu QL^ Q Q Q Q CE N Ns NE NI[ N N N N /1 @ @[ @ @ @ @& 79 2 2 2 2h 68 # # # #J   =A E E' E E E EN BFb " "w " " " "H.A .A .A .A .A .A` -/ D D: D D D DL *, B BV B B B BH ?CQUdhqs 8K 8K 8K 8K3 8K^a 8Kx|  ~B  yC 8K 8K 8K 8Kt
 
 
4 
 
 
 
() ) ) ) ): *, ,, ,, ,, ,, ,, ,,\ @DB S SS S SS\ S S S S, :>DY[ " "w "c "`j " " " "H& &4 & &6 & & & &P 6:" $G $G7 $G $G $G $G $GL 68 A A AF A A A AU U Uv U U U U Un <@d[] )= )= )=S )= )=bfglbm )= )= )= )=V 37TX\eg \@ \@C \@s \@RU \@ \@ \@ \@| eg S S# SY SV[ S S S S  XZ T Tc T T T T T Y[ U Us U% U U U U mqy{ c2 c2 c2I c2Y c2X] c2fi c2 c2 c2 c2J 9=R .* .*S .*# .* .* .* .*` 8<B ' 'C ' ' ' ' 'R ?CQUdhqs H? H?3 H? H?3 H?^a H? H? H? H?T 59tZ^gi V Vc V VTW Vnrsxny V V V Vp: : :< < <&C C Cv C C C C CJ 9=4^bkm W W# WS WX[ Wrvw|r} W W W Wr fjx|  FH (* (*3 (* (*9 (*I (*_b (*ru (* (* (* (*T =? "
 "
 "
> "
 "
 "
 "
H   QU]_ : :3 : : :# :do : : : :@:s : : : :z
 z
T z
X z
Q\ z
 z
 z
 z
x <@daenp 2T 2TS 2T 2T[^ 2Tuy  {F  vG 2T 2T 2T 2Th 37TX\eg 2F 2FC 2Fs 2FRU 2Flpq|l} 2F 2F 2F 2Fh ;?r 17 17 17C 17 17 17 17f 8<B 17 17c 17 17 17 17 17f 04$UYbd 2F 2F 2FC 2Fs 2Fimnyiz 2F 2F 2F 2Fh &eBSW P P P P&# # #(c (3 (S (# (X\ (dg ( ( ( ( ( ( ( (r  r)   )/ ccxt.async_support.base.exchanger   ccxt.abstract.exmor   r  r  ccxt.base.typesr   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#   r$   r%   ccxt.base.decimal_to_precisionr&   ccxt.base.preciser'   r)    r  r  <module>r=     s   6 5 5 5 5 5 * * * * * *   j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j  j       * * * * * * 0 0 0 0 0 0 - - - - - - . . . . . . ' ' ' ' ' ' . . . . . . ) ) ) ) ) ) * * * * * * . . . . . . * * * * * * ) ) ) ) ) ) 4 4 4 4 4 4 % % % % % %X) X) X) X) X)8[ X) X) X) X) X)r  