Fix SDK - openbb.ta.ma_chart - Command fails if index column is not labeled: "date". (#3556)

* fix date error

* add examples
This commit is contained in:
montezdesousa
2022-11-24 12:55:51 +00:00
committed by GitHub
parent a4d62fe1ad
commit 222cceb1f3

View File

@@ -56,9 +56,21 @@ def view_ma(
Format to export data
external_axes: Optional[List[plt.Axes]], optional
External axes (1 axis is expected in the list), by default None
Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> df = openbb.stocks.load("AAPL")
>>> openbb.ta.ma_chart(data=df["Adj Close"], symbol="AAPL", ma_type="EMA", window=[20, 50, 100])
>>> from openbb_terminal.sdk import openbb
>>> spuk_index = openbb.economy.index(indices = ["^SPUK"])
>>> openbb.ta.ma_chart(data = spuk_index["^SPUK"], symbol = "S&P UK Index", ma_type = "EMA", window = [20, 50, 100])
"""
# Define a dataframe for adding EMA series to it
price_df = pd.DataFrame(data)
price_df.index.name = "date"
l_legend = [symbol]
if not window: