Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a Volume Profile and split in Buy/Sell Volume in Plot #5795

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

fxxmr
Copy link

@fxxmr fxxmr commented Oct 25, 2021

Summary

I missed a volume profile in the plot, so I added one

Quick changelog

  • Adding a volume profile on the right side of the main plot
  • Allowing to split the volume bars in sell and buy volume
  • Make everything configurable in the plot_config
  • Adding some basic unit tests

What's new?

Volume Profile

You can activate a volume profile in the plot. This can be activated by 'showVolumeProfile': 'true' in plot_config
volume Profile

Split volume by sell and buy volume

You can also split the 'normal' volume on the bottom of the plot in buy and sell volume. This can be activated by 'showBuySell': 'true' in plot_config
volume_bars

This are all new possible parameters in the plot_config:

plot_config = {
'main_plot': { },
'subplots': { },
'volume': {
'showBuySell': 'true', #split the volume graph on the bottom in buy and sell volume; default: false
'showVolumeProfile': 'true', #show a volume profile on the right of the main plot; default: false
'VolumeProfileHistoryBars': 96, #define how many bars should be used for the volume profile; default: all bars in the plot
'VolumeProfilePriceRangeSplices': 100 # define in how many 'slices' the price is split up; default: 50
}
}
By default, all this is disabled.

Possible improvements

Next step could be to just show the volume profile for the zoomed-in area. Currently, the volume profile is always based on all data in the plot for the last x bars (see VolumeProfileHistoryBars). It would be cool to dynamically calculate the vp based on the currently selected are/zoom.

new features:
  - volumeProfile on the right side of the plot
  - separating the Volume and volumeProfile in
     seperate buy and sell trades
showVolumeProfile is false
adding stackmode when VolumeProfile disabled
@xmatthias xmatthias added the Plotting Issues related to plot commands. label Oct 25, 2021
@xmatthias
Copy link
Member

xmatthias commented Oct 25, 2021

In general, i'm not in favor of adding new functionalities to the plotting module at this point, as we'll be removing this way to do plots at some point in the near/mid term future in favor of freqUI (which allows basically the same plots we have at this moment, but with more interactivity, dynamically adding/removing indicators), while at the same time being able to handle more data.

It's not yet 100% feature-complete/identical - which is why the existing plotting modules have not yet been removed, however, it should be considered "in maintenance mode" - which means we should not be adding new features - as this will widen the gap we have to bridge for freqUI.

Instead, new functionality should be added to freqUI.

In this particular case - i can see us adding support for this here, but we would want to get a PR adding the same functionality to freqUI.

edit: to be clear - this does not mean we'll not merge this if we don't get a PR for freqUI - but we'll hold merging this until we find time to add it there, too.

@coveralls
Copy link

coveralls commented Oct 25, 2021

Coverage Status

Coverage decreased (-0.0006%) to 98.273% when pulling e7ead1e on fxxmr:feat/plot_volumeprofile into 20a61e0 on freqtrade:develop.

@xmatthias xmatthias added the Enhancement Enhancements to the bot. Get lower priority than bugs by default. label Oct 25, 2021
@fxxmr
Copy link
Author

fxxmr commented Oct 26, 2021

In this particular case - i can see us adding support for this here, but we would want to get a PR adding the same functionality to freqUI.

edit: to be clear - this does not mean we'll not merge this if we don't get a PR for freqUI - but we'll hold merging this until we find time to add it there, too.

I will check it out later this week and see if I can create a PR for it

Comment on lines +216 to +217
'showBuySell': 'true',
'showVolumeProfile': 'true',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be easier (both here and when handling it) to have it be real booleans (no quotes) - not strings?
Obviously it'll have to be True then ... but ...


for i in range(len(candles)):

candles['volume_buy'].iat[i] = (candles['volume'].iat[i] *
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a quick look, i think it should be possible to vectorize this (avoid looping).

You'll see that doing so will greatly improve the speed.
i guess it'll look something along these lines:

candles['volume_buy'] = np.where(dataframe['high'] > dataframe['low'], dataframe['volume'] * <....>), 0)

Comment on lines +432 to +435
VolumeProfileHistoryBars = volume_config['VolumeProfileHistoryBars'] if \
'VolumeProfileHistoryBars' in volume_config else -1
VolumeProfilePriceRangeSplices = volume_config[
'VolumeProfilePriceRangeSplices'] if 'VolumeProfilePriceRangeSplices' in \
Copy link
Member

@xmatthias xmatthias Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of these 2 variables is very missleading / confusing, as it doesn't really adhere to python standards.

In python, it's common to use lowercase variable names (in snake_case formatting).
capitalized names are usually classes (this is also visible by the color highlighting github applies).

I'd therefore: leave the settings as they are (it's a json object, so capitalization is not that important)
Modify the python variables to follow at least some style (so at least color highlighting is not broken) - to avoid confusing your friendly reviewer 😆

@lucca65
Copy link

lucca65 commented Jan 9, 2023

is this still alive? looking for something exactly like this

@xmatthias
Copy link
Member

not ... really - and based on the discussion in #6845 - it's also not very likely to be accepted, as apparently the volume profile calculation is not accurate this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancements to the bot. Get lower priority than bugs by default. Plotting Issues related to plot commands.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants