Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Buying the closing low of the last 30 days

Good morning,

I am really new to the Quantopian Platform and I need help on the coding.
I want to compare Google today's close from its last 30 closing days and to give me a signal if today's close is the lower.

Is there any function that I can use to do that?
Thank you

2 responses

@Tony,

Is there any function that I can use to do that?

You can use something like this

    stock = symbol('GOOG')  
    prices = data.history(stock, 'close', 30, '1d')

    if prices[-1] < prices[0]:                     # if today's close < close 30 trading days ago  
        order_target_percent(stock, x)             # x is your choice 1.0 -> buy 100%, 0 -> sell all, -1.0 -> sell short 100% ...

Hi Vladimir,
It worked! Thank you so much fort your help