Liquidity Management – Execution Venue Pricing

During some late night code sessions, I’ve refactored the previous blogged actor liquidity management code, and borrowed a few lines of code from Typesafe’s Reactive Stock sample – specifically the price generator:

  // A random data set which uses stockQuote.newPrice to get each data point
  var stockHistory: Queue[java.lang.Double] = {
    lazy val initialPrices: Stream[java.lang.Double] = (new Random().nextDouble * 800) #:: => stockQuote.newPrice(previous))

  // Fetch the latest stock value every 75ms
  val stockTick = context.system.scheduler.schedule(Duration.Zero, 75.millis, self, FetchLatest)

I also made a basic start to adding Testkit test coverage:

class TieredPricerSpec(_system: ActorSystem)
  extends TestKit(_system)
  with ImplicitSender
  with ShouldMatchers
  with FlatSpec
  with BeforeAndAfterAll {

  def this() = this(ActorSystem("LiquidityManagementSpec"))

  override def afterAll: Unit = {

  "An TieredPricer" should "be able to store a price" in {
    val actor = TestActorRef(Props[TieredPricer])
    actor ! CorePrice("GBPUSD", 1.5)
    actor.underlyingActor.asInstanceOf[TieredPricer].prices("GBPUSD") should be(1.5)

  it should "be able to store two price" in {
    val actor = TestActorRef(Props[TieredPricer])
    actor ! CorePrice("GBPUSD", 1.5)
    actor ! CorePrice("GBPEUR", 1.15)
    actor.underlyingActor.asInstanceOf[TieredPricer].prices("GBPUSD") should be(1.5)
    actor.underlyingActor.asInstanceOf[TieredPricer].prices("GBPEUR") should be(1.15)

  it should "be able able to provide a price given an RFQ" in {
    val actor = TestActorRef(Props[TieredPricer])
    actor ! CorePrice("USDEUR", 1.15)
    actor ! RFQ("USDEUR")
    expectMsgType[TieredPrice].price should be(1.15)


~ by mdavey on December 3, 2013.

One Response to “Liquidity Management – Execution Venue Pricing”

  1. Great post! Thanks for sharing this! Very informative. I’m sure this is very helpful for other people too who are into Payment processing programs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: