Back to Community
Alphalens with japanese stocks

Dear team,

I am trying to do an Alphalens test with Japanese stocks but I am getting the following error. Could you help me?


Loading notebook preview...
1 response

The error you are seeing is in line 54 with get_pricing. The error message is ValueError: At least one valid asset id is required.. This is saying there were no valid assets passed to the get_pricing method. Currently, the get_pricing method only supports US equities. So, fetching prices to calculate returns in this manner, for non-US equities, doesn't work.

What's the solution? Take a look at Jamie McCorriston's post on Global Equity Pricing and Fundamental Data. There is notebook, with some helper functions, which explains how to get returns from pipeline (which is supported for non-US equities) instead of get_pricing. I have attached a notebook which uses the provided template and should be a good starting point for what you are trying to accomplish.

However, there are a couple of other issues. First, the user defined factor being analyzed must be a factor which returns a numerical number proportional to alpha for each security. Though not required, ideally it would return negative numbers for securities to short and positive numbers for those to go long. It cannot be a filter. The first issue is that the factor being passed to Alphalens in the original notebook, erp5, is a filter and not a factor.

    erp5= high_ey & low_pb & high_roic 

The second issue is the screen or filter being used.

    screen = (volume > 50000) & erp5 & small_cap,

This filter is very restrictive and leaves very few securities. Alphalens does best with a larger universe of securities to analyze. Otherwise, the binning and quantile results become distorted, or at worst, fail. The recommended approach is to initially use the screen (or filter) to simply limit the stocks one would trade. For example, exclude low liquidity and penny stocks. One can then iterate with Alphalens and narrow the filter to those stocks which ones factor seems to show the best correlation of alpha to returns. It's meant to filter the universe to those securities which the Alpha factor best works. It is not meant to filter to those securities to trade. That is the job of the factor.

Hope this gets you going. Do read over Jamie's post. It should answer a number of questions.

Loading notebook preview...

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.