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.