Java Code Examples for com.paritytrading.foundation.ASCII#getLong()

The following examples show how to use com.paritytrading.foundation.ASCII#getLong() . 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 vote down vote up
@Override
public void orderRejected(POE.OrderRejected message) throws IOException {
    long orderEntryId = ASCII.getLong(message.orderId);

    Order order = orders.findByOrderEntryID(orderEntryId);
    if (order == null)
        return;

    switch (message.reason) {
    case POE.ORDER_REJECT_REASON_UNKNOWN_INSTRUMENT:
        sendOrderRejected(order, OrdRejReasonValues.UnknownSymbol);
        break;
    case POE.ORDER_REJECT_REASON_INVALID_PRICE:
        sendOrderRejected(order, OrdRejReasonValues.Other);
        break;
    case POE.ORDER_REJECT_REASON_INVALID_QUANTITY:
        sendOrderRejected(order, OrdRejReasonValues.IncorrectQuantity);
        break;
    default:
        sendOrderRejected(order, OrdRejReasonValues.Other);
        break;
    }

    orders.removeByOrderEntryID(orderEntryId);
}
 
Example 2
Source File: Session.java    From parity with Apache License 2.0 6 votes vote down vote up
@Override
public void orderExecuted(POE.OrderExecuted message) throws IOException {
    long orderEntryId = ASCII.getLong(message.orderId);

    Order order = orders.findByOrderEntryID(orderEntryId);
    if (order == null)
        return;

    Instrument config = instruments.get(order.getSymbol());

    double lastQty = message.quantity / config.getSizeFactor();
    double lastPx  = message.price    / config.getPriceFactor();

    order.orderExecuted(lastQty, lastPx);

    sendOrderExecuted(order, lastQty, lastPx, config);

    if (order.getLeavesQty() == 0) {
        orders.removeByOrderEntryID(orderEntryId);

        if (order.isInPendingStatus())
            sendOrderCancelReject(order);
    }
}
 
Example 3
Source File: Session.java    From parity with Apache License 2.0 6 votes vote down vote up
@Override
public void orderCanceled(POE.OrderCanceled message) throws IOException {
    long orderEntryId = ASCII.getLong(message.orderId);

    Order order = orders.findByOrderEntryID(orderEntryId);
    if (order == null)
        return;

    Instrument config = instruments.get(order.getSymbol());

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

    sendOrderCanceled(order, config);

    if (order.getLeavesQty() == 0)
        orders.removeByOrderEntryID(orderEntryId);
}
 
Example 4
Source File: ITCHClientEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void instrumentDirectory(ITCHClient session, ITCH.InstrumentDirectory packet) {
    long numberOfCurrencyPairs = ASCII.getLong(packet.numberOfCurrencyPairs);

    List<String> currencyPairs = new ArrayList<>();

    for (int i = 0; i < numberOfCurrencyPairs; i++)
        currencyPairs.add(ASCII.get(packet.currencyPair[i]));

    events.add(new InstrumentDirectory(currencyPairs));
}
 
Example 5
Source File: CboeFXBookEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void newOrder(CboeFXBook.NewOrder message) {
    byte   buyOrSellIndicator = message.buyOrSellIndicator;
    String currencyPair       = ASCII.get(message.currencyPair);
    String orderId            = ASCII.get(message.orderId);
    long   price              = ASCII.getFixed(message.price, PRICE_DECIMALS);
    long   amount             = ASCII.getLong(message.amount);
    long   minqty             = ASCII.getLong(message.minqty);
    long   lotsize            = ASCII.getLong(message.lotsize);

    events.add(new NewOrder(buyOrSellIndicator, currencyPair, orderId,
                price, amount, minqty, lotsize));
}
 
Example 6
Source File: CboeFXBookEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyOrder(CboeFXBook.ModifyOrder message) {
    String currencyPair = ASCII.get(message.currencyPair);
    String orderId      = ASCII.get(message.orderId);
    long   amount       = ASCII.getLong(message.amount);
    long   minqty       = ASCII.getLong(message.minqty);
    long   lotsize      = ASCII.getLong(message.lotsize);

    events.add(new ModifyOrder(currencyPair, orderId, amount,
                minqty, lotsize));
}
 
Example 7
Source File: CboeFXBookEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void marketSnapshotEntry(CboeFXBook.MarketSnapshotEntry entry) {
    String currencyPair       = ASCII.get(entry.currencyPair);
    byte   buyOrSellIndicator = entry.buyOrSellIndicator;
    long   price              = ASCII.getFixed(entry.price, PRICE_DECIMALS);
    long   amount             = ASCII.getLong(entry.amount);
    long   minqty             = ASCII.getLong(entry.minqty);
    long   lotsize            = ASCII.getLong(entry.lotsize);
    String orderId            = ASCII.get(entry.orderId);

    events.add(new MarketSnapshotEntry(currencyPair, buyOrSellIndicator,
                price, amount, minqty, lotsize, orderId));
}
 
Example 8
Source File: CboeFXBookEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void ticker(CboeFXBook.Ticker message) {
    byte   aggressorBuyOrSellIndicator = message.aggressorBuyOrSellIndicator;
    String currencyPair                = ASCII.get(message.currencyPair);
    long   price                       = ASCII.getFixed(message.price, PRICE_DECIMALS);
    long   transactionDate             = ASCII.getLong(message.transactionDate);
    long   transactionTime             = ASCII.getLong(message.transactionTime);

    events.add(new Ticker(aggressorBuyOrSellIndicator, currencyPair,
                price, transactionDate, transactionTime));
}
 
Example 9
Source File: ITCHServerEvents.java    From juncture with Apache License 2.0 5 votes vote down vote up
@Override
public void loginRequest(ITCHServer session, ITCH.LoginRequest packet) {
    String loginName             = ASCII.get(packet.loginName);
    String password              = ASCII.get(packet.password);
    byte   marketDataUnsubscribe = packet.marketDataUnsubscribe;
    long   reserved              = ASCII.getLong(packet.reserved);

    events.add(new LoginRequest(loginName, password, marketDataUnsubscribe, reserved));
}
 
Example 10
Source File: Session.java    From parity with Apache License 2.0 5 votes vote down vote up
@Override
public void orderAccepted(POE.OrderAccepted message) throws IOException {
    long orderEntryId = ASCII.getLong(message.orderId);

    Order order = orders.findByOrderEntryID(orderEntryId);
    if (order == null)
        return;

    order.orderAccepted(message.orderNumber);

    sendOrderAccepted(order);
}
 
Example 11
Source File: ITCH.java    From juncture with Apache License 2.0 4 votes vote down vote up
void get(ByteBuffer buffer) {
    buffer.get(numberOfCurrencyPairs);

    for (int i = 0; i < ASCII.getLong(numberOfCurrencyPairs); i++)
        buffer.get(currencyPair[i]);
}
 
Example 12
Source File: ITCH.java    From juncture with Apache License 2.0 4 votes vote down vote up
void put(ByteBuffer buffer) {
    buffer.put(numberOfCurrencyPairs);

    for (int i = 0; i < ASCII.getLong(numberOfCurrencyPairs); i++)
        buffer.put(currencyPair[i]);
}
 
Example 13
Source File: ITCHClientEvents.java    From juncture with Apache License 2.0 4 votes vote down vote up
@Override
public void loginAccepted(ITCHClient session, ITCH.LoginAccepted packet) {
    long sequenceNumber = ASCII.getLong(packet.sequenceNumber);

    events.add(new LoginAccepted(sequenceNumber));
}