Algorithmic Trading from Home: Building a Reliable Linux Server

A few weeks ago I closed all of my Metatrader 4 accounts in order to start trading outside of this unprofessional trading platform. Using the Oanda Java API – which I access using the Asirikuy Trader python front-end – the possibility to move outside of Windows has also become a reality.  Trading from Linux is something I have always wanted since the Linux operating system offers a much higher level of stability with a much more powerful console implementation and open source solutions for an extremely wide array of applications. Today I am going to talk about the setup of my Linux trading server for algorithmic trading, why I decided to set it up here instead of using an online Virtual Private Server (VPS), which precautions I had to care about and which distribution and system specifications I have decided to use for this setup. After reading this article you should be able to analyse whether a Linux home trading server is the right choice for you and what you need to take into account before moving in this direction.

When deciding to move away from Windows and into a Linux trading server, the first thing I considered was to migrate my trading to a VPS setup similar to the Windows setup I was previously using. Linux VPS are usually cheaper or the same price for the same technical specifications so it seemed like a good idea to migrate to a Linux server. However upon reviewing the commercial offerings available I quickly noticed some problems with what was available, Linux VPS offered only single core implementations (for the same price as windows dual core ones) and – more importantly – these VPS implementations were thought more for web hosting than for hosting processor intensive software implementations like those I intended to use for trading. While the Windows VPS commercial offering has adapted to offer solutions catering to what traders using MT4 need, the Linux VPS offering has been limited to offering what the web hosting community demands (which is what the Linux VPS are most often used for).

Since I was going to be paying about 300 USD a month in servers (to host all the accounts I wanted to trade), it became evident that a home solution might be cheaper and more suitable to my needs. Using our trading setups the RAM consumption per account is around 30-80 MB while the processing needs vary depending on the strategies used with most accounts consuming roughly less than 10% of an intel i7 processor when they are executed (roughly every 30 seconds). For the amount of accounts I want to trade an intel i7 processor (which is a quad core) with 8GB of RAM seemed ideal. I also decided to go with a solid state drive (100 GB) in order to have reliable storage. The computer is connected directly to my internet router using an ethernet cable (no wifi to increase reliability) and I have also added a 4G modem (about 30 USD/month) in order to provide internet access whenever my primary connection is down. The computer is also connected to a UPS (Universal Power Supply) that contains enough charge to allow for about 2 hours of sustained use if the power goes out. Electricity costs for this server setup should be about 25 USD/month where I live, so total costs are around 55 USD/month including the secondary internet option.

Regarding the operating system, I decided to setup Linux Mint instead of Ubuntu (to avoid some of Canonical’s bloatware), which provides a similar look-and-feel without some of the added unnecessary complexities of Ubuntu for the setup I wanted. I also decided to go with a desktop type distribution instead of a hard-core server distribution because I still want to be able to have a good level of regular user usability (like a user-interface, etc). The computer is connected to one of my screens and keyboard/mouse through a KVM (Keyboard-Video-Mouse switch), which allows me to access this computer whenever I want without having a completely separate setup. Installation of all my trading software went without any issues. I was able to compile F4 without any problems (as I have done on Ubuntu for a while) and launch the Asirikuy Trader program to connect with the Oanda trading servers via the Java API. I have also setup a BitTorrent Sync service so that I can backup everything during the week-end (clearly backups during the week aren’t ideal due to the constant log writing of the trading instances) and I have also added all my accounts to the system startup (via a simple script). After all this setup I still have a good chunk of my hard drive (+50%) free, so the 100GB choice was just right for what I wanted to achieve.

Linux_tux_mocking_windows_by_HuffyLigator

The above setup seems to be very robust. The Asirikuy Trader is a very slick console application that is only concerned with algorithmic execution (no bloatware like MT4 with its marketplace, charts, etc) so trading systems are ran in a much more efficient manner. The program is also executed within a bash shell loop, so any exceptions that may cause the program to crash are easily recovered from by simply launching the program again. The Asirikuy Trader also contains emailing functionality so I can easily receive emails in case of any failure or problem with any of the trading instances (like disconnections or other such problems). Right now I am testing demo implementations of all the setups I want to trade live in order to iron out any issues before moving into actual live trading. Up to now execution has been completely in-line with my expectations, finally giving me that professional trading setup feeling I had always been looking for – but never found – with Metatrader 4.

From this experience I have to say that the cost/control/reliability of a Linux trading server implementation can be just as good as that of a Linux VPS, provided that you care for things such as internet connection redundancy, backups and power redundancy. In the case of Windows VPS implementations this difference is not so strong because the Windows market has already adapted significantly to the needs of the Metatrader community (therefore providing good performance/price ratios for these needs) but in the Linux market I failed to find a powerful solution that offered me an acceptable performance to price ratio. Another thing worth considering is server latency, if you’re far away from the trading server and you’re trading systems that operate at a higher frequency then trading closer to the source (which an adequate VPS host can give you) might be completely worth the additional price to pay. In my case the savings are tremendous, from paying what would cost 300 USD/month I ended up paying significantly less than 100 USD. With the initial price of the computer setup (around 600 USD), the investment will be completely worth it after a few months. That said, I am happy to say that I am now MT4 free!

The truth is that a Windows/Linux VPS is not always worth it. Depending on the connection speed, power costs, redundant internet connection costs, computer costs, etc, a local solution might be much better than a remotely hosted solution. This might not be true when you consider the cheapest VPS solutions (like the horrible VPSLand) but trading from this type of hosting is completely crazy as their level of reliability is extremely low (see my open later to VPSLand). It is also true that if your power costs are high then a good Windows VPS (like with accuwebhosting) might make more sense. If you would like to learn more about trading outside of MT4 and how you too can build your own trading portfolio to trade from Linux  please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)

 

 

Print Friendly
You can leave a response, or trackback from your own site.

9 Responses to “Algorithmic Trading from Home: Building a Reliable Linux Server”

  1. Sebastiano Pilla says:

    Did you consider a dedicated server instead of a VPS? There are many providers (Hetzner for example) that offer dedicated servers with much better connectivity and power that anything you can attain with a home setup.

    • admin says:

      Hi Sebastiano,

      Yes, I considered that but the cost would be about 300 USD/month for what I need, therefore it isn’t worth the gain in connectivity since my setups are not overly sensitive to execution timing. As I say under some circumstances it might be worth it to pay the extra cost, but at least in my case it’s not worth it. Thanks for commenting!

      Best Regards,

      Daniel

  2. Dekalog says:

    Nice one! I have been an exclusively Linux only user for years and am now currently running Linux Mint Debian Edition. To encourage your readers to make the change to Linux might I recommend this course from the Linux Foundation – https://www.edx.org/course/linuxfoundationx/linuxfoundationx-lfs101x-introduction-1621

  3. Bob says:

    “Since I was going to be paying about 300 USD a month in servers (to host all the accounts I wanted to trade), ”

    I don’t understand this at all. Why paying monthly fee for servers. Couldn’t you before MT4 from a home server and send the orders through? You systems look quite simple to me to require anything else and collocation is not an issue. Why couldn’t you trade you systems with a fast hole computer and a fast internet connection but you required servers?

    • admin says:

      Hi Bob,

      Thanks for commenting :o) The issue for me with MT4 was simply that the cost of electricity needed to run the MT4 implementations I needed (more than 60) on home computers was much more than the cost of servers. With Windows VPS and MT4 it was simply a cheaper decision to run MT4 from online servers than from a home setup. Let me know if you have other questions!

      Best Regards,

      Daniel

      • BOb says:

        Thanks…and how is your bill going to be lower with Linux? There is no free lunch. How can Linux lower your requirement for hardware? This is not clear from your post.

        By the way I think there is a 6-core i7.

        • admin says:

          Hi Bob,

          The thing is that the Linux implementations are much more efficient compared to the MT4 implementations so I can run many more systems from the same hardware (since I don’t need all the MT4 bloatware). Clearly if I was staying with Mt4 this wouldn’t be possible (especially with the latest builds that consume even more memory/CPU). I hope this clears it up :o)

          Best Regards,

          Daniel

          PS: Thanks for tip on the 6-core i7, I’ll search for it!

  4. Jon says:

    I do know that Commercial Network Services does allow linux to be installed on their vps. You have to contact them privately for that. http://tinyurl.com/cnsvpsaf

    I use them for their windows 2008 implementation in NYC datacenter. Honestly, I wouldn’t trust the internet/power from home….much safer in a datacenter with no forced reboots and very low latency to broker as the majority of them will have servers in New York, London, or maybe Chicago….although I think even the CME has servers in NYC as well.

    CNS has SSD drives + i7 processors (dual, quad, or octa core) depending on what you want.

    • Jon says:

      I cannot edit my comment, but I wanted to add that the primary reason why linux VPS servers have not been competitive is because there is such little demand from them from the retail trading community. How many linux GUI trading platforms do you know of? MacOSX? Windows I bet you can list 5 off the top of your head. It’s just the way it is, although I’m sure if one were built for linux/osx it would probably be much more stable, scale-able and, cheaper to maintain that the windows equivalent.

      We’ll see what happens as Asirikuy becomes more popular.

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!
Show Buttons
Hide Buttons