Design
Main loop
Typical to most trading frameworks flumine uses an event driven design with the main thread handling these events through a FIFO queue.
- handles all events in order one by one
- runs in main
UML Diagrams
Packages
Classes
Events:
MARKET_CATALOGUE
Betfair MarketCatalogue objectMARKET_BOOK
Betfair MarketBook objectRAW_DATA
Raw streaming dataCURRENT_ORDERS
Betfair CurrentOrders objectCLEARED_MARKETS
Betfair ClearedMarkets objectCLEARED_ORDERS
Betfair ClearedOrders object
CLOSE_MARKET
flumine Close Market updateSTRATEGY_RESET
flumine Strategy Reset updateCUSTOM_EVENT
flumine Custom event updateTERMINATOR
flumine End instance update
The above events are handled in the flumine class
MarketBook Cycle
Simulation
Simulation is achieved by monkeypatching the datetime function utcnow(), this allows strategies to be simulated as if they were being executed in real time. Functions such as market.seconds_to_start and fillKill.seconds work as per a live execution.
Streams
- Single stream (market)
- As above but 'data' (flumine listener)
- Order stream
- Future work:
- Custom stream
Strategy
- Class based
- Subscribe to streams
- Single strategy subscribes to a single market stream
Handles
- Stream reconnect
- Trading client login/logout
- Trading client keep alive
- Future work:
- Execution
- place/cancel/replace/update
- controls
- fillKill
- Market Catalogue
- Polling (scores/raceCard etc)
- CurrentOrders / ClearedOrders
- database connection/logging
- Execution
notes
- market middleware (analytics/logging)
- order middleware (controls)
- paper trading
- simulation