-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Adding stock price comparison via -c flag #1745
Adding stock price comparison via -c flag #1745
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @Avani1994 !!
I put my comments below 😄
# This plot has 3 axis | ||
if external_axes is None: | ||
_, axes = plt.subplots( | ||
3, 1, sharex=False, figsize=(12, 7), dpi=cfg_plot.PLOT_DPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the fig size should be plot_autoscale()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I tried this, but then with three figs, the individual plots are quiet small. Wouldn't that be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may be because our default is not ideal, but this should be able to be configurable by the user
_, axes = plt.subplots( | ||
2, 1, sharex=True, figsize=plot_autoscale(), dpi=cfg_plot.PLOT_DPI | ||
# get stock end price for each corresponding day if compare == True | ||
if not compare: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the ax1 and ax2 do not change regardless of whether we display stock price or not. We should do something like the following pseudo-code:
if compare:
ax1,ax2,ax3 are created
else:
ax1,ax2 are created
populate ax1 and ax2 (this avoids repeated code)
if compare:
populate ax3 with stock price
set theme
This allows to minimize duplicated code and makes it easier for debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see yeah this makes sense to me, we have to just write if compare
twice, i thought that wouldn't be good idea, but yeah we can do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes it easier from the readability perspective and maintenance as well since there isn't repeated code
parser.add_argument( | ||
"-c", | ||
"--compare", | ||
action="store", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For true/false flags you can use here "store_true" as action and remove both the type and the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good advice :)
@Avani1994 for the tests to pass you need to run black linting to the @piiq this is also failing in the |
thank you @Avani1994 re: |
@@ -4,8 +4,8 @@ | |||
import argparse | |||
import logging | |||
from pathlib import Path | |||
from typing import List, Tuple, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is why tests are failing
@Avani1994 you just need to fix the test for the |
… into sentiment-enhancement-avani
…i1994/OpenBBTerminal into sentiment-enhancement-avani
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @Avani1994 !
Adding stock price comparison via -c flag
Added a compare flag in twitter sentiment analysis to allow see the movements in stock price alongside the sentiment. It's just a small enhancement to the sentiment command under /stocks/ba/.
I just felt stock price movements along with sentiment will be really helpful from customer point of view.
None of the dependencies are required for this change.
How has this been tested?
Couldn't run tests, as it was asking to uninstall brotlipy and conda uninstall didn't do the job, hopefully CI should catch failing tests if any
$/stocks/ba sentiment -c True
Output:
Checklist: