MAINT: Refactor AlgorithmSimulator.transform.

Breaks out the main snapshot processing loop into its own function, and does
some minor variable renaming-shuffling.

Adds `TradingAlgorithm.on_tick`, a function to be called when the simulation dt
changes, prior to processing any events.

There should be no difference in behavior as a result of this change.