2018-12-15 17:56:29 -08:00
|
|
|
# main.py
|
|
|
|
# Andrew Dinh
|
|
|
|
# Python 3.6.1
|
2019-01-16 08:54:06 -08:00
|
|
|
# Description:
|
2018-12-16 17:58:25 -08:00
|
|
|
'''
|
|
|
|
Asks users for mutual funds/stocks to compare
|
|
|
|
Asks to be compared (expense ratio, turnover, market capitalization, or persistence)
|
|
|
|
Asks for time period (Possibly: 1 year, 5 years, 10 years)
|
|
|
|
Makes the mutual funds as class Stock
|
|
|
|
Gets data from each API
|
|
|
|
Compare and contrast dates and end changeOverTime for set time period
|
2018-12-31 16:37:51 -08:00
|
|
|
NOTES: Later can worry about getting close values to make a graph or something
|
2018-12-16 17:58:25 -08:00
|
|
|
Gives correlation value using equation at the end (from 0 to 1)
|
2018-12-16 14:46:56 -08:00
|
|
|
|
2018-12-16 17:58:25 -08:00
|
|
|
FIRST TESTING WITH EXPENSE RATIO
|
|
|
|
'''
|
2018-12-16 14:46:56 -08:00
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
from StockData import StockData
|
2018-12-19 21:32:14 -08:00
|
|
|
|
2018-12-21 09:59:40 -08:00
|
|
|
listOfStocks = []
|
|
|
|
numberOfStocks = int(input("How many stocks or mutual funds would you like to analyze? "))
|
|
|
|
for i in range(0, numberOfStocks, 1):
|
2018-12-31 16:37:51 -08:00
|
|
|
print("Stock", i+1, ": ", end='')
|
|
|
|
stockName = str(input())
|
|
|
|
listOfStocks.append(i)
|
2019-01-16 08:54:06 -08:00
|
|
|
listOfStocks[i] = StockData()
|
2018-12-31 16:37:51 -08:00
|
|
|
listOfStocks[i].setName(stockName)
|
|
|
|
#print(listOfStocks[i].name)
|
2018-12-19 21:32:14 -08:00
|
|
|
|
2018-12-31 16:37:51 -08:00
|
|
|
sumOfListLengths = 0
|
2018-12-21 09:59:40 -08:00
|
|
|
for i in range(0, numberOfStocks, 1):
|
2018-12-31 16:37:51 -08:00
|
|
|
print(listOfStocks[i].name)
|
2019-01-16 08:54:06 -08:00
|
|
|
StockData.main(listOfStocks[i])
|
2018-12-31 16:37:51 -08:00
|
|
|
# Count how many stocks are available
|
2019-01-16 08:54:06 -08:00
|
|
|
temp = StockData.returnAllLists(listOfStocks[i])
|
2018-12-31 16:37:51 -08:00
|
|
|
sumOfListLengths = sumOfListLengths + len(temp)
|
|
|
|
|
|
|
|
if sumOfListLengths == 0:
|
2019-01-16 08:54:06 -08:00
|
|
|
print("No sources have data for given stocks")
|
|
|
|
exit()
|
2018-12-31 16:37:51 -08:00
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
# Find return over time using either Jensen's Alpha, Sharpe Ratio, Sortino Ratio, or Treynor Ratio
|
|
|
|
#from StockReturn import Return
|
2018-12-31 16:37:51 -08:00
|
|
|
|
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
# Runs correlation or regression study
|
|
|
|
#print(listOfStocks[0].name, listOfStocks[0].absFirstLastDates, listOfStocks[0].finalDatesAndClose)
|
|
|
|
indicatorFound = False
|
|
|
|
while indicatorFound == False:
|
|
|
|
print("\n1. Expense Ratio\n2. Asset Size\n3. Turnover\n4. Persistence\nWhich indicator would you like to look at? ", end='')
|
|
|
|
indicator = str(input())
|
|
|
|
indicatorFound = True
|
2018-12-31 16:37:51 -08:00
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
if indicator == 'Expense Ratio' or indicator == '1' or indicator == 'expense ratio':
|
|
|
|
#from ExpenseRatio import ExpenseRatio
|
|
|
|
print('\nExpense Ratio')
|
2018-12-31 16:37:51 -08:00
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
elif indicator == 'Asset Size' or indicator == '2' or indicator == 'asset size':
|
|
|
|
print('\nAsset Size')
|
2018-12-31 16:37:51 -08:00
|
|
|
|
2019-01-16 08:54:06 -08:00
|
|
|
elif indicator == 'Turnover' or indicator == '3' or indicator == 'turnover':
|
|
|
|
print('\nTurnover')
|
|
|
|
|
|
|
|
elif indicator == 'Persistence' or indicator == '4' or indicator == 'persistence':
|
|
|
|
print('\nPersistence')
|
|
|
|
|
|
|
|
else:
|
|
|
|
indicatorFound = False
|
|
|
|
print('\nInvalid input, please enter indicator again')
|
2018-12-23 09:24:18 -08:00
|
|
|
|
2018-12-21 09:59:40 -08:00
|
|
|
'''
|
2018-12-19 21:32:14 -08:00
|
|
|
stockName = 'IWV'
|
|
|
|
stock1 = Stock(stockName)
|
|
|
|
print("Finding available dates and close values for", stock1.name)
|
2019-01-16 08:54:06 -08:00
|
|
|
StockData.main(stock1)
|
|
|
|
'''
|