Class MyEngine
java.lang.Object
java.lang.Thread
eds.framework.Engine
eds.model.MyEngine
Simulation engine for the order flow model.
This class creates the arrival process, service points, matching components,
and statistics collection used during one simulation run. It processes events
in stages, updates the order book, sends refresh events to the UI controller,
and stores the final results when the run ends.
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Engine
controller, eventList, servicePointsFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionMyEngine(IModelToViewController controller, long seed, double meanValidation, double meanMarketMatching, double meanLimitMatching, double meanExecution, double arrivalMean, double marketOrderRatio, double buyOrderRatio, double initialMidPrice, double priceVolatility, double tickSize, String runTitle) Creates a simulation engine with the selected run parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRuns after each simulation cycle.Returns the latest database record created for the completed run.Returns the latest final statistics snapshot created inresults().protected voidSchedules the first arrival event before the simulation loop starts.protected voidresults()Finalizes the run after the simulation loop ends.protected voidHandles one event from the event list.Methods inherited from class Engine
getDelay, getQueueLengths, run, setDelay, setSimulationTimeMethods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yieldMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IEngine
getDelay, getQueueLengths, interrupt, setDelay, setSimulationTime, start
-
Constructor Details
-
MyEngine
public MyEngine(IModelToViewController controller, long seed, double meanValidation, double meanMarketMatching, double meanLimitMatching, double meanExecution, double arrivalMean, double marketOrderRatio, double buyOrderRatio, double initialMidPrice, double priceVolatility, double tickSize, String runTitle) Creates a simulation engine with the selected run parameters.- Parameters:
controller- controller that receives UI updates from the engineseed- base random seed for the simulationmeanValidation- mean service time for validationmeanMarketMatching- mean service time for market order matchingmeanLimitMatching- mean service time for limit order matchingmeanExecution- mean service time for executionarrivalMean- mean time between arrivalsmarketOrderRatio- share of market orders in generated flowbuyOrderRatio- share of buy orders in generated flowinitialMidPrice- starting mid price for generated orderspriceVolatility- volatility used for generated order pricestickSize- minimum allowed price steprunTitle- title stored with the saved run results
-
-
Method Details
-
initialization
protected void initialization()Schedules the first arrival event before the simulation loop starts.- Specified by:
initializationin classEngine
-
afterCycle
protected void afterCycle()Runs after each simulation cycle. Updates collected statistics, builds a fresh order book snapshot, and sends the new table data to the UI.- Overrides:
afterCyclein classEngine
-
runEvent
Handles one event from the event list. Orders move through validation, matching, and execution stages, while trades and finished orders are recorded in the statistics collector. -
results
-
getStatisticsSnapshot
Returns the latest final statistics snapshot created inresults().- Specified by:
getStatisticsSnapshotin interfaceIEngine- Returns:
- final snapshot for the completed run
-
getStatisticsRecord
Returns the latest database record created for the completed run.- Specified by:
getStatisticsRecordin interfaceIEngine- Returns:
- saved statistics record for the completed run
-