MAINT: Cleaned up sid checks and exception types

Removed unnecessary parens

Keeping NameError reserved for when locals or globals are not found.
Exception is what we use for the other sid checks, so now they are consistent.
MAINT: Refactored unit tests to remove duplication

of arguments to factory.create methods.

Also added checking of the perf period cost basis results after each txn.
BUG: Fix cost basis calculation

Cost basis calculation now takes direction of txn into account.

Closing a long position or covering a short shouldn't affect the cost basis.