In need of a Quant Veterens / Genious advice / Help

Hi Quantopiates,

I am trying to build an algorithm and with much frustration, I cannot figure out how I can ad a basket of stock (for example all stocks in the S&P500 but not the index) all singe stocks which my Algo will then pick as an example the stock that has a 5% over average Volume increase to chose the short or long side of the Trade. NOW, is this possible to even do and if yes I would very much appreciate any Tips..
Second question while I am at this: How would I for example add a Bolinger Bands Algo with another all in one? Is it simply just copy pasting the example Quantopian has under my already existing Algorithm?

Thanks for any clarification or tips!

Cheers,
Brandon

6 responses

Notice that you opened the same thread twice.

Regarding your question, fetch a list of the symbols in the index and work that into a big call to symbols(), with a decent editor it's a matter of seconds.

I'm not sure what you meant with your second question.

Hey Andrea,

I did notice thank you I just cannot seem to find te delete button for it..

Is there a chance you can give me an example on how to manage getting all symbols? Maybe a screen shot or something like that?

Thanks!

I mean literally go on the wikipedia page, select the text in table (possibly in the page source) copy, paste into an editor, give a couple substitution and get a list of symbols as string literals separated by commas. Then copy this list and paste into the algorithm source as argument of symbols()

I don't think a screnshot of me copying the text off wikipedia would actually be useful.

Using the tickers from the wiki link, here is a skeleton structure:

def initialize(context):

context.my_stocks = symbols('MMM',
'ABT',
'ABBV',
'ACN',
'ACE',
'ACT',
)
def handle_data(context,data):
pass


You can include up to 200 securities in your symbols list. Here are the other ways to add securities to your algorithm: https://www.quantopian.com/help#ide-sid-lookup

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.

Note that it's not a very good idea to put the current S&P 500 symbols in your algo and use that as your universe. That is the definition of survivorship bias.

A better bet is to use the fundamentals data, order by market cap and get it as close as you can.

So something like this is a starting point for using fundamentals:

def before_trading_start(context):
fund_df = get_fundamentals(
query(
fundamentals.valuation.market_cap
)
.filter(fundamentals.valuation.market_cap > 100e6)
.order_by(fundamentals.valuation.market_cap.desc())
.limit(150)
)
update_universe(fund_df)

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.