OANDA Forex Forum

A history of transparency

OANDA hosts one of the longest-standing forex forums on the web. Since June 2000, our forum has given forex traders a vehicle for sharing views, airing grievances, and learning from each other. Membership in the OANDA Forex Forum comes with searchable access to diverse topic threads dating back to the very first forex forum posts.

Join in on the discussion with fellow OANDA traders by signing in with your existing fxTrade or fxTrade Practice account. If you don’t already have a forex trading account with OANDA, you can begin by registering for one today.


#1 Oct. 11, 2007 14:13:00

MJ
Member
Member #6535
Registered: 2005-09-30
Posts: 1139
Reputation: +  0  -
Profile  

Own Backtest Engine

hi all,

I'm in the planning stage for my own backtest engine and would like to ask for your wisdom:

1. If you do your own backtesting how do you do it?

2. If you programmed your own backtest suite what was your basic approach.


As I'm in the early state of thinking about it: at the moment my thought go for a 2 state engine.

Similar what we have with OANDA Server and our FX Client.

Which means:
  • 1. A Server engine: which has:
    - all historical Tick by Tick Realtime Rates,
    - calculates the present AccountSituation (Balance, NetAssetValue etc. and tracks the Orders
  • 2. A Client engine: which
    - receives the Rates, open Orders and CurrentAccountSituation from the Server,
    - and also sends new Orders or cancel Orders to the Server.
  • 3. A Timer: which emits a ' virtual time'. (counts the seconds) to run Server and Client simultaneously and can speed up the virtual time by a given factor.

But I'm not really sure what's the best approach - so if you did it yourself or have any ideas - you are more than welcome to share.

regards MJ

[ October 11, 2007, 02:15 PM: Message edited by: MJ ]

Offline

#2 Oct. 11, 2007 16:25:00

bmarlier
Member
Member #4295
From: France
Registered: 2004-08-04
Posts: 72
Reputation: +  0  -
Profile  

Own Backtest Engine

I dont have that Timer server. I use timestamp in ticks for time reference. For the rest, it is basically client/server (all in one process). My server has the same interface as real broker connection so that the client is unaware if its real or not.

Offline

#3 Oct. 11, 2007 18:20:00

cmcmil
Member
Member #5716
From: Kansas
Registered: 2005-05-02
Posts: 160
Reputation: +  0  -
Profile  

Own Backtest Engine

I thought that it would be too much unnecessary work to develop a true client and server with all the associated network code. Instead, I wrote an API of my own to be used in my trading/decision software. This API can be activated in backtest mode, where it reads ticks from a file, feeds them to the decision code (along with a timestamp), and throws trades into a bucket. The results are displayed at the end. It takes only 5-7 minutes to backtest 3 years of ticks on a 1ghz machine.

The benefit of this system is that adding a real API is only a matter of passing trade orders to (and reading the ticks from) Oanda rather than throwing them in a bucket. The backtested decision code doesn't need to be changed at all.

[ October 11, 2007, 06:23 PM: Message edited by: cmcmil ]


"If you watch your pennies, your dollars will take care of themselves."

Offline

#4 Oct. 12, 2007 00:55:00

pippi
Member
Member #6907
Registered: 2005-11-15
Posts: 1077
Reputation: +  1  -
Profile  

Own Backtest Engine

I took a similar approach like cmcmil, altho much simpler. I wrote a few console applications to work with oanda tick-files (append, extract, clean out double ticks, convert UTC to local time etc.), and another console application that parses those tick-files and outputs a transaction-file according to my system-rules i want to test. I can import this transaction file into neoticker for further analysis.

This analysis is in my opinion just as important and as much, or in some cases much more, work than the actual backtesting. If your backtester only outputs "I made x pips in y months" - it wont be very helpful. There is much more to it than only the net p/l.

Offline

#5 Oct. 12, 2007 02:35:00

MJ
Member
Member #6535
Registered: 2005-09-30
Posts: 1139
Reputation: +  0  -
Profile  

Own Backtest Engine

Thanks so far to all of you for your input.

Really helps to rethink what's maybe the best approach for the effort.


regards MJ


PS: still hoping for more to participate.

Offline

#6 Oct. 12, 2007 08:37:00

cmcmil
Member
Member #5716
From: Kansas
Registered: 2005-05-02
Posts: 160
Reputation: +  0  -
Profile  

Own Backtest Engine

I don't know your programming abilities, but if you know perl, you might try this:
http://www.geniustrader.org/


"If you watch your pennies, your dollars will take care of themselves."

Offline

#7 Oct. 13, 2007 03:42:00

MJ
Member
Member #6535
Registered: 2005-09-30
Posts: 1139
Reputation: +  0  -
Profile  

Own Backtest Engine

quote:
Originally posted by cmcmil:
I don't know your programming abilities, but if you know perl, you might try this:
http://www.geniustrader.org/

Thanks cmcmil,

I have a look at it. my programming abilities are as such, that with a lot of patience I usually can do what is needed ;-)
my preferred language is python.

THANKS MJ

Offline

#8 Oct. 15, 2007 20:54:00

DJO
Junior Member
Member #9955
Registered: 2006-10-06
Posts: 5
Reputation: +  0  -
Profile  

Own Backtest Engine

My preference is to hold the data in the database, as it allows greater flexibility to aggregate time windows, create & modify queries/views etc withou much rework.

Since the data is static, your best to pre-process your indicators, removing this overhead for any future models you wish to run.

Also consider whether you need to read each tick, we found that most of our models permitted us to skip ahead minutes/hours to where a particular event occured, removing the need to transact every record. Makes a big difference to your processing time.

Offline

#9 Oct. 17, 2007 19:10:00

Mojo
Member
Member #7327
From: Hong Kong
Registered: 2006-01-07
Posts: 118
Reputation: +  0  -
Profile  

Own Backtest Engine

I actually started the same project last week. I wanted to create a mimic of the OANDA API (Java only) so I could backtest various strategies and have them coded to the API so when I start to pay for it, I can drop the same strategies into forward testing on the FXGame straight away.

I went with the solution of holding a TimeServer singleton that uses the timeMillis of the startDate for the backtest scenario. Each loop of core engine will increment the time by a user defined number of millis and then request the data object to issue the most relevant tick per currency most up to date for the current time. The engine then calls the "client" strategies to do their own processing.

The disadvantage of this is you will not get the most accurate OHLC data since you are not processing every tick and the engine may not accurately execute every order if a tick spiked through the limit and back within the increment period.

The alternative engine I thought of (any may still implement) is to process every tick and then update the TimeServer with the timestamp of that tick. However, as DJO mentioned, this would have a big impact on processing time.

Since I am going to open source this, if you wish to collaborate on development I am more than willing.


Leave till tomorrow what could be done today.

Offline

#10 Oct. 18, 2007 06:52:00

MJ
Member
Member #6535
Registered: 2005-09-30
Posts: 1139
Reputation: +  0  -
Profile  

Own Backtest Engine

quote:
Originally posted by Mojo:
I actually started the same project last week. I wanted to create a mimic of the OANDA API (Java only) so I could backtest various strategies and have them coded to the API so when I start to pay for it, I can drop the same strategies into forward testing on the FXGame straight away.
........
..

Since I am going to open source this, if you wish to collaborate on development I am more than willing.

hi Mojo,

thanks for sharing.

1. as i prefer the rapid development in 'python' over java I think I will not much collaborate.

2. where are you and others are planning to get the FXTicks.

As OANDA offers just 5 pairs??

regards MJ

Offline

Board footer

Moderator control

Powered by DjangoBB

Loading nanoRep