Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Remove superfluous instrument lookups from FIX gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
jvirtanen committed Aug 14, 2017
1 parent eea40f8 commit 2ced042
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,9 @@ private void sendOrderRejected(String clOrdId, int ordRejReason,
fix.send(txMessage);
}

private void sendOrderExecuted(Order order, double lastQty, double lastPx) throws IOException {
private void sendOrderExecuted(Order order, double lastQty, double lastPx, Instrument config) throws IOException {
fix.prepare(txMessage, ExecutionReport);

String symbol = order.getSymbol();

Instrument config = instruments.get(symbol);

int priceFractionDigits = config.getPriceFractionDigits();
int sizeFractionDigits = config.getSizeFractionDigits();

Expand All @@ -581,7 +577,7 @@ private void sendOrderExecuted(Order order, double lastQty, double lastPx) throw
if (order.getAccount() != null)
txMessage.addField(Account).setString(order.getAccount());

txMessage.addField(Symbol).setString(symbol);
txMessage.addField(Symbol).setString(order.getSymbol());
txMessage.addField(Side).setChar(order.getSide());
txMessage.addField(OrderQty).setFloat(order.getOrderQty(), sizeFractionDigits);
txMessage.addField(LastQty).setFloat(lastQty, sizeFractionDigits);
Expand Down Expand Up @@ -623,13 +619,9 @@ private void sendOrderCancelAcknowledgement(Order order, char execType, char ord
fix.send(txMessage);
}

private void sendOrderCanceled(Order order) throws IOException {
private void sendOrderCanceled(Order order, Instrument config) throws IOException {
fix.prepare(txMessage, ExecutionReport);

String symbol = order.getSymbol();

Instrument config = instruments.get(symbol);

int priceFractionDigits = config.getPriceFractionDigits();
int sizeFractionDigits = config.getSizeFractionDigits();

Expand All @@ -651,7 +643,7 @@ private void sendOrderCanceled(Order order) throws IOException {
if (order.getAccount() != null)
txMessage.addField(Account).setString(order.getAccount());

txMessage.addField(Symbol).setString(symbol);
txMessage.addField(Symbol).setString(order.getSymbol());
txMessage.addField(Side).setChar(order.getSide());
txMessage.addField(OrderQty).setFloat(order.getOrderQty(), sizeFractionDigits);
txMessage.addField(LeavesQty).setFloat(order.getLeavesQty(), sizeFractionDigits);
Expand Down Expand Up @@ -711,7 +703,7 @@ public void orderExecuted(POE.OrderExecuted message) throws IOException {

order.orderExecuted(lastQty, lastPx);

sendOrderExecuted(order, lastQty, lastPx);
sendOrderExecuted(order, lastQty, lastPx, config);

if (order.getLeavesQty() == 0) {
orders.removeByOrderEntryID(message.orderId);
Expand All @@ -731,7 +723,7 @@ public void orderCanceled(POE.OrderCanceled message) throws IOException {

order.orderCanceled(message.canceledQuantity / config.getSizeFactor());

sendOrderCanceled(order);
sendOrderCanceled(order, config);

if (order.getLeavesQty() == 0)
orders.removeByOrderEntryID(message.orderId);
Expand Down

0 comments on commit 2ced042

Please sign in to comment.