When Paper Testing, what does the Available Cash amount mean? I started with $60k and although my algorithm has a few very good days, literally every stat is not good despite having 98k in available cash? Does that mean my algorithm is overleveraging and that extra cash is showing up as Cash Available because my long and short positions differ from available cash by about 2k? If this is the case, how do I calculate the gross profits made from the algorithm? Thank You! 1 response The Available Cash value displayed in the live trading dashboard is a bit misleading if the algorithm places any short trades . If one only trades long, this value is straightforward. # Assume cash =$10,000 and positions_value = $0 and portfolio_value =$10,000
# What if we took a long position of XYZ
# Assuming XYZ sells for $10 and$0 commission

order(xyz, 1000)
# Buy reduces cash by $10,000 and increases positions_value by$10,000.
# So cash = $0 and positions_value =$10,000 and portfolio_value = $10,000 # now we sell.. order(xyz, -1000) # Sell increases cash by$10,000 and reduces positions_value by $10,000. # So cash =$10,000 and positions_value = $0 and portfolio_value =$10,000



Pretty straightforward. The Available Cash is what we would expect. Note, we could have purchased $15,000 of XYZ and our cash would be negative. Again, this makes sense. We 'borrowed'$5000 so now we have a negative cash balance.

Now, things become less straightforward if we place any short trades. Let's see how that works.

# Assume cash = $10,000 and positions_value =$0 and portfolio_value = $10,000 # What if we took a short position of XYZ. # Assuming XYZ sells for$10 and $0 commission and a starting balance of$10,000

# All short means is we sell BEFORE we buy it. So...

order(xyz,- 1000)
# Sell increases cash by $10,000 and reduces positions_value by$10,000.
# So cash = $20,000 and positions_value =$-10,000 and portfolio_value = $10,000 # Now we buy (ie close the short position)... order(xyz, 1000) # Buy reduces cash by$10,000 and increases positions_value by $10,000. # So cash =$10,000 and positions_value = $0 and portfolio_value =$10,000



Notice at all times the portfolio_value = $10,000 however the cash goes up to$20,000. Did I make money somehow? No (unfortunately). What isn't shown is the amount you needed to 'borrow' to buy the short stock. That will be the difference between the available cash and cash you started with. In the above example this would be $20,000-$10,000 = $10,000. The term available cash is a bit misleading since it also includes funds 'borrowed' for short sales. That is probably why you are seeing$98k in available cash. You probably have some short positions?

The gross profit is labeled Dollar P/L and is shown on the live trading dashboard at the top. It can be calculated as

profit = starting_cash - buys + sells - commissions + dividends

The key is to remember two accounting rules.

A buy always increases shares and reduces cash.
A sell always reduces shares and increases cash.

The only difference between opening a long or opening a short position is timing.

When taking a long position, one is first placing a buy and then placing a sell.
When taking a short position, one is first placing a sell and then placing a buy (just the reverse).

Maybe more info than you wanted, but that's why the available cash is misleading if ever placing short trades. When live/paper trading you will probably want to look at Dollar P/L.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.