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

Bug in Python for Finance #2

Open
charliemcelfresh opened this issue Nov 14, 2021 · 1 comment
Open

Bug in Python for Finance #2

charliemcelfresh opened this issue Nov 14, 2021 · 1 comment

Comments

@charliemcelfresh
Copy link

Hi Derek, thanks for your awesome videos!

In Python for Finance
https://www.youtube.com/watch?v=nNkKTJTu-mU&list=PLGLfVvz_LVvTHOWIEBAl-YOr_FC8lRmWX

your output shows that Amazon's stock price rose by ~18% in 2020; I think by your calculation in

def get_return_defined_time:

the number should be 0.6166401575831238

The bug is in your date formatting. Where you compare a date formatted like this:

start = f"{syear}-{smonth}-{sday}"

which look like this:

2020-1-1

with dates in your dataframes that look like this:

2020-01-01

your date comparison fails much of the time.

I think if you change your date formatting from this:

start = f"{syear}-{smonth}-{sday}"

to this

start = dt.datetime(syear, smonth, sday).strftime("%Y-%m-%d")

you will be good to go!

@duane5000
Copy link

I'm getting an error just like this and tried your date change - does not appear to be a fix for this. Can you try this yahoo api once more and let me know if its working for you. The error is encountered in Python for Finance 1
, and thrown inside save_to_csv_from_yahoo()

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

No branches or pull requests

2 participants