def updateByDate(tickerName): data = SqliteMethods.getData(tickerName) """Last earnings date of ticker """ lastDate = data[1][0].split('/') print(lastDate) month = float(lastDate[1]) year = float(lastDate[0]) """Todays date. """ today = Utility.getTodaysDate().split('/') currentMonth = float(today[0]) currentYear = float(today[2]) difference = 0 if (currentYear == year): difference = currentMonth - month elif ((currentYear - 1) == year): difference = (12 - month) + currentMonth """If current month and current year is more than 4 months away, try update """ if (difference > 4): print('Attempting update......') update(tickerName) """Display date after update""" data = SqliteMethods.getData(tickerName) """Last earnings date of ticker """ lastDate = data[1][0].split('/') print("Date After update :", end='') print(lastDate) else: print('No Update')
def vacuum(): SqliteMethods.vacuum() # all = getAll() # for i in all: # print(i) # deleteTicker("TCO")
def update(tickerName): # Download.deleteAll(tickerName) # Download.downloadAll(tickerName) """Get data from excel files that were downloaded above """ newData = ReadExcel.readExcel(tickerName) """Get current earnings data""" tempSQLData = SqliteMethods.getData(tickerName) # for i in newData: # print(i) # # for i in tempSQLData: # print(i) # print(len(tempSQLData)) sqlData = [] """Flip data from tempSQLData diagonally across matrix """ for i in range(0, len(tempSQLData[0])): temp = [] for j in range(0, len(tempSQLData)): temp.append(tempSQLData[j][i]) sqlData.append(temp) """ At this point, newData and sqlData is in the form: date 9/5/2017, 5/5/2017,..... revenue 500, 400,.... """ """Find which sqlData is not in newData. """ newDates = newData[0][1:] oldDates = sqlData[0][1:] addDates = [] for i in oldDates: if (i not in newDates): addDates.append(i) """Take data not in newData and add it in First find what the variables are in newData. Then, try to find that variable with the corresponding add date and add it in. If the variable is not found, simply add ' ' Try to find the row/ """ oldVariables = tempSQLData[0] for i in addDates: """Find index of addDate in sqlData """ column = sqlData[0].index(i) for j in newData: currentVariable = j[0] try: row = oldVariables.index(currentVariable) except: try: row = oldVariables.index(compare(currentVariable)) except: row = -1 if (row < 0): j.append(' ') else: j.append(sqlData[row][column]) temp = newData newData = [] for i in range(0, len(temp[0])): tempLine = [] for j in range(0, len(temp)): tempLine.append(temp[j][i]) newData.append(tempLine) # for i in newData: # print(i) # print(len(i)) # print(len(newData)) SqliteMethods.insertSQL(tickerName, newData) return newData
def getData(tickerName): return SqliteMethods.getData(tickerName)
def deleteTicker(tickerName): SqliteMethods.deleteTicker(tickerName)
def getAll(): return SqliteMethods.getAll()
def fundamentalData(tickerName): Download.deleteAll(tickerName) Download.downloadAll(tickerName) data = ReadExcel.readExcel(tickerName) SqliteMethods.insertSQL(tickerName, data)