This post is a technical description on how to set up Amibroker on EC2. For licencing Amibroker running on EC2 or another VPS contact amibroker.com.
This is a rough guide on how to setup Amibroker to run on an Amazon EC2 micro instance.
Turns out, Amibroker runs fast even on this tiny micro instance.
Amazon provides one year free access to a basic micro instance to new users. It’s their way to let new people try out their services.
In a nutshell, setting up an EC2 instance is like setting up a small PC on the cloud. You can install anything on this PC. You can choose the base OS and then configure this virtual PC as needed.
I wanted to setup a “virtual” PC that would use Amibroker to run analysis and generate signals for my EOD trading as well as auto-trade some paper systems on YoutualFunds.com. It would replace my laptop at home that does that every night.
I also wanted to try an alternative to running trading systems through Scripts on Google Docs.
You need to sign up for an account with Amazon.com unless you already have one. Even if you run the free micro instance, you will need to give out your credit card to Amazon.
Please review Amazon’s offering. It should be enough to run free for a year.
If you exceed the quota they give you, you will be charged.
Sett up the instance. I personally used the Windows 2008 32bit AMI, but I guess you can use the Windows 2008 64bit R2 one. The lighter the package, the better since the micro instance has minimal RAM and CPU power. Please watch this video. It will guide you through the steps:
(Start from the middle of the video where he sets up the actual instance).
If you don’t like videos you can read this how to guide:
The default Security Group does not allow Remote Desktop Connection.
When you get at the part of setting security groups, edit the default group and add port 3389 inside the “Port Range”. Press “Add Rule’. This will open up the port for Remote Desktop Connection which is the non-programmer’s way of controlling your remote PC. You can leave Source as is unless you have a static IP and are concerned over security.
Once you have set up port 3389 access you have the minimum to continue. Optionally you can open additional ports (SSH, FTP, etc).
Assuming you have followed the video tutorial you have now a micro instance running on EC2.
1. Connect to the instance using Remote Desktop Connection. Best way is to go to the AWS control panel, right click on the instance and choose Connect. This will download a file and fire up RDC with the right settings. Alternatively, start RDC (Start—>search “remote”) and point it to the instance’s public IP address.
Choose “options” and type “Administrator” under User. Connect. Type in your instance’s administrator password when asked. A window should open with your new desktop.
2. At this point, I was asked to setup my network as Home, Work or Public. I chose Public. That brought problems and caused Internet Explorer to refuse to download stuff… So… I downloaded Firefox.
3. Get Firefox: Start Internet Explorer from the Start Menu. Navigate to “http://www.mozilla.org/en-US/” and download Firefox. If IE refuses, try adding www.mozilla.org to the trusted sites.
4. Get Amibroker: After you install Firefox, launch it and go to http://www.amibroker.com/download.html. Download the official version. Go to the Download folder and launch the installer. Amibroker will install as usual.
7. * Please check with amibroker.com for proper licencing terms.
Send a LostKey request to Amibroker: Assuming you have a valid license, go back to your regular computer (hide the RDC window). Navigate to http://www.amibroker.com/lostkey.html and fill the form. Check your email. Copy the address that was sent to you (highlight it and right click copy).
8. License Amibroker: Now go back to the instance window. Open Firefox (in the instance) if it’s not open. Paste the address that was send on the email. Hit Enter. Check your Download folder for a small file. Double click it. This will authorize Amibroker under you existing license.
Now if you want to transfer files from your computer to your instance, the easiest way is by copy/paste. Select a file (or folder) in your computer desktop and right-click “Copy”. Now go to the instance desktop, right-click “Paste”. That simple.
If you have large files/folders to transfer, copy /paste takes forever. Another way is to set up a Dropbox or SugarSync account and upload your files there. Then from the Instance, turn your browser to that account and download into the instance (at a faster speed since you are using Amazon bandwidth ). Keep in mind that incoming traffic seems to be free, but you do get charged for outward traffic, after a certain quota is reached.
If you want to schedule tasks or custom Jscripts or VBScripts you will have to use the Windows Task Scheduler. Setting that up is more complicated than in your home PC.
Note1: For JScripts,”WScript.Echo()” does not seem to work as expected. You can use:
var WshShell= new ActiveXObject(“Wscript.Shell”);
WshShell.Popup (“Backtest has run”, 5);
Note2: If you are sending emails from the instance, keep in mind Amazon has restrictions on outgoing emails. My Jscript that calls CDO to email, failed because of that. Check Amazon’s aws FAQ for more info.
Note 3: For the Task Scheduler: I am still working on the setup. So far I can advise you that you will need to:
a. Provide a static “computer name” to your instance since the assigned name (i.e. IP-xxxx) changes every time you reboot. Here’s how to do that:
b. Test the tasks using the default basic settings “Run only if User is logged In” This way you can “see” them running and check the Popup messages.
c. Eventually, the instance should run unattended whether logged in or not. You need to change the settings so that the Task runs “Wether User Logged In or Not” and use “Highest Privileges”.
Now, here’s the tricky part: If you try to test a JScript with these settings, you may not see any feedback or Popups while you are logged in. This does not mean it is not running! You may need other ways to monitor. Feel free to contribute on how to do that…
What is left to do:
The initial idea was to set up a EC2 instance that would START up, run for 1 hour ONLY, update quotes, run backtests/exploration, email the trading signals and then STOP. That would translate into less than 30 hours/month EC2 usage time or less than $5 for a Small Windows instance. And even less for a micro.
Turns out, there is no easy way to schedule the instance to START at a certain time (the stopping part can be scheduled inside the instance). I hope a solution is found before the free tier offer expires. The cloud can get very expensive…
Any ideas or suggestions are welcome.