How to develop your own backtester in C/C++ or C# ? - futures io
futures io futures trading



How to develop your own backtester in C/C++ or C# ?


Discussion in Platforms and Indicators

Updated by iantg
      Top Posters
    1. looks_one pstrusi with 2 posts (0 thanks)
    2. looks_two bchip with 2 posts (3 thanks)
    3. looks_3 iantg with 1 posts (0 thanks)
    4. looks_4 amoeba with 1 posts (2 thanks)
    1. trending_up 1,659 views
    2. thumb_up 5 thanks given
    3. group 5 followers
    1. forum 5 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to develop your own backtester in C/C++ or C# ?

(login for full post details)
  #1 (permalink)
Lalin Pontevedra Spain
 
 
Posts: 16 since Sep 2013
Thanks: 9 given, 9 received

I use IB-API but still using NT7 as a trusted platform. Despite I'm satisfied with it, I'm interested to develop my own backtester in C or C#, along with other functional modules. Since I'm just an economist/trader, not a CS guy, I'm learning yet superior programming abilities. So, I'd like to speed my process up and was wondering if there are some : courses, tutorials specialized in these kind of development to learn from.

Thanks in advance for any idea or suggestion

Reply With Quote

Can you help answer these questions
from other members on futures io?
Anyone scalp the Mini-DAX (FDXM)?
Emini and Emicro Index
Think or swim earnings move calculation
Brokers
How to show tick count in or next to the current candlestick?
NinjaTrader
Volume Chart Trend Lines
TradeStation
Scan by comparing SMAs within 5 mins
ThinkOrSwim
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Are sharks watching on the other side?
52 thanks
Sierra Chart ACSIL for Beginners.
27 thanks
Earn2Trade (Helios) - "The Gauntlet"
23 thanks
VWAP for stock index futures trading?
17 thanks
FIO Journal Challenge - June 2020 w/SharkIndicators
16 thanks
 
(login for full post details)
  #2 (permalink)
Sydney, NSW, Australia
 
Experience: Intermediate
Platform: Sierra Chart, Python, C#
Broker: Interactive Brokers
Trading: MJNK, ASX, SPI
 
amoeba's Avatar
 
Posts: 201 since Jan 2014
Thanks: 96 given, 250 received

If you go down the c# path there are a couple of open source libraries available, one is used (or developed) by QuantConnect, which is also a c# online backtest engine;

https://www.quantconnect.com/

or GitHub source at https://github.com/QuantConnect/Lean

Reply With Quote
The following 2 users say Thank You to amoeba for this post:
 
(login for full post details)
  #3 (permalink)
Africa
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
 
Posts: 70 since Sep 2017
Thanks: 90 given, 60 received



pstrusi View Post
I use IB-API but still using NT7 as a trusted platform. Despite I'm satisfied with it, I'm interested to develop my own backtester in C or C#, along with other functional modules. Since I'm just an economist/trader, not a CS guy, I'm learning yet superior programming abilities. So, I'd like to speed my process up and was wondering if there are some : courses, tutorials specialized in these kind of development to learn from.

Thanks in advance for any idea or suggestion

Hi. Ive got quite a bit of experience doing this having done it myself.
All I can say its that it gets very cool having a backtester that does what you need to do,
and if you find anything interesting on the internet you can just add the functionality yourself.
Saying that though, the coding really took me more than a year and a half (part time).
Its also very mathematical, so you constantly have to test the values and make sure every calculation is right.

(TL;DR) Just saying it will take quite a long time and you need to be quite familiar with coding concepts
like object orientation, sorting algorithms, etc


Good luck.

Reply With Quote
The following 2 users say Thank You to bchip for this post:
 
(login for full post details)
  #4 (permalink)
Lalin Pontevedra Spain
 
 
Posts: 16 since Sep 2013
Thanks: 9 given, 9 received


bchip View Post
Hi. Ive got quite a bit of experience doing this having done it myself.
All I can say its that it gets very cool having a backtester that does what you need to do,
and if you find anything interesting on the internet you can just add the functionality yourself.
Saying that though, the coding really took me more than a year and a half (part time).
Its also very mathematical, so you constantly have to test the values and make sure every calculation is right.

(TL;DR) Just saying it will take quite a long time and you need to be quite familiar with coding concepts
like object orientation, sorting algorithms, etc


Good luck.

By any chance would you remind some reference in the net to check it?
Thanks!!

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Africa
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
 
Posts: 70 since Sep 2017
Thanks: 90 given, 60 received


pstrusi View Post
By any chance would you remind some reference in the net to check it?
Thanks!!

Hi

Not sure which part you need references on.
One of the other traders on this forum posted this link:
https://github.com/rediar/InteractiveBrokers-Algo-System

Which is their Java project connecting to IB.

Other than that indicators have many websites that help on calculations,
I found this book also to be quite useful:
https://www.amazon.com/Technical-Analysis-2nd-Steven-Achelis/dp/0071826297

Reply With Quote
The following user says Thank You to bchip for this post:
 
(login for full post details)
  #6 (permalink)
charlotte nc
 
Experience: Master
Platform: ninjatrader
Broker: NinjaTrader
Trading: Emini (ES, YM, NQ, ect.)
 
Posts: 393 since Jan 2015
Thanks: 73 given, 1,006 received

I have build several backtesting tools in SQL. I also develop in C#. The key concepts are largely the same in terms of what you are trying to solve for.

You can hack together a basic HLOC testing system really easily, but if you want to get into the nuances of "would you have realistically gotten filled or not" there are more things to consider.

1. Market Orders: Despite the common misconception that these fill instantly, there is a queue for market orders as well. So you would need to consider this into your logic to have accurate slippage..

2. Execution time relative to realistic latency: This is a huge design consideration if you want to make your system have value. If you mess this part up, the whole project may be worthless. The thing you need to do is built a latency trigger into your system so once you get your alpha signal that tells you to "get in, get out, or cancel", you need to then have a wait period of X before you mark your position in the queue. X = your latency. If you don't know this yet, I can show you how to test this.

3. Limit Orders: This is a big one... Depending on how well you handle this part, your system may be good or completely worthless. When I say completely worthless here is an example. Check the box in NinjaTrader 7 to fill limit orders on touch and then run a simple strategy with random entries (flip a coin on direction / when to get in) and set a profit target and stop loss at 3 ticks. Then watch your account run up millions of fake dollars.... Unless you want your custom testing platform to make the same mistake you will have to do better here.


You will be solving for both level 2 and level 1 data feeds and using volume to define if and when orders get filled. So conceptually you will need to be able to compute lots of running totals in different columns. In SQL, I just have a 5 - 10 different columns calculating different things cumulatively, or one column / another column and if that > 100% then do this.... or that.... etc.

If you are going at this in C# or just application code without a database, your best shot is to use a list. in C# you can use a list object from the Linq class I believe. Here you would just insert specific variables into your list, run your calculations and after you determine the outcome of a trade, clear your list and then repeat.

Keep us posted on how it goes.

Best of luck!

Ian

In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
Visit my futures io Trade Journal Reply With Quote


futures io Trading Community Platforms and Indicators > How to develop your own backtester in C/C++ or C# ?


July 30, 2018


Upcoming Webinars and Events
 

Free BloodHound Licenses for everyone!

June
 

Every journal equals ten meals for the hungry

June
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts