如何从 Alpha Vantage API 中提取数据?

How to extract the data from Alpha Vantage API?

我想为股票设置 RSI 警报。

这是Alpha Vantage API响应我的请求的数据。每当我 运行 代码时,我都想提取最新的 RSI。

本例中为 77.0835。由于日期和时间(即 2020-01-24 14:30)不断变化,我有什么办法可以获得最新的 RSI?

A​​lpha 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]]