I am having trouble modeling short-selling mechanics in my backtesting system.
When I sell stock short, I make the following changed to account variables in my backtesting program:
When I sell stock short, I make the following changed to account variables in my backtesting program:
- Credit Balance += 200% of the stock value sold short (assuming a 100% initial margin requirement)
- Cash -= 100% of the stock value (the cash is transferred to the Credit Balance account to collaterize the short sale)
- Short Market Value (SMV) -= 100% of stock value (this is the market value of the shorted stock)
- Net Account Value += Credit Balance + Short Market Value + Cash
- Credit Balance -= 100% of the stock value bought back
- Short Market Value (SMV) += 100% of stock value bought back
- Net Account Value += Credit Balance + Short Market Value + Cash