merge Trade function from spike13