I am getting some weird discrepancies between Portfolio.Cash and the cash reported in errors. Should I be using CashBook instead?
10012 | 02:13:38:
Buy 2019-05-01 12:10:00 1945.041905825USD - BTCUSD - Qty: 0.366 Price: 5294.985 Value: 1937.9645099999998
10013 | 02:13:38:
Backtest Handled Error: Order Error: id: 389, Insufficient buying power to complete order (Value:1941.9058), Reason: Your portfolio holds 7.077395825 USD, 0 USD of which are reserved for open orders, but your Buy order is for 0.365 BTC. Your order requires a total value of 1941.90585 USD, but only a total value of 5.32029 USD is available.
As you can see, Portfolio.Cash reports 1945 USD, but the error states I only have 5.3 USD available. Where is the difference?
Rahul Chowdhury
Hey Nicholas,
Portfolio.Cash returns the sum of all currencies in your cashbook in the base currency (USD). This means the sum of BTC and USD in your portfolio is 1945 USD. You can find how much USD you have in your account by self.Portfolio.CashBook['USD'].Amount.
Best
RahulÂ
Def returns
What defines the cash amount held vs reserved for open orders vs available?
Varad Kabade
Hi Tomes,
We can get the total amount as follows:
Â
and the amount for open orders as:
Â
and the reserved amount as follows:
Â
Best,
Varad Kabade
Def returns
Varad kabade Thank you!Â
Nicholas Strong
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!