Capital Markets Adapters 10.11 | Apama Capital Markets Adapters Documentation 10.11 | Apama Base FIX Adapter | FIX service monitors | Client session | FIX_OrderManager | Event Interfaces APIs
 
Event Interfaces APIs
Package com.apama.fix
Order Manager(OM) provides the following interfaces and factory interfaces:
OrderManagerInterface
Provides the callback actions to handle the com.apama.oms New/Amend/Cancel events and session reconfiguration.
event OrderManagerInterface
{
// action call back for handle Neworder
action<com.apama.oms.NewOrder /*newOrder*/, dictionary<integer, float>
/*timestamps*/ > onNewOrder;
// action call back for handle AmendOrder
action<com.apama.oms.AmendOrder /*amendOrder*/ , dictionary<integer, float>
/*timestamps*/ > onAmendOrder;
// action call back for handle CancelOrder
action<com.apama.oms.CancelOrder /cancelOrder*/ , dictionary<integer, float>
/*timestamps*/ > onCancelOrder;
// action call back for handle Mass CancelOrder
action<com.apama.oms.CancelOrder /*massCancel*/ > CancelAllOrders;
// action call back for Session configuration
action<SessionConfiguration /*config*/> handleSessionReconfigurations;

// action to set a callback for order update
action < action<com.apama.oms.OrderUpdate /*update*/, boolean /*isFinial*/,
dictionary<integer, float> /*timeStamp*/ > > setOnOrderUpdateCallback;

//following actions are for internal use only
action<ContextDictInterface, MultiContextAPI> contextInit;
action<> reset;
}
Description:
action<com.apama.oms.NewOrder /*order*/, dictionary<integer, float>
/*timestamps*/ > onNewOrder : This action will be called when Neworder
event listener is triggered.
Argument :
@1 - com.apama.oms.NewOrder event object
@2 - timestamps dictionary
action<com.apama.oms.AmendOrder /*amendOrder*/, dictionary<integer, float>
/*timestamps*/ > onAmendOrder : This action will be called when AmendOrder
event listener is triggered.
Argument :
@1 - com.apama.oms.AmendOrder event object
@2 - timestamps dictionary
action<com.apama.oms.CancelOrder /cancelOrder*/, dictionary<integer, float>
/*timestamps*/ > onCancelOrder : This action will be called when
CancelOrder event listener is triggered.
Argument :
@1 - com.apama.oms.CancelOrder event object
@2 - timestamps dictionary
action<com.apama.oms.CancelOrder /*massCancel*/> CancelAllOrders :
This action will be called when CancelOrder(for MassCancel)
event listener is triggered.
Argument :
@1 - com.apama.oms.CancelOrder event object
action<SessionConfiguration /*config*/> handleSessionReconfigurations :
This action is used to handle the session re-configuration.
Argument :
@1 - SessionConfiguration event object
The response for all placed Orders must be updated by setOnOrderUpdateCallback callback.
action < action<com.apama.oms.OrderUpdate /*update*/, boolean /*isFinial*/,
dictionary<integer, float> /*timeStamp*/ > > setOnOrderUpdateCallback :
Argument :
@1 - An update action that will be called whenever an order update is received.
This action should have the following parameters -
@1 - com.apama.oms.OrderUpdate event object
@2 - the Order is finished or not
@3 - timestamps dictionary
See "BaseFIXOrderManager" module in "FIX_OrderManager.mon" file for the default implementation of above call backs. You can provide custom implementation by overriding these actions.
Messagehandleriface
This interface provides a set of callbacks for handling the FIX based (both downstream and upstream ) messages.
event Messagehandleriface
{
//send NewOrdereSingle message
action <string /*orderId*/,string /*fixSymbol*/,string /*side*/,
string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.NewOrder/*origOrder*/,
dictionary<integer,float> /*timeStamp*/> sendNewOrderSingleMessage;

//send OrderCancelReplaceRequest message
action <string /*origClOrdId*/,string /*ClOrdId*/,string /*marketOrderId*/ ,
string /*fixSymbol*/,string /*side*/,string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.AmendOrder/*amendOrder*/,
dictionary<integer,float> /*timeStamp*/> sendOrderCancelReplaceRequest;

//send OrderCancelReplaceRequest message
action <string /*origClOrdId*/,string /*clOrdId*/,string /*marketOrderId*/,
string /*fixSymbol*/, string /*side*/,integer /*quantity*/,
dictionary <string, string> /*extraParams*/,
dictionary<integer,float> /*timeStamp*/> sendOrderCancelRequest;

//send sendQuoteResponse message
action <string /*orderId*/,string /*fixSymbol*/,string /*side*/,
string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.NewOrder/*origOrder*/,
dictionary <integer,float> /*timeStamp*/> sendQuoteResponse;


action <string /*clOrderId*/ >sendOrderMassCancelRequest;


action <string /*fixId*/,string /*preFixId*/ ,OrderCancelReject
/*orderCancelReject*/, OrderContainer /*orderContainer*/,
float /*bustTime*/,dictionary <string, string>
/*orderRejectedIDs*/ > gotOrderChangeReject;


action <ExecutionReport /*executionReport*/,OrderContainer
/*orderContainer*/,float /*bustTime*/,
dictionary <string, string> /*orderRejectedIDs */ ,
dictionary<string,OrderContainer>
/*clOrdIdToOrderContainer*/ > gotExecutionReport;


action < action<com.apama.oms.OrderUpdate, boolean,
dictionary<integer, float> >,
action<string /*fixId*/,OrderContainer /*ordContainer*/>
/*finishedOrder*/ > setUpdateCallbacks;

// action call back for Session configuration
action<SessionConfiguration> handleSessionReconfiguration;

// generate FIX Order ID
action <> returns string getFIXOrderID;

action<> reset;
}
Description:
action <string /*orderId*/,string /*fixSymbol*/,string
/*side*/,string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.NewOrder/*origOrder*/,
dictionary<integer,float> /*timeStamp*/> sendNewOrderSingleMessage;
It is used to create the NewOrderSingle message based on parameters
and send it to exchange. When OM receives the NewOrder request,
it will validate the request then call this interface action for
order handling.
Argument :
@1 - string /*orderId*/ -> clOrdId
@2 - string /*fixSymbol*/ -> symbol
@3 - string /*side*/ -> order side
@4 - string /*ordType*/ -> Order type
@5 - float /*OrderQty*/ -> Order quantity,
@6 - dictionary <string, string> /*extraParams*/ -> dictionaries
of extraParams of NewOrders
@7 - com.apama.oms.NewOrder/*origOrder*/ -> NewOrder object
@8 - dictionary<integer,float> /*timeStamp*/ -> timestamps
action <string /*origClOrdId*/,string /*ClOrdId*/,string /*marketOrderId*/ ,
string /*fixSymbol*/,string /*side*/,string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.AmendOrder/*amendOrder*/,
dictionary<integer,float> /*timeStamp*/> sendOrderCancelReplaceRequest;
This is used to create the OrderCancelReplaceRequest message based on
parameters and send it to exchange.
When OM receives the Amend order request, it will validate the request
then call this interface action for handle the AmendOrder.
Argument :
@1 - string /*origClOrdId*/ -> original clOrdId
@2 - string /*ClOrdId*/ -> clOrdId
@3 - string /*marketOrderId*/ -> market Order Id
@4 - string /*fixSymbol*/ -> symbol
@5 - string /*side*/ -> order side
@6 - string /*ordType*/ -> Order type
@7 - float /*OrderQty*/ -> Order quantity,
@8 - dictionary <string, string> /*extraParams*/ ->
dictionaries of extraParams of Amend order
@9 - com.apama.oms.AmendOrder/*amendOrder*/ -> AmendOrder object
@10 - dictionary<integer,float> /*timeStamp*/ -> timestamps
action <string /*origClOrdId*/,string /*clOrdId*/,string
/*marketOrderId*/,string /*fixSymbol*/,
string /*side*/,integer /*quantity*/,dictionary <string, string>
/*extraParams*/,dictionary<integer,float> /*timeStamp*/>
sendOrderCancelRequest;
This is used to create the OrderCancelRequest message based on
parameters and send it to exchange.
On receiving the Cancel order request, OM validates the request
then call this interface action for handling the Cancel order.
Argument :
@1 - string /*origClOrdId*/ -> original clOrdId
@2 - string /*ClOrdId*/ -> clOrdId
@3 - string /*marketOrderId*/ -> market Order Id
@4 - string /*fixSymbol*/ -> symbol
@5 - string /*side*/ -> order side
@6 - float /*OrderQty*/ -> Order quantity,
@7 - dictionary <string, string> /*extraParams*/ ->
dictionaries of extraParams of order
@8 - dictionary<integer,float> /*timeStamp*/ -> timestamps
action <string /*orderId*/,string /*fixSymbol*/,string
/*side*/,string /*ordType*/,float /*OrderQty*/,
dictionary <string, string> /*extraParams*/,
com.apama.oms.NewOrder/*origOrder*/,
dictionary<integer,float> /*timeStamp*/> sendQuoteResponse;
This is used to create the QuoteResponse message based on parameters
and send it to exchange.
Argument :
@1 - string /*orderId*/ -> clOrdId
@2 - string /*fixSymbol*/ -> symbol
@3 - string /*side*/ -> order side
@4 - string /*ordType*/ -> Order type
@5 - float /*OrderQty*/ -> Order quantity,
@6 - dictionary <string, string> /*extraParams*/ ->
dictionaries of extraParams of order
@7 - com.apama.oms.NewOrder/*origOrder*/ -> NewOrder object,
@7 - dictionary<integer,float> /*timeStamp*/ -> timestamps.
action <string /*origClOrdId*/,string /*clOrdId*/,string
/*marketOrderId*/,string /*fixSymbol*/,
string /*side*/,integer /*quantity*/,dictionary <string, string>
/*extraParams*/,dictionary<integer,float> /*timeStamp*/>
sendOrderCancelRequest;
This is used to create the OrderCancelRequest message based on parameters
and send it to exchange.
On received the Cancel order request,OM validate the request then
call this interface action for handling the Cancel order.
Argument :
@1 - string /*origClOrdId*/ -> original clOrdId
@2 - string /*ClOrdId*/ -> clOrdId
@3 - string /*marketOrderId*/ -> market Order Id
@4 - string /*fixSymbol*/ -> symbol
@5 - string /*side*/ -> order side
@6 - float /*OrderQty*/ -> Order quantity,
@7 - dictionary <string, string> /*extraParams*/ ->
dictionaries of extraParams of order
@8 - dictionary<integer,float> /*timeStamp*/ -> timestamps.
action <string /*clOrderId*/ >sendOrderMassCancelRequest;
This is used to create the OrderMassCancelRequest message
based on parameters and send it to exchange.
On receiving the Mass Cancel request, OM validates the request
then call this interface action for handling the Mass cancel.
Argument :
@1 - string /*clOrderId*/ -> clOrdId .
action<SessionConfiguration /*config*/> handleSessionReconfiguration;
It is used to handled the session re-configuration.
Argument :
@1 - SessionConfiguration /*config*/ -> SessionConfiguration object
action <> returns string getFIXOrderID;
It is used to generate the FIX order id. By overriding this call back
user can provide the custom implementation.
action < action<com.apama.oms.OrderUpdate, boolean,
dictionary<integer, float> >,
action<string /*fixId*/,OrderContainer /*ordContainer*/>
/*finishedOrder*/ > setUpdateCallbacks;
Using above callbacks , user should update the OrderUpdate and
finishedOrder details to "BaseFIXOrderManager" module which is
responsible for memory cleaner and/or update the order response
to user.

action<com.apama.oms.OrderUpdate, boolean, dictionary<integer,
float> /*onOrderUpdateCallback*/ - > Order Update call back.
Argument :
@1 - com.apama.oms.OrderUpdate /*update*/ -> Order Update object
@2 - boolean /*isFinial*/ -> is Order finished ?
@3 - dictionary<integer, float> -> timeStamp.

action<string /*fixId*/,OrderContainer /*ordContainer*/>
/*finishedOrder*/ - > finishedOrder
Argument :
@1 - string /*fixId*/ -> clOrdId
@2 - OrderContainer /*container*/ -> Order Container list
Downstream Message handle callbacks
action <string /*fixId*/,string /*preFixId*/, OrderCancelReject
/*orderCancelReject*/, OrderContainer /*orderContainer*/,float
/*bustTime*/,dictionary <string, string> /*orderRejectedIDs*/ >
gotOrderChangeReject;
On receiving the OrderChangeReject request, OM calls this interface action
to process the Order amend/cancel reject message and update the
result by calling onOrderUpdateCallback.
Argument :
@1 - string /*fixId*/ -> clOrdId
@2 - string /*preFixId*/ -> original clOrdId
@3 - OrderCancelReject /*orderCancelReject*/ -> orderCancelReject object
@4 - OrderContainer /*orderContainer*/ ->
OrderContainer (it contains corresponding dictionaries)
@5 - float /*bustTime*/ -> bustTime
@6 - dictionary <string, string> /*orderRejectedIDs*/ ->
previous orderRejectedIDs list
action <ExecutionReport /*executionReport*/,OrderContainer
/*orderContainer*/,float /*bustTime*/,
dictionary <string, string> /*orderRejectedIDs */ ,
dictionary<string,OrderContainer> /*clOrdIdToOrderContainer*/ >
gotExecutionReport;

On receiving the ExecutionReport request, OM calls this interface action
to process the execution report message and update the result by calling
onOrderUpdateCallback.
Argument :
@1 - ExecutionReport /*executionReport*/ -> ExecutionReport object
@2 - OrderContainer /*orderContainer*/ -> OrderContainer
(it contains corresponding dictionaries)
@3 - float /*bustTime*/ -> bustTime
@4 - dictionary <string, string> /*orderRejectedIDs*/ -> previous
orderRejectedIDs list
@5 - dictionary<string,OrderContainer> /*clOrdIdToOrderContainer*/ ->
dictionary for clOrdId to OrderContainer.
Factory API's:(package com.apama.fix)
The factory object performs the following steps and returns corresponding interface to the user.
*Create an interface object
*Create the default handler object
*Maps each callbacks to default handler actions.
DefaultMessagehandlerfactory
This factory object takes Messagehandleriface interface as input and maps it to the DefaultMessagehandler.
It initializes the interface, maps each actions to the default implementation and returns an interface object (Messagehandleriface).
action create(SessionConfiguration config ,string idNum,
OrderManagerUtils orderManagerUtils) returns Messagehandleriface.
Argument:
@1 - SessionConfiguration /*config*/ -> session config parameter
@2 - string /*idNum*/ -> which is used during FIX order id generation.
@3 - OrderManagerUtils -> OrderManagerUtils object.
BaseFIXOrderManagerFactory
This factory object takes OrderManagerInterface interface as input and maps it to the BaseFIXOrderManager.
It initializes the interface, maps each actions to the default implementation and returns an interface object (OrderManagerInterface).
action create(string serviceId,string CONNECTION, SessionConfiguration config,
OrderManagerUtils orderManagerUtils, Messagehandleriface msgIface )
returns OrderManagerInterface
Argument:
@1 - string /*serviceId*/ -> serviceId
@2 - string /*CONNECTION*/ -> TransportName
@3 - SessionConfiguration /*config*/ -> session config parameter
@4 - OrderManagerUtils -> Order Manager Utils object.
@5 - Messagehandleriface -> Messagehandleriface interface object.
Example(custom implementation for Amend order)
monitor OrderManager
{
constant string MONITOR_NAME := "FIX Order Manager";
string SERVICE_NAME := "FIX";

SessionConfiguration config;

// the connection to use
string CONNECTION;

//the current id
string idNum := "0";
OrderManagerUtils orderManagerUtils;

action onload()
{
orderManagerUtils.init();

on all unmatched SessionConfiguration():config {
integer val := integer.parse(idNum)+1;
idNum:=val.toString();
spawn newSession;
}
}

action newSession {

CONNECTION:=config.connection;;

SERVICE_NAME := config.getConfigString(FIXConfigParams.SERVICEID,SERVICE_NAME);

Messagehandleriface mhiface := (new DefaultMessagehandlerfactory).
create(config, idNum, orderManagerUtils);
OrderManagerInterface iface := (new BaseFIXOrderManagerFactory).
create(SERVICE_NAME, CONNECTION, config, orderManagerUtils, mhiface);

iface.onAmendOrder := customAmendOrderHandler;

GenericOrderManager genOMImp := new GenericOrderManager;
genOMImp.init(SERVICE_NAME,CONNECTION,iface, config) ;
}

action customAmendOrderHandler()
{
}
}