I am currently developing a commercial automated trading program in which users can write their own proprietary code and develop strategies, like in NinjaTrader, MetaTrader etc. Right now I am working on the order handling part, which is really important. I can not figure out how to reference the orders entered during the execution of a strategy.
Suppose in a strategy, there is this piece of code:
if(some_condition)
EnterLong("IBM",100)
My problem is some_condition
can be set to true several times, which results in generating several buy orders. Somehow I have to provide the ability for users to modify or cancel some of these orders.
NinjaTrader, for example, has a feature called EntriesPerDirection
, which limits the entry number for a direction (long or short). So you can have a certain number of order objects (or an array of orders) that are returned by order entry functions and say order1.Cancel();
However, this does not make any sense for an iceberging strategy in which thousands of orders could be generated. Both programs enable the user to iterate over the orders that have not led to a transaction yet. This again could be painful for iceberging purposes. I think those two programs are not specifically built for handling large numbers of orders or for developing execution algorithms (e.g., VWAP, Arrival Price, Implementation Shortfall) which are widely used among buy-side firms.
Also both NT and MT have events (OnOrderUpdate
, OnExecution
, OnTrade
) that are fired when the status of an order is changed. This is a good idea, but I am not sure it is the best solution.
Are there any approaches or methodologies addressing my problem that are commonly used by other automated trading software?