Traders, learning to write computer programs

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2040
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Traders, learning to write computer programs

Post by AFJ Garner » Tue Jul 26, 2011 2:22 pm

Moderators note -- Split off from parent to eradicate the scourge of the meandering thread
sluggo wrote: Hey it's just a small matter of software. Why not code it up, try it out, and see whether it adds value? If so, boom shakka lakka lakka boom! You've improved your edge in a way that few others can. Because it involves writing software, a scary monster that terrifies most people. They won't write code and won't hire someone to do it for them, either.
Very valid comment. Having someone else write the software is beyond the scope of most private traders however. The only sensible option is to learn a programming language and programming from scratch. It is an uphill task but once the hill has been climbed you need never look back. You need not fear your software of choice becoming unavailable to you because of licensing problems and the policy of vendors/ licencors. You can ensure you can continue to run your system even if you lose your Mechanica dongle and Bob Spears has packed up shop. You need not worry about phoning home on the internet from TB. You can create your own (perhaps simplified) contract rolling software.

Whatever one's view of the High Priest of Tahoe (now Austin), I believe he has it right when he tells people to do it themselves. I don't think you can or should trade a mechanical system without eventually learning to code from scratch. It is the very basis of your skills and trade. I believe it has to be tackled at some stage for the serious player and I have been eating my own cooking.

Chris67
Roundtable Knight
Roundtable Knight
Posts: 1046
Joined: Tue Dec 16, 2003 2:12 pm
Location: London

Post by Chris67 » Tue Jul 26, 2011 4:00 pm

Anthony - How does it taste so far ?

I agree with you entirely - however if your running a business that outside of trading , let alone system design / coding , consumes 10 hours per day its a tough call - but I guess its all about deploment of time and resources. I do howver agree that coding up one's own system on one's own platform has to be the only way forward for the serious player - also I guess working off one's own data too.

As a novice in programming where would you begin - c++ for dummies ?
best
C

rhc
Roundtable Knight
Roundtable Knight
Posts: 464
Joined: Tue Nov 18, 2008 8:46 pm
Location: Oz

Post by rhc » Tue Jul 26, 2011 6:06 pm

I agree with Chris in that although desirable, sometimes it can be very difficult to allocate the time needed to become proficient in programming.
This is especially true if you are afflicted with that debilitating condition known as 9-to-5 employment and you have other hobbies, family commitments, interests etc.
It’s always difficult to squeeze 25 hours into a 24 hour day.

Since my programming skills leave much to be desired, my solution has been to utilise the services of one of the Trading Blox ‘system development partners’ and I have been thoroughly satisfied with this decision.
My ideas have been programmed, my tests can be run, my time has been saved, I’m less stressed and plus I have a full head of hair (which I may not have otherwise had, tearing it out over debugging issues)
What has taken the ‘system development partner’ say, 10 hours to do would have taken me perhaps triple that . . . . and then some! (not including the learning curve)

Of course, there are some that will whinge & whine that it’s too expensive but consider this;
If the system development partner charges $150 per hour and you only earn $50 per hour in your day job then if it takes you 4 hours to code & debug something then it’s better to use the partner.
You could have used that 4 hours to earn $200 and paid the partner $150 and still been ahead by $50.
(this of course assumes you are able to work the extra time for the extra pay at your day job, but you get my drift)
. . . and if you earn $300 per hour, why would you ever do it yourself? (if you time poor that is)

It’s called division of labour and this is how society has advanced as rapidly as it has
http://en.wikipedia.org/wiki/Division_of_labour

If my water pipes start to leak, sure I can learn about plumbing (which is always a good skill to have) or I can simply call a plumber.
There’s only so many things we can become proficient at.

Having said all of the above, Ideally, of course one should learn to code. It’s a extremely valuable skill.
All I’m saying is that if one is strapped for time then there are other ways to get your job done.

blueberrycake
Roundtable Knight
Roundtable Knight
Posts: 125
Joined: Mon Apr 21, 2003 11:04 pm
Location: California

Post by blueberrycake » Tue Jul 26, 2011 6:40 pm

Chris67 wrote: As a novice in programming where would you begin - c++ for dummies ?
A script based language is much easier to learn and also much faster to write code in. You only need languages like Java and C++ if you need ultra-high performance code.

I recommend either using the R statistical package (it uses a language called "S", which is easy to learn and provides one with lots of tools for data analysis and transformations) or using the Python programming language (easy to learn and has lots of built in libraries available).

-bbc

babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader » Tue Jul 26, 2011 7:43 pm

A script based language is much easier to learn and also much faster to write code in. You only need languages like Java and C++ if you need ultra-high performance code.

I recommend either using the R statistical package (it uses a language called "S", which is easy to learn and provides one with lots of tools for data analysis and transformations) or using the Python programming language (easy to learn and has lots of built in libraries available).

-bbc
Or use Octave, which is compatible with MATLAB, which means you can easily cannibalize all the MATLAB code that is on the web.

GL
Contributor
Contributor
Posts: 1
Joined: Mon Feb 16, 2004 6:43 am
Location: Zurich, Switzerland

Post by GL » Wed Jul 27, 2011 6:27 am

Most quant traders are better off using a software like Trading Blox in combination with other software tools to support research and trading. There are medium-sized CTAs out there that use off-the-shelf products like TradeStation, which as you know has no portfolio capabilities, and these managers still do fine. The key is to identify what your requirements are and then to find appropriate and reliable third-party solutions.

If you still want to develop a custom trading application, then that’s great. Focus on excelling at what you are good at and don’t try to develop such software if you are lacking the know-how. We can’t all be innovative trading model designers, have a PhD in statistics, be experts in portfolio management and then also be great coders.

Many traders out there are building similar proprietary tools. If you have the opportunity, then team up with other traders that are pursuing the same goals and that have complimentary skill sets. That’s more efficient and fun than purely outsourcing the work.

AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2040
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner » Wed Jul 27, 2011 8:00 am

GL wrote:Most quant traders are better off using a software like Trading Blox in combination with other software tools to support research and trading.
TB is a great tool for R&D. So is Mechanica. Once you have a system or systems you are happy with that is the time to translate that system or systems into your own signal generating software. I would not attempt to duplicate TB or Mechanica - no need and too time consuming. A Liechtenstein acquaintance spent 7 years perfecting his TB equivalent and it would cost perhaps $1m + to have someone design one for you.

My real point is signal generation for the specific system or systems you trade. If you have your own software for THAT, then you can rest secure in your bed knowing that you are self reliant. For research you can continue to use your third party tool of choice. If that ceases to exist you will have the time to re-learn a new testing harness secure in the knowledge you can continue to generate your daily trading signals.

Learning to code in TB or Mechanica is a huge stepping stone towards being able to code your system on a stand alone basis in your chosen programming language. It is NOT such a great leap.

You will already have the basic coding skills necessary.

CyTrend
Roundtable Fellow
Roundtable Fellow
Posts: 57
Joined: Mon Oct 25, 2010 5:28 pm

Post by CyTrend » Fri Jul 29, 2011 9:03 am

As a novice in programming where would you begin - c++ for dummies ?
Chris67 i think if your primary objective is problem solving and writing computer algorithms your best bet for a first language should be one that is very simple and powerful so that you can spend your time thinking about the solution to the problem rather than translating that solution into the correct syntax of a complicated language. I think Python is your best bet as a first programming language , it is simple yet powerful(Google software engineers use this alot) and there are a lot of resources on the internet ( MIT Open Courseware has a fantastic course that introduces computer science using Python + there is a great free e-book "How to think like a Computer Scientist:Python" that should be enough to get you started). also packages like sciPy and matPlotlib can be used in conjuction with TB for all your data analysis. Happy to help out if you go down that path.

techtrade89
Senior Member
Senior Member
Posts: 28
Joined: Tue Dec 30, 2008 5:36 pm

Post by techtrade89 » Fri Jul 29, 2011 10:16 pm

I have no recommendation. But, for what it's worth, I program in C#. I learned basic C a while back (FORTRAN before that, believe it or not), then used C++ (mostly the C code in a C++ environment) and then migrated to C#

I am not a professional programmer, but (i) I like the flexibility; (ii) programming my own code I think enhances the likelihood I will find systems that others are not are likely to find since I am doing my own thing; and (iii) the debugging sometimes drives me batty and can eat up time (it helps to make lots of backups as you go to step back to earlier versions).

If you want to explore this route here is a good resource to start with C#:

http://www.joegrip.com/csharp-course.html

Good luck!

Macro
Roundtable Fellow
Roundtable Fellow
Posts: 70
Joined: Sat Dec 03, 2011 11:22 am

Post by Macro » Wed Dec 28, 2011 1:36 pm

Hat tip to blueberrycake and CyTrend for recommending Python. Aside from the 'Think Like a Computer Scientist' book recommended by CyTrader, 'Dive Into Python' (http://diveintopython3.ep.io/) is also a great way to get started along with Google's Python class ("http://code.google.com/edu/languages/go ... hon-class/").

trackstar
Roundtable Fellow
Roundtable Fellow
Posts: 76
Joined: Sun Mar 09, 2008 11:03 pm
Location: Houston Texas

Post by trackstar » Wed Dec 28, 2011 3:24 pm

Great topic. I recently was at a crossroads of moving over to Trading Blox from various other platforms. I did a trial and found out that it was mainly a closed environment in which I would have little access to code new pieces to test (although still the best option around). I then decided to keep plugging away at my own platform which is now mostly developed. Every day I wonder why it took me so long to trust in myself and take the leap.

Oh, BTW I did this in good ol VBA. I'm sure this is the language shunned by most, but with SQL Server and some elbow grease you can really do anything you can imagine.

OEXTrader
Contributing Member
Contributing Member
Posts: 5
Joined: Fri Jan 13, 2012 5:10 pm

Post by OEXTrader » Tue Jan 17, 2012 9:45 am

Hi folks. This is my first post here and I want to thank you for all your excellent contributions. With respect to the post above, I only know VBA and this is what I use for my backtesting. What I am missing out for not taking the time to learn another language like C# or Python or any other? My main concern with VBA is the time it takes to run trials. However I feel that I have been able to test whatever came to my mind.

trackstar
Roundtable Fellow
Roundtable Fellow
Posts: 76
Joined: Sun Mar 09, 2008 11:03 pm
Location: Houston Texas

Post by trackstar » Tue Jan 17, 2012 10:24 am

hmmm, VBA may not be as fast as C++ but in many cases you can fix its weak spots with other programs, such as SQL Server. In any case, if you are already comfortable with VBA I would venture to say you should stick with it rather than starting fresh with a new language.

OEXTrader
Contributing Member
Contributing Member
Posts: 5
Joined: Fri Jan 13, 2012 5:10 pm

Post by OEXTrader » Tue Jan 17, 2012 1:59 pm

I see. Good to know. Thank you Trackstar. I did take a semester of Matlab and C++ in college, unfortunatly i had no use for programming at that time and didnt take it seriously. I think I would be able to pick up Matlab again without too much effort, but I m not sure how much useful it gets past the backtesting stage, ie to send orders and all. I'm a total newbie for full disclosure. My knowledge of system trading doesnt go beyond the Ernest Chan and the Robert Pardo books. I manually trade my backtested ideas but I would like to eventually trade in smaller time frames and fully automatized.

Moto moto
Roundtable Knight
Roundtable Knight
Posts: 427
Joined: Mon Jun 01, 2009 4:12 am
Location: once again in the UK

Post by Moto moto » Wed Jan 18, 2012 3:49 am

or if time is a constraint - the programming in Trading Blox is not that difficult if you understand the basics of programming - might be worth the time saved verses the costs of buying TB as a specific tool for backtesting...
As even if you learn another language, you still have to then build a system.
Maybe just save and buy TB if thats all you want it for?

PNW_Trader
Senior Member
Senior Member
Posts: 37
Joined: Wed Jul 21, 2010 1:00 am
Location: Portland, OR

Post by PNW_Trader » Fri Jan 27, 2012 2:17 pm

I'm a big fan of Matlab/Octave (Octave is the free open source version). It fits nicely between excel and a full programming language such as C++. I much prefer it to excel VBA as it is much, much more capable and in my opinion much easier to learn. To me, excel VBA is very kludgy - a direct result of the need to retrofit a programming language to excel. Even if you program in TBLOX, you can use Matlab for supplemental analysis. Once you get the basic idea of how it deals with data (vectors, arrays, etc.) the learning curve is not that steep. Matlab has been around long enough, and used enough, that you can easily figure out how to do something simply by using Google search. Cheers.

Eventhorizon
Roundtable Knight
Roundtable Knight
Posts: 229
Joined: Thu Jul 08, 2010 2:36 pm
Location: Boulder, CO
Contact:

Post by Eventhorizon » Fri Jan 27, 2012 4:04 pm

In addition to Matlab / Octave, I would recommend R, in the role suggested by PNW_Trader. It's open source, there is a huge library of gnu packages that comes with it, a lot of focus on financial time series analysis, etc. It seems, to me at least, to be the dominant statistical package in academia.

I understand if you already know Matlab / Octave, you might not want to make the transition to R, but if you are starting from scratch give it serious consideration.

babelproofreader
Roundtable Knight
Roundtable Knight
Posts: 138
Joined: Wed Nov 10, 2004 4:36 pm

Post by babelproofreader » Fri Jan 27, 2012 5:10 pm

I understand if you already know Matlab / Octave, you might not want to make the transition to R
Websites such as this one make transitioning between Octave/MATLAB and R much less painful.

Macro
Roundtable Fellow
Roundtable Fellow
Posts: 70
Joined: Sat Dec 03, 2011 11:22 am

Post by Macro » Wed Feb 01, 2012 4:01 am

Octave seems interesting and I'll certainly look into it- I'm currently learning R with the goal of being able to construct a basic statarb strategy. Does Octave have libraries to run co-integration tests using the augmented dickey fuller method?

Also, this may sound rather naive, but this question has been in the back of my mind for a while now:

If you were to use Trading Blox for back testing, and Excel/ R/ NumPy for further statistical analysis, why would one need to use VBA/ C++/ Java/ Python etc for a trend following strategy? Two possibilities come to my mind:

1- Buy/ Sell signal generation
2- Automatic execution through broker API etc.

Is there anything else that I'm missing?

Thanks.

PNW_Trader
Senior Member
Senior Member
Posts: 37
Joined: Wed Jul 21, 2010 1:00 am
Location: Portland, OR

Post by PNW_Trader » Wed Feb 01, 2012 8:07 pm

Macro wrote:Octave seems interesting and I'll certainly look into it- I'm currently learning R with the goal of being able to construct a basic statarb strategy. Does Octave have libraries to run co-integration tests using the augmented dickey fuller method?
As you Google around be sure to use keyword 'Matlab' as well as 'Octave.' Most Matlab scripts and toolboxes you find in the public domain run just fine in Octave. In the case where they don't, someone has used a function from a Matlab toolbox. And, there's usually some public Octave code somewhere which you can dig up for that function as well.

Macro wrote:If you were to use Trading Blox for back testing, and Excel/ R/ NumPy for further statistical analysis, why would one need to use VBA/ C++/ Java/ Python etc for a trend following strategy? Two possibilities come to my mind:

1- Buy/ Sell signal generation
2- Automatic execution through broker API etc.
Matlab/Octave are not well suited to direct market access. It can be done, but they are just not designed as real time software. That's where C++ comes into play. As I understand it, the greatest percent of software which automatically executes trades is in C++.

Post Reply