Hi, I test the following code. in 2022, I print the price of AAPL. it's something around 25, but the real price should be above 100. any idea?
def initialize(context):
# Securities and target weights
context.securities = {
'SPY': 0.25,
'AAPL': 0.07,
}
# Schedule rebalance for once a month
schedule_function(rebalance, date_rules.month_start(), time_rules.market_open())
def rebalance(context, data):
# Loop through the securities
for sec, weight in context.securities.items():
sym = sid(get_securities(symbols=sec, vendors='sharadar').index[0])
print('=======',sym, data.current(sym,'price'))
# Check if we can trade
if data.can_trade(sym):
# Reset the weight
order_target_percent(sym, weight)