Hello,

I would like to use custom data such as SECReport10K in my algorithms, but I get an out of memory exception as soon as I use more than a few handful of securities.

I add the data with AddData.

Is there anything I should do to free memory when the security is removed from the universe, or is custom data unsubscription taken care of automatically?
 

Has anybody had better luck?
Looking forward to your thoughts.

 

  1. public override void Initialize()
  2. {
  3. SetStartDate(2018, 1, 12); //Set Start Date
  4. SetCash(100000); //Set Strategy Cash
  5. AddUniverse(Universe.DollarVolume.Top(50)); // creashes already with 30 or less
  6. }
  7. public override void OnData(Slice data)
  8. {
  9. foreach (BaseData baseData in data.Values.Where(sym => sym.Symbol.IsCustomDataType<SECReport10K>())) {
  10. Debug($"{Time}: {baseData}");
  11. }
  12. }
  13. public override void OnSecuritiesChanged(SecurityChanges changes)
  14. {
  15. base.OnSecuritiesChanged(changes);
  16. foreach (Security security in changes.AddedSecurities) {
  17. AddData<SECReport10K>(security.Symbol);
  18. }
  19. // foreach (Security security in changes.RemovedSecurities) {
  20. // .. is there something we should do to remove custom data?
  21. // }
  22. }
+ Expand

Author

R G Quant

July 2022