def compute_daily_change_for_range(symbol, start_date, end_date):
    """
    Computes daily change in value over a range

    :param symbol: (String) ticker symbol of the stock
    :param start_date: (DateTime)
    :param end_date: (DateTime)
    :return: (list) List of daily changes
    """
    symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
    closing_price = list(symbol_data["Close"])

    # Data Integrity
    if symbol.lower() in tickers:
        closing_price = verify_data_with_quandl(
            symbol, start_date, end_date, closing_price)

    daily_change = []
    if closing_price is None:
        return daily_change
    for i in range(0, len(closing_price) - 1):
        cur = closing_price[i]
        daily_change.append(((closing_price[i + 1] - cur) / cur) * 100)

    return daily_change
def compute_daily_change_for_past_given_days(symbol, number_of_days_back):
    """
    Computes daily change in value

    :param symbol: (String) ticker symbol of the stock
    :param number_of_days_back: (Int) number of days back from today
    :return: (list) List of daily changes
    """
    start_date = date.today() - timedelta(days=number_of_days_back)
    end_date = date.today()
    symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
    closing_price = list(symbol_data["Close"])

    # Data Integrity
    if symbol.lower() in tickers:
        closing_price = verify_data_with_quandl(
            symbol, start_date, end_date, closing_price)

    daily_change = []
    for i in range(0, len(closing_price) - 1):
        cur = closing_price[i]
        daily_change.append(
            ((closing_price[i + 1] - cur) / cur) * 100)

    return daily_change
def get_stock_volume_traded_for_a_month(symbol):
    """
    Gets the volume traded for the specified stock in the last month.

    :param symbol: (str)
    :return: (list) [ [date1, rri], [date2, rri], .... [date365, rri] ]
    """
    start_date = date.today() - timedelta(days=30)
    end_date = date.today()
    volume_list = yahoo_finance.get_stock_data(
        symbol, start_date, end_date)["Volume"]
    return volume_list
Example #4
0
def compute_daily_change_for_range(symbol, start_date, end_date):
	""" 
	Parameter:	symbol -> ticker symbol of the stock (Type -> String)
			start_date, end_date -> range you want to compute on (Type -> String)		

	return: list of daily change (Type -> list float)
	"""
	symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
	closing_price = list(symbol_data["Close"])

	daily_change = []
	for i in range(0, len(closing_price)-1):
		daily_change.append(((closing_price[i+1] - closing_price[i])/closing_price[i])*100)
	
	return daily_change
def get_price_for_number_of_days_back_from_today(symbol, number_of_days_back):
    """
    Returns a list of closing prices

    :param symbol: (String) ticker symbol of the stock
    :param number_of_days_back: (int) number of days back from today
    :return: (float) daily closing prices
    """
    start_date = date.today() - timedelta(days=number_of_days_back)
    end_date = date.today()
    symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
    graphing_tuples = []
    value_timestamps = symbol_data.index
    values = symbol_data["Close"]
    for i in range(len(values)):
        graphing_tuples.append((value_timestamps[i], round(values[i], 3)))
    return graphing_tuples
Example #6
0
def compute_daily_change_for_range(symbol, start_date, end_date):
    """ 
	Parameter:	symbol -> ticker symbol of the stock (Type -> String)
			start_date, end_date -> range you want to compute on (Type -> String)		

	return: list of daily change (Type -> list float)
	"""
    symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
    closing_price = list(symbol_data["Close"])

    daily_change = []
    for i in range(0, len(closing_price) - 1):
        daily_change.append(
            ((closing_price[i + 1] - closing_price[i]) / closing_price[i]) *
            100)

    return daily_change
Example #7
0
def compute_daily_change_for_past_given_days(symbol, number_of_days_back):
	""" 
	Parameter:	symbol -> ticker symbol of the stock (Type -> String)
			number_of_days_back -> number of days back from today 
						for which you want the daily change 
						(Type -> integer)
	return: list of daily change (Type -> list float)
	"""
	start_date = date.today() - timedelta(days=number_of_days_back)
	end_date = date.today()
	symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
	closing_price = list(symbol_data["Close"])

	daily_change = []
	for i in range(0, len(closing_price)-1):
		daily_change.append(((closing_price[i+1] - closing_price[i])/closing_price[i])*100)
	
	return daily_change
Example #8
0
def compute_daily_change_for_past_given_days(symbol, number_of_days_back):
    """ 
	Parameter:	symbol -> ticker symbol of the stock (Type -> String)
			number_of_days_back -> number of days back from today 
						for which you want the daily change 
						(Type -> integer)
	return: list of daily change (Type -> list float)
	"""
    start_date = date.today() - timedelta(days=number_of_days_back)
    end_date = date.today()
    symbol_data = yahoo_finance.get_stock_data(symbol, start_date, end_date)
    closing_price = list(symbol_data["Close"])

    daily_change = []
    for i in range(0, len(closing_price) - 1):
        daily_change.append(
            ((closing_price[i + 1] - closing_price[i]) / closing_price[i]) *
            100)

    return daily_change