
    !:hkf                         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    F/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/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                 f    | j                          | j                  |      }| j                  |      S )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>`
        )load_marketsprivateGetUserr   )r   paramsr   s      r   fetch_balancezpaymium.fetch_balance   s1     	&&v.!!(++r   NrS   limitc           	          | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||d   ddddd      S )	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
        r   rR   rS   N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   so     	V$t
 224;;w3OP$$Xvh/?vvW^`hiir   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                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||      S )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>`
        r   rR   )r   r   publicGetDataCurrencyTickerr   r   )r   rS   r   r   r   r   s         r   fetch_tickerzpaymium.fetch_ticker   s`     	V$t
 11$++gv2NO&   00r   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                     | j                          | j                  |      }d|d   i}| j                  | j                  ||            }| j	                  ||||      S )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>`
        r   rR   )r   r   publicGetDataCurrencyTradesr   parse_trades)r   rS   r   r   r   r   r   r   s           r   fetch_tradeszpaymium.fetch_trades<  sb     	V$t
 33DKK4PQ  65%@@r   r   c                 f    | j                          | j                  |      }| j                  |      S )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>`
        )r   privatePostUserAddressesparse_deposit_address)r   r   r   r   s       r   create_deposit_addresszpaymium.create_deposit_addressP  s3     	008 ))(33r   c                     | j                          d|i}| j                  | j                  ||            }| j                  |      S )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>`
        address)r   privateGetUserAddressesAddressr   r   )r   r   r   r   r   s        r   fetch_deposit_addresszpaymium.fetch_deposit_addressf  sL     	t
 66t{{7F7ST ))(33r   codesc                 h    | j                          | j                  |      }| j                  ||      S )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>`
        )r   privateGetUserAddressesparse_deposit_addresses)r   r   r   r   s       r   fetch_deposit_addresseszpaymium.fetch_deposit_addresses  s5     	//7 ++He<<r   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                    | j                          | j                  |      }| j                  |      dz   |d   ||d}|dk7  r||d<   | j                  | j	                  ||            }	| j                  |	|	d   d|      S )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>`
        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--dkk'6.JK6" 
  	r   rR   c                 r    d|i}| j                  | j                  ||            }| j                  d|i      S )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   r   )!privateDeleteUserOrdersUuidCancelr   r   )r   rR   rS   r   r   r   s         r   cancel_orderzpaymium.cancel_order  sH     B
 99$++gv:VWH 
  	r   fromAccount	toAccountc                 x   | j                          | 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                  ||            }| j                  ||      S )	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>`
        @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>
 55dkk'66RSB ""8X66r   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   r5  r6  r  r  r!  r   r   requestHeadersrequestBodyr8  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  r4  intr<  __classcell__)r   s   @r   r   r      s/   L# L\) )  $& ,( , :>b js j3 jY j&.4 . .6 .` 02 "13 "1f "1H v  0 6:UW A3 As A# A\`af\g A( 8: 43 4n 4, 79 4# 4^ 42 8<B =W =4P^K_ =0
h 
R` 
& gksu 3 i y RW `c < 37r s C ( [] :7S :7% :7c :7c :7an :7x1
t 1
x 1
= 1
f:C :C : &eBSW P6c 3 S # X\ dg r   r   )ccxt.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>rL     sJ    ( -  c  c  c  c  c  * 4 %c	h c	r   