-
Notifications
You must be signed in to change notification settings - Fork 653
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
Support for ununiformly spaced data #393
Comments
Marty,
By definition,
|
Thanks a lot for your answer! My options are the following for plotting above:
I acknowledge it is a very edgy case. To me it looks like I would rather need to change this value mplfinance/src/mplfinance/_widths.py Line 103 in d777f43
An alternative could be to keep all bars of the same width (including the candles), but to distort the time axis to take into account this non-uniformity. Edit: Most probably the plot I gave above is misleading to carry my point. The issue is not with 0 volumes rows (rows with NaN values), but rather stems from the fact that each row have time points which are not equally spaced. |
So you actually want the candle widths and volume bar widths to vary? Wider for a larger time period since the previous candle and narrower for a smaller time period? |
Please confirm the above question. |
Thanks a lot! Yes, when this case arises, I would either expect:
In the evening I can post a proper file for the data if you want to have a look. |
Here is a reproducible example: https://pastebin.com/4Ft7Md04 |
As noted in your PR, Non-trading periods are defined as rows that are completely missing from the dataframe: that is, both the data and the datetime index entry are missing for a given date/time where trading does not occur. However a row that exists but is filled with |
@fxmarty As I understand it, one of the central ideas in candlestick charts is that each candle represents a set chunk of time, be it 1 minute per candle, or 15 minutes per candle, or an hour, a day, a week, etc. This enables one to visualization not only where the market is moving, but also how fast the market is moving. Since each candle represents the same amount of time, then taller candles represent fast moving markets, while shorter candles represent slow moving markets. So I would be very interested to learn if some people routinely use a type of candlestick chart where the width of each candle varies. Can you point to an example and/or article online somewhere? Thanks. --Daniel |
Thanks a lot for your thoughtful remarks! Actually this got me curious and I did not know it, but it looks like this kind of chart with width-variable candles are used as a type of candle called "CandleVolume": see https://school.stockcharts.com/doku.php?id=chart_analysis:candlevolume and https://cmtassociation.org/kb/candlevolume-chart-definition/ . It looks a bit exotic though, but funny to see. As I said a bit above, the use case I was thinking about is a bit different: for blockchains which record transactions (swaps) and do not have a fixed block time. Say block 0 is minted at 5:46:05, block 1 is minted at 5:48:23, and block 2 is minted at 5:52:12. Say we want to plot a chart with a 5 min resolution. Does block 2 belong to the time frame 5:45-5:50 or to the time frame 5:50-5:55? Obviously we can do an arbitrary choice (and that is what I came up to do in the end), but an other approach, if you are not so much concerned about time but more concerned about the blocks themselves, would be to have on your x axis the block number. A third approach would be to keep time on the x axis, but either 1/ to distort the time axis, or 2/ have candles of variable width. |
@fxmarty Regarding your block chain use-case. My inclination would be that block 2 definitely goes into the 5:45-5:50 block. You may find it useful to use Pandas resampling to bucket your data into even time periods. If you are not familiar, you can see some examples here. (And some additional references can be found here.) You may also be interested in Renko charts where the x-axis represents blocks of price movement (instead of time). Just use I don't understand how distorting the time axis would work or be helpful. |
Hello,
Today I tried to plot data for which the time column was not uniformly spaced, there is the result:
Corresponding data:
We can see two problems:
It would be nice to be able to handle this case natively with mplfinance.
Note: The use case is to inspect transactions inside blocks in a given blockchain (e.g. Bitcoin, Ethereum). The mining time is not constant.
Thank you!
The text was updated successfully, but these errors were encountered: