
    Mg
                     T    S SK r S SKJr  S SKJr  / SQrS rS r\" S5      S 5       rg)	    N)Fore)plugin)zBTC/USDTzETH/USDTzLTC/USDTzXRP/USDTzADA/USDTzXMR/USDTc                     [        U 5      S:  a0  [        R                  [        U 5      -   S-   [        R                  -   $ [        R
                  S-   [        U 5      -   S-   [        R                  -   $ )z
Prints the price change with color. If the price is down, print in red.
If the price is up, print in green.

Parameters
----------
change: str
    The price change.
r   %+)floatr   REDstrRESETGREEN)changes    C/Users/admin/workspace/ai/Jarvis/jarviscli/plugins/cryptotracker.pyprint_in_colorr      sW     V}qxx#f+%+djj88zzC#f+-3djj@@    c           
         SnSU R                  5       UR                  5       -   0n [        R                  " USS0US9R                  5       nUS   nUS   n[	        SR                  U R                  5       UR                  5       U[        U5      5      5        g! [         a:    [	        S	R                  U U[        R                  [        R                  S
95         gf = f)z"
It requires the base and target currency symbols,
e.g. [btc, usdt], to build the URL and print the price
and  the price change.

Parameters
----------
base: str
    The base currency
target: str
    The target currency
z*https://api.binance.com/api/v3/ticker/24hrsymbolz
User-AgentJarvis)headersparamsaskPricepriceChangePercentz	{}/{}
Price: {}
Change: {}
z{WARNING}Wrong pair {}/{}!{COLOR_RESET} 
Full list of symbols is here: https://api.binance.com/api/v3/ticker/price
Due to API Changes please use USDT for USD Prices
)WARNINGCOLOR_RESETN)upperrequestsgetjsonprintformatr   KeyErrorr   r	   r   )basetargeturlr   responsepricer   s          r   check_pricesr&   !   s     7C4::<&,,.0F><<h(0688< 	 $./" 	077

llne^F%;= 	>  
)  JJ	  (		)
)s   0B ACCcryptotrackerc           	      P   U(       a    UR                  S5      u  p#[        X#5        g[         H!  nUR                  S5      u  p#[        X#5        M#     g! [         aG    [        SR	                  [
        R                  [
        R                  [
        R                  S95         gf = f)z
Finds the price and the change of the price, for
a pair of currencies or for the default list of favorite pairs.
-- Example:
    cryptotracker BTC/USDT
/z{WARNING}Wrong format!{COLOR_RESET} Try {ADVICE}cryptotracker base_currency/target_currency{COLOR_RESET} OR {ADVICE}cryptotracker{COLOR_RESET})r   ADVICEr   N)
splitr&   
ValueErrorr   r   r   r	   BLUEr   	FAVORITES)jarvissr!   r"   pairs        r   mainr2   P   s     	
	-773<LD& D::c?LD&   	-55;V HH99 $

 6< 6,-	-s   A AB%$B%)r   coloramar   r   r.   r   r&   r2    r   r   <module>r5      s:      	A ,>^ ' 'r   