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

Commit

Permalink
Merge pull request #61 from jvirtanen/features/foundation
Browse files Browse the repository at this point in the history
Use Foundation
  • Loading branch information
jvirtanen committed Apr 21, 2016
2 parents c55a5a2 + c178402 commit 26ab0fa
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 68 deletions.
8 changes: 4 additions & 4 deletions parity-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<artifactId>parity-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -45,10 +49,6 @@
<groupId>org.jvirtanen.config</groupId>
<artifactId>config-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.lang</groupId>
<artifactId>lang-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.util</groupId>
<artifactId>util-extras</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jvirtanen.parity.client.command;

import static org.jvirtanen.lang.Strings.*;
import static org.jvirtanen.parity.client.TerminalClient.*;

import com.paritytrading.foundation.ASCII;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.Scanner;
Expand All @@ -23,7 +23,7 @@ public EnterCommand(byte side) {
public void execute(TerminalClient client, Scanner arguments) throws CommandException, IOException {
try {
long quantity = arguments.nextInt();
long instrument = encodeLong(arguments.next());
long instrument = ASCII.packLong(arguments.next());
long price = (int)(arguments.nextDouble() * PRICE_FACTOR);

if (arguments.hasNext())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jvirtanen.parity.client.event;

import static org.jvirtanen.lang.Strings.*;
import static org.jvirtanen.parity.client.TerminalClient.*;

import com.paritytrading.foundation.ASCII;
import org.jvirtanen.parity.util.Timestamps;

public class Order {
Expand Down Expand Up @@ -60,7 +60,7 @@ public long getQuantity() {
public String format() {
return String.format(LOCALE, "%12s %16s %c %8s %10d %9.2f",
Timestamps.format(timestamp / NANOS_PER_MILLI), orderId, side,
decodeLong(instrument), quantity, price / PRICE_FACTOR);
ASCII.unpackLong(instrument), quantity, price / PRICE_FACTOR);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jvirtanen.parity.client.event;

import static org.jvirtanen.lang.Strings.*;
import static org.jvirtanen.parity.client.TerminalClient.*;

import com.paritytrading.foundation.ASCII;
import org.jvirtanen.parity.util.Timestamps;

public class Trade {
Expand Down Expand Up @@ -30,7 +30,7 @@ public long getTimestamp() {
public String format() {
return String.format(LOCALE, "%12s %16s %c %8s %10d %9.2f",
Timestamps.format(timestamp / NANOS_PER_MILLI), order.getOrderId(), order.getSide(),
decodeLong(order.getInstrument()), quantity, price / PRICE_FACTOR);
ASCII.unpackLong(order.getInstrument()), quantity, price / PRICE_FACTOR);
}

}
8 changes: 4 additions & 4 deletions parity-fix/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<artifactId>parity-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -36,10 +40,6 @@
<groupId>org.jvirtanen.config</groupId>
<artifactId>config-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.lang</groupId>
<artifactId>lang-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.util</groupId>
<artifactId>util-extras</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static com.paritytrading.philadelphia.fix44.FIX44Enumerations.*;
import static com.paritytrading.philadelphia.fix44.FIX44MsgTypes.*;
import static com.paritytrading.philadelphia.fix44.FIX44Tags.*;
import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import com.paritytrading.nassau.soupbintcp.SoupBinTCP;
import com.paritytrading.nassau.soupbintcp.SoupBinTCPClient;
import com.paritytrading.nassau.soupbintcp.SoupBinTCPClientStatusListener;
Expand Down Expand Up @@ -199,7 +199,7 @@ private void newOrderSingle(FIXMessage message) throws IOException {
String symbol = symbolValue.asString();

try {
enterOrder.instrument = encodeLong(symbol);
enterOrder.instrument = ASCII.packLong(symbol);
} catch (IllegalArgumentException e) {
incorrectDataFormatForValue(message, "Expected 'String' in Symbol(55)");
return;
Expand Down
8 changes: 4 additions & 4 deletions parity-net/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<name>Parity Network Protocols</name>

<dependencies>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -23,10 +27,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvirtanen.nio</groupId>
<artifactId>nio-extras</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jvirtanen.parity.net.pmd;

import static org.jvirtanen.nio.ByteBuffers.*;
import static com.paritytrading.foundation.ByteBuffers.*;

import java.nio.ByteBuffer;
import org.jvirtanen.parity.net.ProtocolMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jvirtanen.parity.net.pmr;

import static org.jvirtanen.nio.ByteBuffers.*;
import static com.paritytrading.foundation.ByteBuffers.*;

import java.nio.ByteBuffer;
import org.jvirtanen.parity.net.ProtocolMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jvirtanen.parity.net.poe;

import static org.jvirtanen.nio.ByteBuffers.*;
import static com.paritytrading.foundation.ByteBuffers.*;
import static org.jvirtanen.parity.net.poe.ByteBuffers.*;

import java.nio.ByteBuffer;
Expand Down
8 changes: 4 additions & 4 deletions parity-reporter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<artifactId>parity-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -36,10 +40,6 @@
<groupId>org.jvirtanen.config</groupId>
<artifactId>config-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.lang</groupId>
<artifactId>lang-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.util</groupId>
<artifactId>util-extras</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jvirtanen.parity.reporter;

import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import org.jvirtanen.parity.net.pmr.PMR;
import org.jvirtanen.parity.util.Timestamps;

Expand All @@ -18,8 +17,8 @@ public DisplayFormat() {
@Override
public void trade(PMR.Trade message) {
printf("%12s %8s %10d %9.2f %8s %8s\n", Timestamps.format(message.timestamp / NANOS_PER_MILLI),
decodeLong(message.instrument), message.quantity, message.price / PRICE_FACTOR,
decodeLong(message.buyer), decodeLong(message.seller));
ASCII.unpackLong(message.instrument), message.quantity, message.price / PRICE_FACTOR,
ASCII.unpackLong(message.buyer), ASCII.unpackLong(message.seller));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jvirtanen.parity.reporter;

import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import org.jvirtanen.parity.net.pmr.PMR;
import org.jvirtanen.parity.util.Timestamps;

Expand All @@ -27,12 +26,12 @@ public void trade(PMR.Trade message) {
printf("%s\t%d\t%s\t%d\t%.2f\t%s\t%d\t%s\t%d\n",
Timestamps.format(message.timestamp / NANOS_PER_MILLI),
message.matchNumber,
decodeLong(message.instrument).trim(),
ASCII.unpackLong(message.instrument).trim(),
message.quantity,
message.price / PRICE_FACTOR,
decodeLong(message.buyer).trim(),
ASCII.unpackLong(message.buyer).trim(),
message.buyOrderNumber,
decodeLong(message.seller).trim(),
ASCII.unpackLong(message.seller).trim(),
message.sellOrderNumber);
}

Expand Down
8 changes: 4 additions & 4 deletions parity-system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<artifactId>parity-net</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -40,10 +44,6 @@
<groupId>org.jvirtanen.config</groupId>
<artifactId>config-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.lang</groupId>
<artifactId>lang-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.util</groupId>
<artifactId>util-extras</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jvirtanen.parity.system;

import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.List;
Expand Down Expand Up @@ -41,7 +40,7 @@ public MatchingEngine(List<String> instruments, MarketData marketData, MarketRep
EventHandler handler = new EventHandler();

for (String instrument : instruments)
markets.put(encodeLong(instrument), new Market(handler));
markets.put(ASCII.packLong(instrument), new Market(handler));

this.marketData = marketData;
this.marketReporting = marketReporting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jvirtanen.parity.system;

import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import com.paritytrading.nassau.soupbintcp.SoupBinTCP;
import com.paritytrading.nassau.soupbintcp.SoupBinTCPServer;
import com.paritytrading.nassau.soupbintcp.SoupBinTCPServerStatusListener;
Expand Down Expand Up @@ -94,7 +93,7 @@ public void loginRequest(SoupBinTCPServer session, SoupBinTCP.LoginRequest paylo
close();
}

username = encodeLong(payload.username);
username = ASCII.packLong(payload.username);
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions parity-ticker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<artifactId>parity-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.paritytrading.foundation</groupId>
<artifactId>foundation</artifactId>
</dependency>
<dependency>
<groupId>com.paritytrading.nassau</groupId>
<artifactId>nassau</artifactId>
Expand All @@ -46,10 +50,6 @@
<groupId>org.jvirtanen.config</groupId>
<artifactId>config-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.lang</groupId>
<artifactId>lang-extras</artifactId>
</dependency>
<dependency>
<groupId>org.jvirtanen.util</groupId>
<artifactId>util-extras</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jvirtanen.parity.ticker;

import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -29,7 +28,7 @@ public DisplayFormat(List<String> instruments) {
trades = new Long2ObjectArrayMap<>();

for (String instrument : instruments)
trades.put(encodeLong(instrument), new Trade());
trades.put(ASCII.packLong(instrument), new Trade());

printf("\n%s\n", HEADER);
}
Expand All @@ -38,7 +37,7 @@ public DisplayFormat(List<String> instruments) {
public void bbo(long instrument, long bidPrice, long bidSize, long askPrice, long askSize) {
Trade trade = trades.get(instrument);

printf("%12s %8s ", Timestamps.format(timestampMillis()), decodeLong(instrument));
printf("%12s %8s ", Timestamps.format(timestampMillis()), ASCII.unpackLong(instrument));

if (bidSize != 0)
printf("%9.2f %10d ", bidPrice / PRICE_FACTOR, bidSize);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jvirtanen.parity.ticker;

import static org.jvirtanen.lang.Strings.*;
import static org.jvirtanen.util.Applications.*;

import com.paritytrading.foundation.ASCII;
import com.paritytrading.nassau.MessageListener;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
Expand Down Expand Up @@ -52,7 +52,7 @@ private static void main(Config config, boolean taq) throws IOException {
Market market = new Market(listener);

for (String instrument : instruments)
market.open(encodeLong(instrument));
market.open(ASCII.packLong(instrument));

MarketDataProcessor processor = new MarketDataProcessor(market, listener);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jvirtanen.parity.ticker;

import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE;
import static org.jvirtanen.lang.Strings.*;

import com.paritytrading.foundation.ASCII;
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
import java.nio.charset.Charset;
import java.time.LocalDate;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void trade(long instrument, Side side, long price, long size) {
private String instrument(long instrument) {
String cached = instruments.get(instrument);
if (cached == null) {
cached = decodeLong(instrument).trim();
cached = ASCII.unpackLong(instrument).trim();

instruments.put(instrument, cached);
}
Expand Down
Loading

0 comments on commit 26ab0fa

Please sign in to comment.