joshuaulrich / rfimport

getSymbols() reboot
16 stars 2 forks source link

Plotting #8

Open pverspeelt opened 2 years ago

pverspeelt commented 2 years ago

Is plotting going to be part of this? At the moment you can plot ohlc data with quantmod via chartSeries or chart_Series. You could use rtsplot (underappreciated by many as it uses base plotting), ggplot2 after transforming the data to a data.frame either by fortify.zoo or timetk::tk_tbl or using tidyquant / yfR / getBatchSymbols. Plotting in ggplot2 either via using geom_barchart or geom_candlestick from tidyquant, And I'm probably forgetting a few.

But the challenge is plotting and using the TTR info. The help with rtsplot shows how to use the RSI and some MA functions, but this is extendible to use the other info with a bit of programming. tidyquant's functions allow only for Bolinger Bands and the set of MA's. chart_Series has all or at least most of them available but is not documented at all.

Personally I tend to switch between chart_Series and ggplot depending on what I'm doing but I always miss functionalities either by missing out on TTR functions in ggplot, or by not being able to quickly compare plots like I can do with ggplot.

Basically a direction I would like to see is one of the following:

  1. extract chart_Series out of quantmod into this package or, better yet, a separate package, like quanteda.textplots and document.
  2. recreate the chart_Series functionality either in this package or a separate one.
  3. use rtsplot as a basis and extend it to handle TTR calls in a simple way.
  4. create ggplot2 extensions to handle TTR calls, like add_RSI() in chart_Series. Though ggplot2 and adding subplots is not straightforward. But by using patchwork that should be possible.
  5. other.
  6. not in scope.
joshuaulrich commented 2 years ago

Thanks for your thoughts! I didn't know about rtsplot. That looks interesting!

My preference is that this package stay focused on importing data only. I'd like to rework TTR and the charting too, and agree those should be in separate packages.

We used the chart_Series() code in plot.xts(), with the intent to then use plot.xts() in the chart_Series() code. So my initial plan was to use plot.xts() as the underlying engine for a chart_Series() reboot. But I would like to expose the par() functionality using more user-friendly arguments/parameters.

  1. Agreed.
  2. Some of this exists in plot.xts(), but is not specific to financial time series.
  3. An interesting proposal. I'll need to familiarize myself with this package.
  4. I don't know enough about ggplot to do anything in this area. I imagine it would be very useful for many people though!