Showing posts with label max drawdown. Show all posts
Showing posts with label max drawdown. Show all posts

Tuesday, 30 January 2018

FANG Stocks, tech portfolio

Everyone knows about the FANG stocks rally. But what does FANG mean? It’s a group of technology stocks, Facebook, Amazon, Netflix, and Google. If we look back to the beginning of 2015, we would regret not having invested in these stocks. Please bear in mind that it’s my first article using Python, so it can seem a little bit simple.


Stocks summary


Facebook

       Facebook stock, own elaboration with python and Quandl

Facebook is the biggest social network. It enables users to share opinions, ideas, photos, videos, and other activities online. It´s involved in the development of social media applications for people to connect through electronic devices. Its products include Facebook, Instagram, Messenger, WhatsApp, and Oculus. The revenue comes mainly from advertising.

Amazon

         Amazon stock, own elaboration with python and Quandl

It´s engaged in the provision of online retail shopping services  The efficiency of its distribution centers makes difficult to compete with Amazon. In addition, they have Amazon Web that it’s focused on the global sales of computing, storage, database, and AWS service offerings for start-ups, enterprises, government agencies, and academic institutions.

Netflix

        Netflix stock, own elaboration with python and Quandl

This company provides subscription service streaming movies and TV episodes over the Internet and sending DVDs by mail. Netflix obtains content from various studios and other content providers through fixed-fee licenses, revenue sharing agreements and direct purchases.

Google

        Google stock, own elaboration with python and Quandl

Alphabet operates as a holding company with interests in software, health care, transportation and other technologies. It operates through 2 segments: Google and Other Bets segments. The first one includes the following services: Search, Ads, Commerce, Maps, YouTube, Apps, Cloud, Android, Chrome, Google Play as well as hardware products, such as Chromecast, Chromebooks, and Nexus. The other one includes: as Access or Google Fiber, Calico, Nest, Verily, GV, Google Capital, X, and other initiatives.

Individual Stocks

At this point, I believe that you have your own preferences but let´s imagine that we are in 2015. Wouldn’t be better to create a portfolio with all of them?  Also, it´s another way to diversify our portfolio


    Log returns own elaboration using python

We can see how the individual stocks performed in the period. As you can see Netflix has been the more volatile. 


                                                                 Arithmetic Returns of the individual stocks

Google was the worst performer but it doubled in value. I would like to remind you that the Nasdaq index has returned 63% since 2015.
Before we put together all these stocks, let´s check the individual distributions:


             Log return distributions own elaboration

All of them have in common that the extreme observations are positive, which explains in part the reason of the rise in these stocks.

The Portfolio

After reviewing these companies and considering that they have different business units, we decide to create a portfolio. In order to make it simple, we can assign the same weight for each stock, in this case 25% of the initial capital. 

     Portfolio statistics and log returns distribution own elaboration

Considering the long run and this portfolio´ strategy (buy and hold), it´s easy to think that the majority of the daily returns are bigger than zero. This is confirmed by the chart above.
Is it safe to build a portfolio like we have done?  No, some of the reasons are that it´s not properly diversified and the correlation between the assets is positive. Luckily the companies have diversified some of their activities and they are heavily investing in technology which will bring revenue in the future. 
The portfolio return has been 104%.

                                                            Portfolio return own elaboration

Now it's the time to check the risk:

    Portfolio drawdown history, own elaboration

One of my favourites risk metrics is the drawdown. I created this chart showing the portfolio drawdown over the time. The maximum drawdown was 14.10%. This figure surprised me but the main concern is that the stock market raised on a daily basis

Sum up

I hope you like it. We have seen how the main tech portfolio has behaved since 2015. I wouldn’t invest in this kind of portfolio for the reasons mentioned above. In addition, I think that the index rally has been supported by an accommodative monetary policy. Using Python and Quandl has been great and I hope to bring more content in the future. Thanks.

Have a good trading!!


Disclaimer


I wrote this article myself, and it expresses my own opinions that shouldn't be used as a trading advice. Trading carries considerable risk due to the high leverage involved

#Alphabet #Amazon #drawdown #Facebook #FANG #Google #investing #maxdrawdown #Netflix #portfolio #python #quandl #stocks #Trading

Sunday, 3 December 2017

Trading system based on a proprietary indicator Part 1


This is a new concept. I will do three parts to analyze the trading system in a better way and compare it with a benchmark. The idea is introducing the trading system, showing the backtesting (last 5 years), comparing with the 10 years backtesting, studying the system vs the benchmark and applying money management to see how the performance and risk parameters change.

Brief explanation of the trading system


The system is based on a proprietary indicator as you can see in the title. The idea behind this system is mean reversion. The levels are chosen from the study of the returns’ distribution. Does it sound familiar to you? In addition, a strict risk management system has been applied. The maximum loss allowed is 0.5% as we will see in the next points. The trading system trades 1000 shares in each trade (in the future I will apply money management) The initial portfolio

 


Results after the last 5 years (backtesting)



Backtesting statiestics from RStudio and Excel
     Backtesting statistics from RStudio and Excel, own elaboration


As you can see the system makes 95.86 euros on average per trade. I would like to make clear that the system traded 133 trades and the commissions are not included. The maximum profit in a trade was 1650 euros while the biggest loss was limited to 100 euros.  The return was 12750 euros which is the equivalent of 63.75% in 5 years (around 12.75% per year). As you can imagine, considering the strict risk management, the losing trades percentage is higher than the winning trades percentage. But the average winner is higher than the average loss. The Sharpe Ratio is 4.32, which confirms the profitability of the system.



Max Drawdown, own elaboration
                                  Max Drawdown, own elaboration using RStudio


This is the measure that I like the most. The system only loses 925 euros in the worst trading period. If we check in percentage terms, it represents a 3.53% loss. According to the asymmetrical leverage rule with a gain of 3.57%, we offset the loss. This shows the importance of risk management.

Portfolio performance
      Trading system track record, own elaboration using RStudio


Here you can see how the portfolio has been performing. The most important is its consistency.

As a curiosity, performance comparison with different initial capital


comparison

With these numbers, we would be tempted to invest 5000 euros or less. The system doesn’t require a lot of capital. The main problem with a 5000 portfolio is that we will struggle because the costs are not included and we couldn´t trade 1000 shares each time.


Conclusion


This has been the first part of a series of posts about the same trading system. In my opinion, the performance and the risk metrics are good. In the next post, I will review the 10 years backtest. The purpose of that is to check that the system hasn´t been overfitted for the last 5 years and show how it performed in a longer period. I hope that you like it.

Have a good trading!!



Disclaimer


I wrote this article myself, and it expresses my own opinions that shouldn't be used as a trading advice. Trading carries considerable risk due to the high leverage involved



Saturday, 18 November 2017

How can we make a strategy profitable modifying a couple of things?

Nowadays trading is in vogue, even more, if we consider the new cryptocurrency trend. Basically, everyone wants to jump in. The trader lifestyle is desired by all the people. Sadly, trading is harder than what the social media shows. The industry is changing a lot. Concepts such as machine learning, artificial intelligence are taking importance in leading investment banks and hedge funds as they are heavily investing in it.

Why do the biggest companies invest in machine learning, artificial intelligence, and algorithms?


It´s very difficult to replace an experienced trader because he knows how to adapt the strategies in different economic cycles and conditions. Some hedge fund managers are hiring a lot of developers and programmers to create algos that emulate the behaviour of their best traders. This seems really expensive, at least in the first years, but I believe that in the long run will save money for the hedge fund. How can you emulate the trader behaviour? In my humble opinion, I would divide the strategies applied by the trader in little pieces and I will study the trader´s track record in order to study the conditions (price, type of order, macro events on that day, news) of the trades. Once I understand the reasons I will try to replicate its piece of strategy and I will code it. Once it’s coded and tested, I will assign a subaccount to use this strategy and I will do the same process for each strategy. To sum up, I will have a trading account made-up of subaccounts that run a specific strategy. We can say that the main account is the portfolio and the subaccounts are different traders or fund managers.
This process can take a lot of time and some parts can be difficult to replicate.

What aspects should we modify to make a simple strategy profitable?


The strategy is based on the EURUSD futures but I'm not going to explain how it works. The main purpose of this post is to show you how to modify a simple strategy to improve the profitability and reduce the risk. It only trades once a day if the conditions are met. This backtest shows the last 5 years. The initial portfolio was 50000 USD.

Plain strategy



This is the strategy without any modification. 

     Statistics of the strategy, own elaboration using RStudio

The mean is positive and it shows that the system will make on average 16.21 USD per day. Sadly is not that easy, because there are winning days and losing days. The best day it banked a 3250USD profit. On the other hand, the worst day shows a loss of 2440 USD. The Sharpe Ratio is very low. The returns’ distribution was a normal distribution around 0. The main problem is that there were trades that lost a big percentage of the portfolio. This is why I decided to limit the loses in the second strategy. Let’s see the maximum Drawdown.


     Max drawdown and track record of the strategy, own elaboration using RStudio

Any serious investor can’t tolerate this drawdown considering the size of the portfolio. I wouldn’t be confident to use this system after reviewing the track record. Basically, it goes sideways.

Strategy 2, limiting loses


In this case, I decided to limit the loss to 600USD per day. Let’s see if the system has improved or not.



     Statistics of the strategy, own elaboration using RStudio

In general terms, this system is worse than the first one. The system makes 15,19 USD per trade on average, which is  1 dollar less than in the first strategy. The worst loss has been limited but the distribution contains more days on the negative side. The days with big swings generated the most part of the loses. The return is only 19.96% in the backtesting.




     Profit and Loss from trades distribution, own elaboration using RStudio

The losing days are concentrated around the maximum loss allowed.


     Max drawdown and track record of the strategy 2, own elaboration using RStudio

The distribution is not appealing to me. The best thing is that the max drawdown is smaller than in the first strategy. This system is clearly limited by days with big ranges.

Strategy 3, looking for different entries


Once I limited the losses of the first system and I checked that it wasn’t working as I would like it, I decided to change my entries. Will this be the solution?


     Statistics of the strategy, own elaboration using RStudio

Modifying the entries improved a lot the system. Now the system mades 49.88 USD per day. The standard deviation is lower. It would have returned 81.4% in 5 years, around 17% per year. What a change!! The winning days' percentage has increased and the Sharpe Ratio is very good. You should think that the commissions are not included.


    Max drawdown and Track record of the system, own elaboration

This is the best point. Look at the line! Now the system is consistent and the maximum drawdown has decreased a lot.

Conclusion


Even if you have read or heard about a successful trading system, you shouldn’t trade it without testing it before. We have seen that with minor tweaks the strategy can improve a lot. I hope that this post will help you to understand the process. The sky is the limit, in this field, the creativity doesn’t have limits. If you are a professional trader this can help you to test ideas and become more confident. Another important point is that you shouldn’t invest in these strategies even when the statistics are good. You should test them with a paper trading account and compare that the behaviour is similar to the previous backtesting. This is crucial because there is the risk of overfitting. I hope you like.

Have a good trading!



Disclaimer

I wrote this article myself, and it expresses my own opinions that shouldn't be used as a trading advice. Trading carries considerable risk due to the high leverage involved

Sunday, 8 October 2017

Quantitative Strategy FGBL Futures

Some time ago, I was checking some charts when I decided to create an algorithm. The product chosen was the FGBL, the Euro-Bund futures. Basically, I thought that was a relationship between the past and the future. It sounds familiar, doesn't it? I found the historical and I started working on it.
First I run the strategy without any stop or money management strategy but I was disappointed with the results. Sadly I don't have any screenshot of that.
Second, I decided to apply risk management and limit the amount I could lose.
This improved a lot the strategy but I wasn't happy at all. Using my background, reading, and learning, I started applying money management. It had a better risk-reward, but it was riskier. I backtested this system from the 04/01/2016 to the 30/12/2016.
These are a couple of tables that explain some ratios: 

Initial Portfolio
50000 euros
Final Portfolio
77140 euros
Annual Return
54,28%
Positive days
457
Negative days
548
Positive trades (% of the total)
44,46%
Negative trades (% of the total)
53,31%
Mathematical Expectancy
9,1299
Positive days average
192,36 euros
Negative days average
-143,99euros
Max Drawdown
28,55%












Portfolio value
Lots
Max risk per trade
40000 euros
3
1.5%
60000 euros
4
1.33%
80000 euros
5
1.25%
Please have in mind that I haven't included the cost of trading (execution costs, market data, trading platform) I believe that the execution cost would be around 12-13k, so the profit would be half of the figure shown above. It's riskier than a normal hedge fund because they normally have less than 20% drawdown. The asymmetric leverage is really important. I've never traded with this system and I can adjust the risk management and the money management to meet certain goals. I should have backtested at least 5 years and then do the out of sample to check that it behaves like the backtested sample. This is only an example of how to design a trading system. 

Disclaimer

I wrote this article myself, and it expresses my own opinions that shouldn't be used as a trading advice. Trading carries considerable risk due to the high leverages involved

 

8th day small profit that helps me to keep going in the competition

After a successful week and most importantly from recovering almost $6k, I wanted to consolidate my positive results. My desire was to b...