Refactoring T_TRADE statement generation

No longer the confusing split in 2 parts.
I still think this code is too messy, more refactoring should be done.