Usim booting and working process are predefined and completely predictable. Both PMs and quants need to understand the processes before they start any real work.
Usim will go through a well defined booting process to check working environment as well as construct basic infrastructures before carrying out any real simulation and realtime trading.
Step 1: Usim will ensure current working directory has only one usim instance running, and the xml configuration file conforms to xml format protocal, otherwise abort;
Step 2: Usim will start to read xml file. Now she will construct a gloablinfo structure, which will be used by all modules throughout the entire usim lifetime;
Step 3: Usim will initialize assistant components: log, securitymanager, and messagepool;
Step 4: Usim constructs universe, including collecting all relevant securities, time ticks, and time axis;
Step 5: Usim loads all defined modules from so files, including dataloaders, metronomes, vanguard, alphas, stats, trades, and etc. When loading dataloaders, they automatically construct Udata along time axis and read in all history data.
Step 6: After loading all modules, usim now construct metronome and vanguard instance for use. Each usim can only have one metronme and vanguard.
Step 7: Afterwards, usim construct all PM instances; For each PM, construct their alpha, trade, and stat instances.
Step 8: Usim booting accomplished, transfers control to metronome and party begins.
Immediately after booting process and usim transferring control to metronme, metronome starts the working process.
A typical usim working process is a looping along the time axis. The time axis could well span across history and realtime: usim is perfectly happy with simulation+realtime seamless work.
For each loop, usim processes one tick on the time axis and move forward afterwards. Usim does not discriminate the tick nature: be it 1 macrosecond, 1 milliseond, 1 second, or even 1 hour.
For history simulation, dataloaders have already loaded with history data, hence usim just calls each PM's alphas and accompanied stat and trade modules. But for realtime trading, usim will first call each dataloader's update function to load the new data.
In realtime trading, metronome will block to wait for next ti on the time axis. Vanguard plays important role here. Since metronome needs vanguard to tell her whether next tick arrives.