Monday, September 26, 2016

Intraday trading algorithm - 2

Hello, welcome back to my blog about automated trading. This time I am going to see if there is some way how to extend algorithm from this post.

For the source code, please download repository and update to branch 21-algo_implementation-5, changeset b4eb575aecd0. For this time as example depends on intrady quotes which I can't give to you. So you will need to either fill in your own credentials to mbTrading data provider or make your own implementation of the historical data. Otherwise you can just get an inspiration from the code.

Algorithm

The whole idea behind this algorithm is to take the one from the previous post and extend it for multiple symbols. Theory behind is that more trades will be done. And as there are stocks which are cheaper than Microsoft, then bigger volume can be purchared and therefore more profit can be gained.

Implementation is under class DayTradeAlgo2 and test application is DayTradeAlgo2TestApp. Remember to put your credentials in, otherwise it won't run. Just note I have renamed the old implementation to DayTradeAlgo1 with related test application.

Results

I have set up 3 back tests. All of them have same parameters.
  • Start date - March 27, 2016
  • End date - September 26, 2016
  • Initial capital - $30.000
  • Transaction cost - $10
First is with previous intrady algorthm (1), second with current algorithm (2) and third with long term algorithm (3). Now following the charts with results.

(1) old day trade algo - final result $30.238

(2) new day trade algo - final result $32.363

(3) long term algo - final result $35.678

To make conclusion. I personally prefer to stay away from day trading. And results from the backtests giving me stronger confidence. I can see that new version of day trading algorithm might peform better. When I was playing with this a little more, then the discovery was that wrong stock selection will lead to the big loses as well. Even when day trading. So be carefull. The best seems to choose stocks which follows some regular patterns. This opens a question. How to decide whether stock is following regular patterns or not? Will return to this question sometime later.

That's it for today. Next time I am going to revisit the risk model for long term algorithm. Thank you for reading!

Monday, September 12, 2016

Funky time

Hello, welcome back to my blog about automated trading. Last time I presented algo based on the company rating. Then there was an event calle TechInAsia and I attended it. It was a lot of work and on the other hand pretty fun. So I decided to take this post easy and just share experience.

My friend Ivo Barteček was kind and took my project under the wings of his WikiLook株式会社 so I was able to attend this event. Main point was to discover that 90% of people would never care about such project, 9% found it curious, stop by and walk away. Then finally there was this 1% for who this was interesting. And this is the group to focus on.

First day - speed dating. First day I went with Ivo for the speed dating to pitch my project to the investors. Every project has exactly 5 minutes for presentation in front of investor. This must be enough to catch the attention and make follow up later. In total we were able to meet 4 investors and one of them came back after and we agreed to make a follow up.

Second day - booth. We made a presentations of our projects. This is actually pretty good way how to contact many people in the short time. Especially there are startups which are hiring so if you want to get a job, then this is a way how to walk around the standardized recruiting process. And it ended up by drinknig party.

After the event my creativity part started working out so I have decide to create a promotional video. It ended up to be pretty scammy, but why not.


I DO NOT recommend to use this for presentation to the unknown audience. How would you rate this?

Next time I will get back to track and continue with trading algorithms.

If you have any question or just want me to look for any topic, please let feel free to contact me at radek.hecl@gmail.com. My promise is to give the honest answer without BS.

Thank you for reading!

Monday, September 5, 2016

Rating based algo

Hello, welcome back to my blog about automated trading. Last time I summarized the experience after 2 months of trading with real money. This week I am going to present the trading strategy based on previously discussed company rating.

For the full source code, please download repository and update to branch 20-algo_implementation-4, changeset c4d0c7ebdae5.

Theory behind

This strategy works on the very simple principle. The total available budget is split into N equal dolar amount and each of this portion is expected to be invested in one stock (later discussed how this is selected). Then the stop loss and take profit limits are set up simply when the price moves by 50% (risk reward is 1:1 in this case). Once any stock is sold then the money will be reinvested in another company as soon as there is budget for it. Theory is that if the company selection is good, then I should be getting more wins than losses and therefore be in the profit over the long period of time.

Regarding the stock selection. I ordered them by this rating. Then buy first N from that list.

Coding and results

Algo implementation implemented as RatingAlgo1 and test application as RatingAlgo1TestApp. Please feel free to run it and expect it will take some time to complete, because the whole process is downloading more than 7000 pages.

Here is the test set up:
  • Start date - September 5, 2015
  • End date - September 5, 2016
  • Initial capital - $30.000
  • Transaction cost - $10
  • Risk per trade - $1.000 (determines size of order for each stock)
And I got the result +20.5% (this means approx. $36000 at the end). This is not that bad for the first blind shoot. I haven't try any analysis, parameter optimization or whatever funky improvement. Also please note that there is survivorship and fundamental bias (I don't have data to get rid of them. If you can tell me how to get rid of these, then please...).

So what I will do next. I will improve my platform to be able run backtests with this strategy more efficiently. I will also set up this alorithm for the forward test. This way I will get more accurate result over the time.

That's it for today. Next time I am going to focus on the previously discussed intraday trading algorithm. I want to improve it and make sure that at least one trade is opened every day.

If you have any question or just want me to look for any topic, please let feel free to contact me at radek.hecl@gmail.com. My promise is to give the honest answer without BS.

Thank you for reading!