简体   繁体   English

使用人工神经网络进行长期预测

[英]Long term prediction using Artificial Neural Network

I am working on a project to predict stock price using ANN . 我正在做一个使用ANN预测股票价格的项目。 I have trained the system using previous 7 years data and it works fine to predict data for one day . 我已经使用过去7年的数据对系统进行了培训,并且可以很好地预测一天的数据。 Now I want to predict stock price for next seven days . 现在我要预测未来7天的股价。

My Idea is to predict day 2 data using day 1 , day 3 data using predicted data of day 2 and day 1 and so on. 我的想法是使用第1天来预测第2天数据,使用第2天和第1天的预测数据来预测第3天的数据,依此类推。 But it's not working properly . 但是它不能正常工作。

I have trained ANN to predict closing price using opening price , maximum and minimum price of a day . 我曾训练过ANN使用开盘价,一天的最高价和最低价来预测收盘价。

What is the idea to predict data of next seven days ?? 预测未来7天的数据的想法是什么?

Maruf, if you have a reliable ANN predictor for 1 day ahead, please contact me to discuss further! Maruf,如果您有可靠的ANN预报器,可提前1天,请与我联系以进一步讨论! LOL 大声笑

Joking aside. 开个玩笑。 Neural Networks and other non-linear predictors are just that - predictors. 神经网络和其他非线性预测器就是预测器。 The data you are dealing with (stock price data) is largely random. 您正在处理的数据(股价数据)在很大程度上是随机的。 If you don't believe me, try to generate a random walk using the following psuedo-code and plotting it on the screen: 如果您不相信我,请尝试使用以下伪代码生成随机游走并将其绘制在屏幕上:

let min = -0.5
let max = +0.5
let bias = 0.01
let random = rand(min, max)
y[i] = y[i-1] + random + bias

Adjust bias slightly (from -0.01 to 0.01) and you end up with series which looks a LOT like a trending stock price. 稍微调整偏差(从-0.01到0.01),您将得到一系列看起来像股价趋势的系列。 The reason for this is in any underlying trend there are people that are making decisions no better than a coin flip. 这样做的原因是,在任何潜在趋势中,做出决策的人都不比掷硬币更好。 Did you know the average trader is right 55% of the time? 您知道平均交易员55%的时间正确吗? That's all he needs... 这就是他所需要的...

Now, if the data is largely random then it becomes very hard to predict. 现在,如果数据在很大程度上是随机的,则很难预测。 You are looking for a signal in a large amount of noise. 您正在寻找噪声很大的信号。 Every day ahead you try to predict your prediction becomes less accurate. 每天您都在尝试预测自己的预测变得不那么准确。

May I ask - what inputs have you put into the ANN to get a 1-day ahead prediction? 请问-您将什么输入ANN以获得提前1天的预测? If for instance you are using a daily stock prices plus other derived factors (such as rate of change, volumes, divergences etc...) to get an accurate 1-day prediction, you might find you can get an accurate 1 week prediction by substituting all the above with weekly stock data. 例如,如果您使用每日股价加上其他衍生因素(例如变化率,数量,差异等)来获得准确的1天预测,则可能会发现您可以通过以下方式获得准确的1周预测:将以上所有内容替换为每周库存数据。

Edit: 编辑:

Secondly, what are you doing to test accuracy of the predictor? 其次,您正在做什么以测试预测变量的准确性? To augment mikera's answer I would suggest a strategy such as the following. 为了扩大mikera的答案,我建议采取以下策略。

Given a data window of 1000 days, take 800 of these and train your ANN. 给定一个1000天的数据窗口,请选择其中的800天并训练您的ANN。 Now predict one day int he future. 现在预测未来的一天。 Compare the predicted direction (Up, Down) with the predicted closing price (% difference) to gauge accuracy for that result. 将预测方向(上,下)与预测收盘价(差异%)进行比较,以衡量该结果的准确性。 Now slide the window 1 day to the right. 现在,将窗口向右滑动1天。 Re-train the ANN and perform a 1 day prediction, noting results. 重新训练ANN并执行1天的预测,并注意结果。

If you continue this for the remaining 200 days, what proportion of results got the correct direction (up, down)? 如果您在剩下的200天中继续进行此操作,那么有多少比例的结果获得了正确的方向(上,下)? What proportion of results were within 10% of the actual predicted closing price? 在实际预期收盘价的10%以内,结果的比例是多少? If your ANN was placing orders at close of business of each day and closing them at the end of the next day, how much money would it have made? 如果您的ANN每天都在营业时间关闭并在第二天结束时关闭订单,那么它可以赚多少钱? Accounting for slippage and trading fees of course ... 当然要考虑滑点和交易费...

This will give you an idea of just how accurate and worthwhile the system is. 这将使您了解系统的准确性和价值。

You've done very well if you can predict even one day ahead effectively - the usual issues are: 如果您可以有效地预测甚至提前一天,那么您就做得很好-常见问题是:

  • Are you sure you are not overfitting, eg learning to replicate the features of your training data exactly? 您确定自己并不过分吗,例如学会精确地复制训练数据的特征? If you haven't tried it yet then I'd strongly recommend testing your ANN on 20% of your data after training it with the other 80% to be sure of this. 如果您还没有尝试过,那么我强烈建议您在与其他80%的数据进行训练之后,对您的20%的数据进行ANN测试,以确保这一点。
  • Also are you learning to predict absolute price values or deltas? 您还在学习预测绝对价格值或增量吗? if the former, then you are probably just getting a good fit from the fact that by far the best predictor of the next day's closing price is today's closing price (because the data has so much serial correlation). 如果是前者,那么到目前为止,第二天收盘价的最佳预测指标是今天的收盘价(因为数据具有如此大的序列相关性),这可能很适合您。 It's not uncommon to get 99%+ R-squared fits by making this mistake.... 通过犯此错误来获得99%+的R平方拟合并不少见....

Assuming you haven't fallen into one of the above traps, then the way to do multiple days of prediction is to simply have separate predicted variables for each of the future days independently. 假设您尚未陷入上述陷阱之一,那么进行多天的预测的方法就是简单地为未来的每一天分别设置单独的预测变量。 There isn't much additional value in feeding the next day predictions into the 2nd day etc. (since you don't have any new information in your input data), but you can try it if you like (can't do any harm, might speed up learning by providing a useful feature detector etc.). 将第二天的预测提供给第二天等等并没有太多附加价值。(因为您的输入数据中没有任何新信息),但是您可以尝试尝试(不会造成任何伤害) ,可以通过提供有用的特征检测器等来加快学习速度)。

Also you would expect uncertainly / variation on the further-out predictions to be greater (because there are more days of uncertain stock price movements between now and then). 此外,您可能会期望不确定性/进一步预测的差异会更大(因为从现在到现在,不确定的股票价格会有更多的日子出现)。 It's worth trying to predict the variance of your statistics as well as the mean for this reason. 因此,值得尝试预测统计数据的差异以及均值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM