def get(self, request): form = PortfolioForm() current_user = request.user symbol = current_user.portfolio_set.values_list('stock_name', flat=True) purchase_price = current_user.portfolio_set.values_list( 'purchase_price', flat=True) purchase_quantity = current_user.portfolio_set.values_list( 'purchase_quantity', flat=True) comment = current_user.portfolio_set.values_list('comment', flat=True) pk = current_user.portfolio_set.values_list('pk', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, purchase_price, purchase_quantity, q.yearhighlist, q.yearlowlist, comment, pk) context = { 'form': form, 'title': 'Analytics', 'mylist': mylist, } return render(request, self.template_name, context)
def undervaluedstocks(request): symbol = UndervaluedStocks.objects.values_list('stock_name', flat=True) comment = UndervaluedStocks.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'undervaluedstocks': UndervaluedStocks.objects.all(), 'title': 'Undervalued stocks', 'mylist': mylist, } return render(request, 'ideabox/undervalued_stocks.html', context)
def toplargecaps(request): symbol = TopLargecaps.objects.values_list('stock_name', flat=True) comment = TopLargecaps.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'toplargecaps': TopLargecaps.objects.all(), 'title': 'Top 1% Largecap stocks', 'mylist': mylist, } return render(request, 'ideabox/top_largecaps.html', context)
def stockmonth(request): symbol = StockMonth.objects.values_list('stock_name', flat=True) comment = StockMonth.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'stockmonth': StockMonth.objects.all(), 'title': 'Stock of the month', 'mylist': mylist, } return render(request, 'ideabox/stock_month.html', context)
def highriskreward(request): symbol = HighRiskReward.objects.values_list('stock_name', flat=True) comment = HighRiskReward.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'highriskreward': HighRiskReward.objects.all(), 'title': 'High Risk, High Reward', 'mylist': mylist, } return render(request, 'ideabox/highrisk_reward.html', context)
def dividendchampions(request): symbol = DividendChampions.objects.values_list('stock_name', flat=True) comment = DividendChampions.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'dividendchampions': DividendChampions.objects.all(), 'title': 'Dividend Champions', 'mylist': mylist, } return render(request, 'ideabox/dividend_champions.html', context)
def zerodebt(request): symbol = ZeroDebt.objects.values_list('stock_name', flat=True) comment = ZeroDebt.objects.values_list('comment', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, comment) context = { 'zerodebt': ZeroDebt.objects.all(), 'title': 'Zero debt stocks', 'mylist': mylist, } return render(request, 'ideabox/zero_debt.html', context)
def post(self, request): form = PortfolioForm(request.POST) current_user = request.user if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() stock_name = form.cleaned_data['stock_name'] purchase_price = form.cleaned_data['purchase_price'] purchase_quantity = form.cleaned_data['purchase_quantity'] comment = form.cleaned_data['comment'] form = PortfolioForm() messages.success(request, f'The stock has been added to your portfolio!') symbol = current_user.portfolio_set.values_list('stock_name', flat=True) purchase_price = current_user.portfolio_set.values_list( 'purchase_price', flat=True) purchase_quantity = current_user.portfolio_set.values_list( 'purchase_quantity', flat=True) comment = current_user.portfolio_set.values_list('comment', flat=True) pk = current_user.portfolio_set.values_list('pk', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, purchase_price, purchase_quantity, q.yearhighlist, q.yearlowlist, comment, pk) args = { 'form': form, 'title': 'Analytics', 'mylist': mylist, 'stock_name': symbol, 'purchase_price': purchase_price, 'purchase_quantity': purchase_quantity, 'comment': comment, } return render(request, self.template_name, args)
def get(self, request): form = WatchlistForm() current_user = request.user symbol = current_user.watchlist_set.values_list('stock_name', flat=True) target_price = current_user.watchlist_set.values_list('target_price', flat=True) comment = current_user.watchlist_set.values_list('comment', flat=True) pk = current_user.watchlist_set.values_list('pk', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, target_price, q.yearhighlist, q.yearlowlist, comment, pk) context = { 'form': form, 'title': 'Watchlist', 'mylist': mylist, } return render(request, self.template_name, context)
def post(self, request): form = WatchlistForm(request.POST) current_user = request.user if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() stock_name = form.cleaned_data['stock_name'] target_price = form.cleaned_data['target_price'] comment = form.cleaned_data['comment'] form = WatchlistForm() messages.success(request, f'The stock has been added to your watchlist!') symbol = current_user.watchlist_set.values_list('stock_name', flat=True) target_price = current_user.watchlist_set.values_list('target_price', flat=True) comment = current_user.watchlist_set.values_list('comment', flat=True) pk = current_user.watchlist_set.values_list('pk', flat=True) q = getQuotes(symbol) q.run() mylist = zip(symbol, q.stocknamelist, q.closepricelist, target_price, q.yearhighlist, q.yearlowlist, comment, pk) args = { 'form': form, 'title': 'Watchlist', 'stock_name': symbol, 'target_price': target_price, 'comment': comment, 'mylist': mylist } return render(request, self.template_name, args)