Implement a Julia type, Order (or AbstractOrder from which more concrete order types could be children, like MarketOrder, LimitOrder, StopOrder, etc.) for storing, processing, and manipulating orders.
This type should be able to interact with a Portfolio object in a highly structured order queue processing pattern. In other words, when a Signal/Rule triggers some market action, it should be communicated through an Order type.
At a broad level I imagine it would look somewhat like this.
Indicator function runs computations on raw market data at each time t
Signal function fires based on results of Indicator calculations
Rule dictates what action to take when the Signal is triggered
- At time t, when a
Rule is processed, it should should output an Order
- This
Order object should then be placed in an order queue to be handled at time t+1
- Based on the order type logic and perhaps some other settings (e.g. which price to trade at, generally assumed to be the open), at time t+1 all orders should be "processed"
- This
Order "processing" logic should probably depend on a Portfolio object, which should receive a series of Orders and make the appropriate adjustments at time t+1 to the position holdings and update the per-asset portfolio weights
Questions:
- Given an order queue containing some n, how should capital constraints be applied in deciding how to allocate trades under capital budgeting constraints? In other words, if we have $100 in the bank and all of today's orders would have us buying $120 worth of stocks, how should these trades be allocated? Just allocate pro-rata based on the sizes of all the orders?
- How should the above consideration be altered in the face of different asset classes? There should be logic added at some point that is intelligent enough to know that submitting an
Order to buy an equity constitutes a cash outflow at time t but that the same does not go for a futures contract. But futures contracts should probably have their own logic as well (e.g. initial margin, maintenance margin, etc).
Implement a Julia type,
Order(orAbstractOrderfrom which more concrete order types could be children, likeMarketOrder,LimitOrder,StopOrder, etc.) for storing, processing, and manipulating orders.This type should be able to interact with a
Portfolioobject in a highly structured order queue processing pattern. In other words, when aSignal/Ruletriggers some market action, it should be communicated through anOrdertype.At a broad level I imagine it would look somewhat like this.
Indicatorfunction runs computations on raw market data at each time tSignalfunction fires based on results ofIndicatorcalculationsRuledictates what action to take when theSignalis triggeredRuleis processed, it should should output anOrderOrderobject should then be placed in an order queue to be handled at time t+1Order"processing" logic should probably depend on aPortfolioobject, which should receive a series ofOrders and make the appropriate adjustments at time t+1 to the position holdings and update the per-asset portfolio weightsQuestions:
Orderto buy an equity constitutes a cash outflow at time t but that the same does not go for a futures contract. But futures contracts should probably have their own logic as well (e.g. initial margin, maintenance margin, etc).