Hey everyone. I'm stuck while backtesting my algo. I can't seem to get an accurate, current, updated value for Portfolio.Cash.
After placing a MarketOrder with 50% of the cash in my portfolio. The order seem to fill fine. I've put a breakpoint in OnOrderEvent, and it looks like it has filled properly.
Shortly thereafter I place another MarketOrder with the remaining cash in my portfolio. But for some reason Portfolio.Cash is not correct, it's value seems to have only subtracted the transaction fee. The first order did not get subtracted.
It looks like things are behaving in a synchronous manner with the MarketOrder. Is there some lag with when Portfolio.Cash updates? Do I need to force an update?
Thanks!
Michael P
Also, I'm using the GDAX bockerage model and cash account type. Attempting to backtest a strategy with multuple crypto currencies.
Michael P
Oh man, after a bunch of digging through the forums I think I found the issue. Since this is a crypto account. Cash is the sum of all the things. I should be specifilcally retreiving the USD amount:
self.Portfolio.CashBook['USD'].Amount
Kevin Virgil
Thanks for sharing this! I was having the same problem and am very glad to have found your explanation here.
Michael P
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!