For some reason I am having trouble gathering and displaying the current price of each equity in my array. Any help would be greatly appreciated. Thank you
import numpy
def initialize(context):
context.limit = 10
current_price = []
def before_trading_start(context,data):
context.fundamentals = get_fundamentals(
query(
fundamentals.valuation_ratios.peg_ratio,
fundamentals.operation_ratios.roe,
fundamentals.operation_ratios.net_income_growth
)
.filter(fundamentals.valuation_ratios.peg_ratio < 1)
.filter(fundamentals.operation_ratios.roe > 0.04)
.filter(fundamentals.operation_ratios.net_income_growth > 0)
.order_by(
fundamentals.valuation.market_cap.desc(),
fundamentals.operation_ratios.roe.desc(),
fundamentals.operation_ratios.net_income_growth.desc(),
)
.limit(context.limit)
)
context.hello = context.fundamentals
update_universe(context.hello.columns.values)
print "___________________________________\n"
cash = context.portfolio.cash
cpp = context.portfolio.positions_value
print "Cash = %s" % cash
print "Position Value = %s" % cpp
def handle_data(context, data):
for stock in range(context.limit):
print context.hello.columns[stock]
current_price[stock] = data[context.hello.columns[stock]].close_price
print current_price
order(context.hello.columns[stock], 5)