Back to Community
get_pricing() not working?

Hi all,

I am currently working on a modified version of the algorithm
https://www.quantopian.com/posts/how-to-build-a-pairs-trading-strategy-on-quantopian

and have encountered a problem. Whenever I try to build the algorithm, I get the following message:
There was a runtime error.
NameError: global name 'get_pricing' is not defined
... USER ALGORITHM:34, in initialize
securities_panel = get_pricing(symbol_list, fields=['price']

If anyone can tell me why I am unable to use get_pricing(), that would be great.

symbol_list = symbols('ABT', 'ABBV', 'ACN', 'ACE', 'ADBE', 'ADT', 'AAP', 'AES', 'AET', 'AFL', 'AMG', 'A', 'GAS',  
              'APD', 'ARG', 'AKAM', 'AA', 'AGN', 'ALXN', 'ALLE', 'ADS', 'ALL', 'ALTR', 'MO', 'AMZN', 'AEE',  
             'AAL', 'AEP', 'AXP', 'AIG', 'AMT', 'AMP', 'ABC', 'AME', 'AMGN', 'APH', 'APC', 'ADI', 'AON',  
              'APA', 'AIV', 'AMAT', 'ADM', 'AIZ', 'T', 'ADSK', 'ADP', 'AN', 'AZO', 'AVGO', 'AVB', 'AVY',  
              'BHI', 'BLL', 'BAC', 'BK', 'BCR', 'BXLT', 'BAX', 'BBT', 'BDX', 'BBBY', 'BRK-B', 'BBY', 'BLX',  
              'HRB', 'BA', 'BWA', 'BXP', 'BMY', 'BRCM', 'BF-B', 'CHRW', 'CA', 'CVC', 'COG', 'CAM', 'CPB',  
              'COF', 'CAH', 'HSIC', 'KMX', 'CCL', 'CAT',)  
securities_panel = get_pricing(symbol_list, fields=['price']  
                               , start_date='2014-01-01', end_date='2015-01-01')  

Cheers, Ben

2 responses

Hello Ben,

The get_pricing function is only defined in the research environment. In order to query pricing data in an algorithm you need to use the data object, specifically the data.current anddata.history functions.

I would recommend you checking out the Getting Started tutorial, which walks you through developing and backtesting an algorithm and covers different parts of the platform's API. There you will find examples on how to use the functions I mentioned above.

I hope this helps.

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.

Thanks Ernesto! Appreciate the help.