yacoubb / stock-trading-ml

A stock trading bot that uses machine learning to make price predictions.
GNU General Public License v3.0
595 stars 254 forks source link

prediction timeframe #5

Open AndreasWSB opened 4 years ago

AndreasWSB commented 4 years ago

hello there!

i am quite a newbie to ML and wanted to ask if there is any way I can adjust the prediction timeframe to more than just one day in advance. the prediction accuracy is not important in this case.. it is just to do some additional research in combination with other tools.

thanks in advance andreas

akildemir commented 4 years ago

hello @AndreasWSB if you want to increase the timeframe all you need to do is chance the training data and train the network with this new data. For example, If you wanna predict next week price, just use weekly data in the same format. Everything else can stay same. But as you said this will significantly increase the error rate since the training data drops 7x.

AndreasWSB commented 4 years ago

hello @akildemir, thank you!

AndreasWSB commented 4 years ago

Hello Yacoub!

Have you already tried other indicators? I would like to include the stochastic and the RSI in the training model as well.

Best regards Andreas

Am Sa., 19. Okt. 2019 um 14:41 Uhr schrieb akildemir < notifications@github.com>:

hello @AndreasWSB https://github.com/AndreasWSB if you want to increase the timeframe all you need to do is chance the training data and train the network with this new data. For example, If you wanna predict next week price, just use weekly data in the same format. Everything else can stay same. But as you said this will significantly increase the error rate since the training data drops 7x.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yacoubb/stock-trading-ml/issues/5?email_source=notifications&email_token=AJP3ODXOC7ITXMA55HASCHTQPL6ALA5CNFSM4JCFEBPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBXOS6A#issuecomment-544139640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJP3ODTOJ3IDESVZ777Q75TQPL6ALANCNFSM4JCFEBPA .

AndreasWSB commented 4 years ago

Hello Yacoub! Startup problems ...;) I get in line 52 of util.py

52 "assert ohlcv_histories_normalised.shape [0] == next_day_open_values_normalised.shape [0] == technical_indicators_normalised.shape [0]"

the following error message:

Value 'ohlcv_histories_normalised.shape' is unsubscriptable "

Can you maybe check that out please? Best regards Andreas

rpngithub commented 4 years ago

Hi @yacoubb First of all.. Thanks for sharing the code. Its really a learning material for a starter like me.

Please explain why are you taking just the last value in calc_ema return ema_values[-1]

so in model.fit(x=[ohlcv_train, tech_ind_train], y=y_train, batch_size=32, epochs=50, shuffle=True, validation_split=0.1)

ohlcv_train = [[0-50 historical prices], [51-52 historical prices]...] tech_ind_train = [[EMA of 0-50 historical close prices], [EMA of 51-52 historical close prices]]

I am using TA-Lib for finding the EMA For [0-50 historical prices] calculating EMA for timeperiod=12 gives me nparray(50) with first 11 as NaN

Please help me how to provide the tech_ind_train. Is there any concept/methodology for the same.

Thanks again.

davidmroth commented 4 years ago

I think its more like:

ohlcv_train = [[0-50 historical prices], [1-51 historical prices],[1-51 historical prices]...]
tech_ind_train = [[EMA of 0-50 historical close prices], [EMA of 1-51 historical close prices], [EMA of 1-51 historical close prices]]

Basically, you are creating 50 historical entries for every item in the data set. Makes sense?

This could be why you're running into issues.