I am trying to sum up the value of all my short positions only. So.... I want to parse thru all open positions and if the number of shares opened is negative (a short position) then I was to add that position's value to a variable. Here is a sample of the loop
for pos in context.portfolio.positions:
# print(str(pos.sid) )
if pos.amount<0: #short position
context.totalShorts += (pos.amount * pos.price)
and I'm getting this error
AttributeError: 'Security' object has no attribute 'amount'
USER ALGORITHM:40, in handle_data
if pos.amount<0: #short position