mirror of
https://github.com/andrewkdinh/fund-indicators.git
synced 2024-11-21 23:04:18 -08:00
Started Expense Ratio
This commit is contained in:
parent
d2b58de37a
commit
d3c1bf0155
20
ExpenseRatio.py
Normal file
20
ExpenseRatio.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# ExpenseRatio.py
|
||||||
|
# Andrew Dinh
|
||||||
|
# Python 3.6.1
|
||||||
|
# Description:
|
||||||
|
'''
|
||||||
|
Asks user for expense ratio of stock (I don't think there's an API for expense ratios)
|
||||||
|
Runs corrrelation study (I'm not sure if I want another class for this or not)
|
||||||
|
'''
|
||||||
|
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
def main(): # For testing purposes
|
||||||
|
a = [1,4,6]
|
||||||
|
b = [1,2,3]
|
||||||
|
c = numpy.corrcoef(a, b)[0, 1]
|
||||||
|
print(c)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -60,6 +60,9 @@ class Stock:
|
|||||||
def setName(self, newName):
|
def setName(self, newName):
|
||||||
self.name = newName
|
self.name = newName
|
||||||
|
|
||||||
|
def getAllLists(self):
|
||||||
|
return self.allLists
|
||||||
|
|
||||||
def getIEX(self):
|
def getIEX(self):
|
||||||
url = ''.join(('https://api.iextrading.com/1.0/stock/', self.name, '/chart/5y'))
|
url = ''.join(('https://api.iextrading.com/1.0/stock/', self.name, '/chart/5y'))
|
||||||
#link = "https://api.iextrading.com/1.0/stock/spy/chart/5y"
|
#link = "https://api.iextrading.com/1.0/stock/spy/chart/5y"
|
||||||
@ -434,7 +437,8 @@ class Stock:
|
|||||||
socket.create_connection(("www.andrewkdinh.com", 80))
|
socket.create_connection(("www.andrewkdinh.com", 80))
|
||||||
return True
|
return True
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
#pass
|
||||||
|
print("\nNo internet connection!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
@ -449,7 +453,6 @@ class Stock:
|
|||||||
# Test internet connection
|
# Test internet connection
|
||||||
internetConnection = Stock.is_connected()
|
internetConnection = Stock.is_connected()
|
||||||
if internetConnection == False:
|
if internetConnection == False:
|
||||||
print("\nNo internet connection!")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
listOfFirstLastDates = []
|
listOfFirstLastDates = []
|
||||||
@ -498,7 +501,6 @@ class Stock:
|
|||||||
finalClose = self.finalDatesAndClose[1]
|
finalClose = self.finalDatesAndClose[1]
|
||||||
print(len(finalDates), "unique dates:", finalDates[len(finalDates)-1], "...", finalDates[0])
|
print(len(finalDates), "unique dates:", finalDates[len(finalDates)-1], "...", finalDates[0])
|
||||||
print(len(finalClose), "close values:", finalClose[len(finalClose)-1], "...", finalClose[0])
|
print(len(finalClose), "close values:", finalClose[len(finalClose)-1], "...", finalClose[0])
|
||||||
#print("Uncomment above line in code to see output")
|
|
||||||
else:
|
else:
|
||||||
print("No sources have data for", self.name)
|
print("No sources have data for", self.name)
|
||||||
|
|
||||||
|
35
main.py
35
main.py
@ -27,14 +27,41 @@ for i in range(0, numberOfStocks, 1):
|
|||||||
listOfStocks[i].setName(stockName)
|
listOfStocks[i].setName(stockName)
|
||||||
#print(listOfStocks[i].name)
|
#print(listOfStocks[i].name)
|
||||||
|
|
||||||
|
sumOfListLengths = 0
|
||||||
for i in range(0, numberOfStocks, 1):
|
for i in range(0, numberOfStocks, 1):
|
||||||
print("\n")
|
|
||||||
print(listOfStocks[i].name)
|
print(listOfStocks[i].name)
|
||||||
Stock.main(listOfStocks[i])
|
Stock.main(listOfStocks[i])
|
||||||
|
# Count how many stocks are available
|
||||||
|
temp = Stock.getAllLists(listOfStocks[i])
|
||||||
|
sumOfListLengths = sumOfListLengths + len(temp)
|
||||||
|
|
||||||
|
if sumOfListLengths == 0:
|
||||||
|
print("No sources have stock data for given stocks")
|
||||||
|
|
||||||
|
else:
|
||||||
|
#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
|
||||||
|
|
||||||
|
if indicator == 'Expense Ratio' or indicator == '1' or indicator == 'expense ratio':
|
||||||
|
print('\nExpense Ratio')
|
||||||
|
|
||||||
|
elif indicator == 'Asset Size' or indicator == '2' or indicator == 'asset size':
|
||||||
|
print('\nAsset Size')
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
#print(listOfStocks[0].name, listOfStocks[0].absFirstLastDates, listOfStocks[0].finalDatesAndClose)
|
|
||||||
print("\nWhich indicator would you like to look at? \n1. Expense Ratio")
|
|
||||||
indicator = str(input)
|
|
||||||
'''
|
'''
|
||||||
stockName = 'IWV'
|
stockName = 'IWV'
|
||||||
stock1 = Stock(stockName)
|
stock1 = Stock(stockName)
|
||||||
|
@ -1 +1,2 @@
|
|||||||
requests==2.21.0
|
requests==2.21.0
|
||||||
|
numpy==1.15.4
|
Loading…
Reference in New Issue
Block a user