I specifically want to be able to run a trading strategy multiple times while changing the parameters without the code pulling the historical prices every time the code runs again.
I am using the getSymbols function from the quantmod package and was wondering how I could store the pulled data into the environment so that when the code runs the 2nd,3rd,..., etc time it does not need to take forever to pull the 500+ financial data per ticker. Thank you so much.
As for the OP title's question, "how to store data in an environment", you need to use the function assign():
foo=new.env() # create environment.
assign(x="a",value=10,envir=foo) # assigns value 10 to variable 'a' in environment 'foo'.
ls(envir=foo) # lists variables in environment 'foo'.
get(x="a",envir=foo) # get the value of variable 'a' in environment 'foo'.
And this will also work to get the variable value, as mentioned in another reply:
foo$a