Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Headbutting the wall... Python fundamental lack of knowledge

So this is my second foray into Python (the last effort was successful geointegration of photos with lat/long exif data in ArcMap) and I was able to structure a framework that weighs technical indicators to establish an overall "direction" that a stock may be going. My main issue stems from limited Python knowledge... it's something I can do in VBA, but no luck in Python.

I need to figure out how to programmatically create lists with unique names based off of the stock.symbol to store the previously calculated "weight" of the technical indicators. That list is then averaged to figure which "direction" the momentum of the stock is going. As the code sits, the historical indicators are appended to a list, but those historical values for each stock are added to the same list, mucking up the results. When tested with individual stocks, it performs acceptably (but weighted factors need fine tuning). I'm really struggling with defining unique lists programmatically.

Fortunately it seems to limit risk fairly well!

1 response

I'm new to Python as well, but I think what you're looking for is called a "dictionary" in Python, it's like an associative array.

context.pastindicator = {}  

then you can

context.pastindicator[stock] = 'whatever'