def historical_quotes(request): symbols = [] for position in Position.all(): symbols.append(position.symbol) start_date = request.GET.get('start_date') stop_date = request.GET.get('stop_date') if start_date: Quote.yahoo( position.symbol, start_date=datetime.strptime(start_date, '%Y-%m-%d').date(), stop_date=datetime.strptime(stop_date, '%Y-%m-%d').date()) else: Quote.yahoo(position.symbol) return redirect(request)
def fixture(request): Position.delete_all() Quote.delete_all() Portfolio.delete_all() avanza = Portfolio(name='Avanza', currency='SEK').save() Portfolio(name='XO', currency='GBP').save() Position(symbol='AAPL', currency='SEK', currency_rate=1.0, enter_date=date.today(), enter_price=5000.0, enter_commission=99.0, shares=1000.0, portfolio=avanza).save() Quote(symbol='AAPL', close=1234.5, high=1234.5, low=1234.5, open=1234.5, date=date.today()).save() return HttpResponseRedirect('/')