diff --git a/.gitignore b/.gitignore index 46723b9..293b5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ __pycache__/ quickstart.py creds.json test/ +.vscode/ +listGoogle.py \ No newline at end of file diff --git a/README.md b/README.md index 0670ca7..36ff698 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ A project to determine indicators of overperforming mutual funds. This project is written in Python and will examine market capitalization, persistence, turnover, and expense ratios. ### Prerequisites +`$ pip install -r requirements.txt` +or `$ pip install requests` Created by Andrew Dinh from Dr. TJ Owens Gilroy Early College Academy diff --git a/StockData.py b/StockData.py index 1571222..e2a90a9 100644 --- a/StockData.py +++ b/StockData.py @@ -141,9 +141,17 @@ class StockData: def getAV(self): listAV = [] - url = ''.join(('https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=', self.name, '&apikey=', apiAV)) + #url = ''.join(('https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=', self.name, '&apikey=', apiAV)) # https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=MSFT&apikey=demo + + #url = ''.join(('https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=', self.name, '&outputsize=full&apikey=', apiAV)) + # https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&outputsize=full&apikey=demo + + url = ''.join(('https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=', self.name, '&outputsize=full&apikey=', apiAV)) + # https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=full&apikey=demo + print("\nSending request to:", url) + print("(This will take a while)") f = requests.get(url) json_data = f.text loaded_json = json.loads(json_data) @@ -156,9 +164,9 @@ class StockData: return 'Not available' #print(loaded_json['Monthly Time Series']) - monthlyTimeSeries = loaded_json['Monthly Time Series'] + dailyTimeSeries = loaded_json['Time Series (Daily)'] #print(monthlyTimeSeries) - listOfDates = list(monthlyTimeSeries) + listOfDates = list(dailyTimeSeries) #print(listOfDates) firstDate = listOfDates[-1] @@ -179,8 +187,9 @@ class StockData: values = [] for i in range(0, len(listOfDates), 1): temp = listOfDates[i] - loaded_json2 = monthlyTimeSeries[temp] - value = loaded_json2['4. close'] + loaded_json2 = dailyTimeSeries[temp] + #value = loaded_json2['4. close'] + value = loaded_json2['5. adjusted close'] values.append(value) listAV.append(values) #print(listOfDates[0]) @@ -485,6 +494,8 @@ class StockData: listOfFirstLastDates = [] self.allLists = [] + print('\nNOTE: Only IEX and Alpha Vantage support adjusted returns') + # IEX print("\nIEX") listIEX = StockData.getIEX(self) @@ -504,6 +515,7 @@ class StockData: # COMMENTED OUT FOR NOW B/C LIMITED ''' print("\nTiingo") + print("NOTE: Tiingo does not return adjusted returns!!") listTiingo = StockData.getTiingo(self) #print(listTiingo) if listTiingo != 'Not available': @@ -515,7 +527,7 @@ class StockData: #print(listOfFirstLastDates) if (len(self.allLists) > 0): print("\n") - print(len(self.allLists), "available sources for", self.name) + print(len(self.allLists), "available source(s) for", self.name) self.absFirstLastDates = StockData.getFirstLastDate(self, listOfFirstLastDates) print("\nThe absolute first date with close values is:", self.absFirstLastDates[0]) print("The absolute last date with close values is:", self.absFirstLastDates[1]) diff --git a/StockReturn.py b/StockReturn.py index c99579a..44e36bb 100644 --- a/StockReturn.py +++ b/StockReturn.py @@ -107,11 +107,12 @@ class Return: print("\nPlease enter a time frame in years: ", end='') #timeFrameYear = int(input()) timeFrameYear = 5 + print(timeFrameYear) self.timeFrame.append(timeFrameYear) print("Please enter a time frame in months (30 days): ", end='') #timeFrameMonth = int(input()) timeFrameMonth = 0 - print('') + print(timeFrameMonth) self.timeFrame.append(timeFrameMonth) #print(self.timeFrame) self.firstLastDates = Return.getFirstLastDates(self, stock) @@ -124,7 +125,8 @@ class Return: print('\nGetting unadjusted return') unadjustedReturn = Return.getUnadjustedReturn(self, stock) self.listOfReturn.append(unadjustedReturn) - print(self.listOfReturn[0], '%') + print(self.listOfReturn[0]) + print(self.listOfReturn[0]/timeFrameYear, '%') def main(): stockName = 'spy'