Back

Determining Availibile Cash for Cash and Margin Accounts

So one problem I have noticed is the backtester does not simulate availability of funds accurately. First, for a Cash account, it assumes that once a sell order is fulfilled, those funds become available, when in reality it takes 3 days. For more rapid trading strategies that can cause problems in live trading (where trades can be rejected due to lack of funds). Is there functionality for a cash or margin account that lets you accurately determine intraday availability of funds that I'm missing?
Update Backtest








I believe the 3 day rule is typical of US equity non-margin accounts. Currently I'm not sure we could get this to work reliably in the cloud back tester. I believe we would need to add the concept of pending margin to the portfolio.

After the above feature is implemented, it should be relatively easy to write a custom SecurityPortfolioModel that holds off on applying the funds for the 3 day period with a few tweaks to the engine. I've submitted an issue to the github project to add this feature.
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.


In my experience after you sold the security (and the funds are not available until 3rd day), the broker will actually allow you to buy new shares, but you will get a call if you attempt to sell these new shares before the 3 day period expired.
0

I believe I've experienced the same @nik. I think that case could currently be handled with a custom SecurityPortfolioModel and/or BrokerageModel and a little creativity. It would need to track recent fills and verify that you're not selling shares purchased with uncleared funds. The BrokerageModel can be used to prevent orders from filling via the CanExecuteOrder method, while the SecurityPortfolioModel.ProcessFill is used to actually do something with the generated fills.
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.


Just a note from guys at Tradier: https://brokerage.tradier.com/support

How does Regulation T govern the usage of funds in a cash account?

When shares of stock or option contracts are sold in a cash account, there is a settlement period during which time the cash and the stock or options are exchanged. For stocks, this settlement period is 3 business days. For options it is 1 business day. When a stock or option is sold, these unsettled funds are available to use for purchase. However, if the newly purchased stock or option is sold prior to the settlement of the previous sale, this transaction violates Regulation T. Violations of Regulation T could result in restrictions being placed on the account. Please click here to see the Regulation T section on the SEC Website (http://www.sec.gov/investor/alerts/cashaccounts.pdf).
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.


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