Giter Site home page Giter Site logo

derekbanas / python4finance Goto Github PK

View Code? Open in Web Editor NEW
470.0 33.0 268.0 19.2 MB

I get many questions about how to analyze the Stock Market with Python. I am creating a new playlist of videos that will completely cover Python for Finance.

Jupyter Notebook 100.00%

python4finance's Issues

Serious issue in Python for Finance 5.ipynb

Hi Derek,
first of all, let me say I appreciate your work a lot, your Youtube tutorials are really helping me.

After watching your video "Stock Market Prediction: Python for Finance 5", I've been working with the code, and I think I found a serious problem. In section Regression Time Series Example with AutoReg, the regression model is initialized as

train_model = AutoReg(a_df['Adj Close'], 500).fit(cov_type="HC0")

The problem is that it uses a_df to train the model, the whole dataset instead of just train_df, the training dataset. This is a serious problem because this way we are also using test data to train the model, this is "cheating"!

I tried fixing this with train_model = AutoReg(train_df['Adj Close'], 500).fit(cov_type="HC0"), and played with the lag parameter, but the correctly trained model is a really bad predictor for test_df.

Bug in Python for Finance

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.