Wiki

Clone wiki

jcs.marketdata.replay / Home

Java Trading Server and Client applications to demonstrate how to persist application runtime data to disk store and replay data from disk store using Apache Java Caching System (JCS) and Javassist

lgplv3-147x51.png

Java code is published under LGPLv3.0 license.

Slideshare

Java Persist and Replay Runtime Data

Trading Server Application

Application streams dummy ticks data (marketdata) for currency pairs for connected traders.

TradingServer.gif

Trading Client Application

Application connects to Trading Server Application and receives ticks data (marketdata) for currency pairs.

  • Download jcs.marketdata.replay.trade.client-1.0.jar

  • Run one instance of trading client application using java -DuserId=trader1 -DuserPwd=12345 -jar jcs.marketdata.replay.trade.client-1.0.jar

  • trader1 have access to all currency pair securities

TradingClient.gif

  • Run another instance of trading client application using java -DuserId=trader2 -DuserPwd=67891 -jar jcs.marketdata.replay.trade.client-1.0.jar

  • trader2 have access to selected currency pair securities

TradingClient - 2.gif

Run Trading Client Application in Data Persistence Mode

  • Create a new folder C:\TradeCache
  • Run trading client application using java -DuserId=trader1 -DuserPwd=1234 -dataPersistenceMode=true -jar jcs.marketdata.replay.trade.client-1.0.jar
  • In this mode application will write data cache in C:\TradeCache folder. Exiting application will persist data.
  • Look for 'Application was running for ... milliseconds' entry in trade-client log file. This milliseconds value will be used for command line value -DcacheReplayUpTime* when running client application in data replay mode.

TradeCache.gif

Run Trading Client Application in Data Replay Mode

  • Run trading client application using java -DuserId=trader1 -DuserPwd=1234 -DdataReplayMode=true -DcacheReplayUpTime=..... -jar jcs.marketdata.replay.trade.client-1.0.jar
  • In this mode application connect to Trade Server for quantification and to get list of securities
  • Market data will be loaded from C:\TradeCache
  • Market data will play in about the same time it took to capture market data in data persistence mode

Useful Methods

com.wishcoder.samples.jcs.trade.client.ClientApp.java

  • prepareNonSerializeSetters() - Java Caching System can only persist serialize objects. Trading application has TickEvent that takes User and TickBook in constructor. Both User and TickBook objects are non-serialize. TickEvent itself is serialized. Java Caching System will persist TickEvent but will lose information about User and TickBook. 'prepareNonSerializeSetters' is used to instrument TickEvent using Javassist by setting dynamic setter methods for User and TickBook.

  • handleTickChange(final Tick tick) - This method use JCS to persist TickEvent in data cache.

  • handleLoginResponse(LoginResponse response) - Based on 'dataReplayMode' command line parameter this method will load data cache from disk store at C:\TradeCache and inject User and TickBook values in TickEvent that was loaded from the cache.

Repository URL

jcs.marketdata.replay

References

Trading Server and Client applications may utilize certain third party software. Such third party software is copyrighted and licensed by their respective owners:

Contact [Ajay Singh]

linked_in_160x33.png

Updated