Back

GetMarginRemaining Methods Changed (no code changed)

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?

Update Backtest







0

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.


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.

0

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.


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

1

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.


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 :-) ).

 

0

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.

0

Hi Mark Uretsky all unit and regression tests came back green. Please send suspected bug reports to support@quantconnect.com 

 

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed