python - 如何从 Alpha Vantage API 中提取数据?
问题描述
我想对股票发出 RSI 警报。
这是 Alpha Vantage API 响应我的请求的数据。每当我运行代码时,我都想提取最新的 RSI。
在这种情况下,它是 77.0835。随着日期和时间(即 2020-01-24 14:30)不断变化,有什么办法可以获得最新的 RSI 吗?
来自 Alpha Vantage 的响应摘录:
{
"Meta Data": {
"1: Symbol": "tlt",
"2: Indicator": "Relative Strength Index (RSI)",
"3: Last Refreshed": "2020-01-24 14:30:46",
"4: Interval": "60min",
"5: Time Period": 14,
"6: Series Type": "close",
"7: Time Zone": "US/Eastern Time"
},
"Technical Analysis: RSI": {
"2020-01-24 14:30": {
"RSI": "77.0835"
},
"2020-01-24 13:30": {
"RSI": "78.0121"
},
"2020-01-24 12:30": {
"RSI": "75.8201"
},
"2020-01-24 11:30": {
"RSI": "75.7447"
},
"2020-01-24 10:30": {
"RSI": "73.9965"
},
"2020-01-24 09:30": {
"RSI": "73.8768"
}
解决方案
这个怎么样?
data = {
"Meta Data": {
"1: Symbol": "tlt",
"2: Indicator": "Relative Strength Index (RSI)",
"3: Last Refreshed": "2020-01-24 14:30:46",
"4: Interval": "60min",
"5: Time Period": 14,
"6: Series Type": "close",
"7: Time Zone": "US/Eastern Time"
},
"Technical Analysis: RSI": {
"2020-01-24 14:30": {
"RSI": "77.0835"
},
"2020-01-24 13:30": {
"RSI": "78.0121"
},
"2020-01-24 12:30": {
"RSI": "75.8201"
},
"2020-01-24 11:30": {
"RSI": "75.7447"
},
"2020-01-24 10:30": {
"RSI": "73.9965"
},
"2020-01-24 09:30": {
"RSI": "73.8768"
}
}
}
most_recent_rsi = data['Technical Analysis: RSI'][sorted(data['Technical Analysis: RSI'])[-1]]
推荐阅读
- r - 我需要通过首先在 rstudio 中找到这些标记的索引来从数据帧中获取两个标记之间的数据
- python - 我如何只允许我的朋友看到我的帖子
- typescript - 如何增加类型化的 npm 模块类型?
- html - 带有表格的 div 内的滚动条
- machine-learning - Keras - 具有经常丢失的 GRU 层 - 损失:'nan',准确度:0
- python - Pip 根本没有安装
- c++ - ARM GCC C++14 POD 类型未放入 ROM
- javascript - 如何在material-ui react中管理多文本字段验证?
- spring-cloud - Spring cloud-config-server Git-Backend on AWS ECS
- javascript - 我们在哪里可以定义 React 中 Material-UI 的主题