Back

How to quit algorithm immediately but guarantee that a log gets generated?

If I call Log() and then throw an exception or crash, a log does not get generated.

Especially in Live Mode.

what's the preferred method for guaranteeing a log gets generated, especially when a crash such as a divide by zero is imminent.

Normally I would call exit(0), exit(1), or abort() for a posix process.

Update Backtest








In answer to my own question... thanks to whoever's algorithm it was that I cloned that had this in their example.

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public override void OnData(Slice slice)
{
try
{
_privateOnData(slice);
}
catch (Exception ex)
{
Error("OnData: " + ex.Message + "\r\n\r\n" + ex.StackTrace);
}
}

public void _privateOnData(Slice slice)
{
... your strategy ...
}

 

1

Sorry we missed this one Keith!

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