Dagger
Search

GetStocks

Overview: This module facilitates the retrieval and analysis of stock data from the S&P 500 index. It uses web scraping to obtain the list of S&P 500 companies and `yfinance` to fetch historical stock data. The module calculates the average annual return for each stock and identifies the top investment options based on these returns.

Functionality: - Scrapes the S&P 500 company symbols from Wikipedia. - Fetches historical stock data for each symbol using `yfinance`. - Calculates the average annual return for each stock based on monthly closing prices. - Ranks the stocks by their average annual returns and returns the top investment options.

Return: - The `stocks` function returns a JSON formatted string representing the top investment options. Each investment option is a dictionary containing the stock symbol and its average annual return. - The `sp500` function returns a JSON string containing the list of S&P 500 company symbols. - The `get_historical_data` function fetches and returns historical stock data as a pandas DataFrame. - The `calculate_avg_return` function computes the average annual return for the given historical data.

Example Call: dagger call stocks

Installation

dagger install github.com/EmmS21/daggerverse/GetStocks@v0.0.4

Entrypoint

Return Type
GetStocks !
Example
dagger -m github.com/EmmS21/daggerverse/GetStocks@6b2bcd5e368501e8e9f7828e9055e9069131243b call \
func (m *myModule) example() *GetStocks  {
	return dag.
			GetStocks()
}
@function
def example() -> dag.GetStocks:
	return (
		dag.get_stocks()
	)
@func()
example(): GetStocks {
	return dag
		.getStocks()
}

Types

GetStocks 🔗

stocks() 🔗

Return Type
String !
Example
dagger -m github.com/EmmS21/daggerverse/GetStocks@6b2bcd5e368501e8e9f7828e9055e9069131243b call \
 stocks
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			GetStocks().
			Stocks(ctx)
}
@function
async def example() -> str:
	return await (
		dag.get_stocks()
		.stocks()
	)
@func()
async example(): Promise<string> {
	return dag
		.getStocks()
		.stocks()
}