Package: python-exsim
IntroductionThis is a simple financial exchange simulator.  It is intended for use
testing trading applications, protocol gateways, and the like.It operates in two basic modes: standalone, or managed:In standalone mode, the matching engine modules operate independently,
processing orders according to their implementation.  This mode is
intended for ad-hoc testing, demonstrations, etc.In managed mode, the simulator is controlled by another process,
typically an integration test module, which can interact with the
matching engine to ensure that it implements a configured scenario
exactly.PluginsThe basic framework can be extended with new matching engine
behaviours and protocol mappings using plugins: Python modules that
provide derived classes specialising the default behaviours.Once imported, these modules can be registered with the framework
(using a ‘register’ function), and are then available from the
standard factory functions.UsageIn a Python unittest module, you should import the exsim module, and
create an instance of the API class.You can then load any additional (third-party) plugins before
configuring and creating a server instance.  The server instance is
created by forking the calling process, so any Python setup or
environment variables, etc, that exist are inherited by the service.
All subsequent interaction with the service uses IPC.DesignRun a basic event loop.Listen on one-or-more TCP sockets, and accept connections.Decode messages according to protocol module configured for that
session.Dispatch messages via central dispatcher.Support for automatic test-requests/heartbeats.Messages can be queued for explicit handling in managed mode.Policy modules can be loaded for automatic message handling.Basic matching engine will manage books, publish data, and match
orders.ClassesEndpointA listening socket, attached to a matching engine, and configured
with a protocol to encode and decode received messages.SessionA socket connection, initiated by a client application.  Sessions
are created by Endpoints, and inherit their Endpoint’s Protocol and
Engine.ProtocolAn encoder and decoder that converts messages in a trading protocol
(like, FIX or OUCH) into Python dictionaries that are passed to the
matching engine for action.The protocol can optionally handle some of the “mechanics” of the
communication: sequence numbers, heartbeats, etc.  But actual
trading messages are simply translated and handed off to the engine.Management Protocolcreate_engine name classCreate a matching engine of the specified class.delete_engine nameDelete a matching engine.set_engine_property engine_name property_name valueConfigure the engine.create_endpoint name engine protocolCreate a listening protocol endpoint, using a specified protocol,
and attach it to the specified engine.delete_endpoint nameDelete a listening endpoint.set_protocol_property endpoint_name property_name valueConfigure the protocol module.create_book name engine symbolCreate a book within a matching for trading of the specified instrument.delete_book name engineDelete a book from an engine.create_quote quote_id engine book_nameCreate a (market maker) quoteset_quote_property quote_id name valueConfigure a quotesubmit_quote quote_idPost a quotedelete_quote quote_idRemove a quote.create_order order_id book_nameCreate an orderset_order_property order_id name valueConfigure an ordersubmit_order order_idPost an order.delete_order order_idManage an order.match_orders book_name order_a order_bMatch two orders.The service starts with a control port listening for the management
protocol on a specified port.  The client API can connect to this
control port, and sends RPCs to the server.There are no asynchronous events from the server: the client can poll
for queued events.  This simplifies the integration of the client API
with testing frameworks.In managed mode, there is no configuration of the server other than via
the client API.  This ensures that test case code represents the
complete description of the required environment.RoadmapM1Basic FIX 4.x protocol moduleSingle orders onlyDrop copyMarket dataBasic simulation matching enginePrice-time matchingOrders only (no quoting, etc)Instrument types:StandardAuto-fillAuto-partialAuto-rejectAuto-cancelPartial-then-cancelActivity levelsNone (client application trading only)SlowFastRead configuration from fileBasically a script of the same operations as possible via the
(future) management protocolM2Management protocolREST?  WSS?Logon authenticationRead and queue data for collectionTimeoutsHeartbeatsClient-side API for PythonUse requests module?Completely synchronous RPC-style.Optionally, spawn simulator process in backgroundExamples using unittest & pytestBacklogSupport acquiring instruments and pricing data from an external source.Stream FIX (?) market dataFigure out how best to allow trading against those quotes/orders.Add ITCH/OUCH (with SOUP TCP) support to ensure the abstraction isn’t
too FIX-specificAdd support for an RFQ workflow / matching engine.Licenseexsim is licensed under the GNU Public License.While this is not legal advice, in short this means you’re free to use
this code at no cost.  You may also change it and run the modifified
version, or integrate it with other code, but if you do you must not
distribute the changed code or a system that integrates this software
unless it is also made available under the GPL license.ContributingComments, suggestions, bug reports, bug fixes – all contributions to
this project are welcomed.  See the project’sGitHubpage for access to the latest
source code, and please open anissuefor comments, suggestions,
and bugs.