
    !:h'g                         d dl mZ d dlmZ d dlZd dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ 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CurrencyDepositAddressIntMarketNum	OrderBook	OrderSide	OrderTypeStrStringsTickerTradeTransferEntry)List)ExchangeError)	TICK_SIZE)Precisec                       e Zd Zdef 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d0d	ed
edefdZi fdedefdZd0d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defdZi fdedefdZdi fdedee   fdZd0de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"i fdededed ede#f
d!Z$d0d"edede#fd#Z%d$e!de!fd%Z&d&d'i ddfd(Z'd)e(d*ed+ed,ed-ed.efd/Z) xZ*S )1paymiumreturnc                    | j                  t        t        |          d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ddddddddddd
dddiddg d d!d"d#g d$ig d%g d&g d'd(d)d*| j	                  d+d*d,d-d.d+d	dd/      id0| j                  d1      | j                  d2      d3it        ddddd ddd ddddd4dddddddd5d d d d d d d d6	d d d7d d d7d8d9      S ):Nr   PaymiumFREUi  v1CORSTspotmarginswapFfutureoptioncancelOrdercreateDepositAddresscreateOrderfetchBalancefetchDepositAddressfetchDepositAddressesfetchDepositAddressesByNetworkfetchFundingHistoryfetchFundingRatefetchFundingRateHistoryfetchFundingRates)
fetchIndexOHLCVfetchMarkOHLCVfetchOpenInterestHistoryfetchOrderBookfetchPremiumIndexOHLCVfetchTickerfetchTradesfetchTradingFeefetchTradingFeestransferzdhttps://user-images.githubusercontent.com/51840849/87153930-f0f02200-c2c0-11ea-9c0a-40337375ae89.jpgrestzhttps://paymium.com/apizhttps://www.paymium.comz&https://www.paymium.com/page/help/fees)z,https://github.com/Paymium/api-documentationz'https://www.paymium.com/page/developersz,https://paymium.github.io/api-documentation/zBhttps://www.paymium.com/page/sign-up?referral=eDAzPoRQFMvaAB8sf-qj)logoapiwwwfeesdocreferralget)	countries
currencieszdata/{currency}/tickerzdata/{currency}/tradeszdata/{currency}/depthzbitcoin_charts/{id}/tradeszbitcoin_charts/{id}/depth)useruser/addresseszuser/addresses/{address}user/ordersuser/orders/{uuid}user/price_alertszmerchant/get_payment/{uuid})rF   rG   zuser/withdrawalszuser/email_transferszuser/payment_requestsrI   zmerchant/create_payment)rH   zuser/orders/{uuid}/cancelzuser/price_alerts/{id})rB   postdelete)publicprivatezBTC/EUReurBTCEURbtc)idsymbolbasequotebaseIdquoteIdtyper!   tradingz-0.001z0.005)makertaker)IOCFOKPOGTD)
marginModetriggerPricetriggerDirectiontriggerPriceTypestopLossPricetakeProfitPriceattachedStopLossTakeProfittimeInForcehedgedtrailingleveragemarketBuyByCostmarketBuyRequiresPriceselfTradePreventioniceberg)	sandboxr(   createOrdersfetchMyTrades
fetchOrderfetchOpenOrdersfetchOrdersfetchClosedOrders
fetchOHLCV)linearinverse)r!   r#   r$   )rR   namerC   	rateLimitversionhasurlsr=   marketsr?   precisionModefeatures)deep_extendsuperr   describesafe_market_structureparse_numberr   )self	__class__s    T/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/async_support/paymium.pyr   zpaymium.describe   s{   gt = ? $ 	
 % % t ' t  &t ( 1% &u #E  *5!" $U#$ $)"',1"&*/###($) 7< 5 1@
 a   
'%N 455Uiafqv  CH  UZ  dj  tx  7y  z !..x8!..w7 '  %&+(-,1,0).+06:#(#("'#(	( #($)$)+/27/4#()$, %)%)"&'+#')-"&=B ##
 ##K)CKB
 K K	    c                 x   d|i}t        | j                  j                               }t        dt	        |            D ]k  }||   }| j                  |      }|d   }d|z   }||v s(| j                         }	d|z   }
| j                  ||      |	d<   | j                  ||
      |	d<   |	||<   m | j                  |      S )Ninfor   rR   balance_locked_freeused)	listrD   keysrangelencurrencyaccountsafe_stringsafe_balance)r   responseresultrD   icoder   
currencyIdr   r   r   s              r   parse_balancezpaymium.parse_balance   s    )$//..01
q#j/* 
	'Aa=D}}T*H!$J
*Dx,,. :-"&"2"28T"B"&"2"28T"B&t
	'   ((r   c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)ar  
        query for balance and get the amount of funds available for trading or funds locked in orders

        https://paymium.github.io/api-documentation/#tag/User/paths/~1user/get

        :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privateGetUserr   )r   paramsr   s      r   fetch_balancezpaymium.fetch_balance   sG      !!!,,V44!!(++ 	"4   A	AA	AA	A	NrS   limitc           	         K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  ||d   ddddd      S 7 _7  w)	ab  
        fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data

        https://paymium.github.io/api-documentation/#tag/Public-data/paths/~1data~1%7Bcurrency%7D~1depth/get

        :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
        Nr   rR   rS   bidsaskspriceamount)r   marketpublicGetDataCurrencyDepthextendparse_order_book)r   rS   r   r   r   requestr   s          r   fetch_order_bookzpaymium.fetch_order_book   s      !!!V$t
 88Wf9UVV$$Xvh/?vvW^`hii 	"
 Ws"   A:A6A A:A8A:8A:tickerr   c                 V   | j                  d |      }| j                  |d      }| j                  |d      }| j                  |d      }t        j                  ||      }| j                  |d      }| j                  i d|d|d| j                  |      d| j                  |d      d	| j                  |d	      d
| j                  |d
      dd d| j                  |d      dd d|d| j                  |d      d|d|dd dd d| j                  |d      dd |||d|      S )Natvwapvolumer   rS   	timestampdatetimehighlowbid	bidVolumeask	askVolumeopencloselastpreviousClosechange
percentage	variationaverage)
baseVolumequoteVolumer   )safe_symbolsafe_timestampr   r   
string_mulsafe_tickeriso8601)	r   r   r   rS   r   r   r   r   r   s	            r   parse_tickerzpaymium.parse_ticker   s   & !!$/''5	/%%fh7
((T:0 !
f!
!
 Y/!
 D$$VV4	!

 4##FE2!
 4##FE2!
 !
 4##FE2!
 !
 D!
 D$$VV4!
 T!
 D!
 T!
 d!
  $**6;?!!
" t#!
$ %&)!
* + 	r   c                    K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  ||      S 7 W7 w)a   
        fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

        https://paymium.github.io/api-documentation/#tag/Public-data/paths/~1data~1%7Bcurrency%7D~1ticker/get

        :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   rR   )r   r   publicGetDataCurrencyTickerr   r   )r   rS   r   r   r   r   s         r   fetch_tickerzpaymium.fetch_ticker   sy      !!!V$t
 77GV8TUU&   001 	"
 Vs"   A2A.A A2A0A20A2tradec                 j   | j                  |d      }| j                  |d      }| j                  d |      }| j                  |d      }| j                  |d      }d|d   j                         z   }| j                  ||      }| j	                  ||d || j                  |      |d   d |d ||d d d|      S )	Ncreated_at_intuuidsider   traded_rT   rS   )r   rR   orderr   r   rS   rX   r   takerOrMakerr   r   costfee)r   r   safe_marketlower
safe_trader   )	r   r   r   r   rR   r   r   amountFieldr   s	            r   parse_tradezpaymium.parse_trade$  s    ''/?@	eV,!!$/v.  0&."6"6"88!!%5"Y/X&  
  	r   sincec                    K   | j                          d{    | j                  |      }d|d   i}| j                  | j                  ||             d{   }| j	                  ||||      S 7 Y7 w)aM  
        get the list of most recent trades for a particular symbol

        https://paymium.github.io/api-documentation/#tag/Public-data/paths/~1data~1%7Bcurrency%7D~1trades/get

        :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   rR   )r   r   publicGetDataCurrencyTradesr   parse_trades)r   rS   r   r   r   r   r   r   s           r   fetch_tradeszpaymium.fetch_trades<  s{      !!!V$t
 99$++gv:VWW  65%@@ 	"
 Xs"   A4A0A A4A2A42A4r   c                    K   | j                          d{    | j                  |       d{   }| j                  |      S 7 .7 w)a  
        create a currency deposit address

        https://paymium.github.io/api-documentation/#tag/User/paths/~1user~1addresses/post

        :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>`
        N)r   privatePostUserAddressesparse_deposit_address)r   r   r   r   s       r   create_deposit_addresszpaymium.create_deposit_addressP  sI      !!!66v>> ))(33 	">r   c                    K   | j                          d{    d|i}| j                  | j                  ||             d{   }| j                  |      S 7 B7 w)a  
        fetch the deposit address for a currency associated with self account

        https://paymium.github.io/api-documentation/#tag/User/paths/~1user~1addresses~1%7Baddress%7D/get

        :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>`
        Naddress)r   privateGetUserAddressesAddressr   r   )r   r   r   r   r   s        r   fetch_deposit_addresszpaymium.fetch_deposit_addressf  sf      !!!t
 <<T[[RX=YZZ ))(33 	" [s!   AA,AAAAcodesc                    K   | j                          d{    | j                  |       d{   }| j                  ||      S 7 /7 w)a  
        fetch deposit addresses for multiple currencies and chain types

        https://paymium.github.io/api-documentation/#tag/User/paths/~1user~1addresses/get

        :param str[]|None codes: list of unified currency codes, default is None
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a list of `address structures <https://docs.ccxt.com/#/?id=address-structure>`
        N)r   privateGetUserAddressesparse_deposit_addresses)r   r   r   r   s       r   fetch_deposit_addresseszpaymium.fetch_deposit_addresses  sK      !!!55f== ++He<< 	"=s   A
AA
AA
A
r   c                 z    | j                  |d      }| j                  |d      }|| j                  ||      d |d dS )Nr   r   )r   r   networkr   tag)r   safe_currency_code)r   depositAddressr   r   r   s        r   r   zpaymium.parse_deposit_address  sN     "">9=%%njA
"//
HE
 	
r   rX   r   r   r   c                 2  K   | j                          d{    | j                  |      }| j                  |      dz   |d   ||d}|dk7  r||d<   | j                  | j	                  ||             d{   }	| j                  |	|	d   d|      S 7 |7 w)	a  
        create a trade order

        https://paymium.github.io/api-documentation/#tag/Order/paths/~1user~1orders/post

        :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
        :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        NOrderrR   )rX   r   	directionr   r   r   r   )r   rR   )r   r   
capitalizeprivatePostUserOrdersr   
safe_order)
r   rS   rX   r   r   r   r   r   r   r   s
             r   create_orderzpaymium.create_order  s      !!!V$OOD)G3t	
 8$GG33DKK4PQQ6" 
  	 	" Rs"   BBAB6B7BBrR   c                    K   d|i}| j                  | j                  ||             d{   }| j                  d|i      S 7 w)a  
        cancels an open order

        https://paymium.github.io/api-documentation/#tag/Order/paths/~1user~1orders~1%7Buuid%7D/delete
        https://paymium.github.io/api-documentation/#tag/Order/paths/~1user~1orders~1%7Buuid%7D~1cancel/delete

        :param str id: order id
        :param str symbol: not used by paymium cancelOrder()
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
        r   Nr   )!privateDeleteUserOrdersUuidCancelr   r   )r   rR   rS   r   r   r   s         r   cancel_orderzpaymium.cancel_order  sV      B
 ??GU[@\]]H 
  	 ^s   )AAAfromAccount	toAccountc                   K   | j                          d{    | j                  |      }|j                  d      dk  rt        | j                  dz         |dk7  r|dk7  rt        | j                  dz         |d   | j                  ||      |d	}| j                  | j                  ||             d{   }| j                  ||      S 7 7 w)
a:  
        transfer currency internally between wallets on the same account

        https://paymium.github.io/api-documentation/#tag/Transfer/paths/~1user~1email_transfers/post

        :param str code: unified currency code
        :param float amount: amount to transfer
        :param str fromAccount: account to transfer from
        :param str toAccount: account to transfer to
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
        N@r   z5 transfer() only allows transfers to an email addressrO   rP   z" transfer() only allows BTC or EURrR   )r   r   email)	r   r   findr   rR   currency_to_precisionprivatePostUserEmailTransfersr   parse_transfer)	r   r   r   r   r  r   r   r   r   s	            r   r:   zpaymium.transfer  s      !!!==&>>#"*a abb5=TU]*N NOO 00v>
 ;;DKKQW<XYYB ""8X66[ 	" Zs"   CCB C7C8CCr:   c                    | j                  |d      }| j                  |d      }| j                  |      }| j                  |d      }| j                  |di       }| j                  |d      }|| j                  |d      || j                  |      | j	                  ||      | j                  |d      d | j                  |d      | j                  |      d		S )
Nr   
updated_ataccount_operationsr   stater   r   r   )	r   rR   r   r   r   r   r   r  status)r   
parse_date
safe_valuer   r   safe_numberparse_transfer_status)	r   r:   r   r   	updatedAt
timetstampaccountOperationsfirstOperationr  s	            r   r  zpaymium.parse_transfer  s    B %%h
;
$$X|<	__Y/
 OOH6JK):ArB!!(G4""8V4#Z0//
HE&&x:)).)D008

 
	
r   r  c                 0    ddi}| j                  |||      S )Nexecutedok)r   )r   r  statusess      r   r  zpaymium.parse_transfer_statusK  s%    
 &&99r   rL   GETc                    | j                   d   d   dz   | j                  z   dz   | j                  ||      z   }| j                  || j	                  |            }|dk(  r|r|d| j                  |      z   z  }n| j                          t        | j                               }	|	|z   }
| j                  |	d}|dk(  r|r<| j                  |      }|
|z  }
d|d	<   n |r| j                  |      }|
|z  }
|d|z   z  }| j                  | j                  |
      | j                  | j                        t        j                        |d
<   ||||dS )Nr=   r;   /rL   ?)zApi-Keyz	Api-NoncePOSTzapplication/jsonzContent-TypezApi-Signature)urlmethodbodyheaders)r}   r{   implode_paramsomitextract_params	urlencodecheck_required_credentialsstrnonceapiKeyjsonhmacencodesecrethashlibsha256)r   pathr=   r   r   r"  r!  r  queryr)  authqueryStrings               r   signzpaymium.signR  sM   iiv&,t||;cADDWDWX\^dDee		&$"5"5d";<(?sT^^E222++-

%E3;D;;"G 99U+DDLD.@GN+"&.."7KK'D3,,C'+yyT1BDKKPTP[P[D\^e^l^l'mGO$fdwOOr   httpCodereasonr  r   r"  r!  c
                     |y | j                  |d      }
|
*t        | j                  dz   | j                  |      z         y )Nerrors )r  r   rR   r+  )r   r6  r7  r  r   r"  r!  r   requestHeadersrequestBodyr9  s              r   handle_errorszpaymium.handle_errorsm  sE    84#		(0C CDDr   )N)+__name__
__module____qualname__r   r   r   r   r   r(  r	   r   r   dictr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   floatr   r   r   r   r   r:   r  r  r5  intr=  __classcell__)r   s   @r   r   r      s7   L# L\) )  *, , , @DB jS j jS\ j&.4 . .6 .` 68 "1 "1F "1H v  0 <@d[] A AS A Abfglbm A( >@ 4 4N 4, =? 4 4> 42 >B" =7 =QUVdQe =0
h 
R` 
& mqy{  I Y X] fi < 9=R S # ( ac :73 :7 :7C :7TW :7gt :7x1
t 1
x 1
= 1
f:C :C : &eBSW P6c 3 S # X\ dg r   r   ) ccxt.async_support.base.exchanger   ccxt.abstract.paymiumr   r/  ccxt.base.typesr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   typingr   ccxt.base.errorsr   ccxt.base.decimal_to_precisionr   ccxt.base.preciser   r    r   r   <module>rM     sJ    6 -  c  c  c  c  c  * 4 %c	h c	r   