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

Feature Request: Plot percent price change on the y-axis #79

Open
fintron opened this issue Apr 4, 2020 · 8 comments
Open

Feature Request: Plot percent price change on the y-axis #79

fintron opened this issue Apr 4, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@fintron
Copy link

fintron commented Apr 4, 2020

Is your feature request related to a problem? Please describe.

When I want to compare two stocks, I'm interested in seeing the % changes in those two stocks over a period of time. Currently when I plot two stocks in mplfinance (using a secondary y-axis), I can't see the day-to-day percent changes, I only see the day-to-day price changes, which can be on different axes and thus inaccurate to compare directly.

For example, if I want to compare SPY and GOOG over a time period, I want to see the percent changes between the two (for easy comparison) rather than their stock prices which are almost an order of magnitude apart.

Describe the solution you'd like

A plot option that lets you plot the % change and lets you specify the start value that the percent changes should be compared against.

@fintron fintron added the enhancement New feature or request label Apr 4, 2020
@coffincw
Copy link
Collaborator

Hi @fintron

I'm having some difficulties understanding the feature you are requesting. Are you looking to plot two plots with the percentage difference from a specified value for each stock?

-- Caleb

@fintron
Copy link
Author

fintron commented Apr 12, 2020

In one chart, I want to plot two series. The y axis is the change each had from the start of day.

Does that make sense?

@DanielGoldfarb
Copy link
Collaborator

So just to clarify, you want the percent change from the Open to the Close each day (as opposed to percent change from previous day's close).

So for example, if this is your data:

Date Open High Low Close
2016-03-04 102.370003 103.750000 101.370003 103.010002
2016-03-07 102.389999 102.830002 100.959999 101.870003
2016-03-08 100.779999 101.760002 100.400002 101.029999
2016-03-04 101.309998 101.580002 100.269997 101.120003

The percent change would be:

Date Open High Low Close PercentChg
2016-03-04 102.370003 103.750000 101.370003 103.010002 0.625182
2016-03-07 102.389999 102.830002 100.959999 101.870003 -0.507858
2016-03-08 100.779999 101.760002 100.400002 101.029999 0.248065
2016-03-04 101.309998 101.580002 100.269997 101.120003 -0.187538

Is that correct?


taking the first row, for example, that was calculated as:

100.0 * ( (Close/Open ) - 1.0 )

or

100.0 * ( (103.01/102.37 ) - 1.0 )

So the plot should look (for example) something like this:

image

Is that what you want?

@fintron
Copy link
Author

fintron commented Apr 15, 2020

No - actually I meant that I would pick a value which is the baseline - for example "102.370003". Then, I will just look at the percent change from that value for the remaining days. Does that make sense? The user could for example choose 2016-03-01's open value and then basically see the percent change from that point.

This is useful to say plot the % change of the SPY over time vs a stock you are interested in.

@DanielGoldfarb
Copy link
Collaborator

Do you have an example of such a chart from another location? If not, no worries, I will try to work up a prototype from your description and post it here to see if that's what you are looking for. But if you can point to an example that would be helpful.

@fintron
Copy link
Author

fintron commented Apr 18, 2020

Here's an example plot from Yahoo Finance showing what I had in mind - GOOG vs SPY:

https://finance.yahoo.com/chart/GOOG#eyJpbnRlcnZhbCI6ImRheSIsInBlcmlvZGljaXR5IjoxLCJ0aW1lVW5pdCI6bnVsbCwiY2FuZGxlV2lkdGgiOjUxLCJmbGlwcGVkIjpmYWxzZSwidm9sdW1lVW5kZXJsYXkiOnRydWUsImFkaiI6dHJ1ZSwiY3Jvc3NoYWlyIjp0cnVlLCJjaGFydFR5cGUiOiJsaW5lIiwiZXh0ZW5kZWQiOnRydWUsIm1hcmtldFNlc3Npb25zIjp7InByZSI6dHJ1ZSwicG9zdCI6dHJ1ZX0sImFnZ3JlZ2F0aW9uVHlwZSI6Im9obGMiLCJjaGFydFNjYWxlIjoicGVyY2VudCIsInBhbmVscyI6eyJjaGFydCI6eyJwZXJjZW50IjoxLCJkaXNwbGF5IjoiR09PRyIsImNoYXJ0TmFtZSI6ImNoYXJ0IiwiaW5kZXgiOjAsInlBeGlzIjp7Im5hbWUiOiJjaGFydCIsInBvc2l0aW9uIjpudWxsfSwieWF4aXNMSFMiOltdLCJ5YXhpc1JIUyI6WyJjaGFydCIsIuKAjHZvbCB1bmRy4oCMIl19fSwic2V0U3BhbiI6eyJtdWx0aXBsaWVyIjoxLCJiYXNlIjoibW9udGgiLCJ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ifSwicGFuZWwiOiJjaGFydCIsImZpbGxHYXBzIjpmYWxzZSwiYWN0aW9uIjoiYWRkLXNlcmllcyIsInN5bWJvbCI6Il5HU1BDIiwiZ2FwRGlzcGxheVN0eWxlIjoidHJhbnNwYXJlbnQiLCJuYW1lIjoiXkdTUEMiLCJvdmVyQ2hhcnQiOnRydWUsInVzZUNoYXJ0TGVnZW5kIjp0cnVlLCJoZWlnaHRQZXJjZW50YWdlIjowLjcsIm9wYWNpdHkiOjEsImhpZ2hsaWdodGFibGUiOnRydWUsInR5cGUiOiJsaW5lIiwic3R5bGUiOiJzdHhfbGluZV9jaGFydCIsImhpZ2hsaWdodCI6ZmFsc2V9fV0sInN0dWRpZXMiOnsi4oCMdm9sIHVuZHLigIwiOnsidHlwZSI6InZvbCB1bmRyIiwiaW5wdXRzIjp7ImlkIjoi4oCMdm9sIHVuZHLigIwiLCJkaXNwbGF5Ijoi4oCMdm9sIHVuZHLigIwifSwib3V0cHV0cyI6eyJVcCBWb2x1bWUiOiIjMDBiMDYxIiwiRG93biBWb2x1bWUiOiIjZmYzMzNhIn0sInBhbmVsIjoiY2hhcnQiLCJwYXJhbWV0ZXJzIjp7IndpZHRoRmFjdG9yIjowLjQ1LCJjaGFydE5hbWUiOiJjaGFydCIsInBhbmVsTmFtZSI6ImNoYXJ0In19fX0%3D

@DanielGoldfarb
Copy link
Collaborator

Thanks. Will try to make time to look into this later this week.

@DanielGoldfarb
Copy link
Collaborator

No - actually I meant that I would pick a value which is the baseline - for example "102.370003". Then, I will just look at the percent change from that value for the remaining days. Does that make sense? The user could for example choose 2016-03-01's open value and then basically see the percent change from that point.

This is useful to say plot the % change of the SPY over time vs a stock you are interested in.

@fintron
It appears to me, from the example tahoo finance plot you posted above, that rather than specify a specific baseline, the plot always chooses the first date (first data point) as the baseline. That makes sense to me. Any concerns or comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants