Back

Help - Speeding Up Tick Testing for the EURUSD

Hi there, currently I have to OC my i7-4790K to backtest tick data (Dukascopy >9GB) from 2007 to 2014. It takes me approximately 5 minutes per run while my optimization takes at least 10 days. I was so happy when I came across QuantConnect because I thought that I could speed up my back testing using the cloud. Unfortunately, it is not the case since a single run of FXCM data from 2007 to 2015 takes 2778.23 seconds (46 minutes). I don't know the exact tickdata size of FXCM to compare with Dukascopy; hence, it may not be an apple to apple comparison. Attached are my simple backtest and my code.

65 | 09:01:17 : Backtesting Project ID: 42348
66 | 09:01:17 : Successfully sent backtest request for 'Smooth Violet Goat', (Compile Id: 90ba9292d6a71daedf3f7154c8a2c6b6)
67 | 09:01:20 : Backtest ID: 0034ffcbc1bbe9e25f9b6eb1c5820baa successfully sent to cloud.
68 | 10:01:38 : Algorithm Notice: Memory 754Mb Used of Maxiumum 1024Mb. Try not to store data in your algorithm.
69 | 10:01:39 : Algorithm Id:(0034ffcbc1bbe9e25f9b6eb1c5820baa) completed analysis in 2478.23 seconds
70 | 10:01:39 : Your log was successfully created and can be downloaded from: http://data.quantconnect.com/backtests/9052/42348/0034ffcbc1bbe9e25f9b6eb1c5820baa-log.txt


namespace QuantConnect
{
/*
* QuantConnect University: Full Basic Template:
*
* The underlying QCAlgorithm class is full of helper methods which enable you to use QuantConnect.
* We have explained some of these here, but the full algorithm can be found at:
* https://github.com/QuantConnect/QCAlgorithm/blob/master/QuantConnect.Algorithm/QCAlgorithm.cs
*/
public class BasicTemplateAlgorithm : QCAlgorithm
{
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{

//Start and End Date range for the backtest:
SetStartDate(2007, 4, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));

//Cash allocation
SetCash(25000);

//Add as many securities as you like. All the data will be passed into the event handler:
AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Tick);

}

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
{
// "TradeBars" object holds many "TradeBar" objects: it is a dictionary indexed by the symbol:
//
// e.g. data["MSFT"] data["GOOG"]

if (!Portfolio.HoldStock)
{
int quantity = (int)Math.Floor(Portfolio.Cash / data["EURUSD"].Close);

//Order function places trades: enter the string symbol and the quantity you want:
Order("EURUSD", quantity);

//Debug sends messages to the user console: "Time" is the algorithm time keeper object
Debug("Purchased EURUSD on " + Time.ToShortDateString());

//You can also use log to send longer messages to a file. You are capped to 10kb
//Log("This is a longer message send to log.");
}
}
}
}
Update Backtest








Hey uncle! Welcome to QuantConnect! We have millisecond resolution ticks from FXCM - each day of data is roughly 10MB. For that period 2007-2014 its roughly 18-21GB of tick data depending on the symbols requested and their activity.

I'd say we might not be as good as your beautiful i7 -- the individual processors currently aren't as powerful as your box, but the cloud wins with parallelism. We're speeding things up in 2 ways:

1 - We're upgrading our boxes now to 64GB i7-3930's so they'll be roughly 2-3x faster in CPU and 3x bigger in ram allocation per algorithm (ETA Friday 30th).

2 - We'll launch an optimization service after live trading (ETA Optimization Feb-15th). This will allow scaling a private cloud of 10-100 nodes to process backtests massively in parallel and collate all the results!

Thank you for your patience :) We're aiming to be the best of the cloud + desktop. I'd recommend downloading the LEAN engine and running it locally with your Dukascopy data to see how we perform vs your current system. We definitely know we can optimize more and will be improving it over the next few weeks.

This week we're launching paper trading & IB to subscribers! It'll be an awesome month!
1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Jared,

Thanks for your quick reply as I am all for the cloud.
0

Jared,

Can you confirm that the i7-3939 are now in place? I would like to perform the benchmarking test again?

Many thanks
0

Apologies @Uncle we were 100% focused on live trading last week. I've been syncing the data for the new nodes all morning. Syncing can take 4-6 hours but once its done I'll unleash the new nodes with a fresh build from GitHub :)
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thanks for the update.
0

Jared,

I re-ran the tick test today and it took 79 minutes.

2014-12-26 15:59:58 Algorithm Liquidated
2014-12-26 15:59:58 Algorithm Id:(cce1c44c2e950ba148cc71d0068c7933) completed analysis in 4753.77 seconds

What am I doing wrong?
0

I'd recommend testing LEAN locally on your PC Bob - how is your data stored? Can you hook it up to LEAN and then run a local bench mark? This way it will be a direct side by side comparison. Once you have it running locally we can work on making it faster.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Jared,

See my code below as I am performing a very simple test.


namespace QuantConnect
{
/*
* QuantConnect University: Full Basic Template:
*
* The underlying QCAlgorithm class is full of helper methods which enable you to use QuantConnect.
* We have explained some of these here, but the full algorithm can be found at:
* https://github.com/QuantConnect/QCAlgorithm/blob/master/QuantConnect.Algorithm/QCAlgorithm.cs
*/
public class BasicTemplateAlgorithm : QCAlgorithm
{
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{


SetStartDate(2007, 4, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));

SetCash(25000);

AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Tick);

}


public void OnData(TradeBars data)
{


if (!Portfolio.HoldStock)
{
int quantity = (int)Math.Floor(Portfolio.Cash / data["EURUSD"].Close);

//Order function places trades: enter the string symbol and the quantity you want:
Order("EURUSD", quantity);

//Debug sends messages to the user console: "Time" is the algorithm time keeper object
Debug("Purchased EURUSD on " + Time.ToShortDateString());

//You can also use log to send longer messages to a file. You are capped to 10kb
//Log("This is a longer message send to log.");
}
}
}
}
0

Thanks @Bob -It was just missing the OnTick event. I also found & fixed a little glitch which was slowing us down for tick data - please see the attached. Its back to 46 minutes for a 7.5 year, millisecond tick-event level backtest. Unfortunately for tick it looks like the upgrade didn't help (where minute resolution saw a 40% increase).

Can you please download LEAN and run this algorithm locally as a test? If you find places to speed up the backtest we can transfer those to the cloud and your optimizations will be faster as well.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed