In this article I wanted to concentrate on some basic time series analysis, and on efforts to see if there is any simple way we can improve our prediction skills and abilities in order to produce more accurate results. When considering most financial asset price time series you would be forgiven for concluding that, at various time frames (some longer, some shorter) many, many of the data sets we try to analyse can appear completely random. At least random enough that any hope of easily forecasting future value and paths is going to be a tough ask at the every least!
I thought it was about time for another blog post, and this time I have decided to take a look at the “Ichimoku Kinko Hyo” trading strategy, or just “Ichimoku” strategy for short. The Ichimoku system is a Japanese charting and technical analysis method and was published in 1969 by a reporter in Japan.
I thought I would spend this post on the creation of the indicator elements themselves, along with a couple of plotting examples usikng both Matplotlib and then Plotly.
So the Ichimoku “set up” is a technical indicator that is used to gauge momentum, along with future areas of support and resistance and consists of five main components.
In this article I thought I would take a look at and compare the concepts of “Monte Carlo analysis” and “Bootstrapping” in relation to simulating returns series and generating corresponding confidence intervals as to a portfolio’s potential risks and rewards.
Both methods are used to generate simulated price paths for a given asset, or portfolio of assets but they use slightly differing methods, which can appear reasonably subtle to those who haven’t come across them before. Technically Bootstrapping is a special case of the Monte Carlo simulation, hence why it may seem a little confusing at first glance.
With Monte Carlo analysis (and here we are talking specifically about the “Parametric” Monte Carlo approach) the idea is to generate data based upon some underlying model characteristics. So for example, we generate data based upon a Normal distribution, specifying our desired inputs to the model, in this case being the mean and the standard deviation. Where do we get these input figures from I hear you ask…well more often than not people tend to use values based on the historic, realised values for the assets in question.
This blog post is a result of a request I received on the website Facebook group page from a follower who asked me to analyse/play around with a csv data file he had provided. The request was to use Pandas to wrangle the data and perform some filtering and aggregation, with the view to plot the resulting figures using Matplotlib. Now Matplotlib was explicitly asked for, rather than Seaborn or any other higher level plotting library (even if they are built on the Matplotlib API) so I shall endeavour to use base Matplotlib where possible, rather than rely on any of the aforementioned (more user friendly) modules.
Well it’s time for part 4 of our mini-series outlining how to create a program to generate performance reports in nice, fancy looking HTML format that we can render in our browser and interact with (to a certain extent). The previous post can be found here. If you copy and paste the last iteration of the code for “main.py” and “template.html” from the last post into your own local files and recreate the folder and file structure outline in part 1 (which can be found here), then you should be ready to follow on from here pretty much.
So I promised at the end of the last post that I would stop adding random charts and tables with additional KPIs and equity curves and what not, and try to add a bit of functionality that one may actually find useful even if it weren’t part of this whole specific performance report creation tutorial. I know many people are interested in the concept of Monte Carlo analysis and the insights it can offer above and beyond those statistics and visuals created from the actual return series of the investment/trading strategy under inspection.
This is the third part of the current “mini-series” providing a walk-through of how to create a “Report Generation” tool to allow the creation and display of a performance report for our (backtest) strategy equity series/returns.
To recap, the way we left the code and report output at the end of the last blog post is shown below. The “main.py” file looked like this:
Hi all – here is the last in what has turned out to be a 3 part “series” of posts, dealing with my journey (so far) of learning Python – how I went about it and what resources I ended up using.
As a quick recap of the main points highlighted so far:
- It is VITAL to identify and select a project you wish to eventually create – something that really means something to you and excites you when you think about it.
- Steer clear of Codecademy as an early Python resource – Most of it is now behind a paywall and the whole concept of trapping you inside their sandboxed environment can end up causing added confusion rather than helping.
- Consider signing up to a quality MOOC beginner Python course – my recommendations are the two listed in the previous blog post. (I’m sure there are many other quality courses on offer out there, but those are the two I have experience with and they both did a good job of getting me from zero to “absolute beginner”).
- Approach the MOOC courses you decide to take in a “serious manner”. You’ll gain so much more if you solve the exercises and homeworks yourself, without searching for solutions etc on Google – it’ll take a lot longer, and take a lot more effort but that’s when the learning happens!! After all, you’re doing all this to learn right? Nothing worth having comes easy! 😉
- Prepare mentally for when you reach the inevitable “cliff of confusion” and “desert of despair” – both are surmountable with enough perseverance, hard work and simple belief in yourself!
- Be willing to take a step back and take stock of your situation objectively. You may need to revisit the process of following structured Python courses for a period, that perhaps don’t teach EXACTLY what it is your trying to focus on for your end goal. This is ok….don’t beat yourself up about it. Take a moment to appreciate how far you have come since you sat down on day 1. Perhaps even go back and attempt some of the exercises you completed in your previous MOOC courses – compare your new solution to your old one, both in terms of conceptual approach and code style or efficiency etc. I bet you surprise yourself.