NexusFi: Find Your Edge


Home Menu

 





Protecting code


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sefstrat with 8 posts (7 thanks)
    2. looks_two sam028 with 4 posts (1 thanks)
    3. looks_3 Richard with 4 posts (1 thanks)
    4. looks_4 toulouse-lautrec with 3 posts (0 thanks)
      Best Posters
    1. looks_one piersh with 4 thanks per post
    2. looks_two roonius with 1.5 thanks per post
    3. looks_3 sefstrat with 0.9 thanks per post
    4. looks_4 Richard with 0.3 thanks per post
    1. trending_up 21,448 views
    2. thumb_up 18 thanks given
    3. group 16 followers
    1. forum 29 posts
    2. attach_file 0 attachments




 
Search this Thread

Protecting code

  #1 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

It seems that C# code, just like Java, are quite easy to decompile.
C# is not as fast as some real compiled languages like C.
I'm trying to avoid/limit these drawbacks.
The idea is, for NT strategies, is to write the core of the strategy logic in an "harder to decompile" language, C++ for example, and let the NT C# indicators sending to the C++ program the needed data for taking the right decisions.
Questions:
- is this a silly idea ?
- does someone here has already played with something like this ?
I've started something, the C# coded strategy use a socket, to talk to a "strategy server", which send back to the NT strat what to do, but if somebody has already done this kind of job, well, I don't want to reinvent the wheel .

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #2 (permalink)
 
sefstrat's Avatar
 sefstrat 
Austin, TX
 
Experience: Advanced
Platform: NT/Matlab
Broker: Interactive Brokers
Trading: FX majors
Posts: 285 since Jun 2009
Thanks Given: 20
Thanks Received: 768

Many of the commercial indicators work this way, calling external c++ dlls, for instance the Kase Statware, Kwikpop and Jurik indicators all do this.

You don't need to use sockets though, you can use managed interop to call c++ methods straight from c#.

Reply With Quote
The following 2 users say Thank You to sefstrat for this post:
  #3 (permalink)
 toulouse-lautrec 
Europe
 
Experience: Beginner
Platform: NinjaTrader
Posts: 73 since Jun 2009
Thanks Given: 13
Thanks Received: 53



sam028 View Post
I've started something, the C# coded strategy use a socket, to talk to a "strategy server", which send back to the NT strat what to do, but if somebody has already done this kind of job, well, I don't want to reinvent the wheel .

since you already use sockets to talk to that strategy server, you may think about placing startegy server remotely .... thus the local "strategy" on the client side would be just a dummy.
Disadvantage - latency, no offline operation, backtesting might not work....
advantage - since the core of the code is not present on the client side there might not be much to crack .... lol

Reply With Quote
  #4 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


sam028 View Post
It seems that C# code, just like Java, are quite easy to decompile.
C# is not as fast as some real compiled languages like C.
I'm trying to avoid/limit these drawbacks.
The idea is, for NT strategies, is to write the core of the strategy logic in an "harder to decompile" language, C++ for example, and let the NT C# indicators sending to the C++ program the needed data for taking the right decisions.
Questions:
- is this a silly idea ?
- does someone here has already played with something like this ?
I've started something, the C# coded strategy use a socket, to talk to a "strategy server", which send back to the NT strat what to do, but if somebody has already done this kind of job, well, I don't want to reinvent the wheel .

you need to obfuscate the dll. try this free obfuscator.

Eazfuscator.NET ? Free .NET Obfuscator

Reply With Quote
  #5 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

Thx for answers.
@sefstrat: I'm a Unix/Linux guy, I have made a lot of socket and other IPC stuff, socket is much more easier for me than interop things (interop == 我愛奶酪和法國葡萄酒 for me, and I don't write/speak chinese ).
@toulouse-lautrec: my "strategy server" is already on another machine, so the client part can be decompiled, I don't care...
@bukkan: I've tested few obfuscators, but none were perfect, and I like the idea of having the core logic deported somewhere else.

Backtesting will not be possible, but as I don't really trust NT backtests, it's ok for me.
Latency does not seems to be a problem, because most of the data needed to decide what to do are already on the remote server.

Follow me on Twitter Started this thread Reply With Quote
  #6 (permalink)
 
sefstrat's Avatar
 sefstrat 
Austin, TX
 
Experience: Advanced
Platform: NT/Matlab
Broker: Interactive Brokers
Trading: FX majors
Posts: 285 since Jun 2009
Thanks Given: 20
Thanks Received: 768

managed interop is as simple as..

using System.Runtime.InteropServices;

then inside your class define method signature from c++ dll, for example:

[DllImport("myUnmanagedDll.dll")]
private static extern bool MethodName(float Open, float Close, float High, float Low, int dateStamp, out float var1, out float var2, out float var3);

then you can just call it like a normal managed method =)

But yeah if you are really interested in security then keep the sensitive parts on the server side, that is the only way to guarantee they can't be decrypted/deobfuscated. Then the only issue is latency but that is probably workable as long as you aren't doing very high frequency trades.

Reply With Quote
The following user says Thank You to sefstrat for this post:
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

Thx sefstrat, I'll take a look at how to use managed interop, it can be useful in another context.
The strats I'm working on are not "high frequency", they are supposed to still profitable with a 800/1000 ms delay.
I've been working for a big bank, which was playing with "high frequency trading", this is another world...

Follow me on Twitter Started this thread Reply With Quote
  #8 (permalink)
 toulouse-lautrec 
Europe
 
Experience: Beginner
Platform: NinjaTrader
Posts: 73 since Jun 2009
Thanks Given: 13
Thanks Received: 53

I am currently also thinking of making some of my creations available to a some people, and would like to protect the code as effectively as possible.
The solution recommended by NT has some serious issues (which i am not going to discuss here), so if anyone has any recommendations (free or commercial) i would be very happy to hear about it.
I have spent some time browsing around and looking at solutions available, there seem to be many, which makes it not easy.
Any comments, also via PM, would be appreciated.

Reply With Quote
  #9 (permalink)
 
sefstrat's Avatar
 sefstrat 
Austin, TX
 
Experience: Advanced
Platform: NT/Matlab
Broker: Interactive Brokers
Trading: FX majors
Posts: 285 since Jun 2009
Thanks Given: 20
Thanks Received: 768

Don't waste your money on anything commercial, any .net protection can be reversed all the way back to IL code quite easily by someone who knows what they are doing.

Most secure way of course is to code all the important parts in c++, other than that obfuscation is your best bet.

Here is a good, free obfuscator: NTCore's Homepage

Reply With Quote
The following user says Thank You to sefstrat for this post:
  #10 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295



toulouse-lautrec View Post
I am currently also thinking of making some of my creations available to a some people, and would like to protect the code as effectively as possible.
The solution recommended by NT has some serious issues (which i am not going to discuss here), so if anyone has any recommendations (free or commercial) i would be very happy to hear about it.
I have spent some time browsing around and looking at solutions available, there seem to be many, which makes it not easy.
Any comments, also via PM, would be appreciated.

NT recommends Remotesoft.
What issues are you talking about?

Reply With Quote





Last Updated on April 13, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts