Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Can you arbitrarily change portfolio.cash

I was reading on one of the threads (apologies because I don't remember which one) that the backtest is initialized with a starting lump sum of money which could not be altered, and in order to model adding an additional infusion of cash (like a portion of a paycheck put into savings) one needs to create a "fake cash" variable to hold that information.

Did I understand that correctly? It seems like if I want to model taking $500 every month from my paycheck and introduce it to my portfolio that I should simply be able to add 500 to portfolio.cash and then that money would be available for trades. Perhaps I misunderstood what was being discussed. I just wanted clarification on what the impact of my changing the value of portfolio.cash is.

1 response

See Dan's post in https://www.quantopian.com/posts/dollar-value-averaging for the "fake cash" example. For backtesting, capital can flow out, in the form of commissions, but not in. Presumably, this won't be the case when trading with real money through Interactive Brokers (IB), so I'm guessing that Quantopian will figure out how to incorporate the addition of cash into backtesting.