我正在從
我有以下代碼,其中from_unixtime包含尚未定義的占位符函式:
import mplfinance as mpf
import pandas as pd
from polygon import RESTClient
def main():
key = "keyhere"
with RESTClient(key) as client:
start = "2019-01-01"
end = "2019-02-01"
resp = client.stocks_equities_aggregates("AAPL", 1, "minute", start, end, unadjusted=False)
df = pd.DataFrame(resp.results)
df.index = [from_unixtime(ts) for ts in df['t']]
df.index.name = 'Timestamp'
# mpf expects a dataframe containing Open, High, Low, and Close data with a Pandas TimetimeIndex
df.columns = ['Volume', 'Volume Weighted', 'Open', 'Close', 'High', 'Low', 'Time', 'Num Items']
mpf.plot(df, type='candlestick', no_xgaps = True)
if __name__ == '__main__':
main()
uj5u.com熱心網友回復:
嘗試更換
df.index = [from_unixtime(ts) for ts in df['t']]
和
df.index = pd.DatetimeIndex( pd.to_datetime(df['t'],unit='s') )
米克
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/392638.html
