OpenBB-finance / OpenBB

Investment Research for Everyone, Everywhere.
https://openbb.co
Other
34.05k stars 3.12k forks source link

[FR] Add ability to compare percentage gain of multiple stocks over N period of time #3115

Closed not-aristotle closed 5 months ago

not-aristotle commented 2 years ago

What's the problem of not having this feature? For example, it would be very useful for a user to see how their favorite stock compares to other similar stocks or benchmarks.

Describe the solution you would like I would like to have this option available in Comparison Analysis Menu. Alternatively, it could be under any command as long as it is intuitive and properly documented.

Additional information Similar feature is available in Yahoo Finance:

Screenshot 2022-10-26 at 10 28 08 PM

I would say either graph or even tabular format would be fine. I actually tend to think that tabular format is more concise and preferable since it probably doesn't matter what fluctuations were there along the way... I imagine tabular format to be something like:

Results over 5Y - ideally this would be a top row with merged cells - could not accomplish it with markdown 😔 Company A Company B
123% 78%
Aditya04-code commented 2 years ago

I have a suggestion can we use plotly ! for that as it provides interactive graphs that help in better understanding of graphs

deeleeramone commented 5 months ago

Closing, this is part of the openbb-charting library.

SPDRS = [
    "SPY",
    "XLE",
    "XLB",
    "XLI",
    "XHB",
    "XLP",
    "XLY",
    "XRT",
    "XLF",
    "XLV",
    "XLK",
    "XLC",
    "XLU",
    "XLRE",
]
start_date = (datetime.now() - timedelta(weeks=52*5)).date()
spdrs = obb.equity.price.historical(SPDRS, start_date=start_date, provider="yfinance", chart=True)

spdrs.show()

SPDRs Cumulative Returns - 5 years

YTD:

new_data = spdrs.to_df().loc[datetime(2023,12,29).date():]
spdrs.charting.to_chart(data=new_data, title="YTD")

SPDRs Cumulative Returns - YTD