Just realized that my data had negative quantities for sales, thus I was getting unwanted sub-lots. Originally I thought it was due to buys and sells on the same day which wasn't represented in the test data, which adding that conditioned fixed. Once I retested your code with those scenarios, then I knew I had mangled your code or had other issues. Thanks for responding so quickly, again nice piece of code.
... View more