Ready. Fire.

By akohad Nov4,2022

[ad_1]

Put To Use What You’ve Learned So Far

2 Sigma Forecast (author)

This is Part 3 of the Getting The Most Out of Neural Prophet series. In this episode I will show you an example of how I use the output of a Neural Prophet model to help me make short term trading decisions with cryptos.

I use charts and indicators to develop algorithms to inform my trading decisions. So for me the best use of Neural Prophet is marrying its predictions with real time technical analysis to see how well they get along together. If Neural Prophet is predicting an event, a continuation or a turn then I want to know about it.

There Are Benefits of Visual Analysis

My technical analysis charting software is something that I developed on my own with C#. I figured that the best way to learn C# was to produce something that I would use. I chose C# because it is well suited for a desktop application, and because it came with a free charting package that looked as good to me as the $1,000 commercial offerings. Say what you want about Microsoft but the total out of pocket for the terrific Visual Studio IDE, C#, and the charting package was zero.

I’ve produced several different versions of my charting programs over the years. This version has maybe 100 standard and custom indicators that I can mix and match, and change on the fly, across time frames to see with my own eyes what combinations could be used to develop algorithmic trading strategies. I can automatically run a list of symbols through several strategies during the day and get notified by SMS or screen message that I got a hit. Heck, you can have the thing talk to you to tell you what’s it doing if that’s what you want.

Helping non programmers develop their own C# desktop charting program is my next project.

Python has its distinct advantages because of the libraries that are available to gather and process enormous amounts of data, but it cannot provide the interactivity and visual information that you get from a desktop charting program. That’s the reason I say that if you want to be a self-reliant algo trader that should learn both C# and Python. Or enough of each to get done what you need to do.

I brought up the visual charting aspect because I see many examples of people touting Python trading algorithms that were developed using a couple popular indicators and brute force programming to produce a table of impressive risk-reward metrics. Maybe that’s OK. Times change. I have done enough of that kind of thing on my own to make an informed judgment that in the long run you will be better off understanding how any particular indicator is derived, and exactly what that indicator is informing you about market conditions and the price action on the chart. I don’t think you can do that without looking at a chart.

Watch Out For Those Hyper Parameters

One more aside. In previous episodes I showed the code for the Neural Prophet engine with several hyper parameter options (input variables) without explaining them and how they could influence the output. That was probably a mistake. You wouldn’t encourage anybody to walk into a nuclear reactor control room and start pushing random buttons. Same thing with willy-nilly adding hyper parameter values to a neural net model, but with much less serious possible consequences of course. I’ll be more thoughtful going forward.

The Python Code

For today’s episode we are going to add only a few lines of code to any existing model.

predict = forecast.tail(200)
std = predict['yhat1'].std()
upper = predict['yhat1'] + (2.0 * std)
lower = predict['yhat1'] - (2.0 * std)
actual = predict['y']
fcst = predict['yhat1']
dates = predict['ds']

What we’re doing here is creating the ‘predict’ dataframe out of the last 200 data points in the ‘forecast’ dataframe and getting the standard deviation from the mean of that data. In financial modeling of all sorts two standard deviations, or 2 sigma, is considered a very significant boundary. In any distribution, about 95% of values will be within 2 standard deviations of the mean.

When your data wanders outside the 2 sigma boundary you want to know about it because the breach is often signaling that something unusual is happening that merits your attention. It could be that new information has entered the system, or it could be that things have run too far too fast and are now more likely than not going to return to the mean.

df1 = pd.DataFrame({'date': dates, 'actual': actual, 'fcst':fcst, 'upper': upper, 'lower':lower})
df1.plot(x='date', y=['actual', 'upper', 'fcst', 'lower'], figsize=(14,6), title = ticker)

That last little bit of code plots the 2 sigma chart that you see at the top of the post. It shows actual price data, the forecast price and the 2 sigma boundary above and below the forecast price. This plot provides you some potentially useful information you can integrate into your decision making process.

It tells you:

  • when the current ticker price is pushing against a 2 sigma boundary and is likely to return toward the mean. The green forecast line in this case, and
  • if the anticipated bounce back toward the mean is going to be a trend-following move or a counter-trend move, and
  • about anticipated turns in the trend in this time frame.

I saved this screenshot and used it as the title image because it was such a good example of a boundary bounce and a forecast trend change in this time frame. You even get the time of day of the anticipated trend change. The time axis is Universal Time (UTC) so your location will probably differ by several hours plus or minus if you get a plot like this after a model run.

Look at this way. How would it affect your trading results if you could plot the NEXT 10 or so most likely bars on your charts?

New to trading? Try crypto trading bots or copy trading

[ad_2]

Source link

By akohad

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *