我试图通过调用alphavantage的API来为公司获取JSON.对于一些公司数据即将到来,对于一些公司来说,它失败了.数据即将来临的公司 - 数据失败的TCS,INFY,MSFT公司 - TATAMOTORS,RCOM,SBIN
TCS JSON的链接
TATAMOTORS的链接
谁能帮助我为什么会这样?
json finance google-finance-api quantitative-finance alphavantage
我正在使用python及其框架烧瓶来构建frontEnd backEnd项目。该项目需要库存数据。在停止工作之前,我使用了Yahoo的Api,现在使用的是Alpha Vantage API。它工作得很好,但是我在纳斯达克,道琼斯等股票市场指数上遇到困难。.在使用雅虎时,我使用了其股票代码(如符号)(^ IXIC,^ DJI ...),但似乎不起作用与阿尔法有利。有没有人使用过alpha vantage?
用于获取Microsoft数据的url示例:https :
//www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=full&apikey=CN3J
Python代码:
@app.route('/pfa/medaf/IndAct', methods = ['POST'])
def donnee():
Action1 = request.form['code1']
Action2 = request.form['code2']
Indice = request.form['Ind']
url="https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol="
urlInd=url+Indice+"&apikey=CN3J"
urlAct1=url+Action1+"&apikey=CN3J"
urlAct2=url+Action2+"&apikey=CN3J"
respInd = urlopen(urlInd)
dataInd = json.loads(respInd.read().decode(respInd.info().get_param('charset') or 'utf-8'))
coursIndice=[]
listInd=[]
for elt in dataInd['Time Series (Daily)'].keys():
listInd.append(elt)
listInd.sort(reverse=True)
for e in listInd:
coursIndice.append(float(dataInd['Time Series (Daily)'][e]['4. close']))
lenIndice = len(coursIndice)
rentabIndice=[]
for j in range(lenIndice-1):
rentabIndice.append(100*(coursIndice[j+1]/coursIndice[j] -1 ))
moyenneMarche=sum(rentabIndice)/len(rentabIndice)
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<section class="cols pad_left1">
<form action = "http://localhost:5000/pfa/medaf/IndAct" method = …
Run Code Online (Sandbox Code Playgroud) 我一直在使用ROMEL托雷斯的alpha_vantage包,但也想从蟒蛇直接使用阿尔法华帝API(提供了更大的功能)与包请求作为这里所描述的卷曲通过Python的API调用:
import requests
import alpha_vantage
API_URL = "https://www.alphavantage.co/query"
data = {
"function": "TIME_SERIES_DAILY",
"symbol": "NIFTY",
"outputsize": "compact",
"datatype": "csv"
"apikey": "XXX",
}
response = requests.get(API_URL, data)
print(response.json())[/code]
Run Code Online (Sandbox Code Playgroud)
但是正在返回的字典中收到以下错误消息:
{“错误消息”:“无效的API调用。请在TIME_SERIES_DAILY之前重试或访问文档(https://www.alphavantage.co/documentation/)。'}
使用requests.post(),结果为:
response = requests.post(API_URL, data)
{'detail': 'Method "POST" not allowed.'}
Run Code Online (Sandbox Code Playgroud)
I've re-checked the documentation and am following all the required API parameters. Appreciate some help re what I might be missing here and what the correct call would be and/or any other alternative approach. Thanks