如何在 Python 中使用 pandas_ta 库添加 ichimoku?

How can add ichimoku with the pandas_ta library in Python?

https://github.com/twopirllc/pandas-ta#overlap-33

import pandas_ta as ta
import pandas as pd


ichimoku = ta.ichimoku(df['high'], df['low'], df['close'])
df = pd.concat([df, ichimoku], axis=1)

TypeError:无法连接类型为“”的对象;只有 Series 和 DataFrame 对象有效

ichimoku returns 两个数据框。一个 returns 高点和低点指标,另一个 returns 前瞻指标,因此将它们组合起来需要每个数据框。

import yfinance as yf
import pandas_ta as ta
import pandas as pd

df = yf.download("AAPL", start="2021-01-01", end="2022-01-01")

ichimoku = ta.ichimoku(df['High'], df['Low'], df['Close'])
df = pd.concat([df, ichimoku[0], ichimoku[1]], axis=1)

df.head()
Open    High    Low     Close   Adj Close   Volume  ISA_9   ISB_26  ITS_9   IKS_26  ICS_26  ISA_9   ISB_26
2021-01-04  133.520004  133.610001  126.760002  129.410004  128.617111  143301900.0     NaN     NaN     NaN     NaN     135.389999  NaN     NaN
2021-01-05  128.889999  131.740005  128.429993  131.009995  130.207291  97664900.0      NaN     NaN     NaN     NaN     135.130005  NaN     NaN
2021-01-06  127.720001  131.050003  126.379997  126.599998  125.824326  155088000.0     NaN     NaN     NaN     NaN     135.369995  NaN     NaN
2021-01-07  128.360001  131.630005  127.860001  130.919998  130.117859  109578200.0     NaN     NaN     NaN     NaN     133.190002  NaN     NaN
2021-01-08  132.429993  132.630005  130.229996  132.050003  131.240936  105158200.0     NaN     NaN     NaN     NaN     130.839996  NaN     NaN