Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A puzzle

Hi Team,

Hope everyone is having as much fun as I am and a little more success. I'm trying to write a very basic technical algorithm and was wondering if anybody could help me.

I am trying to create a cardinal indicator to attach to a handful of securities.

My plan was to have a function which updates the indicator for each security:

I(1) = (f(Price) + q(Volume))*I(0) + 1

where I(0) is the previous iteration of the calculation and I(1) is the update and then ranks the securities on this basis. I haven't really worked out what I would make f() or q() but thought I would work out the base before experimenting. Unfortunately this is apparently beyond my python skills. Any suggestions would be greatly appreciated!

1 response

I have an answer for anyone wondering

def initialize(context):  
    set_benchmark(sid(24))  
    context.securities = symbols('AAPL', 'GOOG')  
    context.Dictionary = {}  
def handle_data(context, data):

    for stock in data:  
        if str(stock) in context.Dictionary:  
            context.Dictionary[str(stock)] = context.Dictionary[str(stock)] + 1  
        else:  
            context.Dictionary.update({str(stock): 1})  
        print(context.Dictionary)