SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
pentagram
Topic Author
Posts: 26
Joined: November 9th, 2010, 11:40 am

C# cointegration

December 17th, 2010, 6:38 am

I'm coding up an automated trading system, after giving it some thought,I chose C#. C++ will require a longer development cycle, who knows what Oracle will do to Java, Matlab is expensive and R does not provide a compile to give binaries. Not to mention that Matlab and R require to load all the data in memory before the processing takes place.C# seems decent enough, and fast enough for home-purposes. Ofc C++ would be better but I can't have it all The only way I have found to do that in C#, is to make my own wrappers for libgretl. Are there any alternatives to this? are there better libraries to use?Also if somebody has done something similar any additional advice would be appreciated
 
User avatar
Cuchulainn
Posts: 61184
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C# cointegration

December 17th, 2010, 7:07 am

Depending on your goals (speed, proof of concept etc.) I would say that C# is worth a shot. Productivity levels are 5 times that of C++ and C# speed is OK. A nice feature is C#/Excel interop.I suppose gretl is a C time series package. You could integrate it with C++ using C++/CLI (Managed C++). Here is a Boost library that seems to be relevant accumulator
Last edited by Cuchulainn on December 16th, 2010, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
pentagram
Topic Author
Posts: 26
Joined: November 9th, 2010, 11:40 am

C# cointegration

December 17th, 2010, 7:51 am

Thanks for your response! My goal is an automated trading system for home(*), that's cross platform (I'm using Mono so far and I have to say it's a pretty good IDE, albeit not Visual Studio material). For now I want something that's not slow (e.g. not R) nor too expensive (e.g. Matlab). With regard to long-term goals, I'd like the system to be in principle extensible to parallel processing, multithreading etc but all these are not really goals for now. I just want to be able to implement them in principle, should I choose to do so in the (very distant) future.(*) I plan to use the cointegration code as part of the backtesting module. With regard to speed, the more the better but being realistic, I cannot hope to code this in C++, already coding in C# will require quite a few months and the longer the development time, the smaller the probability to complete the project. I think C# is the golden cut, it is a "clean" language, fast enough for this purpose, doesn't require a license and I hope it offers a productivity boost s.t. I can take the mental pain to code this up. Integration with Excel is a big plus ofc thanks for pointing that out. Is this boost library widely adopted? to put it more simply, is this the "standard" library people use when they write C++ code for cointegration ? By the way since other people may want to use C# for their coding and they may choose Mac/Linux/BSD as their dev platform, I'm posting the links on how to call unmanaged C++/C from C# in Mono.http://www.mono-project.com/Embedding_M ... _Libraries http://www.mono-project.com/DllImport"> http://www.mono-project.com/DllImportQuoteOriginally posted by: CuchulainnDepending on your goals (speed, proof of concept etc.) I would say that C# is worth a shot. Productivity levels are 5 times that of C++ and C# speed is OK. A nice feature is C#/Excel interop.I suppose gretl is a C time series package. You could integrate it with C++ using C++/CLI (Managed C++). Here is a Boost library that seems to be relevant accumulator
Last edited by pentagram on December 16th, 2010, 11:00 pm, edited 1 time in total.
 
User avatar
endian675
Posts: 143
Joined: March 11th, 2008, 7:09 pm

C# cointegration

December 17th, 2010, 9:10 am

If the cointegration test is purely part of the backtest then I suggest you use the RCom connection to push your data in to R, calculate the statistics in there (Google for "Chan cointegration price R" for R source code), then get your results out. I had that up and running in one day.
 
User avatar
pentagram
Topic Author
Posts: 26
Joined: November 9th, 2010, 11:40 am

C# cointegration

December 17th, 2010, 10:05 am

Since this is using the R binaries (and nothing is scripted), am I correct to assume that this is almost as fast as having C++ libraries to link to? How did you find the performance of your code with regard to calling R from C# ? Also, to the best of my knowledge, RCOM uses the older COM technology, which unlike .net/cli is not cross-platform (unless calling it through wine works). Is there any pure .net connector to R?QuoteOriginally posted by: endian675If the cointegration test is purely part of the backtest then I suggest you use the RCom connection to push your data in to R, calculate the statistics in there (Google for "Chan cointegration price R" for R source code), then get your results out. I had that up and running in one day.
 
User avatar
Cuchulainn
Posts: 61184
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

C# cointegration

December 17th, 2010, 10:05 am

BTW you can download Visual Studio for freehttp://www.microsoft.com/express/Downloads/I do not know in how far accumulators are used, but in general certain libraries in boost are popular. I don't know Mono but if you use VS IDE you may not need it or you can use both environments.
Last edited by Cuchulainn on December 16th, 2010, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
pentagram
Topic Author
Posts: 26
Joined: November 9th, 2010, 11:40 am

C# cointegration

December 17th, 2010, 10:25 am

I'm windows-free since 2002 Visual Studio is the only piece of software I really miss (VS 6.0 was the one I used) but it's not enough to install windows. After Apple released a unix OS which is not too much of a fuss to setup & configure, I never looked back. QuoteOriginally posted by: CuchulainnBTW you can download Visual Studio for freehttp://www.microsoft.com/express/Downloads/I do not know in how far accumulators are used, but in general certain libraries in boost are popular.
Last edited by pentagram on December 16th, 2010, 11:00 pm, edited 1 time in total.
 
User avatar
alderonarino
Posts: 3
Joined: December 31st, 2010, 2:39 pm

C# cointegration

January 10th, 2011, 10:55 pm

I have been trying to get GRETL to compile as C++/CLI, but Visual Studio doesn't like the forward declarations.Please let me know if you find some C/C++/C#/Java code for VECM. I have some VBA code if anyone wants it.
 
User avatar
pentagram
Topic Author
Posts: 26
Joined: November 9th, 2010, 11:40 am

C# cointegration

January 11th, 2011, 11:40 pm

QuoteOriginally posted by: alderonarinoI have been trying to get GRETL to compile as C++/CLI, but Visual Studio doesn't like the forward declarations.Please let me know if you find some C/C++/C#/Java code for VECM. I have some VBA code if anyone wants it. I didn't use gretl (yet) mainly because I wanted to write my own code for some cointegration methods, seeing it as an opportunity to widen my understanding of the method. I will use gretl when adding more of my own code becomes bad (educational) value for my time. The way I intended to do it is through, P/Invoke on a mac (Mono). I don't think you need to compile gretl to use P/Invoke, you would need to use only the pre-compiled binaries from their website. Another common way to do this is through R, e.g. through DCOM (C#) http://www.codeproject.com/KB/cs/RtoCSharp.aspx or similar Java offerings. In my case, since my main development platform is a mac, using DCOM (e.g. through wine) can get quite complicated, so I chose gretl, nothing inherently better in it tho.
 
User avatar
ktang
Posts: 122
Joined: January 15th, 2010, 7:16 pm

C# cointegration

January 13th, 2011, 1:19 pm

QuoteOriginally posted by: pentagramThe only way I have found to do that in C#, is to make my own wrappers for libgretl. Are there any alternatives to this? are there better libraries to use?Also if somebody has done something similar any additional advice would be appreciatedYou can use f# on msvc 2010. It is free. And if you like you can store your market data in kdb and build a connection from f# to retrieve the data.
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On