Thursday, October 7, 2021

Trading212 ISA: A Brilliant Choice Brilliantly Ignored!

 As far as tax saving schemes are concerned, Stock & Shares ISAs are an amazing value for money for knowledgeable retail investors. £20,000 of investment tax free forever: it doesn’t get better than that. Of course, equity investments come with the risk of loss, but if you are confident in your investing abilities, that is not an issue. With this in mind, I started looking around to find a suitable platform. My key criteria were:

·       Low or no fees: transaction and platform fees eat into profits, so it is reasonable to try to keep them as low as possible

·       Wide variety of stocks and ETFs available for trading

·       No frills account with no advice required

The end result was me opening my account with Trading212. And why not? Zero transaction fees, zero platform fees, a large selection of stocks and ETFs, no dealing fees for either stocks or ETFs, fractional shares, no minimum investment level, no annual/monthly fees and a reasonably responsive customer services team. There is a low 0.15% FX fees on foreign currency instruments, but that is a breeze when compared to the kind of horrendous fees other players charge. I have heard a few people complain about the speed of execution, but that is generally not such a big issue if one is looking for long term investment.

What I did find a bit amusing was that of the top 10 non-sponsored links that Google spits out when I search for “best stocks and shares isa”, only one (Times) mentions Trading212, and even then it mentions incorrectly that “you can only invest in a limited number of stocks and shares across various global markets”. At the date of this article, Trading212 offers more than 10,000 stocks and ETFs across the global markets. It also provides access to several investment trusts and IPOs. In comparison, for the best ISA as recommended by Times, Barclays, I was not able to even clearly see that how many stocks were available. Plus, with £6 per trade for stocks and £3 for funds, it could not possibly be more unappealing. One can only wonder how independent these compilations really are…

So, as an outraged happy customer I thought it was only fair to post an article to try to correct the balance somewhat. Assuming you want to deal with shares and ETFs, and are looking for long term investment, I would highly recommend Trading212.

Monday, June 22, 2020

Artificial Intelligence for Trading : Course Review

Udacity was offering the nanodegree Artificial Intelligence for Trading free for a month. This was too good an offer to not sample the course. The expected time to complete the course is c.6months @10 hours a week. I just zipped along as fast as I can with focus on finishing the maximum amount within 1 month.

Pros:

  • Exhaustive course with a lot of material, code and practical projects to do. The course, as expected of a nanodegree, is detailed and deep dives into a lot of theoretical, practical and technical background
  • Introduces you to Factor Investing and how to use AI for it
  • Good course for people looking to work in industry as gives detailed understanding of what being a quant involves
  • Like the ISB course I finished earlier, this course highlights the importance of academic research papers in the quest for alpha
  • Provides an excellent starting point and references, which I think a reasonably informed participant could build upon as they gain more experience

Cons:

  • The modules in both terms start as too easy and then suddenly the difficulty level goes through the roof somewhere after the midpoint. The course would anyway be extremely hard for people with no background in technology and finance, so an intermediate level start gradually building up the difficulty could be better
  • The projects that use zipline at end of term 1 have build problems, something I saw was very common in discussion boards. I could not complete the fourth project simply because it would not build and (given the speed of my review) I had no time looking for solutions. Given the course is pricey at $300/month, I would expect the assignments to work with minimal problem
  • Very less practical application for retail traders looking to set up their own operation as it is more targeted towards an audience aspiring to become a Quant in the industry. Also, while the content is reasonably good, I think you will be able to find similar or better content cheaper elsewhere.

A lot of exercises in the second half of term 1 use zipline, which I reckon is the key reason behind the errors I referred to earlier. Further, to use it independently you may need to buy/ subscribe to a data source and spend time understanding zipline. That does not take away the usefulness of the lessons though. If you are not a fan of zipline, a quick Google search shows some open source alternatives to zipline: Ultra Finance, PyAlgoTrade, BackTrader.

Term 2 covers quite some ground. Unfortunately for course content creators advances in web technology means that you can pretty much not send requests from a computer to a website like before. A few lessons are outdated due to this simple reason.

Overall, a reasonably good course if you want to be a Quant, but not so for a retail trader.

Saturday, May 23, 2020

Python for Finance: Book Review

Python for Finance by Yves Hilpisch is an ambitious, reasonably priced book published by a reputable publishing house on the topic of Algorithmic Trading with Python. I think it provides an excellent starting point and ideas for people trying to get a grip on what it would take to set up an algorithmic trading infrastructure.

The book caters to intermediate and advanced level students, which means you would need at least some coding ability and a decent understanding of financial markets to be able to benefit from this book. Many topics touched upon merit a book on their own, therefore the text is practically brief with the intention of introducing the user to key concepts and further related resources. I especially like the way the author touches upon the theory without getting carried away, keeping the right balance between telling the reader what is happening without theoretical overload, all the while providing working Python examples. Most of the code used in the book can be found in its accompanying website.

Now for a detailed book review/ my advice on how to get the best out of it:
  • If you have experience with Python, you can skim through the first six chapters. Second chapter has some interesting information regarding infrastructure, but it is highly unlikely to be applicable to a single man retail trader army when you are starting up. At certain point you may need to host the development on cloud, for which learning to deploy Jupyter notebook server should suffice. If you are not familiar with Python object model, worth reading the summary in the end of Chapter 6
  • Chapter 7 to 13 digs into many tools and techniques that you may need as a quant. Even if you are an experienced quant, the chapters are still worth a quick read, even if only to get to ideas/validation on efficient Pythonic implementations of some useful mathematical tools. If your algorithms are going to be relatively simple and will not delve into complex derivatives, portfolio management or machine learning, you can more or less skip chapters 11, 12 and 13.
  • Chapter 14 to 16 is where, so to say, the tyre meets the road. For me, this is the highlight of the book as it details how the get tick data and trade using Python in the real world and backtest/ develop your strategy
  • I did not read chapter 17 onwards as I do not plan to do deal with trading and valuation of complex derivatives

Thursday, May 21, 2020

Getting FXCM Working With Python

While I will do a full review on Python for Finance once I am done with the book, enroute I will keep sharing some items I feel may be useful.

In chapter 14 the author demonstrates how a python program can connect to an online broker, FXCM. Just sharing detailed steps on how I got the API token.

1. Sign up for the demo account as suggested by the book. You will receive an email with a password.

2. Sign into your demo account, which for me looked as below:


3. Click the part highlighted in the picture above to bring up a context menu (shown below) and click “Token Management”.


4. You should see a dialog similar to the snapshot below. Enter the password you got on your email to generate the REST API token.


While the book recommends FXCM, I know that Oanda also provides a python wrapper. I won't be using FXCM as at the time of the blog it supported only currencies for algorithmic trading, while I was looking for indices. Only following currency pairs are supported:

('AUDCAD', 'AUDCHF', 'AUDJPY', 'AUDNZD', 'CADCHF', 'EURAUD', 'EURCHF', 'EURGBP', 'EURJPY', 'EURUSD', 'GBPCHF', 'GBPJPY', 'GBPNZD', 'GBPUSD', 'GBPCHF', 'GBPJPY', 'GBPNZD', 'NZDCAD', 'NZDCHF', 'NZDJPY', 'NZDUSD', 'USDCAD', 'USDCHF', 'USDJPY')

For fxcmpy to work, You would need the python-socketio installed.

Also, for In[1] on page 470, I could not get "from pylab import mpl, plt" to work. Changing to "from matplotlib.pylab import mpl, plt" fixed the problem for me.

Wednesday, May 20, 2020

Trading Algorithms

Algorithmic Trading is an exciting proposition. Who wouldn't like to create a machine that could earn while they watch? The honest traders will tell you upfront that there are easier ways to make (lose) money. There are big banks, some very smart/ well connected hedge funds and tech behemoths out there who would have, in all probability, done what you are trying to do on your own. So, does a retail algorithmic trader stand a chance? Honestly, at this point I don't know but I would like to find out. I will not be spending any large sums of money any time soon, as I would keep my learning path limited to reasonably priced books and courses (say, anything less than £100) and trading limited to demo accounts. I will chronicle my journey in this blog and hope that it helps other people take informed decision.

So far I am exploring options on online learning and books. Rather than dumping you with all results from Google search, I will write only about things I have completed myself, including any difficulties I faced. To start with I will write about the specialisation "Trading Strategies in Emerging Markets Specialisation" on Coursera. I targeted this as it had a section on trading algorithms and good reviews.

The course focuses on how to derive algorithms from research papers and does a good job of it. Over the specialisation they take you through 5 papers and teach you how to create an effective strategy using it. We also learn about key portfolio performance measurement techniques. These ideas are good as they are backed by some solid research and not rudimentary technical analysis. This alone makes it worth taking the course. Additionally, if you have a background in finance, the courses are fairly easy to finish faster. While this 5 course specialisation is supposed to run over 5 months, I was able to complete it in less than 2 weeks. Even if you take 2 months, this will cost you c.£80 (they charge per month). Good value for money.

On the flip side, the course has nothing about setting up computing or trading infrastructure, or how to easily get and process the data for the strategies suggested. Procuring latest research papers would also have a cost that a retail trader may not be able to bear. You can't get everything, can you?

Thursday, May 14, 2020

Setting up Docker on Windows

Further to the last blog, I am also summarising how I got Docker to work as mentioned in Python for Finance book.

The first problem I faced was that I was trying to build a linux container while I had built my text file in windows. After typing out and saving the file in the appropriate folder, I used Dos2Unix converter so that my files run without any issues.

Second, what does a dockerfile look like? What is the extension? I installed a sample container from docker installation and copied the dockerfile, which I then changed per book's instructions.
Finally, I edited the dockerfile provided by book a tiny bit to get to a version that worked for me. You can use the install file from previous blog minus the setup for Jupyter notebook server to accompany the dockerfile.

Wednesday, May 13, 2020

Setting up remote Jupyter Notebook

I have recently started reading the book Python for Finance. In chapter 2 the writer explains how to use Docker for professional development and Digital Ocean to run a remote Jupyter Notebook for cloud based development. The scripts provided in the book are good for linux but throw a host of problems when working with windows. Thought will compile a list of issues to watch for. Also the online portal for the book does not provide the scripts in a file, so providing those as well to save you some typing. I assume you have the book for reference.

Firstly, I was not able to use the script in example 2.5 to set up a Droplet. So, I followed the following steps:
  1. Used PuttyGen to generate an SSH key (see footnote on example 2.5 page)
  2. Add the public key to your Digital Ocean Account (Account>Settings>Security)
  3. Set up the Droplet as prescribed in the book, using the SSH key we added above
  4. Turn on your Droplet and open the console. Create a shell file using the editor of your choice which should look like this. Note this will ask for your input to create RSA keys.
  5. Bash the file as "bash install.sh"
  6. Under /root/.jupyter, you can update the jupyter_notebook_config.py file as per the guidance provided in the book. Activate the conda shell as "source activate -py4fi" and start the Jupyter notebook manually with command "jupyter notebook --allow-root". This should get you running. To turn off your droplet use "poweroff" command from the console to avoid any data loss.
AN issue I faced on digital ocean:
The command line interface can sometimes get stuck with caps lock such that whatever you write or paste is in CAPS

Also, I may point out that setting up a secure Jupyter server may be a bit more involved than what we see in the book, as you can find on the official website. I would advise looking at the auto-generated file, which is quite descriptive.

Friday, November 8, 2019

Chaikin Money Flow in MQL

Dabbling with MQL, here is my take on Chaikin Money Flow, adapted from Forex Indicators. Happy for suggestions/ any pointers if you think this is incorrect.

#property copyright "Copyright 2019, Saveen Kumar"
#property copyright "Copyright 2019, Saveen Kumar"
#property link      "https://www.linkedin.com/in/saveenkumar/"
#property version   "1.00"
#property strict

//indicator properties
#property indicator_separate_window
#property indicator_buffers     1
#property indicator_color1      Magenta
#property indicator_level1      0
#property indicator_levelstyle  STYLE_DOT
#property indicator_levelcolor  Black

//indicator inputs
extern int    CMFPeriod = 20; //period for CMF

//buffers
double CMFLineBuffer[]; //for line, value of actual CMF

//+---------------------------------------------------+
//| Custom indicator initialization function          |
//+---------------------------------------------------+
int OnInit()
  {
   //--- check if  CMF period is acceptable
   if(CMFPeriod<2)
    {
     Print("CMF period needs to be more than 2");
      return(INIT_FAILED);
    }
  
   //set up the buffer
    IndicatorBuffers(indicator_buffers); 
    SetIndexStyle(0, DRAW_LINE); 
    SetIndexBuffer(0, CMFLineBuffer);     
   
    //show labels if wanted
    SetIndexLabel(0, "CMF"); 
    IndicatorShortName("CMF (" + 
              IntegerToString(CMFPeriod) +")");
          
    //begin drawing
    SetIndexDrawBegin(0,CMFPeriod);
   
    return(INIT_SUCCEEDED);
  }
//+-------------------------------------------------+
//| Custom indicator iteration function             |
//+-------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {         
         //need minimum bars
         if(rates_total<=CMFPeriod) return(0);
                       
         //the number of bars to calculate in 
         //this iteration
         int limit=0;
      
         //if bars calculated are less than the
         //CMF period, buffer value up to the
         //period will be zero and we begin our
         //calculation of CMF after these
         //initial zero bars
         if(prev_calculated <= CMFPeriod)
         {
            for(int i=1;i<=CMFPeriod;i++) 
            {
               CMFLineBuffer[rates_total-i]=0.0;
            }
            limit=rates_total-CMFPeriod;        
         }
         //if more than CMF period bars already 
         //calculated, start after them  
         else{
            limit=rates_total-prev_calculated;
         }
        
         //main loop, where we are calculating  
         //only as many bars as are absolutely 
         //necessary        
         for(int i=0;i<=limit;i++)
         {
            double ADSum = 0.0;
            double VolSum = 0.0;
            
            for(int j=0;j0)
                  ADSum += tick_volume[i+j]*
                            (close[i+j]-open[j+i])/
                            (high[i+j]-low[i+j]);  
            }
            CMFLineBuffer[i]= ADSum/VolSum;
         }
         
      return(rates_total);   
     
      
  }

Trading212 ISA: A Brilliant Choice Brilliantly Ignored!

 As far as tax saving schemes are concerned, Stock & Shares ISAs are an amazing value for money for knowledgeable retail investors. £20,...