我在做一个股票预测项目。这就是我想要的:
要显示Nifty50、Nifty100左右的所有可用股票,然后用户将选择该股票,仅在第二天预测股票的高和低价格
我用的是Django
我到目前为止所做的: 我可以显示一个股票列表
def index(request):
api_key = 'myAPI_Key'
url50 = 'https://archives.nseindia.com/content/indices/ind_nifty50list.csv'
url100 = 'https://archives.nseindia.com/content/indices/ind_nifty100list.csv'
url200 = 'https://archives.nseindia.com/content/indices/ind_nifty200list.csv'
sfifty = requests.get(url50).content
shundred = requests.get(url100).content
stwohundred = requests.get(url200).content
nifty50 = pd.read_csv(io.StringIO(sfifty.decode('utf-8')))
nifty100 = pd.read_csv(io.StringIO(shundred.decode('utf-8')))
nifty200 = pd.read_csv(io.StringIO(stwohundred.decode('utf-8')))
nifty50 = nifty50['Symbol']
nifty100 = nifty100['Symbol']
nifty200 = nifty200['Symbol']
context = {
'fifty': nifty50,
'hundred': nifty100,
'twohundred': nifty200
}
return render(request, 'StockPrediction/index.html', context)
我想要什么:
我想得到所有股票的实时数据open
,high
,LTP
,Change
,Volume
。实时数据的意思是,它会随着股票价值的变化而变化
请帮忙
您必须组合下面类似
Ajax/Jquery
的代码,定期获取DOM
中的数据并更新值:但是要小心发出过多的请求,您必须在这一行选择适当的间隔
setTimeout(getStocks, "proper interval");
在
view
中,您应该将查询转换为JSON
格式,如下所示:此处
stocks
必须为json
格式相关问题 更多 >
编程相关推荐