Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send code ( a class in this case) to a server/program and receive output

Here is the situation:

I have a huge data set that I need quick access to. It's a financial data set so basically the way it's set up is that at each point in time, you have data for thousands of stocks. Now, loading this data into the program takes a while (20-40 seconds) and I would like to avoid having to do this every time I make changes in the code.

Basically, I had an idea and I want to know if it makes sense / if it is optimal. I was thinking of setting up some kind of server that has all the data loaded and all the object definitions, and then from a second program/client, I would like to send a predefined type of class (a strategy class) to the server, have the server run the code, and then have the server send me back the results of the test.

I am creating trading strategies in this case, so I have an abstract class that defines what a "strategy" needs. I have a market simulator that calls the derived "strategy" every time the date changes, then the strategy buys or sells stocks, and then stores the profits from the strategy in some result object. So I want to be able to code the strategy part, send it over, and receive the result part. I want to avoid loading all the data every time I change params or raw code in my strategy object.

I hope this makes sense to someone and I am sorry if it isn't very clear. Please let me know if this is possible, and then, how would I go about googling for this?? I don't even know what to search for here.

like image 501
philmo Avatar asked Oct 12 '22 16:10

philmo


1 Answers

I'd define an Interface that the server will use to invoke your strategies, then implement each strategy in a separate assembly.

The server would then load each assembly in a separate AppDomain and execute it there. This will give the server process some protection against bugs in the strategy implementation, but more importantly will allow it to unload the assembly.

like image 141
Chris Wenham Avatar answered Oct 19 '22 01:10

Chris Wenham