refactoring / trade integration with matlab