
    eie                         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dS )    )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                 >   |                      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*|                     d+d*d,d-d.d+d	dd/          id0|                     d1          |                     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    J/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/paymium.pyr   zpaymium.describe   s   gt 4 4 = = ? ? $ 	
 % % 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  7y  z  z !..x88!..w77  '  %&+(-,1,0).+06:#(#("'#(	( ( #($)$)+/27/4#()$ $, %)%)"&'+#')-"&= B ## 
 ## K) )CKB
 KB
 K K K	    c                    d|i}t          | j                                                  }t          dt	          |                    D ]}||         }|                     |          }|d         }d|z   }||v rP|                                 }	d|z   }
|                     ||          |	d<   |                     ||
          |	d<   |	||<   |                     |          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011
q#j//** 
	' 
	'Aa=D}}T**H!$J
*Dx,,.. :-"&"2"28T"B"B"&"2"28T"B"B&t  (((r   c                 ~    |                                   |                     |          }|                     |          S )aw  
        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/operation/get-user-info

        :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   s=     	&&v..!!(+++r   NrS   limitc           	          |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||d         ddddd          S )	aS  
        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/operation/get-market-depth

        :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   s     	V$$t
 224;;w3O3OPP$$Xvh/?vvW^`hiiir   tickerr   c                    |                      d |          }|                     |d          }|                     |d          }|                     |d          }t          j        ||          }|                     |d          }|                     i d|d|d|                     |          d|                     |d          d	|                     |d	          d
|                     |d
          dd d|                     |d          dd d|d|                     |d          d|d|dd dd d|                     |d          dd |||d|          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5	//%%fh77
(T::00 !
f!
!
 Y//!
 D$$VV44	!

 4##FE22!
 4##FE22!
 !
 4##FE22!
 !
 D!
 D$$VV44!
 T!
 D!
 T!
 d!
  $**6;??!!
" t#!
$ %&)!
 !
 !
* +  	r   c                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||          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/operation/get-latest-ticker

        :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   sr     	V$$t
 11$++gv2N2NOO&   000r   tradec                    |                      |d          }|                     |d          }|                     d |          }|                     |d          }|                     |d          }d|d                                         z   }|                     ||          }|                     ||d ||                     |          |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0&."6"6"8"88!!%55"Y//X&  
  
   	r   sincec                     |                                   |                     |          }d|d         i}|                     |                     ||                    }|                     ||||          S )a>  
        get the list of most recent trades for a particular symbol

        https://paymium.github.io/api-documentation/#tag/Public-data/operation/get-latest-trades

        :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<  st     	V$$t
 33DKK4P4PQQ  65%@@@r   r   c                 ~    |                                   |                     |          }|                     |          S )a  
        create a currency deposit address

        https://paymium.github.io/api-documentation/#tag/User/operation/create-deposit-address

        :param str code: unified currency code of the currency for the deposit address
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        )r   privatePostUserAddressesparse_deposit_address)r   r   r   r   s       r   create_deposit_addresszpaymium.create_deposit_addressP  s?     	0088 ))(333r   c                     |                                   d|i}|                     |                     ||                    }|                     |          S )a  
        fetch the deposit address for a currency associated with self account

        https://paymium.github.io/api-documentation/#tag/User/operation/get-deposit-address

        :param str code: unified currency code
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :returns dict: an `address structure <https://docs.ccxt.com/?id=address-structure>`
        address)r   privateGetUserAddressesAddressr   r   )r   r   r   r   r   s        r   fetch_deposit_addresszpaymium.fetch_deposit_addressf  s[     	t
 66t{{7F7S7STT ))(333r   codesc                     |                                   |                     |          }|                     ||          S )a  
        fetch deposit addresses for multiple currencies and chain types

        https://paymium.github.io/api-documentation/#tag/User/operation/get-deposit-addresses

        :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  sA     	//77 ++He<<<r   r   c                     |                      |d          }|                      |d          }||                     ||          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  s\     "">9==%%njAA
"//
HEE
 
 	
r   rX   r   r   r   c                 @   |                                   |                     |          }|                     |          dz   |d         ||d}|dk    r||d<   |                     |                     ||                    }	|                     |	|	d         d|          S )a  
        create a trade order

        https://paymium.github.io/api-documentation/#tag/Order/operation/create-order

        :param str symbol: unified symbol of the market to create an order in
        :param str type: 'market' or 'limit'
        :param str side: 'buy' or 'sell'
        :param float amount: how much of currency you want to trade in units of base currency
        :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
        :param dict [params]: extra parameters specific to the exchange API endpoint
        :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.JKK6" 
  
   	r   rR   c                     d|i}|                      |                     ||                    }|                     d|i          S )a  
        cancels an open order

        https://paymium.github.io/api-documentation/#tag/Order/operation/cancel-order

        :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  sS     B
 99$++gv:V:VWWH 
   	r   fromAccount	toAccountc                    |                                   |                     |          }|                    d          dk     rt          | j        dz             |dk    r|dk    rt          | j        dz             |d         |                     ||          |d}|                     |                     ||                    }|                     ||          S )	a5  
        transfer currency internally between wallets on the same account

        https://paymium.github.io/api-documentation/#tag/Transfer/operation/create-email-transfer

        :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b5==TU]]*N NOOO 00v>>
 
 55dkk'66R6RSSB ""8X666r   r:   c                    |                      |d          }|                      |d          }|                     |          }|                     |d          }|                     |di           }|                      |d          }||                      |d          ||                     |          |                     ||          |                     |d          d |                      |d          |                     |          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K):ArBB!!(G44""8V44#Z00//
HEE&&x::)).)DD0088

 

 
	
r   r  c                 8    ddi}|                      |||          S )Nexecutedok)r   )r   r  statusess      r   r  zpaymium.parse_transfer_statusJ  s(    
 &&999r   rL   GETc                    | j         d         d         dz   | j        z   dz   |                     ||          z   }|                     ||                     |                    }|dk    r|r|d|                     |          z   z  }n|                                  t          |                                           }	|	|z   }
| j	        |	d}|dk    r"|r| 
                    |          }|
|z  }
d|d	<   n$|r"|                     |          }|
|z  }
|d|z   z  }|                     |                     |
          |                     | 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.signQ  s   iv&,t|;cADDWDWX\^dDeDee		&$"5"5d";";<<(?? 3sT^^E2222++---

%%E3;D;" G  A99U++DDLD.@GN+ -"&.."7"7KK'D3,,C'+yyT1B1BDKKPTP[D\D\^e^l'm'mGO$fdwOOOr   httpCodereasonr  r  r!  r   c
                     |d S |                      |d          }
|
-t          | j        dz   |                     |          z             d S )Nerrors )r  r   rR   r*  )r   r5  r6  r  r  r!  r   r   requestHeadersrequestBodyr8  s              r   handle_errorszpaymium.handle_errorsl  sP    4844#		(0C0C CDDDtr   )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 L L L L L\) ) ) ) )  $& , ,( , , , , :>b j js j3 jY j j j j&. .4 . .6 . . . .` 02 "1 "13 "1f "1 "1 "1 "1H  v     0 6:UW A A3 As A# A\`af\g A A A A( 8: 4 43 4n 4 4 4 4, 79 4 4# 4^ 4 4 4 42 8<B = =W =4P^K_ = = = =0
 
h 
R` 
 
 
 
& gksu  3 i y RW `c    < 37r  s C    & [] :7 :7S :7% :7c :7c :7an :7 :7 :7 :7x1
 1
t 1
x 1
= 1
 1
 1
 1
f:C :C : : : : &eBSW P P P 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     s   ( ' ' ' ' ' - - - - - -  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c  c       * * * * * * 4 4 4 4 4 4 % % % % % %b	 b	 b	 b	 b	h b	 b	 b	 b	 b	r   