com.apama.sor.oms
Event ParentOrderContainer


Event container structure for a parent order.
Since:
CMF 2.1.0
Routes:
com.apama.sor.oms.AllChildOrdersFinal - 
com.apama.oms.CancelOrder - 
com.apama.sor.oms.ChildOrderFinal - 
com.apama.sor.oms.ChildOrderUpdate - 
com.apama.oms.OrderUpdate - 
com.apama.sor.oms.ParentOrderContainerStopped - 
Sends:
com.apama.oms.SubscribeOrderToContext - 
com.apama.oms.UnsubscribeOrderToContext - 
Listens:
com.apama.sor.oms.AllChildOrdersFinal - 
com.apama.sor.dashboard.AmendChildOrder - 
com.apama.sor.dashboard.CancelChildOrder - 
com.apama.sor.dashboard.CancelChildOrders - 
com.apama.sor.dashboard.CancelParentOrders - 
com.apama.sor.oms.ChildOrderFinal - 
com.apama.sor.oms.ChildOrderUpdate - 
com.apama.sor.oms.OrderUpdate - 
com.apama.sor.oms.ParentOrderContainerStopped - 

Import summary
 TimeFormatPlugintimeFormat
 
Constant summary
 constant floatWAIT_CHILDREN_OUT_TIMEOUT := 60.0
 
Member summary
 wildcard stringid
 wildcard stringname
 wildcard stringownerId
 wildcard stringstrategy
 wildcard floattotalPrice
 wildcard booleanfillsFromLastShares
 dictionary<string, string>decorateExecutionReport
 com.apama.sor.utils.Auditorauditor
 com.apama.sor.utils.LatencyLoggerorderLatencyLogger
 com.apama.sor.utils.LatencyLoggermarketDataOrderLatencyLogger
 com.apama.sor.oms.ChildOrderNormaliserInterfacechildNormaliserIface
 wildcard integerchildOrderNum
 wildcard floatorderStartTimestamp
 wildcard booleanmonitorMarketDataOrderLatency
 dictionary<string, com.apama.sor.oms.ChildOrderContainer>childOrders
 dictionary<string, sequence<string>>destinationToChildOrderIds
 dictionary<string, integer>bustedChildOrders
 com.apama.sor.oms.OrderStatestate
 com.apama.oms.NewOrderorder
 com.apama.oms.OrderUpdateupdate
 com.apama.sor.oms.OrderDataViewdvOrder
 wildcard booleanterminate
 com.apama.sor.Constantsconstants
 wildcard contextmainContext
 wildcard contextorderContext
 
Action summary
 voidaccept(string message)

Called when required to send an order acknowledgment in response to the com.apama.oms.NewOrder event that instigated creation of the parent order container.
 voidamendAccept(float price, integer quantity, string message)

Called when required to send an order amend acknowledgment in response to a com.apama.oms.AmendOrder event received as a request to amend the parent order container details.
 booleanamendChildOrder(string orderId, float price, string type, integer quantity)

Amend a child order. If successful a ChildOrderChangeAccepted event will be routed; if unsuccessful a ChildOrderChangeRejected event will be routed.
 voidamendReject(string message)

Called when required to send an order amend reject in response to a com.apama.oms.AmendOrder event received as a request to amend the parent order container details.
 voidcancelAccept(string message)

Called when required to send an order cancel acknowledgment in response to a com.apama.oms.CancelOrder event received as a request to cancel the parent order container.
 voidcancelAllChildOrders()

Cancel all child orders.
 voidcancelAllChildOrdersFromDestination(string destination)

Cancel all child orders made to a given destination.
 booleancancelChildOrder(string orderId)

Cancel a child order. If unsuccessful a ChildOrderChangeRejected event will be routed; if successful a ChildOrderUpdate event will be routed with a state of CANCELLED.
 voidcancelChildOrders(sequence<string> orderIds)

Cancel a set of child orders.
 voidcancelReject(string message)

Called when required to send an order cancel reject in response to a com.apama.oms.CancelOrder event received as a request to cancel the parent order container.
 voidcreate(string strategy, string id, context mainContext, context orderContext, com.apama.oms.NewOrder order, com.apama.sor.utils.Auditor auditor, com.apama.sor.utils.LatencyLogger orderLatencyLogger, float orderStartTimestamp)

Set event parameters ready for execution.
 floatgetAveragePrice()
 dictionary<string, string>getExtraParams()
 stringgetId()
 stringgetMarket()
 com.apama.oms.NewOrdergetOrder()
 stringgetOwnerId()
 floatgetPrice()
 integergetQty()
 integergetQtyExecuted()
 integergetQtyNotWorking()
 integergetQtyRemaining()
 integergetQtyWorking()
 integergetQuantityInTheMarket(sequence<string> orderIds, boolean includeAll)

Utility action to return the quantity of child orders that are sitting in the market.
 stringgetService()
 stringgetSide()
 com.apama.sor.oms.OrderStategetState()
 stringgetSymbol()
 floatgetTickSize(sequence<string> upperbound, sequence<string> tickSize, float price)

Returns the tick size for a given price.
 stringgetType()
 voidinitialise(com.apama.sor.oms.ChildOrderNormaliserInterface orderNormaliserIface, action<com.apama.sor.oms.ParentOrderContainer> success)

Initialise the parent order container to perform the static and market data lookups.
 booleanisBuy()
 booleanisSell()
 voidkill()

Called to stop the parent order container as a hard kill.
 voidlogAmendOrder(string header, com.apama.oms.AmendOrder amendOrder)

Utility to pretty print an AmendOrder event to log file.
 voidlogCancelOrder(string header, com.apama.oms.CancelOrder cancelOrder)

Utility to pretty print a CancelOrder event to log file.
 voidlogDestinations(string header, dictionary<string, string> destinationToId)

Log the destination to base symbol lookup.
 voidlogNewOrder(string header, com.apama.oms.NewOrder newOrder)

Utility to pretty print a NewOrder event to log file.
 voidlogOrderStats(string header)

Utility to log the parent order container statistics.
 voidlogOrderUpdate(string header, com.apama.oms.OrderUpdate update)

Utility to log an order execution report.
 stringmakeChildOrder(string type, float price, integer quantity, string parentSymbol, string destination, boolean updateParent, boolean thisSide, float marketDataOrderStartTimestamp)

Make a child order. The action constructs a new ChildOrderContainer, submits the order and sets up child order update listeners to track the state of the child order. The destination supplied is mapped into marketId and serviceId via the static data.
 sequence<string>postResidual(integer quantityToPost, dictionary<string, float> post)

Utility action to post a residual quantity into the market as a set of limit orders.
 voidreject(string message)

Called when required to send an order reject in response to the com.apama.oms.NewOrder event that instigated creation of the parent order container.
 voidreload()

Reload the parent order container after setting the state, update and child orders via the public actions. This setups up the child order update listeners, and dashboard event listeners.
 floatroutePrice(float value, float tickSize, string side)

Round price to the supplied tickSize.
 voidsetChild(com.apama.sor.oms.ChildOrderContainer order)

Set a new child order to the list of child orders owned by the parent order container - used for reloading state details.
 voidsetState(com.apama.sor.oms.OrderState state)

Set the state of the parent order container - used for reloading the state details.
 voidsetUpdate(com.apama.oms.OrderUpdate update)

Set the last update of the parent order container - used for reloading the state details.
 voidstart()

Called to start the parent order container - sets up listeners internal to the event to listen for dashboard events.
 voidstop(string message)

Called to stop the parent order container.
 voidupdateParentOrder(integer lastShares, float lastPrice, string childOrderId, dictionary<string, string> extraParams)

Update the parent order for a fill - called when a child order is submitted where updateParent is set to false.
 
Import detail

timeFormat

            TimeFormatPlugin timeFormat
        

Constant detail

WAIT_CHILDREN_OUT_TIMEOUT

            constant float WAIT_CHILDREN_OUT_TIMEOUT := 60.0
        

Member detail

auditor

            com.apama.sor.utils.Auditor auditor
        

bustedChildOrders

            dictionary<string, integer> bustedChildOrders
        

childNormaliserIface

            com.apama.sor.oms.ChildOrderNormaliserInterface childNormaliserIface
        

childOrderNum

            wildcard integer childOrderNum
        

childOrders

            dictionary<string, com.apama.sor.oms.ChildOrderContainerchildOrders
        

constants

            com.apama.sor.Constants constants
        

decorateExecutionReport

            dictionary<string, string> decorateExecutionReport
        

destinationToChildOrderIds

            dictionary<string, sequence<string>> destinationToChildOrderIds
        

dvOrder

            com.apama.sor.oms.OrderDataView dvOrder
        

fillsFromLastShares

            wildcard boolean fillsFromLastShares
        

id

            wildcard string id
        

mainContext

            wildcard context mainContext
        

marketDataOrderLatencyLogger

            com.apama.sor.utils.LatencyLogger marketDataOrderLatencyLogger
        

monitorMarketDataOrderLatency

            wildcard boolean monitorMarketDataOrderLatency
        

name

            wildcard string name
        

order

            com.apama.oms.NewOrder order
        

orderContext

            wildcard context orderContext
        

orderLatencyLogger

            com.apama.sor.utils.LatencyLogger orderLatencyLogger
        

orderStartTimestamp

            wildcard float orderStartTimestamp
        

ownerId

            wildcard string ownerId
        

state

            com.apama.sor.oms.OrderState state
        

strategy

            wildcard string strategy
        

terminate

            wildcard boolean terminate
        

totalPrice

            wildcard float totalPrice
        

update

            com.apama.oms.OrderUpdate update
        

Action detail

accept

            void accept(string message)
        
Called when required to send an order acknowledgment in response to the com.apama.oms.NewOrder event that instigated creation of the parent order container.
Parameters:
message - The message to use in the order update status parameter

amendAccept

            void amendAccept(float price, integer quantity, string message)
        
Called when required to send an order amend acknowledgment in response to a com.apama.oms.AmendOrder event received as a request to amend the parent order container details.
Parameters:
price - The new price of the parent order
quantity - The new quantity of the parent order
message - The message to use in the order update status parameter

amendChildOrder

            boolean amendChildOrder(string orderId, float price, string type, integer quantity)
        
Amend a child order. If successful a ChildOrderChangeAccepted event will be routed; if unsuccessful a ChildOrderChangeRejected event will be routed.
Parameters:
orderId - The id of the child order to amend
price - The price to amend the child order to
type - The type to amend the child order to
quantity - The quantity to amend the child order to
Returns:
Boolean True if the amend was placed

amendReject

            void amendReject(string message)
        
Called when required to send an order amend reject in response to a com.apama.oms.AmendOrder event received as a request to amend the parent order container details.
Parameters:
message - The message to use in the order update status parameter

cancelAccept

            void cancelAccept(string message)
        
Called when required to send an order cancel acknowledgment in response to a com.apama.oms.CancelOrder event received as a request to cancel the parent order container.
Parameters:
message - The message to use in the order update status parameter

cancelAllChildOrders

            void cancelAllChildOrders()
        
Cancel all child orders.

cancelAllChildOrdersFromDestination

            void cancelAllChildOrdersFromDestination(string destination)
        
Cancel all child orders made to a given destination.
Parameters:
destination - The destination the child order was made to

cancelChildOrder

            boolean cancelChildOrder(string orderId)
        
Cancel a child order. If unsuccessful a ChildOrderChangeRejected event will be routed; if successful a ChildOrderUpdate event will be routed with a state of CANCELLED.
Parameters:
orderId - The id of the child order to cancel
Returns:
Boolean True if the amend was placed

cancelChildOrders

            void cancelChildOrders(sequence<string> orderIds)
        
Cancel a set of child orders.
Parameters:
orderIds - The child order ids to cancel
Listens:
com.apama.sor.oms.ChildOrderUpdate - 
com.apama.sor.oms.ChildOrderFinal - 

cancelReject

            void cancelReject(string message)
        
Called when required to send an order cancel reject in response to a com.apama.oms.CancelOrder event received as a request to cancel the parent order container.
Parameters:
message - The message to use in the order update status parameter

create

            void create(string strategy, string id, context mainContext, context orderContext, com.apama.oms.NewOrder order, com.apama.sor.utils.Auditor auditor, com.apama.sor.utils.LatencyLogger orderLatencyLogger, float orderStartTimestamp)
        
Set event parameters ready for execution.
Parameters:
strategy - The name of the strategy creating the parent order
id - The order id of the parent order container
mainContext
orderContext - The context where orders or updates need to be sent to
order - The new order event for the parent order container
auditor - The auditor instance for auditing within the parent order container
orderLatencyLogger - The LatencyLogger helper
orderStartTimestamp - The order start timestamp
Sends:
com.apama.oms.UnsubscribeOrderToContext - 
Listens:
com.apama.sor.oms.ParentOrderContainerStopped - 

getAveragePrice

            float getAveragePrice()
        

getExtraParams

            dictionary<string, string> getExtraParams()
        

getId

            string getId()
        

getMarket

            string getMarket()
        

getOrder

            com.apama.oms.NewOrder getOrder()
        

getOwnerId

            string getOwnerId()
        

getPrice

            float getPrice()
        

getQty

            integer getQty()
        

getQtyExecuted

            integer getQtyExecuted()
        

getQtyNotWorking

            integer getQtyNotWorking()
        

getQtyRemaining

            integer getQtyRemaining()
        

getQtyWorking

            integer getQtyWorking()
        

getQuantityInTheMarket

            integer getQuantityInTheMarket(sequence<string> orderIds, boolean includeAll)
        
Utility action to return the quantity of child orders that are sitting in the market.

If includeAll is set to false, only orders that are in the WORKING state are included in the summation; if includeAll is true then WAITING, PENDING_CANCEL and PENDING_CHANGE orders are also included.
Parameters:
orderIds - The orderIds of the child orders used in the calculation Use childOrders.keys() to get all child order orderIds
includeAll - True to include orders that are still in the WAITING, PENDING_CHANGE and PENDING_CANCELL states
Returns:
The quantity that is sitting in the market

getService

            string getService()
        

getSide

            string getSide()
        

getState

            com.apama.sor.oms.OrderState getState()
        

getSymbol

            string getSymbol()
        

getTickSize

            float getTickSize(sequence<string> upperbound, sequence<string> tickSize, float price)
        
Returns the tick size for a given price.
Parameters:
upperbound
tickSize
price

getType

            string getType()
        

initialise

            void initialise(com.apama.sor.oms.ChildOrderNormaliserInterface orderNormaliserIface, action<com.apama.sor.oms.ParentOrderContainer> success)
        
Initialise the parent order container to perform the static and market data lookups.
Parameters:
orderNormaliserIface
success

isBuy

            boolean isBuy()
        

isSell

            boolean isSell()
        

kill

            void kill()
        
Called to stop the parent order container as a hard kill.
Routes:
com.apama.sor.oms.ParentOrderContainerStopped - 

logAmendOrder

            void logAmendOrder(string header, com.apama.oms.AmendOrder amendOrder)
        
Utility to pretty print an AmendOrder event to log file.
Parameters:
header - A header message to be logged before the new order event
amendOrder

logCancelOrder

            void logCancelOrder(string header, com.apama.oms.CancelOrder cancelOrder)
        
Utility to pretty print a CancelOrder event to log file.
Parameters:
header - A header message to be logged before the cancel order event
cancelOrder

logDestinations

            void logDestinations(string header, dictionary<string, string> destinationToId)
        
Log the destination to base symbol lookup.
Parameters:
header - A header message to be logged before the update
destinationToId

logNewOrder

            void logNewOrder(string header, com.apama.oms.NewOrder newOrder)
        
Utility to pretty print a NewOrder event to log file.
Parameters:
header - A header message to be logged before the new order event
newOrder - The new order event to be logged

logOrderStats

            void logOrderStats(string header)
        
Utility to log the parent order container statistics.
Parameters:
header - A header message to be logged before the stats

logOrderUpdate

            void logOrderUpdate(string header, com.apama.oms.OrderUpdate update)
        
Utility to log an order execution report.
Parameters:
header - A header message to be logged before the update
update - The com.apama.oms.OrderUpdate to log

makeChildOrder

            string makeChildOrder(string type, float price, integer quantity, string parentSymbol, string destination, boolean updateParent, boolean thisSide, float marketDataOrderStartTimestamp)
        
Make a child order. The action constructs a new ChildOrderContainer, submits the order and sets up child order update listeners to track the state of the child order. The destination supplied is mapped into marketId and serviceId via the static data.
Parameters:
type - The type of the order
price - The price of the order to place
quantity - The quantity of the order to place
parentSymbol
destination - The destination to place the order on
updateParent - Boolean to indicate if child order updates result in updating the parent order container
thisSide - Boolean to indicate if the child order is the same side as the parent
marketDataOrderStartTimestamp - Market data order start timestamp
Returns:
The child order id if successful; -1 if not successful

postResidual

            sequence<string> postResidual(integer quantityToPost, dictionary<string, float> post)
        
Utility action to post a residual quantity into the market as a set of limit orders.

The action takes the quantity to post, and a dictionary of the posting percentages to named destinations. To use the posting values as set up for this parent order, use the post parameter of the routingRule global variable, e.g. postResidual(1000, routingRule.post).
Parameters:
quantityToPost - The quantity to post to the available destination
post - A dictionary of the posting values for named markets
Returns:
Sequence of the orderIds submitted to the market

reject

            void reject(string message)
        
Called when required to send an order reject in response to the com.apama.oms.NewOrder event that instigated creation of the parent order container.
Parameters:
message - The message to use in the order update status parameter

reload

            void reload()
        
Reload the parent order container after setting the state, update and child orders via the public actions. This setups up the child order update listeners, and dashboard event listeners.

On reload set the parent order state, child orders, and last update and then invoke this action. Note, do not use the start() method on reloading.

routePrice

            float routePrice(float value, float tickSize, string side)
        
Round price to the supplied tickSize.
Parameters:
value
tickSize
side

setChild

            void setChild(com.apama.sor.oms.ChildOrderContainer order)
        
Set a new child order to the list of child orders owned by the parent order container - used for reloading state details.
Parameters:
order - The com.apama.sor.oms.ChildOrderContainer event

setState

            void setState(com.apama.sor.oms.OrderState state)
        
Set the state of the parent order container - used for reloading the state details.
Parameters:
state - The com.apama.sor.oms.OrderState event to represent the new state

setUpdate

            void setUpdate(com.apama.oms.OrderUpdate update)
        
Set the last update of the parent order container - used for reloading the state details.
Parameters:
update - The com.apama.oms.OrderUpdate event for the new update

start

            void start()
        
Called to start the parent order container - sets up listeners internal to the event to listen for dashboard events.

stop

            void stop(string message)
        
Called to stop the parent order container.
Parameters:
message - A message to use in the order update status parameter

updateParentOrder

            void updateParentOrder(integer lastShares, float lastPrice, string childOrderId, dictionary<string, string> extraParams)
        
Update the parent order for a fill - called when a child order is submitted where updateParent is set to false.
Parameters:
lastShares - The fill amount to add to the parent
lastPrice - The price of the last fill
childOrderId - The child order id where the fill originated from
extraParams - Extra parameters from the child order update