com.paritytrading.philadelphia.FIXValue Java Examples
The following examples show how to use
com.paritytrading.philadelphia.FIXValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Session.java From parity with Apache License 2.0 | 6 votes |
@Override public void logon(FIXConnection connection, FIXMessage message) throws IOException { FIXValue username = message.valueOf(Username); FIXValue password = message.valueOf(Password); if (requiredTagMissing(message, username, "Username(553)")) return; if (requiredTagMissing(message, password, "Password(554)")) return; fix.updateCompID(message); ASCII.putLeft(loginRequest.username, username.asString()); ASCII.putLeft(loginRequest.password, password.asString()); ASCII.putRight(loginRequest.requestedSession, ""); ASCII.putLongRight(loginRequest.requestedSequenceNumber, 0); orderEntry.login(loginRequest); }
Example #2
Source File: Coinbase.java From philadelphia-extras with Apache License 2.0 | 5 votes |
private static void appendField(FIXMessage message, int tag, String fieldName, StringBuilder s) { FIXValue value = message.valueOf(tag); if (value == null) throw new IllegalStateException(fieldName + " not found"); value.asString(s); }
Example #3
Source File: Initiator.java From philadelphia with Apache License 2.0 | 5 votes |
void sendAndReceive(FIXMessage message, FIXValue clOrdId, int orders) throws IOException { for (long sentAtNanoTime = System.nanoTime(); receiveCount < orders; connection.receive()) { if (System.nanoTime() >= sentAtNanoTime) { clOrdId.setInt(sentAtNanoTime); connection.update(message); connection.send(message); sentAtNanoTime += intervalNanos; } } }
Example #4
Source File: Session.java From parity with Apache License 2.0 | 5 votes |
private boolean requiredTagMissing(FIXMessage message, FIXValue value, String tag) throws IOException { if (value != null) return false; fix.sendReject(message.getMsgSeqNum(), SessionRejectReasonValues.RequiredTagMissing, tag + " missing"); return true; }
Example #5
Source File: Session.java From parity with Apache License 2.0 | 4 votes |
private void orderCancel(FIXMessage message, char msgType) throws IOException { FIXValue clOrdIdValue = null; FIXValue origClOrdIdValue = null; FIXValue orderQtyValue = null; for (int i = 0; i < message.getFieldCount(); i++) { switch (message.tagAt(i)) { case ClOrdID: clOrdIdValue = message.valueAt(i); break; case OrigClOrdID: origClOrdIdValue = message.valueAt(i); break; case OrderQty: orderQtyValue = message.valueAt(i); break; } } if (requiredTagMissing(message, origClOrdIdValue, "OrigClOrdID(41)")) return; if (requiredTagMissing(message, clOrdIdValue, "ClOrdID(11)")) return; if (msgType == OrderCancelReplaceRequest) { if (requiredTagMissing(message, orderQtyValue, "OrderQty(38)")) return; } char cxlRejResponseTo = CxlRejResponseToValues.OrderCancelRequest; if (msgType == OrderCancelReplaceRequest) cxlRejResponseTo = CxlRejResponseToValues.OrderCancel; String origClOrdId = origClOrdIdValue.asString(); String clOrdId = clOrdIdValue.asString(); Order order = orders.findByClOrdID(origClOrdId); if (order == null) { sendOrderCancelReject(clOrdId, origClOrdId, cxlRejResponseTo); return; } else if (order.isInPendingStatus()) { sendOrderCancelReject(order, clOrdId, cxlRejResponseTo, CxlRejReasonValues.OrderAlreadyInPendingStatus); return; } if (orders.findByClOrdID(clOrdId) != null) { sendOrderCancelReject(order, clOrdId, cxlRejResponseTo, CxlRejReasonValues.DuplicateClOrdID); return; } double orderQty = 0.0; if (msgType == OrderCancelReplaceRequest) { try { orderQty = orderQtyValue.asFloat(); } catch (FIXValueFormatException e) { incorrectDataFormatForValue(message, "Expected 'float' in OrderQty(38)"); return; } } double qty = Math.max(orderQty - order.getCumQty(), 0); Instrument config = instruments.get(order.getSymbol()); order.setNextClOrdID(clOrdId); order.setCxlRejResponseTo(cxlRejResponseTo); ASCII.putLongLeft(cancelOrder.orderId, order.getOrderEntryID()); cancelOrder.quantity = (long)(qty * config.getSizeFactor()); send(cancelOrder); char execType = ExecTypeValues.PendingCancel; char ordStatus = OrdStatusValues.PendingCancel; if (msgType == OrderCancelReplaceRequest) { execType = ExecTypeValues.PendingReplace; ordStatus = OrdStatusValues.PendingReplace; } sendOrderCancelAcknowledgement(order, execType, ordStatus); }