Factor out trade counting into separate function