Back

Editing Algorithm's BacktestId to prevent threads writing to same file

Hi,

Using some code I've written, I've been able to successfully launch several backtests in parallel. Unfortunately, they tend to try to write to the same file in various instances, say when storing results in BacktestingResultHandler for example.

Most file output functions I have seen make use of `BacktestId` to name the file they are writing to. In my case, all threads seem to have the same `BacktestId`, hence why they're all trying to write to the same file.

Is there any way I can edit this `BacktestId` or randomly generate it? Alternatively, is there a global setting to turn off all writing to files entirely?

Thanks in advance!

Update Backtest







Hi  - the results locally are written with this method: 

https://github.com/QuantConnect/Lean/blob/master/Engine/Results/BaseResultsHandler.cs#L37

Or you can hack the backtest id to be random here:

https://github.com/QuantConnect/Lean/blob/master/Queues/JobQueue.cs#L137
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.


Thank you!

For those curious, I edited this line:

BacktestId = AlgorithmTypeName,

And edited to become the following. Let me know if you have any questions.

BacktestId = AlgorithmTypeName + "-" + Guid.NewGuid(),
0

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