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 20,383 views
    2. thumb_up 18 thanks given
    3. group 16 followers
    1. forum 29 posts
    2. attach_file 0 attachments




Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
  • 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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.

-- Big Mike, Site Administrator

Available coupon codes for premium Elite Membership:
  • If you are a researcher and pay attention to details, you qualify for our 10% discount - "CHARTIST"
  • If you are a veteran or in public/community service, you qualify for 15% discount - "PURPLECHART"
  • If you are 60+ years old, you qualify for our 20% discount - "WISDOM"
  • Discounts are based on the honor system. If we can't trust you to do the right thing, please move along.

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

 
Search this Thread

Protecting code

(login for full post details)
  #1 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,753 since Jun 2009
Thanks Given: 3,822
Thanks Received: 4,623

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?
Actual code for RSI using Wilders average, not the canne …
ThinkOrSwim
Resources to help learn about diversification of algo po …
NinjaTrader
Time and Price Based Horizontal line Indicator - Request
NinjaTrader
RangeDisparityMeter Indicator for NT8
Platforms and Indicators
NT8 Historical Data
NinjaTrader
 

(login for full post details)
  #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: 767

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:
(login for full post details)
  #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
(login for full post details)
  #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
(login for full post details)
  #5 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,753 since Jun 2009
Thanks Given: 3,822
Thanks Received: 4,623

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
(login for full post details)
  #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: 767

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:
(login for full post details)
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,753 since Jun 2009
Thanks Given: 3,822
Thanks Received: 4,623

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
(login for full post details)
  #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
(login for full post details)
  #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: 767

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:
(login for full post details)
  #10 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 294



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





NexusFi Trading Community Platforms and Indicators NinjaTrader > Protecting code


Last Updated on April 13, 2016


© 2023 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