Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Order Management : Risk firewall : Sending orders into a risk firewall : Sample code for using OrderSender
Sample code for using OrderSender
The following sample code show the tasks that must be accomplished before an application can use an order sender to submit orders to a risk firewall. This example uses an order sender to submit a hardcoded new order to the risk firewall. In a real application, the sendOrder() action would likely be called when a user-interface event occurs, such as a user clicking on a Buy button.
using com.apama.firewall.RiskFirewallFactory;
using com.apama.firewall.RiskFirewall;
using com.apama.oms.NewOrder;
 
monitor RiskFirewallExample12 {
 
action onload() {
// Use a risk firewall factory to create a new
// risk firewall instance named MyFirewall. This example
// uses the default configuration parameter settings.
RiskFirewall rfw :=
(new RiskFirewallFactory).create(context.current(), "MyFirewall");
 
// Register a rule class and add an instance of that class.
...
 
// Create a receiver for the orders coming out of the
// risk firewall and add a callback to be executed
// upon approval of new orders.
integer refId := rfw.getOrderReceiver().
addAcceptedOrderCallback( cbOnApprovedNewOrders );
 
// Unlock the risk firewall.
rfw.unlockCb( cbOnFirewallUnlocked );
}
 
// This action is called after the risk firewall is unlocked.
// It indicates that the risk firewall is ready to receive orders.
// Typically, orders are sent at a later time and a callback that
// indicates when orders can be sent is not needed.
action cbOnFirewallUnlocked ( RiskFirewall rfw ) {
 
// Send a new order to the risk firewall.
rfw.getOrderSender().sendOrder(
NewOrder("orderId_1","APMA.L", 1.0, "BUY", "MARKET", 10,
"TargetService", "","","TargetMarket","", "TraderA",
new dictionary<string,string> ) );
}
 
// Set up a callback handler for new orders that the
// risk firewall has approved.
action cbOnApprovedNewOrders( NewOrder order ) {
log "Firewall has approved the NewOrder: "+order.toString();
}
}
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback