My code started showing an error two days ago for the following line:
Decimal remainingMargin = algorithm.Portfolio.GetMarginRemaining(target.Symbol, OrderDirection.Buy);
I am getting the following error:
"No overload for method 'GetMarginRemaining' takes two arguments"
This code has been live for a few weeks and I have not made changes to it, opening up other algorithms I have worked on I also see that same error, did something change a couple days ago?
Martin Molinero
Hi Marcus Weidner!
We recently removed the method in this PR because we believed it wasn't required, sorry for your trouble. To help you further, could you please explain in detail what is your use case?
In the PR, we have refactored the buying power models improving accuracy and usability.
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.
Jared Broad
Hey Marcus,
We did a deep rethink of the internal math we use to calculate the buying power. Previously we had an ugly mix of calculations of buying power based on the order value, leverage, and portfolio value.Â
Now internally we're assigning a fraction of margin used for each position or potential position you'd like to hold. This enabled us to more accurately model all asset types, but it had the most significant impact on futures which now accurately models futures.
Soon this new technology will enable us to accurately model complex options positions, offsetting the risk of one option position with the hedge of another position! To help us point you at the new replacement it would help to know what you're trying to achieve. Â
Thanks
Jared
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.
Marcus Weidner
I can definitely refactor to remove that, I just had a simple check in my execution model to make sure there was sufficient margin remaining for the target I am processing. I added this check because I was getting massive IB errors saying I was over my margin and stopping the orders from going through.
I am not using the helpers to set the position size to be a percentage of my portfolio as I am hand calculating and rounding to the nearest 100 to have even lots of shares (if there was an override in the framework to allow me to round to the nearest 100, I would swap to that :-) ).
Â
Mark Uretsky
I think it's even worse problem the Portfolio.Cash or MarginRemaining always stays the same as SetCash it doesn't change on the back-test after buying stocks I get a bunch of orders invalid messages, can't find a way to check if I have cash to buy it's all fixed to start of balance.
Jared Broad
Hi Mark Uretsky all unit and regression tests came back green. Please send suspected bug reports to support@quantconnect.comÂ
Â
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.
Marcus Weidner
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!