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!

Clone Algorithm
5
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5951d94b7be0fd517ca091ba
There was a runtime error.
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'