Hi all,

I am trying to select some securities over the universe selection. After that, I will send order under the OnData function. I hit errors and here is the message:

This asset symbol (KAL 0) was not found in your security list. Please add this security or check it exists before using it with 'Securities.ContainsKey("KAL 0")' in SecurityManager.cs:line 254

 

I am not able to share the backtest, so here is the main.py

# region imports
from AlgorithmImports import *
# endregion


class QCSymbolStudy(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2023, 2, 17)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash

        self.AddUniverse(self.CoarseSelect, self.FineSelect)
        self.UniverseSettings.Resolution = Resolution.Daily

        self.is_make_order = True

    def OnData(self, data: Slice):
        for d in data.Keys:
            self.Debug(f"{self.UtcTime} OnData: {d}")

        if self.is_make_order:
            self.is_make_order = False
            self.MarketOrder("KAL", 10)

    def CoarseSelect(self, coarse):
        return [c.Symbol for c in coarse]

    def FineSelect(self, fine):
        selected_list = list()
        for f in fine:
            if "KAL" in f.Symbol.Value:
                selected_list.append(f.Symbol)
        self.Debug(f"length: {len(selected_list)}")
        return selected_list

 

I printed the keys in the function and I saw my target name:


2023-02-17 05:00:00+00:00 OnData: KAL XZPS318X97QD
2023-02-17 05:00:00+00:00 OnData: KALA WMCI69Z95F1H
2023-02-17 05:00:00+00:00 OnData: KALU TK3F5EFUQ739
2023-02-17 05:00:00+00:00 OnData: CBYL VZKASE9NEYCL

It seems that there is already data received but I still cannot send out order.

I tried to use

self.AddEquity("KAL", Resoltuion.Daily)

This can fix the issue, but the problem is that I need to use universe selection to do a dynamic selection.

 

I would like to ask how to fix this?

 

Thanks