I have two list of dates I would like to apply to my code ( first date in xx and first date in yy, then second date in xx and second date in yy, etc). (I have a short list of dates for the example). trade1 is empty so I am approaching this wrong.
xx= c('2018-06-28','2018-07-27')
yy= c('2018-07-12','2018-08-13')
for (xx in seq_along(yy))
{
entry_trades = filter(aa2, Date == xx )%>%
rename(entry_price = Price, entry_date = Date)
exit_trades = filter(aa2, Date == yy)%>%
rename(exit_price = Price, exit_date = Date)
trade1 = merge(entry_trades, exit_trades,by='ticker')
trade1 = mutate(trade1, Chg = exit_price - entry_price,
Chg_pct = round((Chg / entry_price)*100 ,1))%>%
arrange(desc(Chg_pct))
}