Click here to Login

Running QuantShare on Amazon's EC2 Cloud & Automate Strategies Signals

Updated on 2012-10-26

A big thanks to Touini, who send us this case study on how to run QuantShare on the cloud (Amazon's EC2 Instance) and use that instance to generate signals for your trading strategies.

Part1: Setting up QS on EC2

What is Amazon's EC2 and why would one want to run QuantShare "on the cloud"?

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 (Windows, Linux, etc.) and then configure this virtual PC as needed. We will be using Windows OS and installing Quantshare.

Potential reasons why it could be beneficial to run QuantShare on the cloud are:
1.      Have access to QuantShare from your ipad or iphone, anywhere in the world.

2.      Schedule the downloaders and build the databases on the cloud without human intervention. Use SugarSync or Dropbox to "sync" the updated database to all home and office computers.

3.      Automate generation of Buy/Sell signals. This includes e-mailing oneself the trading signals, running a trading advisory service or generating orders to sites like All without being at home and worrying about power/internet failures.

4.       Auto-trade an account. This is the most interesting application for real time traders. Especially mid-budget traders that are located outside the U.S., or suffer from bad internet connectivity and cannot afford to co-locate.

Let's start by setting up a virtual PC. There are many providers for cloud computing. We will be taking advantage of the Amazon current offer of one year free access to a basic micro instance to new users.

The micro instance is the smallest instance running at a virtual 1 Ghz, 613 MB Ram. It's not a lot of power but it's enough to run QuantShare and perform some basic tasks.


1.      You need to sign up for an account with 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. 2.

Set up the instance. I 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.

I will not go through the basic setup. This video 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":

keep in mind, the default Security Group does not allow for a 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.

2.       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.

3.      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.

4.      (optional) Get Firefox: Start Internet Explorer from the Start Menu. Navigate to "" and download Firefox. If IE refuses, try adding to the trusted sites.

Now if you want to transfer a few 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. A better way is to set up
a Dropbox or SugarSync account and upload files there. Then from the Instance, we turn our browser to the SugarSync (or Dropbox) site, log in and download the larger files into the instance (at a faster speed since you are using Amazon's 100MB 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.

You can set up QuantShare with Dropbox or SugarSync so that your home computer QS and the EC2 cloud QS are in sync. I will not go into that here. You are welcome to try.

Either way, open QuantShare folder, find QuantShare.exe, make an alias and place it on the Desktop for easy access. Launch QuantShare. Type in your user name and password, choose auto log in and hit ok.

If everything went well, Quantshare is running.

We can reach our virtual PC from our IPad, too. There are many Remote Clients for the IPad. I use Irdesktop.

Part2: Automate Trading Signals from Portfolio Strategies

We will create 4 scripts:

Go to Tools-->Scripts Editor and write a script that calls a downloader to update today's quotes. I use the Daily Stock Quotes downloader.You should edit the script according to your needs. The script has only one line.

Downloader.StartDownloader("Daily Stock Quotes");

Save the script. Let's call it "UpdateQuotes".
We then create a new script. Also has one line:


Keep in mind that when we create a task from this script, we do NOT tick the "Run even if app is not
Loaded" box. We want to Quit QS only if it is running...

The next step is to setup retrieving and emailing of trading signals.

Let's assume you have a portfolio based on a strategy. We will call it "MySystem". We will make a new Script (Tools-->Script Editor)

PortfolioTask task1 = Portfolio.Run("", "MySystem");
while(!task1.IsCompleted) // Wait/Sleep until task is completed
string txt1="";
for (int i=0; i< task1.Orders.Length;i++)
      txt1=txt1+task1.Orders[i].Symbol+","+task1.Orders[i].OrderOrigin+","+task1.Orders[i].Share s+","+task1.Orders[i].OrderType+"\n";
App.Net.SendEmail("QS Cloud Service",txt1) ;

Save this script as “RetrieveSignals”.

One more script:

Order[] orders1=Portfolio.GetOrders("MySystem");
for (int i=0; i< orders1.Length;i++)

Call this "SubmitOrders".

Note: For email to be send, you will have to go to Quantshare's settings menu and add your e-mail account details. If you are using Gmail set port to 25 (or try 587) and Authentication to SSL.

So now we should have 4 scripts. We should schedule them in this order:
1.      Run RetrieveSignals.
2.      Run UpdateQuotes.
3.      Run SubmitSignals
4.      Run Quit_QS

Go "Tools"-->Task Manager to add a Task. We create a task for each Script and schedule it according to the previous logic. Remember to tick the "Run even if app is not Loaded" box in all tasks except the “Quit_QS” task.

So now, you have QS updating quotes, keeping track of portfolios and emailing signals, all by itself.

7 comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

How to Use the Percentage Scale
Posted 50 days ago

Introduction to the Grid Tool
Posted 149 days ago

Trading the Strategy Equity Curve
Posted 286 days ago

Previous Posts

More Posts


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright © 2017
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.