import requests
import json


def get_todays_percent_change_of_symbol(symbol):
    """
    fetch todays change in percent for the given symbol name
    :param symbol: ticker name which will be queried
    :return: todaysChangePercent
    """
    p_auth = "Zay2cQZwZfUTozLiLmyprY4Sr3uK27Vp"
    query = """https://api.polygon.io/v2/snapshot/locale/us/markets/stocks/tickers/""" + symbol + """?&apiKey=""" + p_auth
    print(query)
    response = requests.get(query)
    json_data = json.loads(response.text)
    print(json_data)
    try:
        change = json_data["ticker"]["todaysChangePerc"]
        return change
    except:
        return None