Short-selling accounting

Discussion in 'Taxes and Accounting' started by nijshar28, May 8, 2020.

  1. I am having trouble modeling short-selling mechanics in my backtesting system. This is not a real live accounting question, but it is about accounting at its core. So, I think it is appropriate to ask here.

    When I sell stock short, I make the following changed to account variables in my backtesting program:
    1. Credit Balance += 200% of the stock value sold short (assuming a 100% initial margin requirement)
    2. Cash -= 100% of the stock value (the cash is transferred to the Credit Balance account to collaterize the short sale)
    3. Short Market Value (SMV) -= 100% of stock value (this is the market value of the shorted stock)
    4. Net Account Value += Credit Balance + Short Market Value + Cash
    When I close out the short position later, I change my accounts as follows:
    1. Credit Balance -= 100% of the stock value bought back
    2. Short Market Value (SMV) += 100% of stock value bought back
    3. Net Account Value += Credit Balance + Short Market Value + Cash
    I am pretty sure this second part (closing out the short position) is wrong. At the very least, my cash position should also be affected. Any suggestions on how to fix it? Thank you.
     
  2. newwurldmn

    newwurldmn

    Would it not be the following:

    Opening:
    Cash is debited at SMV
    Liabilities credited for SMV
    Cash credited for margin requirement whatever this is
    Assets debited for margin requirement whatever this is

    Unwind
    would be the opposite with a fifth transaction being equity plug
     
    nijshar28 likes this.
  3. Don't try to compute all your accounting incrementally, it doesn't make sense because everything is a function of the underlying price which is continuously changing. When you execute a trade, the only thing that you need to account for is your number of shares and cost basis, and transaction costs.

    At any given point in time during the day, the value of a position is simply number of shares times (current price - cost basis). Your NAV, SMV, etc are just different sums over your positions.

    Overnight you apply interest charges.
     
    nijshar28 likes this.
  4. Thank you, guys. Both are great pointers and suggestions that have helped me. This is one of those things that seems obvious in retrospect but really it is so much easier when someone can point it out to you.