Algorithmic trading - Integrate C# and Matlab

조회 수: 12 (최근 30일)
condor
condor 2011년 12월 9일
Hi. I need to:
1) connect to a server with a C# API in order to get stock data 2) analyse the data in Matlab 3) return an answer to the server (example "buy" or "sell")
Clearly I need to run this continuously and faster is better...
QUESTION: A) What is the best way to do this? Should I integrate C# inside Matlab or should I integrate Matlab inside a C# program? B) Let's say that I integrate matlab in C# I read these: http://www.codeproject.com/KB/dotnet/matlabeng.aspx http://www.mathworks.com/matlabcentral/fileexchange/12987-integrating-matlab-with-c So, excluding the COM approach (too slow), I can choose between the ".NET" and the the "C shared library" what are the pros and cons? What does it mean that the C shared library - way is very fragile?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 11일
If this is not just for simulation, if this is to be used for real money, I would recommend checking the MATLAB license conditions, as there are some things that MATLAB is not intended to be used for. Nothing that affects human safety, for example. I would not imagine that MathWorks certifies their software as being good enough for use in handling real money.

댓글을 달려면 로그인하십시오.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 12월 9일
Hi Condor,
some thoughts: it depends somewhat on who has control on the process, the server or the client (MATLAB). The description you give (1), 2), 3)) suggests that the client has control. In this case calling the .NET API directly from MATLAB will probably be your best bet.
If you turn around the process: if you are able to tell the server to call some other .NET code, then you could use Builder NE (see here) to compile your MATLAB code into a .NET component. This should be the fastest option.
Titus
  댓글 수: 4
condor
condor 2011년 12월 11일
Yes, it is like a Reuters server, so I have no control over it. I can just retrive data or send orders to buy and sell stocks ... that's it!
Tell me if this is what you think, the process would be:
1) Create a C# project;
2) Integrate the API (the broker gave to me) to connect to the server inside the C# project;
3) Retrive data and pass them to a Matlab .NET (that is integrated inside the C#);
4) Get the results in C# and decide to buy or sell...
What do you think about it?
Titus Edelhofer
Titus Edelhofer 2011년 12월 12일
Hi,
yes, that should work. The alternative would be:
1) Use .NET API in MATLAB to get data.
2) Do computation in MATLAB
3) Buy/sell using .NET API.
It depends: this way should be easier to implement (depending on your C# knowledge). Second, a test about performance (for steps 1) and 2) at least) should be easy to do. The speed probably will depend on the amount of data (converting the retrieved .NET data into MATLAB data I guess will be the bottle neck, although the support for converting object arrays introduced in R2011b should help here).
Titus

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 .NET Client Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by