def get(self): self.response.headers['Content-Type'] = 'text/plain' """ for i in np.arange(250,6001,250): list_of_entities = Forecast.query(ndb.AND(Forecast.rank >= i-250,Forecast.rank < i))#Forecast.rank < 6000) list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) list_of_entities = StockList.query(ndb.AND(StockList.rank >= i-250,StockList.rank < i))#Forecast.rank < 6000) list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) """ for i in np.arange(1,6001,500): list_of_keys = Forecast.query().fetch(500, keys_only=True) #list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) list_of_keys = StockList.query().fetch(25, keys_only=True) #list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) self.response.out.write('All Forecasts Deleted') self.redirect('./')
def get(self): self.response.headers['Content-Type'] = 'text/plain' """ for i in np.arange(250,6001,250): list_of_entities = Forecast.query(ndb.AND(Forecast.rank >= i-250,Forecast.rank < i))#Forecast.rank < 6000) list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) list_of_entities = StockList.query(ndb.AND(StockList.rank >= i-250,StockList.rank < i))#Forecast.rank < 6000) list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) """ for i in np.arange(1, 6001, 500): list_of_keys = Forecast.query().fetch(500, keys_only=True) #list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) list_of_keys = StockList.query().fetch(25, keys_only=True) #list_of_keys = ndb.put_multi(list_of_entities) #list_of_entities = ndb.get_multi(list_of_keys) ndb.delete_multi(list_of_keys) self.response.out.write('All Forecasts Deleted') self.redirect('./')
def get(self): #Get total nubmer of predictions #global_stat = stats.GlobalStat.query().get() #forecastCount = global_stat.count #Get the time, make a string of format: #Tue, Jan 6, 2014, 12:00AM EST - US MARKETS CLOSED now = datetime.now(tz=timezone('US/Eastern')) #Construct the EST time for the top of page if ((now.time() >= time(9, 30) and now.time() <= time(16, 30)) and (now.weekday() <= 4)): timeString = "{0:s} EST - US Markets Are Open".format( now.strftime("%a, %b %d %Y, %I:%M%p")) else: timeString = "{0:s} EST - US Markets Are Closed".format( now.strftime("%a, %b %d %Y, %I:%M%p")) # stockList = StockList.query(StockList.rank.IN([1])) #Init items using info from forecast, just use the first item dayOfForecast = now.strftime("%A, %B %d %Y") dof = now for forecast in stockList: dayOfForecast = forecast.date.strftime("%A, %B %d %Y") dof = forecast.date break if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Sign Up for Updates' template_values = { #'stock_list':stockList, #'forecast_data':forecastPlotData, #'validation_data':validationPlotData, #'computed_values':computedValued, #'forecast_count':forecastCount, 'timeStr': timeString, 'dayOfForecast': dayOfForecast, 'url': url, 'url_linktext': url_linktext, } template = JINJA_ENVIRONMENT.get_template('markets.html') self.response.write(template.render(template_values))
def get(self): #Get total nubmer of predictions #global_stat = stats.GlobalStat.query().get() #forecastCount = global_stat.count #Get the time, make a string of format: #Tue, Jan 6, 2014, 12:00AM EST - US MARKETS CLOSED now = datetime.now(tz=timezone('US/Eastern')) #Construct the EST time for the top of page if( (now.time() >= time(9,30) and now.time() <= time(16,30)) and (now.weekday() <= 4 ) ): timeString = "{0:s} EST - US Markets Are Open".format(now.strftime("%a, %b %d %Y, %I:%M%p")) else: timeString = "{0:s} EST - US Markets Are Closed".format(now.strftime("%a, %b %d %Y, %I:%M%p")) # stockList = StockList.query(StockList.rank.IN([1])) #Init items using info from forecast, just use the first item dayOfForecast = now.strftime("%A, %B %d %Y") dof = now for forecast in stockList: dayOfForecast = forecast.date.strftime("%A, %B %d %Y") dof = forecast.date break if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Sign Up for Updates' template_values = { #'stock_list':stockList, #'forecast_data':forecastPlotData, #'validation_data':validationPlotData, #'computed_values':computedValued, #'forecast_count':forecastCount, 'timeStr':timeString, 'dayOfForecast':dayOfForecast, 'url': url, 'url_linktext': url_linktext, } template = JINJA_ENVIRONMENT.get_template('markets.html') self.response.write(template.render(template_values))
def get(self): #Get total nubmer of predictions #global_stat = stats.GlobalStat.query().get() #forecastCount = global_stat.count #Get the time, make a string of format: #Tue, Jan 6, 2014, 12:00AM EST - US MARKETS CLOSED now = datetime.now(tz=timezone('US/Eastern')) #Construct the EST time for the top of page if( (now.time() >= time(9,30) and now.time() <= time(16,30)) and (now.weekday() <= 4 ) ): timeString = "{0:s} EST - US Markets Are Open".format(now.strftime("%a, %b %d %Y, %I:%M%p")) else: timeString = "{0:s} EST - US Markets Are Closed".format(now.strftime("%a, %b %d %Y, %I:%M%p")) # stockList = StockList.query(StockList.rank.IN(list(np.arange(1,26)))) computedCloseValues = np.zeros((stockList.count(), 3), float) #createa binary list of stock list vs user favorite list user = users.get_current_user() if user: up = UserProfile.query(UserProfile.user_id == str(user.user_id())) favBinary = [] for u in up: for stock in stockList: if stock.symbol in u.favorite_list: favBinary.append(1) else: favBinary.append(0) break #case where user exists(like admin) but no profile yet if stockList.count() != len(favBinary): favBinary = np.zeros((stockList.count(),)) else: favBinary = np.zeros((stockList.count(),)) # i = 0 for stock in stockList: computedCloseValues[i][0] = stock.forecastedPrice-stock.currentPrice computedCloseValues[i][1] = (stock.forecastedPrice-stock.currentPrice)/abs(stock.currentPrice)*100.0 computedCloseValues[i][2] = favBinary[i] i += 1 #Init items using info from forecast, just use the first item dayOfForecast = now.strftime("%A, %B %d %Y") dof = now for stock in stockList: dayOfForecast = stock.date.strftime("%A, %B %d %Y") #dof = forecast.date break if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Sign Up for Updates' template_values = { 'stock_list':stockList, 'computed_values':computedCloseValues, #'forecast_count':forecastCount, 'timeStr':timeString, 'dayOfForecast':dayOfForecast, 'url': url, 'url_linktext': url_linktext, } template = JINJA_ENVIRONMENT.get_template('index.html') self.response.write(template.render(template_values))
def get(self): #Get total nubmer of predictions #global_stat = stats.GlobalStat.query().get() #forecastCount = global_stat.count #Get the time, make a string of format: #Tue, Jan 6, 2014, 12:00AM EST - US MARKETS CLOSED now = datetime.now(tz=timezone('US/Eastern')) #Construct the EST time for the top of page if ((now.time() >= time(9, 30) and now.time() <= time(16, 30)) and (now.weekday() <= 4)): timeString = "{0:s} EST - US Markets Are Open".format( now.strftime("%a, %b %d %Y, %I:%M%p")) else: timeString = "{0:s} EST - US Markets Are Closed".format( now.strftime("%a, %b %d %Y, %I:%M%p")) # stockList = StockList.query(StockList.rank.IN(list(np.arange(1, 26)))) computedCloseValues = np.zeros((stockList.count(), 3), float) #createa binary list of stock list vs user favorite list user = users.get_current_user() if user: up = UserProfile.query(UserProfile.user_id == str(user.user_id())) favBinary = [] for u in up: for stock in stockList: if stock.symbol in u.favorite_list: favBinary.append(1) else: favBinary.append(0) break #case where user exists(like admin) but no profile yet if stockList.count() != len(favBinary): favBinary = np.zeros((stockList.count(), )) else: favBinary = np.zeros((stockList.count(), )) # i = 0 for stock in stockList: computedCloseValues[i][ 0] = stock.forecastedPrice - stock.currentPrice computedCloseValues[i][1] = (stock.forecastedPrice - stock.currentPrice) / abs( stock.currentPrice) * 100.0 computedCloseValues[i][2] = favBinary[i] i += 1 #Init items using info from forecast, just use the first item dayOfForecast = now.strftime("%A, %B %d %Y") dof = now for stock in stockList: dayOfForecast = stock.date.strftime("%A, %B %d %Y") #dof = forecast.date break if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Sign Up for Updates' template_values = { 'stock_list': stockList, 'computed_values': computedCloseValues, #'forecast_count':forecastCount, 'timeStr': timeString, 'dayOfForecast': dayOfForecast, 'url': url, 'url_linktext': url_linktext, } template = JINJA_ENVIRONMENT.get_template('index.html') self.response.write(template.render(template_values))