Code Monkey home page Code Monkey logo

agora's People

Contributors

davidrpugh avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

agora's Issues

Need to implement multiple market-clearing

Based on conversations with economists KAPSARC, there are a number of interesting benchmark cases for multiple market clearing. A similar functionality is also supported by old CRISIS code.

Allowing market orders causes occasional bugs!

Here is an example of the stack trace...

[ERROR] [12/15/2015 14:16:21.061] [model-market-dispatcher-6] [akka://model/user/$b/clearing-mechanism] next on empty iterator
java.util.NoSuchElementException: next on empty iterator
    at scala.collection.immutable.RedBlackTree$TreeIterator.next(RedBlackTree.scala:475)
    at scala.collection.IterableLike$class.head(IterableLike.scala:107)
    at scala.collection.mutable.TreeSet.head(TreeSet.scala:41)
    at scala.collection.TraversableLike$class.headOption(TraversableLike.scala:440)
    at scala.collection.mutable.TreeSet.headOption(TreeSet.scala:41)
    at markets.clearing.engines.CDAMatchingEngine.accumulateBidOrders(CDAMatchingEngine.scala:108)
    at markets.clearing.engines.CDAMatchingEngine.findMatch(CDAMatchingEngine.scala:66)
    at markets.clearing.ClearingMechanismLike$$anonfun$clearingMechanismBehavior$1.applyOrElse(ClearingMechanismLike.scala:39)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:480)
    at markets.clearing.ClearingMechanismActor.aroundReceive(ClearingMechanismActor.scala:39)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Here is the application.conf file used to generate the bug. Bug appeared as soon as I started allowing market orders. This suggests that bug occurs when either askOrderBook or bidOrderBook is empty?

Possibly a bug with TreeSet? Seems unlikely...

Change constructor for ExchangeActor...

If we define an ExchangeActor to be a collection of MarketActors that use the same type of matching engine and share a common settlement platform, then we can have the ExchangeActor create a new MarketActor on the fly...

Need to implement dominance rules..

...need to allow for the possibility that ask or bid orders might be rejected unless they improve upon the current best ask or bid limit prices. In the literature this property is typically referred to as a price improvement or spread reduction rule.

Create a Cassandra database connecting actor

Need some Actor thats serves as a pipeline to a Cassandra database. This actor could be inserted in place of a SettlementActor to capture filled orders more efficiently than logging them to a file.

Move crossing logic down to orders

Currently the MatchingEngineLike has an abstract crossing method that should return true if the incoming order crosses the best existing order. @danftang suggested that the crossing logic should be implemented for each order.

Some notion of a "fuzzy" limit price

Need to have some notion of a "fuzzy" limit price to capture the idea that seller might want to sell for more than X, but would sell for Y < X. This happens in housing markets (for example).

Distinguish between Continuous and Discrete matching engines...

A continuous matching engine attempts to match individual ask and bid orders immediately upon receipt. A discrete matching engine, on the other hand attempts to match collections of incoming ask and bid orders after discrete time intervals.

While the PostedOffer and BilateralNegotiation matching engines could possibly operate as either continuous or discrete matching engines, continuous double auction matching engine would always be continuous and the call auction matching engine would always be discrete.

Add StopOrderLike trait

Should implement a StopOrderLike trait which defines a stop price for an Order. Investorpedia has a decent description of the difference between limit and stop orders.

Abstract over the collection type used to store OrderLike objects

All markets need to store orders in orderbooks. A collection for storing orders needs to be able to do the following...

  1. Insert an order into the collection
  2. Remove an order from the collection
  3. Pop off the "best" item in the collection (where "best" is defined in terms of the ordering/priority over the orders in the collection)

Default implementation uses TreeSet.

Timestamp all messages!

Need to timestamp all messages. Not clear what the optimal way to timestamp messages is for now I am going to call System.currentTimeMillis() as suggested here.

Make API as private as possible!

Hide as much information as possible in the API by making all fields and methods as private as possible. Only expose those fields and methods that might be needed by users!

Be explicit with actor life-cycle hooks...

....currently all actor life-cycle hooks and supervision strategies are implicitly using the default values. I want to force developers to explicitly specify life-cycle hooks and supervision strategies.

Tick size should be variable

Number of policy relevant research questions related to tick size for various assets. User should be able to specify the tick size for a Tradable.

Differentiate between SealedBid and OpenBid auctions...

Important decision in auction design is whether or not market participants can access information about the current state of the order book(s). Auctions mixing in the SealedBidding trait do not allow access to the state of order books; auctions mixing in a OpenBidding trait must implement a method to allow market participants to view the best ask/bid orders contained in the order books.

Make OrderBook covariant in its Order type parameter

Logically, since AskOrder <: Order then it should follow that OrderBook[AskOrder] <: OrderBook[Order] however this is currently not the case in the code. Will need to refactor the add and reduce method signatures to make this possible.

Create a Splitable trait...

...an Order implementing the Splitable trait will represented and order that can be split into separate orders. This feature would be used to capture the "execute and eliminate" orders that are widely used on real financial markets.

Create a LoggingActor

Need some actor that just receives filled orders and logs them to a file. This actor can then be inserted as a SettlementActor. This would be useful for testing purposes as well as for replicating many of the stylised financial market ABMs.

ContinuousDoubleAuction matching engines with fixed size order books

Theoretical literature on market design suggests that the size of a market's memory (i.e., the depth of its order books) is a key parameter. Current default implementation of a continuous double auction matching engine uses a TreeSet to model order books. TreeSet collections do not have a fixed size.

Should our default implementation of a continuous double auction require order books to have a fixed (and configurable) size?

Don't store entire sequence of ticks

It was a mistake to store the entire sequence of ticks in the ticker agent. There should be some fixed number of "recent ticks" stored in the ticker agent. Storage of entire tick history should be done outside the model.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.