Skip to content

Conversation

@serkor1
Copy link
Owner

@serkor1 serkor1 commented Nov 26, 2025

Note

This PR closes #15 and #23

📚 What?

This PR adds a more robust implementation of the <plotly>-methods alongside new implementations.

🚀 New features

  • merge.plotly: Merge two <plotly>-objects that are similar in terms of y-scales. A use-case is the combination of an indicator with varying n

🔨 Developer tools

The most important (internal) additions are:

  • plotly_init(): Initialize an empty <plotly>-object for the subchart indicators.
  • plotly_line(): Create a straight line for indicators with threshold values.
  • plotly_build(): Build a <plotly>-object using the various layout functions

The overall goal with these functions is to ease the development flow and streamline the {plotly} implementation.

📋 TODO

  • Titles for subcharts
  • Univariate and multivariate price charts (e.g. Close only, or Close + Open only, etc.)
  • Append combined indicators to main chart
  • Fix coloring on merge.plotly()
  • Update README with indicators (Add volume, independent indicators and merged indicators)
  • Add and export <plotly>-methods documentation via roxygen
  • Update vignette on charting with the new changes
  • Add decorators (y-axis limits for constrained indicators, last values etc)
  • Set attributes of the indicators to avoid warnings from plotly

* The goal is to ease the process of building individual
  <plotly> elements.

* Added alias to themes as a small step towards normalizing
  the coding
* This commit is a preliminary implementation using Reduce()
  a high-level wrapper will be implemented at a later point when
  the code is completed.
@serkor1 serkor1 added the enhancement New feature or request label Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 91.76570% with 97 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.41%. Comparing base (2c7ab6e) to head (0601644).
⚠️ Report is 1 commits behind head on devel.

Files with missing lines Patch % Lines
R/chart_merge.R 0.00% 17 Missing ⚠️
R/ta_VOLUME.R 83.75% 13 Missing ⚠️
R/chart_layout.R 92.30% 9 Missing ⚠️
R/ta_BBANDS.R 83.33% 6 Missing ⚠️
R/chart_build.R 90.19% 5 Missing ⚠️
R/chart_elements.R 0.00% 4 Missing ⚠️
R/helper.R 95.12% 2 Missing ⚠️
R/chart_options.R 50.00% 1 Missing ⚠️
R/ta_AD.R 92.30% 1 Missing ⚠️
R/ta_ADOSC.R 92.30% 1 Missing ⚠️
... and 38 more
Additional details and impacted files
@@            Coverage Diff             @@
##            devel      #24      +/-   ##
==========================================
- Coverage   96.52%   95.41%   -1.12%     
==========================================
  Files         266      270       +4     
  Lines       11504    11919     +415     
==========================================
+ Hits        11104    11372     +268     
- Misses        400      547     +147     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* The plotly builder is an S3 function for high-level
  building indicators usings list of traces instead of
  coding it in a low-level manner. A similar implementation were done in {cryptoQuotes}.
* The templates are now split in subchart and main chart indicators. This implementation
  is not really clever, as it has just been copy-pasted; but it works.
* The name of the data is fixed, and given the changes
  in 92edf20, it makes sense to
  add a 'data'-argument.
* This is just to play around with it, and have starting point
  for developing the new functions further.
* The functions adds common trace elements to
  a list of traces. It abstracts the lapply code-chain
  in indicators with more than one trace.
* This options is primarily meant for the README.
  In {cryptoQuotes} there is a added an extra padding to
  avoid overlap with the title. Consider whether this is a good
  idea here.
* The README removes the modebar such that it is not
  a part of the figure presented in the chart-section.
* plotly_init: Initializes an empty plotly object using the constructed_indicator object
  from the parent.frame

* plotly_line: Creates a straight line using the number of rows from the constructed_indicator object
  from the parent.frame

The goal is deprecate the subchart() and add_ribbons()
* The template were spelled incorrectly.
* All indicators are now generated conditionally on
  being subchart or main chart indicators
* The implementation is a bit off, some indicators have proper names,
  some doesn't. At the moment the goal is to implement it correctly,
  then implement the small details.
* The functions now uses the same templates and logic as the remaining.
* The low-level implementation uses the ta_MA.c to calculate
  the MAs for the volume
* The function were looking for a non-existent argument.
* The trading volume is now implemented
  similar to the remaining funcitons. It might
  be that this is overkill, but it has been implemented
  nonetheless. This implementation is in response to
  #23
* add_ribbons are replaced by fills in each trace
* subchart is replaced by plotly_init

See 3f423fc for more details
and as a starting point if any interest.
* The merge() function is a S3 function from {base}
  applied to <plotly>-objects. The function is currently
  a rough sketch of how it should function, and requires alot of upstream
  changes (I think).

  At the moment it does not differentiate colors in the merged indicator
  so this needs some (slight) rethinking. A quick-fix could be to add a pool
  of colors to chose from in the function itself.
* I think there might be a bug somewhere. But now its committed.
* The subchart will inherit the title of the subchart indicator
  unless its explicitly passed.
* See 344f8a8
* The generators now supports overriding numeric method availability.
* The plotly_line() function is now more robust to upstream
  logic.

* The produced lines are now a middlepoint between the font and grid color
  with dots instead of dash.

* The mode, type and class of the plotly_line() is hardcoded to avoid
  downstream ambigiuty in plotly_build()
* The function will now add legends by default
  and treats plotly_line() differently from indicator
  traces.

* The function now also builds the gridlines by default.
* The decorators is a list of function for decorating the chart and added indicators.
  An example use-case is forcing limits to the indicators where limits are applied. The ADX
  ranges from 0 to 100, for example, and should therefore be plotted accordingly.

* To support the decorators the templates have been updated, and is.empty() helper-function
  have been introduced to check for empty lists, characters and such. Not sure why, but it was a
  good idea at the time.
* These functions have no decorators for now and can be committed without
  further actions.
* The last value decorators adds the last values
  to the charts with bold and regular fonts.

* The title of the main chart now follows the paper and
  does not overflow to the right.
* The <plotly>-methods have been updated and now uses
  the new decorator interface.
* The legend is now a part of the chart itself instead
  of being outside of the plot area. This layout is consistent
  with other charting software like Binance and TradingView.
* This is a work in progress. The naming and grouping
  of legend entries should be handled by the individual methods.

  - There is too much nitty gritty work around polishing the
    charts. The package is not even published, and based on the experiences
    from {SLmetrics} nobody will 'really' use the package because people do not
    switch from old packages.
* The template will look for decorators and return a list() if not found.
  - There is no reason to scan 100+ indicators to determine if a decorator is needed.
* The build_plotly() now groups and names traces based on the naming and
  title argument.
* All indicators now follows the new structure of the of the plotly_build()
  - the upstream implementation allows for more boilerplate coding at a later point.
* Added RSI and Volume to charts
* The source of the "one config"-warning  could not be located.
  - So instead of baking the config in the plotly_object, it will be applied
    on return instead. So its never really a part of any object.
* Swithced the position of the title and the last OHLC-values
* All margins are set to zero; except right side.
* Both bands are now uniquely identified from the
  legends; multiple bands will provide multiple legend entries
  identifiable from the titles.
* All moving averages are now grouped under
  the 'Moving Averages'-legends.
* This function is essentially a variadic sprintf()-wrapper
  for naming <plotly>-method traces.
* Replaces missing names with NULL
* The function is now internally documented
* The function will now build the minimum required
  elements so the resulting <plotly>-object is uniform
* Implemented new templates
* Minor bug-fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

volume() column names Robust and streamlined {plotly} implementation

2 participants