jcamiloangarita / stocker

Stock Price Prediction
MIT License
118 stars 52 forks source link

Backtest #7

Open bluusun opened 4 years ago

bluusun commented 4 years ago

Love how easy and simple the module works!

How to backtest the prediction algo? I.e. I'd like to use a model for one month - regenerate each month and predict each day for last 400 trading days?

jcamiloangarita commented 4 years ago

Great that you like it!

Well, the main function defines the present day before building the model. However, you could slice the dataset (stock_data) taking only dates before that one you want to predict (e.g. before last 400 periods should be the first case). Then you can use a loop adding each prediction until you reach the present day.

If you want to go further with the function, it could be included, just create a pull request (:

PabloVergara commented 3 years ago

Hi! First of all, thank you very much for this library, it looks easy to use, but It is not very clear to me how to slice the data because of the way it is called. Furthermore, I consider that a mean directional accuracy metric would be much more informative than percentage error, considering that most assets have movements in pips from one day to the next. I would love to be able to evaluate it, could you give me an example of how to slice the data you call from yahoo?

jcamiloangarita commented 3 years ago

Hi @PabloVergara A specific amount of previous data is called based on the property years, it's used internally by the function to generate the model and only the results are being returned i.e. 'close price', 'error', 'respective next day'.

Here you can find the function used to fetch stock data from Yahoo. There are some other functions in the same file to provide different features.