Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Build Error Annoyances: "Nonexistent property:sid"

I'm trying to improve my open source quantopian R&D framework, but I keep running into what appears to be sandboxing limitations.

the latest is: If I have this method in my main class, I get the build error mentioned in the subject.

    def GetOrCreateSecuritySecurities(this,qsecArray):  
        '''pass in an array of quantopian sec (ex:  [sid(24),sid(3113)])  
        and returns an array of unique security objects wrapping them.   duplicate sids are ignored'''

        try:  
            securities = {}  
            if not qsecArray:  
                return securities

            for qsec in qsecArray:  
                sid = qsec.sid  
                securities[sid] = this.GetOrCreateSecurity(qsec)  
                pass  
            return securities.values()  
        except:  
            log.error("FrameworkBase.GetOrCreateSecuritySecurities() error")  
            return {}  
        pass  

Please note that I DO NOT ACTUALLY CALL THIS METHOD ANYWHERE. but the sandboxing doesn't like that I am trying to access a .sid property anyway.

how can I work around this?

4 responses

i tried using hasattr() / getattr() but those are also prohibited by the sandbox

if i'm not clear, here is the culprit line:

sid = qsec.sid  

accessing a .sid property causes this to fail building, even though this function is not used at all.

assuming this takes a long time to fix, here is my workaround: (force user to pass (sid,qsec) tuples)

    def _getOrCreateSecurities(this,qsecArray):  
        '''pass in an array of quantopian sid/sec tuples  (ex:  [(24,sid(24)),(3113,sid(3113))])  
        and returns an array of unique security objects wrapping them.   duplicate sids are ignored'''

        securities = {}

        for sid, qsec in qsecArray:  
            #sid = qsec.sid  
            securities[sid] = this._getOrCreateSecurity(sid,qsec)  
            pass

        return securities.values()  

Hi Jason,

We parse the code prior to execution to discover the SIDs and queue up the correct data for your simulation. Unfortunately, this means that dynamic variables cannot be used in sid() and your code will fail in the initial validation stage. To use the function, you need to explicitly pass in a static variable.

Alisa

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.